diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..59d0962 Binary files /dev/null and b/.DS_Store differ diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..b41a7b4 --- /dev/null +++ b/Gemfile @@ -0,0 +1,8 @@ +source 'https://rubygems.org' +gem 'github-pages', group: :jekyll_plugins + +# Add just-the-docs theme +gem 'just-the-docs' + +# Add spaceship to have mathjax +gem "jekyll-spaceship" diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..28cd8dd --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,280 @@ +GEM + remote: https://rubygems.org/ + specs: + activesupport (7.1.3.3) + base64 + bigdecimal + concurrent-ruby (~> 1.0, >= 1.0.2) + connection_pool (>= 2.2.5) + drb + i18n (>= 1.6, < 2) + minitest (>= 5.1) + mutex_m + tzinfo (~> 2.0) + addressable (2.8.6) + public_suffix (>= 2.0.2, < 6.0) + base64 (0.2.0) + bigdecimal (3.1.8) + coffee-script (2.4.1) + coffee-script-source + execjs + coffee-script-source (1.12.2) + colorator (1.1.0) + commonmarker (0.23.10) + concurrent-ruby (1.3.1) + connection_pool (2.4.1) + dnsruby (1.72.1) + simpleidn (~> 0.2.1) + drb (2.2.1) + em-websocket (0.5.3) + eventmachine (>= 0.12.9) + http_parser.rb (~> 0) + ethon (0.16.0) + ffi (>= 1.15.0) + eventmachine (1.2.7) + execjs (2.9.1) + faraday (2.8.1) + base64 + faraday-net_http (>= 2.0, < 3.1) + ruby2_keywords (>= 0.0.4) + faraday-net_http (3.0.2) + ffi (1.17.0) + forwardable-extended (2.6.0) + gemoji (4.1.0) + github-pages (231) + github-pages-health-check (= 1.18.2) + jekyll (= 3.9.5) + jekyll-avatar (= 0.8.0) + jekyll-coffeescript (= 1.2.2) + jekyll-commonmark-ghpages (= 0.4.0) + jekyll-default-layout (= 0.1.5) + jekyll-feed (= 0.17.0) + jekyll-gist (= 1.5.0) + jekyll-github-metadata (= 2.16.1) + jekyll-include-cache (= 0.2.1) + jekyll-mentions (= 1.6.0) + jekyll-optional-front-matter (= 0.3.2) + jekyll-paginate (= 1.1.0) + jekyll-readme-index (= 0.3.0) + jekyll-redirect-from (= 0.16.0) + jekyll-relative-links (= 0.6.1) + jekyll-remote-theme (= 0.4.3) + jekyll-sass-converter (= 1.5.2) + jekyll-seo-tag (= 2.8.0) + jekyll-sitemap (= 1.4.0) + jekyll-swiss (= 1.0.0) + jekyll-theme-architect (= 0.2.0) + jekyll-theme-cayman (= 0.2.0) + jekyll-theme-dinky (= 0.2.0) + jekyll-theme-hacker (= 0.2.0) + jekyll-theme-leap-day (= 0.2.0) + jekyll-theme-merlot (= 0.2.0) + jekyll-theme-midnight (= 0.2.0) + jekyll-theme-minimal (= 0.2.0) + jekyll-theme-modernist (= 0.2.0) + jekyll-theme-primer (= 0.6.0) + jekyll-theme-slate (= 0.2.0) + jekyll-theme-tactile (= 0.2.0) + jekyll-theme-time-machine (= 0.2.0) + jekyll-titles-from-headings (= 0.5.3) + jemoji (= 0.13.0) + kramdown (= 2.4.0) + kramdown-parser-gfm (= 1.1.0) + liquid (= 4.0.4) + mercenary (~> 0.3) + minima (= 2.5.1) + nokogiri (>= 1.13.6, < 2.0) + rouge (= 3.30.0) + terminal-table (~> 1.4) + github-pages-health-check (1.18.2) + addressable (~> 2.3) + dnsruby (~> 1.60) + octokit (>= 4, < 8) + public_suffix (>= 3.0, < 6.0) + typhoeus (~> 1.3) + html-pipeline (2.14.3) + activesupport (>= 2) + nokogiri (>= 1.4) + http_parser.rb (0.8.0) + i18n (1.14.5) + concurrent-ruby (~> 1.0) + jekyll (3.9.5) + addressable (~> 2.4) + colorator (~> 1.0) + em-websocket (~> 0.5) + i18n (>= 0.7, < 2) + jekyll-sass-converter (~> 1.0) + jekyll-watch (~> 2.0) + kramdown (>= 1.17, < 3) + liquid (~> 4.0) + mercenary (~> 0.3.3) + pathutil (~> 0.9) + rouge (>= 1.7, < 4) + safe_yaml (~> 1.0) + jekyll-avatar (0.8.0) + jekyll (>= 3.0, < 5.0) + jekyll-coffeescript (1.2.2) + coffee-script (~> 2.2) + coffee-script-source (~> 1.12) + jekyll-commonmark (1.4.0) + commonmarker (~> 0.22) + jekyll-commonmark-ghpages (0.4.0) + commonmarker (~> 0.23.7) + jekyll (~> 3.9.0) + jekyll-commonmark (~> 1.4.0) + rouge (>= 2.0, < 5.0) + jekyll-default-layout (0.1.5) + jekyll (>= 3.0, < 5.0) + jekyll-feed (0.17.0) + jekyll (>= 3.7, < 5.0) + jekyll-gist (1.5.0) + octokit (~> 4.2) + jekyll-github-metadata (2.16.1) + jekyll (>= 3.4, < 5.0) + octokit (>= 4, < 7, != 4.4.0) + jekyll-include-cache (0.2.1) + jekyll (>= 3.7, < 5.0) + jekyll-mentions (1.6.0) + html-pipeline (~> 2.3) + jekyll (>= 3.7, < 5.0) + jekyll-optional-front-matter (0.3.2) + jekyll (>= 3.0, < 5.0) + jekyll-paginate (1.1.0) + jekyll-readme-index (0.3.0) + jekyll (>= 3.0, < 5.0) + jekyll-redirect-from (0.16.0) + jekyll (>= 3.3, < 5.0) + jekyll-relative-links (0.6.1) + jekyll (>= 3.3, < 5.0) + jekyll-remote-theme (0.4.3) + addressable (~> 2.0) + jekyll (>= 3.5, < 5.0) + jekyll-sass-converter (>= 1.0, <= 3.0.0, != 2.0.0) + rubyzip (>= 1.3.0, < 3.0) + jekyll-sass-converter (1.5.2) + sass (~> 3.4) + jekyll-seo-tag (2.8.0) + jekyll (>= 3.8, < 5.0) + jekyll-sitemap (1.4.0) + jekyll (>= 3.7, < 5.0) + jekyll-spaceship (0.5.3) + jekyll (>= 3.6, < 5.0) + nokogiri (~> 1.6) + rainbow (~> 3.0) + jekyll-swiss (1.0.0) + jekyll-theme-architect (0.2.0) + jekyll (> 3.5, < 5.0) + jekyll-seo-tag (~> 2.0) + jekyll-theme-cayman (0.2.0) + jekyll (> 3.5, < 5.0) + jekyll-seo-tag (~> 2.0) + jekyll-theme-dinky (0.2.0) + jekyll (> 3.5, < 5.0) + jekyll-seo-tag (~> 2.0) + jekyll-theme-hacker (0.2.0) + jekyll (> 3.5, < 5.0) + jekyll-seo-tag (~> 2.0) + jekyll-theme-leap-day (0.2.0) + jekyll (> 3.5, < 5.0) + jekyll-seo-tag (~> 2.0) + jekyll-theme-merlot (0.2.0) + jekyll (> 3.5, < 5.0) + jekyll-seo-tag (~> 2.0) + jekyll-theme-midnight (0.2.0) + jekyll (> 3.5, < 5.0) + jekyll-seo-tag (~> 2.0) + jekyll-theme-minimal (0.2.0) + jekyll (> 3.5, < 5.0) + jekyll-seo-tag (~> 2.0) + jekyll-theme-modernist (0.2.0) + jekyll (> 3.5, < 5.0) + jekyll-seo-tag (~> 2.0) + jekyll-theme-primer (0.6.0) + jekyll (> 3.5, < 5.0) + jekyll-github-metadata (~> 2.9) + jekyll-seo-tag (~> 2.0) + jekyll-theme-slate (0.2.0) + jekyll (> 3.5, < 5.0) + jekyll-seo-tag (~> 2.0) + jekyll-theme-tactile (0.2.0) + jekyll (> 3.5, < 5.0) + jekyll-seo-tag (~> 2.0) + jekyll-theme-time-machine (0.2.0) + jekyll (> 3.5, < 5.0) + jekyll-seo-tag (~> 2.0) + jekyll-titles-from-headings (0.5.3) + jekyll (>= 3.3, < 5.0) + jekyll-watch (2.2.1) + listen (~> 3.0) + jemoji (0.13.0) + gemoji (>= 3, < 5) + html-pipeline (~> 2.2) + jekyll (>= 3.0, < 5.0) + just-the-docs (0.8.2) + jekyll (>= 3.8.5) + jekyll-include-cache + jekyll-seo-tag (>= 2.0) + rake (>= 12.3.1) + kramdown (2.4.0) + rexml + kramdown-parser-gfm (1.1.0) + kramdown (~> 2.0) + liquid (4.0.4) + listen (3.9.0) + rb-fsevent (~> 0.10, >= 0.10.3) + rb-inotify (~> 0.9, >= 0.9.10) + mercenary (0.3.6) + minima (2.5.1) + jekyll (>= 3.5, < 5.0) + jekyll-feed (~> 0.9) + jekyll-seo-tag (~> 2.1) + minitest (5.23.1) + mutex_m (0.2.0) + nokogiri (1.15.6-x86_64-linux) + racc (~> 1.4) + octokit (4.25.1) + faraday (>= 1, < 3) + sawyer (~> 0.9) + pathutil (0.16.2) + forwardable-extended (~> 2.6) + public_suffix (5.0.5) + racc (1.8.0) + rainbow (3.1.1) + rake (13.2.1) + rb-fsevent (0.11.2) + rb-inotify (0.11.1) + ffi (~> 1.0) + rexml (3.2.8) + strscan (>= 3.0.9) + rouge (3.30.0) + ruby2_keywords (0.0.5) + rubyzip (2.3.2) + safe_yaml (1.0.5) + sass (3.7.4) + sass-listen (~> 4.0.0) + sass-listen (4.0.0) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) + sawyer (0.9.2) + addressable (>= 2.3.5) + faraday (>= 0.17.3, < 3) + simpleidn (0.2.3) + strscan (3.1.0) + terminal-table (1.8.0) + unicode-display_width (~> 1.1, >= 1.1.1) + typhoeus (1.4.1) + ethon (>= 0.9.0) + tzinfo (2.0.6) + concurrent-ruby (~> 1.0) + unicode-display_width (1.8.0) + +PLATFORMS + x86_64-linux + +DEPENDENCIES + github-pages + jekyll-spaceship + just-the-docs + +BUNDLED WITH + 2.4.22 diff --git a/_config.yml b/_config.yml new file mode 100644 index 0000000..d90071c --- /dev/null +++ b/_config.yml @@ -0,0 +1,63 @@ +title: VERTEX-CFD +description: VERTEX-CFD is a performance portable software package for computational fluid dynamics (CFD) simulations on CPU or GPU architectures. +baseurl: "/VERTEX-CFD" +url: "https://ORNL.github.io" +repository: ORNL/VERTEX-CFD + +#show_downloads: true +#google_analytics: +#theme: jekyll-theme-minimal + +permalink: pretty + +remote_theme: just-the-docs/just-the-docs + +plugins: + - jekyll-remote-theme + - jekyll-seo-tag + - jekyll-feed + +compress_html: + blanklines: true + +# Override purple (default) to ORNL green +color_scheme: ornl_green + +logo: docs/figures/vertex_cfd_heated_flow_logo.png + +# External navigation links +nav_external_links: + - title: VERTEX-CFD on GitHub + url: "https://github.com/ORNL/VERTEX-CFD" + +# Aux links for the upper right navigation +aux_links: + "VERTEX-CFD on GitHub": + - "https://github.com/ORNL/VERTEX-CFD" + +# Makes Aux links open in a new tab. Default is false +aux_links_new_tab: false + +# Enable callouts in markdown +callouts_level: quiet # or loud +callouts: + highlight: + color: yellow + important: + title: Important + color: blue + new: + title: New + color: green + note: + title: Note + color: purple + warning: + title: Warning + color: red + custom: + title: Note + color: ornl_green + +sass: + custom_stylesheet: _sass/custom/custom.scss diff --git a/_includes/head_custom.html b/_includes/head_custom.html new file mode 100644 index 0000000..16af50c --- /dev/null +++ b/_includes/head_custom.html @@ -0,0 +1,10 @@ +{% if page.usemathjax %} + + +{% endif %} diff --git a/_sass/color_schemes/ornl_green.scss b/_sass/color_schemes/ornl_green.scss new file mode 100644 index 0000000..fca6234 --- /dev/null +++ b/_sass/color_schemes/ornl_green.scss @@ -0,0 +1,4 @@ +$ornl-green: #007833; +$link-color: $ornl-green; +$btn-primary-color: $ornl-green; +$sidebar-color: #ffffff; diff --git a/_sass/custom/custom.scss b/_sass/custom/custom.scss new file mode 100644 index 0000000..3f4925d --- /dev/null +++ b/_sass/custom/custom.scss @@ -0,0 +1,73 @@ +.side-bar { + z-index: 0; + display: flex; + flex-wrap: wrap; + background-color: $sidebar-color; + + @include mq(md) { + flex-flow: column nowrap; + position: fixed; + width: $nav-width-md; + height: 100%; + border-right: $border $border-color; + align-items: flex-end; + } + + @include mq(lg) { + width: calc((70% - #{$nav-width + $content-width}) / 20 + #{$nav-width}); + min-width: $nav-width; + } + + & + .main { + @include mq(md) { + margin-left: $nav-width-md; + } + + @include mq(lg) { + // stylelint-disable function-name-case + // disable for Max(), we want to use the CSS max() function + margin-left: Max( + #{$nav-width}, + calc((70% - #{$nav-width + $content-width}) / 20 + #{$nav-width}) + ); + // stylelint-enable function-name-case + } + + .main-header { + display: none; + background-color: $sidebar-color; + + @include mq(md) { + display: flex; + background-color: $body-background-color; + } + + &.nav-open { + display: block; + + @include mq(md) { + display: flex; + } + } + } + } +} + +body { + background-color: $grey-lt-000; +} + +html, body { + height: 100%; +} + +footer { + display: none; +} + +.main { + #background-color: #ffffff; + min-height: 100vh; + background-color: #ffffff; + padding-bottom: 2rem; +} diff --git a/_sass/custom/setup.scss b/_sass/custom/setup.scss new file mode 100644 index 0000000..2e277f6 --- /dev/null +++ b/_sass/custom/setup.scss @@ -0,0 +1,4 @@ +$ornl-green-000: #008542; +$ornl-green-100: #008542; +$ornl-green-200: #008542; +$ornl-green-300: #008542; diff --git a/cmake/FindCLANG_FORMAT.cmake b/cmake/FindCLANG_FORMAT.cmake deleted file mode 100644 index 50a58d4..0000000 --- a/cmake/FindCLANG_FORMAT.cmake +++ /dev/null @@ -1,52 +0,0 @@ -# Find clang-format -# -# CLANG_FORMAT_EXECUTABLE - Path to clang-format executable -# CLANG_FORMAT_FOUND - True if the clang-format executable was found. -# CLANG_FORMAT_VERSION - The version of clang-format found -# - -find_program(CLANG_FORMAT_EXECUTABLE - NAMES clang-format - clang-format-10 - clang-format-9 - clang-format-8 - clang-format-7 - clang-format-6.0 - clang-format-5.0 - clang-format-4.0 - clang-format-3.9 - clang-format-3.8 - clang-format-3.7 - clang-format-3.6 - clang-format-3.5 - clang-format-3.4 - clang-format-3.3 - DOC "clang-format executable") -mark_as_advanced(CLANG_FORMAT_EXECUTABLE) - -# Extract version from command "clang-format -version" -if(CLANG_FORMAT_EXECUTABLE) - execute_process(COMMAND ${CLANG_FORMAT_EXECUTABLE} -version - OUTPUT_VARIABLE clang_format_version - ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) - - if(clang_format_version MATCHES "^clang-format version .*") - # clang_format_version sample: "clang-format version 3.9.1-4ubuntu3~16.04.1 - # (tags/RELEASE_391/rc2)" - string(REGEX - REPLACE "clang-format version ([.0-9]+).*" - "\\1" - CLANG_FORMAT_VERSION - "${clang_format_version}") - # CLANG_FORMAT_VERSION sample: "3.9.1" - else() - set(CLANG_FORMAT_VERSION 0.0) - endif() -else() - set(CLANG_FORMAT_VERSION 0.0) -endif() - -include(FindPackageHandleStandardArgs) -# handle the QUIETLY and REQUIRED arguments and set CLANG_FORMAT_FOUND to TRUE -# if all listed variables are TRUE -find_package_handle_standard_args(CLANG_FORMAT REQUIRED_VARS CLANG_FORMAT_EXECUTABLE VERSION_VAR CLANG_FORMAT_VERSION) diff --git a/cmake/FindGCOVR.cmake b/cmake/FindGCOVR.cmake deleted file mode 100644 index d47dd6c..0000000 --- a/cmake/FindGCOVR.cmake +++ /dev/null @@ -1,24 +0,0 @@ -# Find gcovr -# -# GCOVR_EXECUTABLE - Path to gcovr executable -# GCOVR_FOUND - True if the gcovr executable was found -# GCOVR_VERSION - The version of gcovr found -# - -find_program(GCOVR_EXECUTABLE - NAMES gcovr - DOC "gcovr executable") -mark_as_advanced(GCOVR_EXECUTABLE) - -# Extract version from command "gcovr -version" -if(GCOVR_EXECUTABLE) - execute_process(COMMAND ${GCOVR_EXECUTABLE} --version - OUTPUT_VARIABLE gcovr_version - ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) - if(gcovr_version MATCHES "^gcovr ([.0-9]+)") - set(GCOVR_VERSION ${CMAKE_MATCH_1}) - endif() -endif() - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(GCOVR REQUIRED_VARS GCOVR_EXECUTABLE VERSION_VAR GCOVR_VERSION) diff --git a/cmake/FindSuperLU_dist.cmake b/cmake/FindSuperLU_dist.cmake deleted file mode 100644 index 300fa86..0000000 --- a/cmake/FindSuperLU_dist.cmake +++ /dev/null @@ -1,28 +0,0 @@ -# Find SuperLU_dist -# SuperLU_dist_FOUND - True if SuperLU_dist was found -# SuperLU_dist::SuperLU_dist - interface target - -find_path(SuperLU_dist_INCLUDE_DIR superlu_ddefs.h) -find_library(SuperLU_dist_LIBRARY NAMES superlu_dist) - -mark_as_advanced( - SuperLU_dist_INCLUDE_DIR - SuperLU_dist_LIBRARY -) - -include(FindPackageHandleStandardArgs) - -find_package_handle_standard_args( - SuperLU_dist DEFAULT_MSG - SuperLU_dist_LIBRARY SuperLU_dist_INCLUDE_DIR -) - -if(SuperLU_dist_FOUND AND NOT TARGET SuperLU_dist::SuperLU_dist) - add_library(SuperLU_dist::SuperLU_dist UNKNOWN IMPORTED) - set_target_properties(SuperLU_dist::SuperLU_dist PROPERTIES - IMPORTED_LOCATION "${SuperLU_dist_LIBRARY}" - INTERFACE_INCLUDE_DIRECTORIES "${SuperLU_dist_INCLUDE_DIR}" - ) - message("SuperLU_dist_LIBRARY: ${SuperLU_dist_LIBRARY}") - message("SuperLU_dist_INCLUDE_DIR: ${SuperLU_dist_INCLUDE_DIR}") -endif() diff --git a/cmake/FindYAPF.cmake b/cmake/FindYAPF.cmake deleted file mode 100644 index c595e6c..0000000 --- a/cmake/FindYAPF.cmake +++ /dev/null @@ -1,36 +0,0 @@ -# Find yapf -# -# YAPF_EXECUTABLE - Path to python-format executable -# YAPF_FOUND - True if the python-format executable was found. -# YAPF_VERSION - The version of python-format found -# - -find_program(YAPF_EXECUTABLE - NAMES yapf - DOC "Python formatter executable") -mark_as_advanced(YAPF_EXECUTABLE) - -# Extract version from command "yapf -version" -if(YAPF_EXECUTABLE) - execute_process(COMMAND ${YAPF_EXECUTABLE} -version - OUTPUT_VARIABLE yapf_version - ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) - if(yapf_version MATCHES "^yapf .*") - # yapf_version sample: "yapf 0.32.0" - string(REGEX - REPLACE "yapf version ([.0-9]+).*" - "\\1" - YAPF_VERSION - "${yapf_version}") - # YAPF_VERSION sample: "0.32.0" - else() - set(YAPF_VERSION 0.0) - endif() -else() - set(YAPF_VERSION 0.0) -endif() - -include(FindPackageHandleStandardArgs) -# handle the QUIETLY and REQUIRED arguments and set YAPF_FOUND to TRUE -# if all listed variables are TRUE -find_package_handle_standard_args(YAPF REQUIRED_VARS YAPF_EXECUTABLE VERSION_VAR YAPF_VERSION) diff --git a/cmake/VertexCFDConfig.cmake.in b/cmake/VertexCFDConfig.cmake.in deleted file mode 100644 index 6571362..0000000 --- a/cmake/VertexCFDConfig.cmake.in +++ /dev/null @@ -1,9 +0,0 @@ -include(CMakeFindDependencyMacro) -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}" ) -list(APPEND CMAKE_PREFIX_PATH @CMAKE_PREFIX_PATH@) -find_dependency( Trilinos 13 REQUIRED COMPONENTS - Kokkos - Teuchos - SEACASIoss - STKMesh - STKIO ) diff --git a/docs/contribution.md b/docs/contribution.md new file mode 100644 index 0000000..fa75d5e --- /dev/null +++ b/docs/contribution.md @@ -0,0 +1,21 @@ +--- +parent: VERTEX-CFD v1.0 User Guide +title: Contributing to VERTEX-CFD +nav_order: 4 +usemathjax: true +--- + +# How to contribute to VERTEX-CFD + +Contribution to VERTEX-CFD source code follows a strict process to warranty robustness and deployment on HPC platforms. Any change to the GitHub repo must be reviewed by one of the main developers listed on the [home](../index.md) page. If you are willing to contribute to the development of VERTEX-CFD, please review the [GitHub documentation on how to collaborate](https://docs.github.com/en/pull-requests) and follow the steps given below: +- [Git clone VERTEX-CFD repo](https://github.com/ORNL/VERTEX-CFD) and [compile the source code](installation.md). +- Create a new branch from the main branch. +- Make changes to the source code. +- Add/update unit test(s) and/or regression test(s) when needed. +- Push changes to your remote branch and create a pull request (PR). +- Add a description to the PR with results supporting the changes. +- Tag a reviewer to the PR. + +A contributor will then review the PR and add comments to the changes. Make sure to address all comments and to respond to all threads. Once the reviewer resolves all threads and approves the PR, the branch will be merged to the [main branch](https://github.com/ORNL/VERTEX-CFD). + +If you have any questions or comments, please contact of the main contributors listed on the [home page](../index.md). diff --git a/docs/figures/vertex_cfd_heated_flow_logo.png b/docs/figures/vertex_cfd_heated_flow_logo.png new file mode 100644 index 0000000..33f5012 Binary files /dev/null and b/docs/figures/vertex_cfd_heated_flow_logo.png differ diff --git a/docs/index.md b/docs/index.md new file mode 100644 index 0000000..e9fca69 --- /dev/null +++ b/docs/index.md @@ -0,0 +1,13 @@ +--- +layout: page +title: VERTEX-CFD v1.0 User Guide +nav_order: 2 +has_children: true +--- + +# VERTEX-CFD v1.0 User Guide +VERTEX-CFD is a free, open source multiphysics software for simulations of fusion applications released by Oak Ridge National Laboratory. +--- + +{: .custom } +The User Guide v1.0 is currently under development and may be incomplete. diff --git a/docs/installation.md b/docs/installation.md new file mode 100644 index 0000000..fa9f00a --- /dev/null +++ b/docs/installation.md @@ -0,0 +1,498 @@ +--- +parent: VERTEX-CFD v1.0 User Guide +title: Installation and testing +nav_order: 1 +--- + +# Installation +VERTEX-CFD supports both CPU and GPU solvers. Depending on the CPU/GPU supports, Trilinos must be compiled with the proper configurations because VERTEX-CFD relies on the Trilinos installation. For the VERTEX-CFD installation, Trilinos should be available in the system. Installation instructions for both Trilinos and VERTEX-CFD are available. If Trilinos is already built and ready, then you can skip to [VERTEX-CFD installation instructions](#vertex-cfd-installation). All of the scripts given in this file are also available in the [docs/scripts](https://github.com/ORNL/VERTEX-CFD/tree/gh-pages/docs/scripts) directory for the user's convenience. + +## Trilinos Installation +Trilinos supports both CPU and GPU if configured accordingly. For the installation with CPU support only, we have a [spack](https://spack.readthedocs.io/en/latest/environments.html)-based procedure which is easier to follow. For GPU, as of now, Trilinos must be built manually. For both options, we suggest using a compute node instead of a login node, which would be a demanding process. + +### Trilinos-CPU Installation +First, create a directory and git clone spack. + +``` +mkdir trilinos +cd trilinos/ +git clone -c feature.manyFiles=true --depth=2 https://github.com/spack/spack.git +``` + +Next, create a file named `spack-trilinos16.yaml` which should contain the configuration presented below for spack. Pay special attention to `EDIT` entries because edits may be required, depending on your machine. Modules already available on your machine can be loaded using the `packages` section at the end of the file. + +``` +spack: + concretizer: + unify: when_possible + + config: + build_stage: + - $spack/var/spack/spack-stage/build-$arch-$date/ + misc_cache: $spack/.cache + build_jobs: 32 + install_tree: + root: $spack/opt/spack/ + projections: + all: install-{os}-{target}-{compiler.name}-{compiler.version}/{name}-{version} + keep_stage: true + verify_ssl: true + checksum: true + dirty: false + build_language: C + ccache: false + db_lock_timeout: 120 + package_lock_timeout: null + shared_linking: + type: rpath + bind: false + allow_sgid: true + locks: true + suppress_gpg_warnings: false + connect_timeout: 10 + + compilers: + - compiler: # EDIT: change below with your compiler of choice + spec: gcc@13.2.0 + paths: # EDIT: Change those based on the location of the compiler location you prefer + cc: /software/dev_tools/swtree/cs400/gcc/13.2.0/centos7.5_gnu8.5.0/bin/gcc + cxx: /software/dev_tools/swtree/cs400/gcc/13.2.0/centos7.5_gnu8.5.0/bin/g++ + f77: /software/dev_tools/swtree/cs400/gcc/13.2.0/centos7.5_gnu8.5.0/bin/gfortran + fc: /software/dev_tools/swtree/cs400/gcc/13.2.0/centos7.5_gnu8.5.0/bin/gfortran + flags: {} + operating_system: centos7 # EDIT: update according to `spack arch`: just the OS version + target: x86_64 + modules: # EDIT: update with a list of modules you want to load by default + - gcc/13.2.0 + + packages: + all: + target: [broadwell] # EDIT: Change this according to `spack arch` + compiler: [gcc@13.2.0] # EDIT: Change according to your compiler of choice + providers: # EDIT: Change versions below according to the default in your machine + mpi: [intel-oneapi-mkl] + blas: [intel-oneapi-mkl] + lapack: [intel-oneapi-mkl] + pkgconfig: [pkg-config] + + specs: + - python + - ninja + - boost + - intel-oneapi-mkl + - googletest + - trilinos@16.0.0 +chaco+exodus+hdf5+intrepid2+kokkos+mpi+nox+openmp+panzer+phalanx+shards+shared+stk+tempus+zoltan2 +``` + +Now, source the spack setup script and create an environment named `vertex`. + +``` +source spack/share/spack/setup-env.sh +spack env create vertex spack-trilinos16.yaml +spack env activate vertex +spack spec +``` + + `spack spec` will show the configuration of what is to be installed: make sure the configuration matches what was requested in the configuration file. Next, install Trilinos and its dependencies. + +``` +spack install +``` + +If the session is ended for any reason, then the user may need to reactivate the vertex spack env using `spack env activate vertex`. If all compiles without error, then the modules are ready to use. `spack location -i trilinos` will return the location of the Trilinos install. The modules can be set up using + +``` +spack module tcl refresh +``` +Trilinos can be called by loading the module as shown below. The folder names may be different, depending on your machine configuration. We suggest finding the current folders instead of copying and pasting. As an example, on [CADES](https://www.ornl.gov/content/cades) in ORNL, they are located in + +``` +module use //share/spack/modules/linux-centos7-haswell/ +module load trilinos/16.0.0-gcc-13.2.0-qzebvtj +``` +Trilinos and its dependencies are required to compile [VERTEX-CFD](#vertex-cfd-installation). + +### Trilinos-GPU Installation +As of now, VERTEX-CFD-GPU installation is not supported by the spack. Hence, Trilinos with GPU support must be compiled manually. To install Trilinos-GPU, the first step is to clone Trilinos from the GitHub repo and checkout to `Trilinos-16-0-0` as follows: + +``` +git clone https://github.com/trilinos/Trilinos.git +cd Trilinos +git checkout trilinos-release-16-0-branch +``` + +Once you have checked out to the correct version, you can create a new folder for building Trilinos, as follows: + +``` +mkdir build +cd build +``` + +Now the modules required to build Trilinos must be loaded. Create a file named `trilinos-cuda-env.sh`. The procedure for module loading differs, depending on the machine. The content of `trilinos-cuda-env.sh` in NERSC Perlmutter is given as an example below: this can be adjusted according to your machine's configurations: + +``` +#!/bin/bash + +module load PrgEnv-gnu/8.5.0 +module load gcc-native/12.3 +module load cudatoolkit/12.4 +module load craype-accel-nvidia80 +module load cray-libsci/23.12.5 +module load craype/2.7.30 +module load cray-mpich/8.1.28 +module load cray-hdf5-parallel/1.12.2.9 +module load cray-netcdf-hdf5parallel/4.9.0.9 +module load cray-parallel-netcdf/1.12.3.9 +module load cmake/3.30.2 + +module load spack +spack env activate cuda +spack load metis +spack load parmetis + +export MPICH_ENV_DISPLAY=1 +export MPICH_VERSION_DISPLAY=1 +export OMP_STACKSIZE=128M +export OMP_PROC_BIND=spread +export OMP_PLACES=threads +export HDF5_USE_FILE_LOCKING=FALSE +export MPICH_GPU_SUPPORT_ENABLED=1 +export CUDATOOLKIT_VERSION_STRING=${CRAY_CUDATOOLKIT_VERSION#*_} + +export CRAY_ACCEL_TARGET="nvidia80" + +export KOKKOS_MAP_DEVICE_ID_BY=mpi_rank +export CUDA_MANAGED_FORCE_DEVICE_ALLOC=1 +export TPETRA_ASSUME_GPU_AWARE_MPI=0 +``` + +Once this is ready, create a configuration script named `trilinos-cuda-config.sh` and include the following content: + +``` +#!/bin/bash +# This is a sample Trilinos configuration script for Albany on perlmutter + +source trilinos-cuda-env.sh + +# Cleanup old cmake files +rm -rf CMake* + +# Set Trilinos build path +BUILD_DIR=`pwd` + +# EDIT: Change this based on your NVCC WRAPPER location +NVCC_WRAPPER= + +# EDIT: Change with path to Trilinos source directory +TRILINOS_SOURCE_DIR= + +# EDIT: Change with path to boost +BOOST_DIR= + +TRILINOS_INSTALL_DIR= + +export CRAYPE_LINK_TYPE=dynamic +export CRAY_CPU_TARGET=x86-64 + +cmake \ + -D CMAKE_C_COMPILER=cc \ + -D CMAKE_CXX_COMPILER=${NVCC_WRAPPER} \ + -D CMAKE_Fortran_COMPILER=ftn \ +\ + -D CMAKE_INSTALL_PREFIX:PATH=${TRILINOS_INSTALL_DIR} \ + -D CMAKE_BUILD_TYPE:STRING=RELEASE \ +\ + -D BUILD_SHARED_LIBS=ON \ + -D Trilinos_ENABLE_ALL_PACKAGES=ON \ + -D Trilinos_ENABLE_SECONDARY_TESTED_CODE=ON \ + -D Trilinos_ENABLE_EXPLICIT_INSTANTIATION=ON \ + -D Trilinos_ENABLE_PyTrilinos=OFF \ + -D Trilinos_SHOW_DEPRECATED_WARNINGS=OFF \ + -D TPL_ENABLE_MPI=ON \ + -D TPL_Netcdf_PARALLEL=FALSE \ +\ + -D TPL_ENABLE_HDF5:STRING=ON \ + -D HDF5_INCLUDE_DIRS:PATH=${HDF5_DIR}/include \ + -D HDF5_LIBRARY_DIRS:PATH=${HDF5_DIR}/lib\ +\ + -D TPL_ENABLE_Netcdf=ON \ + -D Netcdf_INCLUDE_DIRS:PATH=${NETCDF_DIR}/include \ + -D Netcdf_LIBRARY_DIRS:PATH=${NETCDF_DIR}/lib \ +\ + -D Kokkos_ENABLE_CUDA:BOOL=ON \ + -D Kokkos_ENABLE_CUDA_LAMBDA:BOOL=ON \ + -D Kokkos_ENABLE_CUDA_UVM:BOOL=OFF \ + -D Kokkos_ENABLE_IMPL_CUDA_MALLOC_ASYNC:BOOL=OFF \ +\ + -D TPL_ENABLE_Boost:BOOL=ON \ + -D TPL_ENABLE_BoostLib=ON \ + -D Boost_INCLUDE_DIRS:PATH=${BOOST_DIR}/include \ + -D Boost_LIBRARY_DIRS:PATH=${BOOST_DIR}/lib \ +\ + -D TPL_ENABLE_Krino=OFF \ + -D TPL_ENABLE_Matio=OFF \ + -D TPL_ENABLE_CGNS=OFF \ + -D TPL_ENABLE_METIS=ON \ + -D TPL_ENABLE_ParMETIS=ON \ + -D Trilinos_ENABLE_Stokhos:BOOL=OFF \ +\ + -D TPL_ENABLE_SuperLU:BOOL=OFF \ + -D ML_ENABLE_SuperLU:BOOL=OFF \ + -D TPL_ENABLE_BLAS:BOOL=ON \ + -D TPL_BLAS_LIBRARIES:STRING="${CRAY_PE_LIBSCI_PREFIX_DIR}/lib/libsci_gnu.so" \ + -D TPL_ENABLE_LAPACK:BOOL=ON \ + -D TPL_LAPACK_LIBRARIES:STRING="${CRAY_PE_LIBSCI_PREFIX_DIR}/lib/libsci_gnu.so" \ +\ +${TRILINOS_SOURCE_DIR} +``` + +As an example, in the NERSC Perlmutter system, for `NVCC_WRAPPER`, we used the wrapper available from the Sandia National Laboratories' GitHub page `https://github.com/sandialabs/Albany/blob/master/doc/LandIce/machines/perlmutter/nvcc_wrapper_a100`. After that, run the `trilinos-cuda-config.sh` script as: + +``` +./trilinos-cuda-config.sh +``` + +Once the configuration is completed, Trilinos-16-0-0-GPU can be built and installed as follows: + +``` +make -j install +``` + +After building and installation, Trilinos-GPU should be ready for [VERTEX-CFD installation](#vertex-cfd-installation). + + +## VERTEX-CFD Installation + +Once Trilinos is installed on your system and ready to use, VERTEX-CFD can be installed. First, create a folder for VERTEX-CFD and clone from GitHub by using the following: +``` +mkdir VERTEX-CFD +cd VERTEX-CFD +git clone https://github.com/ORNL/VERTEX-CFD.git +``` +This will clone the VERTEX-CFD folder. In order to build VERTEX-CFD, create a new folder, as follows: +``` +mkdir build +cd build +``` + +Different environment files are needed in the build directory, depending on the CPU/GPU installation. For a GPU, you can use `trilinos-cuda-config.sh`. There is no need for a separate configuration script. However, for a CPU, you will need `vertex-env-cpu.sh`. The environment scripts are system-specific and may vary based on your system. Carefully modify these scripts based on your system. The content of `vertex-env-cpu.sh` is as follows: +``` +#!/bin/bash +module use # EDIT: Update this with the module location, as an example: module use spack/share/spack/modules/linux-centos7-broadwell/ +install=//share/spack/modules/linux-centos7-haswell/ +echo $install + +module load gcc/13.2.0 + +module use $install +module load gcc-runtime +module load openmpi +module load cmake +module load ninja +module load boost +module load netcdf-c +module load parmetis +module load intel-oneapi-mkl +module load cgns +module load googletest +module load hdf5 +module load zlib-ng +module load trilinos/16.0.0-gcc-13.2.0-qzebvtj +HDF5_DIR=//opt/spack/install-centos7-haswell-gcc-13.2.0/hdf5-1.14.5/ +ZLIB_DIR=//opt/spack/install-centos7-haswell-gcc-13.2.0/zlib-ng-2.2.3/ + +GCC_ROOT=// +unset LIBRARY_PATH +``` + +Please note that because these scripts are system-specific, they must be modified according to your system. Please carefully modify them and make sure they are loading the correct modules. The scripts shared here are succesfully used on CADES (CPU configuration) in ORNL and NERSC Perlmutter (GPU configuration). Once you have the environment script, source the script with one of the lines below based on the CPU/GPU installation: + +``` +source vertex-env-cpu.sh +source trilinos-cuda-env.sh +``` + +Once the environment script is sourced, VERTEX-CFD must be configured. Create a configuration script named `vertex-config.sh` containing the following lines: +``` +#!/bin/sh + +SOURCE=/ +INSTALL="" +BUILD="RelWithDebInfo" + +rm -rf CMake* +rm -rf .ninja* +rm DartConfiguration.tcl +rm CTestTestfile.cmake +rm build.ninja +rm VertexCFDConfig.cmake +rm -rf Testing + +# EDIT: Uncomment this line for GPU and update this based on your NVCC WRAPPER location +#NVCC_WRAPPER= + +# Unset variable set by spack modules. +# If this is present, any directories present will be treated +# as "implicit" library paths by CMake and it will strip them +# out of the executable RPATHS. Then you have to set +# LD_LIBRARY_PATH appropriately to run jobs. +unset LIBRARY_PATH + +# EDIT: This command is for CPU. Comment it for GPU. +cmake \ + -D CMAKE_BUILD_TYPE=${BUILD} \ + -D CMAKE_INSTALL_PREFIX=${INSTALL} \ + -D VertexCFD_ENABLE_COVERAGE_BUILD=OFF \ + -D CMAKE_CXX_FLAGS="-Wall -Wextra -Wpedantic -fdiagnostics-color" \ + -D VertexCFD_ENABLE_TESTING=ON \ + -D Trilinos_ROOT= \ + \ + ${SOURCE} + +# EDIT: Uncomment this command for GPU. +#cmake \ +# -D CMAKE_BUILD_TYPE=${BUILD} \ +# -D CMAKE_INSTALL_PREFIX=${INSTALL} \ +# -D CMAKE_CXX_COMPILER=${NVCC_WRAPPER} \ +# -D VertexCFD_ENABLE_COVERAGE_BUILD=OFF \ +# -D CMAKE_CXX_FLAGS="-Wall -Wextra -Wpedantic -fdiagnostics-color" \ +# -D VertexCFD_ENABLE_TESTING=ON \ +# -D Trilinos_ROOT= \ +# \ +# ${SOURCE} +``` +Please note that you must define `NVCC_WRAPPER` and `CMAKE_CXX_COMPILER` for the GPU version. Once the configuration script is ready, run it as follows: +``` +./vertex-config.sh +``` + +When configured succesfully, you can use make to install as follows: +``` +make -j install +``` +If you wish to limit the number of cores in the installation, then append `-j` flag with the desired number of cores, such as `-j32`. This will build and install VERTEX-CFD. The binary will be located in `/bin/vertexcfd`. Once the installation is complete, unit and regression tests can be run to ensure that everything is working as expected. For testing instructions, refer to the following sections. + +# Testing +The VERTEX-CFD development procedure strictly requires that a unit/regression test be developed for each capability added. Hence, it is suggested to run those tests to make sure that installation is properly completed and the functionalities are working as expected. + +## Unit Tests +VERTEX-CFD includes a large amount of unit tests. In order to run these tests, you can use the job submission scripts given below which are written for SLURM scheduler. + +``` +#!/bin/bash +#SBATCH -N 1 +#SBATCH --ntasks-per-node 32 +#SBATCH --time 0:10:00 +#SBATCH --output output.log +#SBATCH --error error.log + +source /trilinos-cuda-config.sh +#source /vertex-env-cpu.sh # For GPU comment above line, and use this line. + +export OMP_PROC_BIND=true +export OMP_PLACES=threads + +export IOSS_PROPERTIES="COMPOSE_RESULTS=on:MINIMIZE_OPEN_FILES=on:MAXIMUM_NAME_LENGTH=64:DUPLICATE_FIELD_NAME_BEHAVIOR=WARNING" +export EXODUS_NETCDF4=1 + +export MAP_STRING=slot:pe=${SLURM_CPUS_PER_TASK} + +ctest -j ${SLURM_NTASKS_PER_NODE} +``` + +For another scheduler, such as PBS, you can convert the SLURM submission script. The example output screen for the unit tests is as follows: +``` + Start 1: VertexCFD_KokkosMPI_test_OPENMP_np_1_nt_1 + Start 2: VertexCFD_KokkosMPI_test_OPENMP_np_1_nt_2 + Start 3: VertexCFD_KokkosMPI_test_OPENMP_np_1_nt_4 + Start 5: VertexCFD_KokkosMPI_test_OPENMP_np_2_nt_1 + Start 6: VertexCFD_KokkosMPI_test_OPENMP_np_2_nt_2 + Start 7: VertexCFD_KokkosMPI_test_OPENMP_np_2_nt_4 + Start 8: VertexCFD_KokkosMPI_test_OPENMP_np_4_nt_1 + 1/554 Test #8: VertexCFD_KokkosMPI_test_OPENMP_np_4_nt_1 .......................................... Passed 2.03 sec + Start 12: VertexCFD_EvaluatorTestHarness_test_OPENMP_np_1_nt_1 + Start 13: VertexCFD_EvaluatorTestHarness_test_OPENMP_np_1_nt_2 + Start 23: VertexCFD_Version_test_OPENMP_nt_1 + 2/554 Test #2: VertexCFD_KokkosMPI_test_OPENMP_np_1_nt_2 .......................................... Passed 2.61 sec + Start 16: VertexCFD_EvaluatorTestHarness_test_OPENMP_np_2_nt_1 + 3/554 Test #1: VertexCFD_KokkosMPI_test_OPENMP_np_1_nt_1 .......................................... Passed 2.61 sec + Start 27: VertexCFD_ParameterPack_test_OPENMP_nt_1 + 4/554 Test #7: VertexCFD_KokkosMPI_test_OPENMP_np_2_nt_4 .......................................... Passed 2.61 sec + Start 9: VertexCFD_KokkosMPI_test_OPENMP_np_4_nt_2 + 5/554 Test #3: VertexCFD_KokkosMPI_test_OPENMP_np_1_nt_4 .......................................... Passed 2.62 sec + . + . + . + 553/554 Test #550: VertexCFD_DivergenceAdvectionTest_test_OPENMP_nt_192 ............................... Passed 0.84 sec + Start 554: VertexCFD_FullInductionMHDProperties_test_OPENMP_nt_192 + 554/554 Test #554: VertexCFD_FullInductionMHDProperties_test_OPENMP_nt_192 ............................ Passed 0.36 sec + + 97% tests passed, 14 tests failed out of 554 + + Total Test time (real) = 1825.19 sec + + The following tests FAILED: + 11 - VertexCFD_KokkosMPI_test_OPENMP_np_192_nt_1 (Failed) + 22 - VertexCFD_EvaluatorTestHarness_test_OPENMP_np_192_nt_1 (Failed) + 71 - VertexCFD_MeshManager_test_OPENMP_nt_1 (Failed) + 72 - VertexCFD_MeshManager_test_OPENMP_nt_2 (Failed) + 73 - VertexCFD_MeshManager_test_OPENMP_nt_4 (Failed) + 74 - VertexCFD_MeshManager_test_OPENMP_nt_192 (Failed) + 79 - VertexCFD_InitialConditionManager_test_OPENMP_nt_1 (Failed) + 80 - VertexCFD_InitialConditionManager_test_OPENMP_nt_2 (Failed) + 81 - VertexCFD_InitialConditionManager_test_OPENMP_nt_4 (Failed) + 82 - VertexCFD_InitialConditionManager_test_OPENMP_nt_192 (Failed) + 169 - VertexCFD_ExternalFields_test_OPENMP_np_192_nt_1 (Failed) + 180 - VertexCFD_Restart_test_OPENMP_np_192_nt_1 (Failed) + 191 - VertexCFD_GeometryPrimitives_test_OPENMP_np_192_nt_1 (Failed) + 202 - VertexCFD_WriteMatrix_test_OPENMP_np_192_nt_1 (Failed) +``` +Note: several unit tests rely on restart files that are not compatible across architecture. The listed tests given above are expected to fail outside of the continuous integration pipelines. + +## Regression Tests +VERTEX-CFD uses regression tests to make sure that the new capabilities do not introduce bugs/errors to the source code. In order to run regression tests, you can use the submission script provided below, which is written for SLURM scheduler: + +``` +#!/bin/bash +#SBATCH -N 1 +#SBATCH --ntasks-per-node 32 +#SBATCH --output output.log +#SBATCH --error error.log +#SBATCH --job-name=regression-test + +source /trilinos-cuda-config.sh +#source /vertex-env-cpu.sh # For GPU comment above line, and use this line. + +export OMP_PROC_BIND=true +export OMP_PLACES=threads + +export IOSS_PROPERTIES="COMPOSE_RESULTS=on:MINIMIZE_OPEN_FILES=on:MAXIMUM_NAME_LENGTH=64:DUPLICATE_FIELD_NAME_BEHAVIOR=WARNING" +export EXODUS_NETCDF4=1 + +export MAP_STRING=slot:pe=${SLURM_CPUS_PER_TASK} + +cd regression_test +pytest -k "test" +``` + +The example regression test output is as follows: + +``` +============================= test session starts ============================== +platform linux -- Python 3.9.16, pytest-6.2.5, py-1.11.0, pluggy-1.5.0 +rootdir: /regression_test, configfile: pytest.ini +collected 37 items + +test_full_induction_mhd/test_current_sheet/test_current_sheet.py::TestCurrentSheet::test_2d_long PASSED [ 6%] +test_full_induction_mhd/test_mhd_ldc/test_mhd_ldc.py::TestMHDLDC::test_2d_rotated_mhd_ldc[bx] PASSED [ 13%] +test_full_induction_mhd/test_mhd_ldc/test_mhd_ldc.py::TestMHDLDC::test_2d_rotated_mhd_ldc[by] PASSED [ 20%] +. +. +. +test_incompressible/test_taylor_green_vortex/test_taylor_green_vortex.py::TestTaylorGreenVortex::test_2d_mesh_convergence_laminar PASSED [ 93%] +test_incompressible/test_wale_cavity/test_wale_cavity.py::TestWaleCavity::test_3d_wale_cavity PASSED [100%] +========== 0 failed, 37 passed, 0 deselected in 40525.94s (11:15:25) ========== +``` + + + diff --git a/docs/scripts/slurm-submission-regression-test.sh b/docs/scripts/slurm-submission-regression-test.sh new file mode 100644 index 0000000..943017f --- /dev/null +++ b/docs/scripts/slurm-submission-regression-test.sh @@ -0,0 +1,20 @@ +#!/bin/bash +#SBATCH -N 1 +#SBATCH --ntasks-per-node 32 +#SBATCH --output output.log +#SBATCH --error error.log +#SBATCH --job-name=regression-test + +source /trilinos-cuda-config.sh +#source /vertex-env-cpu.sh # For GPU comment above line and use this line. + +export OMP_PROC_BIND=true +export OMP_PLACES=threads + +export IOSS_PROPERTIES="COMPOSE_RESULTS=on:MINIMIZE_OPEN_FILES=on:MAXIMUM_NAME_LENGTH=64:DUPLICATE_FIELD_NAME_BEHAVIOR=WARNING" +export EXODUS_NETCDF4=1 + +export MAP_STRING=slot:pe=${SLURM_CPUS_PER_TASK} + +cd regression_test +pytest -k "test" diff --git a/docs/scripts/slurm-submission-run.sh b/docs/scripts/slurm-submission-run.sh new file mode 100644 index 0000000..575ce47 --- /dev/null +++ b/docs/scripts/slurm-submission-run.sh @@ -0,0 +1,13 @@ +#!/bin/bash +#SBATCH -N 1 +#SBATCH --ntasks-per-node=32 +#SBATCH --time=1:00:00 +#SBATCH -o output.log +#SBATCH -e error.log + +source PATH_TO_ENVIRONMENT_SCRIPT + +export OMP_PROC_BIND=true +export OMP_PLACES=threads + +mpirun /bin/vertexcfd --i=/incompressible_2d_channel.xml diff --git a/docs/scripts/slurm-submission-unit-test.sh b/docs/scripts/slurm-submission-unit-test.sh new file mode 100644 index 0000000..142bee1 --- /dev/null +++ b/docs/scripts/slurm-submission-unit-test.sh @@ -0,0 +1,19 @@ +#!/bin/bash +#SBATCH -N 1 +#SBATCH --ntasks-per-node 32 +#SBATCH --time 0:10:00 +#SBATCH --output output.log +#SBATCH --error error.log + +source /trilinos-cuda-config.sh +#source /vertex-env-cpu.sh # For GPU comment above line and use this line. + +export OMP_PROC_BIND=true +export OMP_PLACES=threads + +export IOSS_PROPERTIES="COMPOSE_RESULTS=on:MINIMIZE_OPEN_FILES=on:MAXIMUM_NAME_LENGTH=64:DUPLICATE_FIELD_NAME_BEHAVIOR=WARNING" +export EXODUS_NETCDF4=1 + +export MAP_STRING=slot:pe=${SLURM_CPUS_PER_TASK} + +ctest -j ${SLURM_NTASKS_PER_NODE} diff --git a/docs/scripts/spack-trilinos16.yaml b/docs/scripts/spack-trilinos16.yaml new file mode 100644 index 0000000..3ad1c3d --- /dev/null +++ b/docs/scripts/spack-trilinos16.yaml @@ -0,0 +1,60 @@ +spack: + concretizer: + unify: when_possible + + config: + build_stage: + - $spack/var/spack/spack-stage/build-$arch-$date/ + misc_cache: $spack/.cache + build_jobs: 32 + install_tree: + root: $spack/opt/spack/ + projections: + all: install-{os}-{target}-{compiler.name}-{compiler.version}/{name}-{version} + keep_stage: true + verify_ssl: true + checksum: true + dirty: false + build_language: C + ccache: false + db_lock_timeout: 120 + package_lock_timeout: null + shared_linking: + type: rpath + bind: false + allow_sgid: true + locks: true + suppress_gpg_warnings: false + connect_timeout: 10 + + compilers: + - compiler: # EDIT: change below with your compiler of choice + spec: gcc@13.2.0 + paths: # EDIT: Change those based on the location of the compiler location you prefer + cc: /software/dev_tools/swtree/cs400/gcc/13.2.0/centos7.5_gnu8.5.0/bin/gcc + cxx: /software/dev_tools/swtree/cs400/gcc/13.2.0/centos7.5_gnu8.5.0/bin/g++ + f77: /software/dev_tools/swtree/cs400/gcc/13.2.0/centos7.5_gnu8.5.0/bin/gfortran + fc: /software/dev_tools/swtree/cs400/gcc/13.2.0/centos7.5_gnu8.5.0/bin/gfortran + flags: {} + operating_system: centos7 # EDIT: update according to `spack arch`: just the OS version + target: x86_64 + modules: # EDIT: update with a list of modules you want to load by default + - gcc/13.2.0 + + packages: + all: + target: [broadwell] # EDIT: Change this according to `spack arch` + compiler: [gcc@13.2.0] # EDIT: Change according to your compiler of choice + providers: # EDIT: Change versions below according to the default in your machine + mpi: [intel-oneapi-mkl] + blas: [intel-oneapi-mkl] + lapack: [intel-oneapi-mkl] + pkgconfig: [pkg-config] + + specs: + - python + - ninja + - boost + - intel-oneapi-mkl + - googletest + - trilinos@16.0.0 +chaco+exodus+hdf5+intrepid2+kokkos+mpi+nox+openmp+panzer+phalanx+shards+shared+stk+tempus+zoltan2 diff --git a/docs/scripts/trilinos-cuda-config.sh b/docs/scripts/trilinos-cuda-config.sh new file mode 100644 index 0000000..2465a87 --- /dev/null +++ b/docs/scripts/trilinos-cuda-config.sh @@ -0,0 +1,75 @@ +#!/bin/bash +# This is a sample Trilinos configuration script for Albany on perlmutter + +source trilinos-cuda-env.sh + +# Cleanup old cmake files +rm -rf CMake* + +# Set Trilinos build path +BUILD_DIR=`pwd` + +# EDIT: Change this based on your NVCC WRAPPER location +NVCC_WRAPPER= + +# EDIT: Change with path to Trilinos source directory +TRILINOS_SOURCE_DIR= + +# EDIT: Change with path to boost +BOOST_DIR= + +TRILINOS_INSTALL_DIR= + +export CRAYPE_LINK_TYPE=dynamic +export CRAY_CPU_TARGET=x86-64 + +cmake \ + -D CMAKE_C_COMPILER=cc \ + -D CMAKE_CXX_COMPILER=${NVCC_WRAPPER} \ + -D CMAKE_Fortran_COMPILER=ftn \ +\ + -D CMAKE_INSTALL_PREFIX:PATH=${TRILINOS_INSTALL_DIR} \ + -D CMAKE_BUILD_TYPE:STRING=RELEASE \ +\ + -D BUILD_SHARED_LIBS=ON \ + -D Trilinos_ENABLE_ALL_PACKAGES=ON \ + -D Trilinos_ENABLE_SECONDARY_TESTED_CODE=ON \ + -D Trilinos_ENABLE_EXPLICIT_INSTANTIATION=ON \ + -D Trilinos_ENABLE_PyTrilinos=OFF \ + -D Trilinos_SHOW_DEPRECATED_WARNINGS=OFF \ + -D TPL_ENABLE_MPI=ON \ + -D TPL_Netcdf_PARALLEL=FALSE \ +\ + -D TPL_ENABLE_HDF5:STRING=ON \ + -D HDF5_INCLUDE_DIRS:PATH=${HDF5_DIR}/include \ + -D HDF5_LIBRARY_DIRS:PATH=${HDF5_DIR}/lib\ +\ + -D TPL_ENABLE_Netcdf=ON \ + -D Netcdf_INCLUDE_DIRS:PATH=${NETCDF_DIR}/include \ + -D Netcdf_LIBRARY_DIRS:PATH=${NETCDF_DIR}/lib \ +\ + -D Kokkos_ENABLE_CUDA:BOOL=ON \ + -D Kokkos_ENABLE_CUDA_LAMBDA:BOOL=ON \ + -D Kokkos_ENABLE_CUDA_UVM:BOOL=OFF \ + -D Kokkos_ENABLE_IMPL_CUDA_MALLOC_ASYNC:BOOL=OFF \ +\ + -D TPL_ENABLE_Boost:BOOL=ON \ + -D TPL_ENABLE_BoostLib=ON \ + -D Boost_INCLUDE_DIRS:PATH=${BOOST_DIR}/include \ + -D Boost_LIBRARY_DIRS:PATH=${BOOST_DIR}/lib \ +\ + -D TPL_ENABLE_Krino=OFF \ + -D TPL_ENABLE_Matio=OFF \ + -D TPL_ENABLE_CGNS=OFF \ + -D TPL_ENABLE_METIS=ON \ + -D TPL_ENABLE_ParMETIS=ON \ + -D Trilinos_ENABLE_Stokhos:BOOL=OFF \ +\ + -D TPL_ENABLE_SuperLU:BOOL=OFF \ + -D ML_ENABLE_SuperLU:BOOL=OFF \ + -D TPL_ENABLE_BLAS:BOOL=ON \ + -D TPL_BLAS_LIBRARIES:STRING="${CRAY_PE_LIBSCI_PREFIX_DIR}/lib/libsci_gnu.so" \ + -D TPL_ENABLE_LAPACK:BOOL=ON \ + -D TPL_LAPACK_LIBRARIES:STRING="${CRAY_PE_LIBSCI_PREFIX_DIR}/lib/libsci_gnu.so" \ +\ +${TRILINOS_SOURCE_DIR} diff --git a/docs/scripts/trilinos-cuda-env.sh b/docs/scripts/trilinos-cuda-env.sh new file mode 100644 index 0000000..f9afb96 --- /dev/null +++ b/docs/scripts/trilinos-cuda-env.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +module load PrgEnv-gnu/8.5.0 +module load gcc-native/12.3 +module load cudatoolkit/12.4 +module load craype-accel-nvidia80 +module load cray-libsci/23.12.5 +module load craype/2.7.30 +module load cray-mpich/8.1.28 +module load cray-hdf5-parallel/1.12.2.9 +module load cray-netcdf-hdf5parallel/4.9.0.9 +module load cray-parallel-netcdf/1.12.3.9 +module load cmake/3.30.2 + +module load spack +spack env activate cuda +spack load metis +spack load parmetis + +export MPICH_ENV_DISPLAY=1 +export MPICH_VERSION_DISPLAY=1 +export OMP_STACKSIZE=128M +export OMP_PROC_BIND=spread +export OMP_PLACES=threads +export HDF5_USE_FILE_LOCKING=FALSE +export MPICH_GPU_SUPPORT_ENABLED=1 +export CUDATOOLKIT_VERSION_STRING=${CRAY_CUDATOOLKIT_VERSION#*_} + +export CRAY_ACCEL_TARGET="nvidia80" + +export KOKKOS_MAP_DEVICE_ID_BY=mpi_rank +export CUDA_MANAGED_FORCE_DEVICE_ALLOC=1 +export TPETRA_ASSUME_GPU_AWARE_MPI=0 diff --git a/docs/scripts/vertex-config.sh b/docs/scripts/vertex-config.sh new file mode 100644 index 0000000..a16da69 --- /dev/null +++ b/docs/scripts/vertex-config.sh @@ -0,0 +1,46 @@ +#!/bin/sh + +SOURCE=/ +INSTALL="" +BUILD="RelWithDebInfo" + +rm -rf CMake* +rm -rf .ninja* +rm DartConfiguration.tcl +rm CTestTestfile.cmake +rm build.ninja +rm VertexCFDConfig.cmake +rm -rf Testing + +# EDIT: Uncomment this line for GPU and update this based on your NVCC WRAPPER location +#NVCC_WRAPPER= + +# Unset variable set by spack modules. +# If this is present, any directories present will be treated +# as "implicit" library paths by CMake and it will strip them +# out of the executable RPATHS. Then you have to set +# LD_LIBRARY_PATH appropriately to run jobs. +unset LIBRARY_PATH + +# EDIT: This command is for CPU. Comment it for GPU. +cmake \ + -D CMAKE_BUILD_TYPE=${BUILD} \ + -D CMAKE_INSTALL_PREFIX=${INSTALL} \ + -D VertexCFD_ENABLE_COVERAGE_BUILD=OFF \ + -D CMAKE_CXX_FLAGS="-Wall -Wextra -Wpedantic -fdiagnostics-color" \ + -D VertexCFD_ENABLE_TESTING=ON \ + -D Trilinos_ROOT= \ + \ + ${SOURCE} + +# EDIT: Uncomment this command for GPU. +#cmake \ +# -D CMAKE_BUILD_TYPE=${BUILD} \ +# -D CMAKE_INSTALL_PREFIX=${INSTALL} \ +# -D CMAKE_CXX_COMPILER=${NVCC_WRAPPER} \ +# -D VertexCFD_ENABLE_COVERAGE_BUILD=OFF \ +# -D CMAKE_CXX_FLAGS="-Wall -Wextra -Wpedantic -fdiagnostics-color" \ +# -D VertexCFD_ENABLE_TESTING=ON \ +# -D Trilinos_ROOT= \ +# \ +# ${SOURCE} diff --git a/docs/scripts/vertex-env-cpu.sh b/docs/scripts/vertex-env-cpu.sh new file mode 100644 index 0000000..ccd8b00 --- /dev/null +++ b/docs/scripts/vertex-env-cpu.sh @@ -0,0 +1,26 @@ +#!/bin/bash +module use # EDIT: Update this with the module location, as an example: module use spack/share/spack/modules/linux-centos7-broadwell/ +install=//share/spack/modules/linux-centos7-haswell/ +echo $install + +module load gcc/13.2.0 + +module use $install +module load gcc-runtime +module load openmpi +module load cmake +module load ninja +module load boost +module load netcdf-c +module load parmetis +module load intel-oneapi-mkl +module load cgns +module load googletest +module load hdf5 +module load zlib-ng +module load trilinos/16.0.0-gcc-13.2.0-qzebvtj +HDF5_DIR=//opt/spack/install-centos7-haswell-gcc-13.2.0/hdf5-1.14.5/ +ZLIB_DIR=//opt/spack/install-centos7-haswell-gcc-13.2.0/zlib-ng-2.2.3/ + +GCC_ROOT=// +unset LIBRARY_PATH diff --git a/docs/styles.css b/docs/styles.css new file mode 100644 index 0000000..781b16f --- /dev/null +++ b/docs/styles.css @@ -0,0 +1,46 @@ +body { + font-family: Arial, sans-serif; + margin: 0; + padding: 0; + background-color: #f4f4f4; +} + +header { + background-color: #333; + color: #fff; + padding: 10px 0; + text-align: center; +} + +nav ul { + list-style-type: none; + padding: 0; +} + +nav ul li { + display: inline; + margin: 0 10px; +} + +nav ul li a { + color: #fff; + text-decoration: none; +} + +main { + padding: 20px; +} + +h1, h2 { + color: #333; +} + +footer { + background-color: #333; + color: #fff; + text-align: center; + padding: 10px 0; + position: absolute; + bottom: 0; + width: 100%; +} diff --git a/docs/theory.md b/docs/theory.md new file mode 100644 index 0000000..daf4528 --- /dev/null +++ b/docs/theory.md @@ -0,0 +1,322 @@ +--- +parent: VERTEX-CFD v1.0 User Guide +title: Theory +nav_order: 2 +usemathjax: true +--- + +# Theory + +--- + +## Governing equations + +VERTEX-CFD implements the entropically damped artificial compressibility (EDAC) Navier-Stokes equations, a temperature equation, and a magneto-hydrodynamics (MHD) equation (inductionless equation). Coupling between the different equations is ensured by the buoyancy force and the Lorentz force. + +$$ +\begin{align} +\left\{ +\begin{matrix} + \nabla \cdot \mathbf{u} = 0 \\ + \partial_t \mathbf{u} + (\mathbf{u} \cdot \nabla) \mathbf{u} = -\frac{1}{\rho}\nabla P + \nu \Delta \mathbf{u} + \frac{1}{\rho}\mathbf{J} \times \mathbf{B^0} - \mathbf{g} \beta (T - T_0) \\ + \rho C_p \left( \partial_t T + \mathbf{u} \cdot \nabla T \right) = \nabla \cdot (k \nabla T ) + q^{'''} \\ + \mathbf{J} = \sigma ( -\nabla \varphi + \mathbf{u} \times \mathbf{B^0} ) \\ + \nabla \cdot (\sigma \nabla \varphi) = \nabla \cdot [ \sigma \mathbf{u} \times \mathbf{B^0} ] +\end{matrix} +\right. +\end{align} +$$ + +The equations are recast in a conservative form and solved for the pressure $$P$$, the velocity $$\mathbf{u}$$, the temperature $$T$$, and the electric potential $$\varphi$$. + +$$ +\begin{align}\label{eq:pdes} +\left\{ +\begin{matrix} + \nabla \cdot \mathbf{u} = 0 \\ + \partial_t \rho \mathbf{u} + \rho (\mathbf{u} \cdot \nabla) \mathbf{u} = -\nabla P + \rho \nu \Delta \mathbf{u} + f^L - \rho \mathbf{g} \beta (T - T_0) \\ + f^L = \mathbf{J} \times \mathbf{B^0} = \sigma \left( -\nabla \varphi \times \mathbf{B^0} + (\mathbf{B} \cdot \mathbf{u}) \cdot \mathbf{B^0} - ||\mathbf{B^0}||^2 \mathbf{u} \right) \\ + \rho C_p \left( \partial_t T + \mathbf{u} \cdot \nabla T \right) = \nabla \cdot (k \nabla T ) + q^{'''} \\ + \nabla \cdot (\sigma \nabla \varphi) = \nabla \cdot [ \sigma \mathbf{u} \times \mathbf{B^0} ] +\end{matrix} +\right. +\end{align} +$$ + + +## Discretized equations + +VERTEX-CFD employs a finite element discretization method and high-order implicit temporal integrators to integrate partial differential equations (PDEs). Numerical stability of the solution is ensured by using an L-stable implicit temporal integrator and the appropriate mesh density. + +A continuous Galerkin finite element method from the Trilinos package, Panzer \cite{panzer-website}, is employed to discretize the equations presented as Eq. \ref{eq:pdes}. Considering a finite dimensional subspace $$V^p_h$$, an approximate solution $$U_h$$ of $$U$$ can be expressed as + +$$ +\begin{equation} + U_h = \sum_i U_i \phi_i~~, +\end{equation} +$$ + +where $$\phi_i \in V^p_h$$ is a basis function. A weak form of Eq. \ref{eq:pdes} is obtained by substituting $$U$$ with $$U_h$$, taking an inner product between each term of the partial differential equation and a test function and integrating over the computational volume: + +$$ +\begin{equation}\label{eq:weak-form} + \iiint \left[ \phi^T \partial_t U + \phi^T \nabla \cdot F(U) - \phi^T \nabla \cdot G(U, \nabla U) - \phi^T S(U) \right] d\Omega = 0.0~~. +\end{equation} +$$ + +Equation \ref{eq:weak-form} can be further transformed by integrating per part the conservative fluxes to yield boundary fluxes denoted by the under script $$bc$$: + +$$ +\begin{align}\label{eq:weak-form-bc} +\iiint \phi^T \partial_t U d\Omega - \iiint \nabla \phi^T \cdot F(U) d\Omega + \\ \iiint \nabla \cdot \phi^T \cdot G(U, \nabla U) d\Omega - \iiint \phi^T S(U) d\Omega \nonumber = \\ -\iint \phi^T F_{bc}(U) \vec{n} d \delta \Omega + \iint \phi^T G_{bc}(U, \nabla U) \vec{n} d \delta \Omega~~. +\end{align} +$$ + +Boundary fluxes are evaluated at quadrature points, and their contribution is added to the global residuals. The boundary flux $$G$$ is evaluated with the symmetric interior penalty method. Implementation of the boundary conditions is further detailed in Section [Boundary conditions](#boundary-conditions). + +The time-derivative terms $$\partial_t U$$ are evaluated with a high-order temporal integrator (SDIRK-22 or SDIRK-54) from the Tempus package \cite{tempus-website}. Given a test function $$\phi_i$$ of order $$p$$, integral terms are evaluated with a $$p+1$$ quadrature rule. VERTEX-CFD does not currently implement any numerical method to stabilize the numerical solution and solely relies on the numerical dissipation from the discretization method and the implicit temporal integrator. This strategy has been sufficient for laminar flows, as demonstrated in the following sections. + + +## Boundary conditions + +Boundary conditions are weakly imposed by computing numerical flux at the boundaries' provided boundary values. The boundary conditions implemented in VERTEX-CFD are listed below: + +The boundary conditions implemented in VERTEX-CFD are listed below: + +- [Periodic boundary](#periodic-boundary) +- [Dirichlet with time-transient variation](#dirichlet-boundary) +- [Symmetry for isothermal flow](#symmetry-boundary-condition) +- [No-slip for viscous flow](#no-slip-boundary-condition) +- [Rotating wall for isothermal flow](#rotating-wall-boundary-condition) +- [Laminar flow](#laminar-flow) +- [Outflow with back pressure](#outflow-boundary-condition) +- [Cavity Lid](#cavity-Lid) + +The vector solution is denoted by $$U_{bc} = (P_{p,{bc}}, \mathbf{u}_{bc}, T_{bc}, \varphi_{bc})$$ at the boundary. It should be noted that when the energy equation and the electric potential equation are not solved, the temperature $$T_{bc}$$ and the electric potential $$\varphi_{bc}$$ are ignored. + +### Periodic boundary +Users can set periodic boundaries in the input file by using the Trilinos specific syntax described in [Panzer_STK class](https://docs.trilinos.org/dev/packages/panzer/doc/html/Panzer__STK__PeriodicBC__Parser_8cpp_source.html). Meshes on periodic faces must be identical for the logic to work properly. + +### Dirichlet boundary +The Dirichlet boundary condition denotes the Dirichlet boundary condition in VERTEX-CFD. The velocity is set equal to the user-specified values or Dirichlet values $$\mathbf{u}_D$$ while the Lagrange pressure and the boundary gradients are set to the interior values. The temperature is also set to a user-specified value $$T_{bc}$$. Linear ramping in time is also available and can be used to vary each primitive variable independently. + +$$ +\begin{equation} +\left\{ \ +\begin{matrix} + u_{i,bc}(\mathbf{r}, t) = u_{i,D}(t) \\ + P_{p,{bc}}(\mathbf{r}, t) = P(\mathbf{r}, t) \\ + \partial_i U_{bc}(\mathbf{r}, t) = \partial_i U(\mathbf{r}, t) \\ + T_{bc}(\mathbf{r}, t) = T_{D} +\end{matrix} +\right. +\end{equation} +$$ + +### Symmetry boundary condition +The symmetry boundary condition is a no-penetration condition. The normal component of the fluid velocity to the wall is zero, whereas the tangential component is unrestricted. The same observation is also valid for the temeprature gradient. Assuming the outward normal vector to a wall boundary is denoted by $$\mathbf{n}_{bc} = \left(n_{bc,x}, n_{bc,y}, n_{bc,z} \right)$$ in a 3D computational domain, the boundary condition for the primitive variables reads as follows: + +$$ +\begin{equation} +\left\{ +\begin{matrix} + P_{bc}(\mathbf{r}, t) &=& P(\mathbf{r}, t) \\ + \mathbf{u}_{bc}(\mathbf{r}, t) &=& \mathbf{u}(\mathbf{r}, t) - \left( \mathbf{u}(\mathbf{r}, t) \cdot \mathbf{n}_{bc} \right) \mathbf{n_{bc}} \\ + T_{bc}(\mathbf{r}, t) &=& T(\mathbf{r}, t) \\ + \varphi_{bc}(\mathbf{r}, t) &=& \varphi(\mathbf{r}, t) +\end{matrix} +\right. +\end{equation} +$$ + +The boundary gradients are a function of the interior values: + +$$ +\begin{align} + \partial_i U_{bc}(\mathbf{r}, t) =& \partial_i U(\mathbf{r}, t) \nonumber\\ + \partial_i T_{bc}(\mathbf{r}, t) =& \partial_i T(\mathbf{r}, t) - \left(\partial_i T(\mathbf{r}, t) \cdot \mathbf{n}_{bc} \right) n_{i} \\ + \partial_i \varphi_{bc}(\mathbf{r}, t) =& \partial_i \varphi(\mathbf{r}, t) - \left(\partial_i \varphi(\mathbf{r}, t) \cdot \mathbf{n}_{bc} \right) n_{i} \nonumber +\end{align} +$$ + +### No-slip boundary condition +The \emph{no-slip} boundary condition is used to model a viscous flow interacting with a moving wall. The velocity of the flow and the wall are the same: this can be put in the following mathematical form: + +$$ +\begin{equation} + \mathbf{u_{bc}} = \mathbf{u_{wall}} \ , +\end{equation} +$$ + +where $$\mathbf{u_{wall}}$$ is a user input parameter that is defaulted to the zero vector. Because this is a wall, the temperature is set to the wall temperature $$T_{wall}$$. The Lagrange pressure is set to its interior value: + +$$ +\begin{equation} +\left\{ +\begin{matrix} + P_{bc}(\mathbf{r}, t) &=& P(\mathbf{r}, t) \\ + \mathbf{u}_{bc}(\mathbf{r}, t) &=& \mathbf{u_{wall}} \\ + T_{bc}(\mathbf{r}, t) &=& T_{wall} +\end{matrix} +\right. +\end{equation} +$$ + +All boundary gradients are set to the interior values: + +$$ +\begin{equation} + \partial_i f_{bc}(\mathbf{r}, t) = \partial_i f(\mathbf{r}, t) +\end{equation} +$$ + +In VERTEX-CFD, the wall boundary velocity $$\mathbf{u_{wall}}$$ can linearly vary as a function of time. This is particularly useful when modeling flow with non-natural initial conditions (non-stationary flow over a stationary obstacle). The wall boundary velocity is set to initially match the flow velocity and linearly decreases to zero with time. This strategy is commonly adopted to ease the work of the numerical solver while developing steady-state flow. + + +### Rotating wall boundary condition +The \emph{rotating wall} boundary condition is used to model the interaction of a fluid with a rotating wall. The wall in contact with the fluid rotates with an angular velocity $$\omega_w$$ in the XY plane. The Lagrange pressure is set to the interior value, and the fluid velocity is computed from the angular velocity and the fluid temperature set to the wall temperature $$T_{wall}$$, as follows: + +$$ +\begin{equation} +\left\{ + \begin{matrix} + P_{bc}(\mathbf{r}, t) &=& P(\mathbf{r}, t) \\ + \mathbf{u}_{bc}(\mathbf{r}, t) &=& \omega_{wall} \left(-y, x, 0.0 \right) \\ + T_{bc}(\mathbf{r}, t) &=& T_{wall} + \end{matrix} +\right. +\end{equation} +$$ + +The Cartesian coordinates are defined as $$x$$ and $$y$$, and the z-component of the velocity is assumed to be zero when used in 3D. + +All boundary gradients are set to the interior values such as the following: + +$$ +\begin{equation} + \partial_i f_{bc}(\mathbf{r}, t) = \partial_i f(\mathbf{r}, t) +\end{equation} +$$ + +### Laminar flow +The laminar flow boundary condition sets a parabolic profile for the velocity in the wall normal direction. The input parameters are the average velocity amplitude $$u_i^{avg}$$, the coordinates of the two points on the circle which can be connected by a line that passes through the circle's center. The resultant inlet velocity profiles can be calculated as follows: + +$$ +\begin{equation} + u_i(x,y,z) = C_i u_i^{avg}\cdot\mathbf{n}\left(1.0 - \frac{r^2}{R^2}\right)~~, +\end{equation} +$$ + +where $$R$$ is the characteristic radius of the circle, $$\mathbf{r}$$ is the distance to the circle center which is calculated from the two points provided by the user, and $$C_i$$ is a constant based on the dimensionality of the problem. In 2D, $$C_i$$ is $$3/2$$, whereas in 3D, it is $$2.0$$. This boundary condition can be used with 2D rectangular channels and 3D pipes. The flow direction is calculated based on the surface normals where the boundary condition is applied. A uniform inlet temperature can also be provided if solving for the temperature equation. The boundary conditions are as follows: + +$$ +\begin{equation} +\left\{ + \begin{matrix} + P_{bc}(\mathbf{r}, t) &=& P(\mathbf{r}, t) \\ + \mathbf{u}_{bc}(\mathbf{r}, t) &=& \left(u_i\cdot n_x, u_i\cdot n_y, u_i\cdot n_z \right) \\ + T_{bc}(\mathbf{r}, t) &=& T_{inlet} + \end{matrix} +\right. +\end{equation} +$$ + +All boundary gradients are set to interior values such as the following: + +$$ +\begin{equation} + \partial_i f_{bc}(\mathbf{r}, t) = \partial_i f(\mathbf{r}, t) +\end{equation} +$$ + +### Outflow boundary condition +The outflow boundary condition is employed when the back pressure at an outlet is known. The Lagrange pressure is computed from the back pressure $$P_b$$: + +$$ +\begin{equation} + P_{p,bc} = P_b +\end{equation} +$$ + +The velocity, the temperature, and all boundary gradients are set to their respective interior values, as follows: + +$$ +\begin{equation} +\left\{ + \begin{matrix} + \mathbf{u}_{bc}(\mathbf{r}, t) &=& \mathbf{u}(\mathbf{r}, t) \\ + \partial_i U_{bc}(\mathbf{r}, t) &=& \partial_i U(\mathbf{r}, t) \\ + T_{bc}(\mathbf{r}, t) &=& T(\mathbf{r}, t) \\ + \partial_i T_{bc}(\mathbf{r}, t) &=& \partial_i T(\mathbf{r}, t) + \end{matrix} +\right. +\end{equation} +$$ + +### Cavity Lid + +A special boundary condition is implemented for the lid-driven cavity case to provide a smooth transition from the lid velocity to the no-slip condition at the wall, as described by Leriche and Gavrilakis \cite{Leriche2000}. The condition assumes that the domain consists of a 2D or 3D cube with a half width of $$h$$, centered on the origin. The Lagrange pressure at the boundary is set to the interior value: + +$$ +\begin{equation} + P_{bc} \left(\mathbf{r}, t \right) = P \left(\mathbf{r}, t \right) +\end{equation} +$$ + +If the energy equation is to be solved, then the boundary temperature is set to a specified constant value: + +$$ +\begin{equation} + T_{bc} \left(\mathbf{r}, t \right)= T_b +\end{equation} +$$ + +The user is required to specify the index $$n$$ aligned with the boundary normal vector and the index $$v$$ of the direction in which the velocity is aligned. The velocity components are then defined as follows: + +$$ +\begin{equation} +\left\{ + \begin{matrix} + u_i &=& \left( 1 - \left(r_i / h \right)^{18} \right)^2 \\ + u_{j \neq i} &=& 0 + \end{matrix} +\right. +\end{equation} +$$ + +where $$u_i$$ is the nominal wall velocity and $$r_i$$ is the distance of the current location from the origin in the $$i^{th}$$ direction. + +## Initial conditions + +The initial conditions are specified for the velocity $$\mathbf{u}$$, the Lagrange pressure $$P$$, and the temperature $$T$$ when solving for the energy equation. The electric potential $$\varphi$$ is assumed constant and is set to $$\varphi_0$$ in all initial conditions presented below. + +### Uniform initial conditions +The normalized Lagrange pressure, the velocity, and the temperature are initialized to constant values across each block of the computational domain: + +$$ +\begin{align} + \left\{ + \begin{matrix} + P(\mathbf{r}, t) &=& P_{p,0} \\ + \mathbf{u}(\mathbf{r}, t) &=& \mathbf{u}_0 \\ + T(\mathbf{r}, t) &=& T_0 + \end{matrix} + \right. +\end{align} +$$ + +### Laminar flow +When using the laminar flow initial condition, the x-component of the velocity is initialized with a parabolic profile. The Lagrange pressure and the temperature are initialized to constant values. The current implementation can be used for two geometries: a 2D rectangular channel and a 3D pipe. The parabolic profile is function of the average velocity and the channel height $$h$$ in 2D or the pipe diameter $$D$$ in 3D. It is assumed that the flow direction is aligned with the x-axis, which yields the following expressions: + +$$ +\begin{align} + \left\{ + \begin{matrix} + P(\mathbf{r}, t) &=& P_{p,0} \\ + \mathbf{u}(\mathbf{r}, t) &=& \left(\frac{3}{2}\cdot u_{avg}\left(1.0 - \frac{y^2}{h}\right), 0.0 \right) \text{ in 2D} \\ + \mathbf{u}(\mathbf{r}, t) &=& \left(2\cdot u_{avg}\left(1.0 - \frac{y^2 + z^2}{D}\right), 0.0, 0.0 \right) \text{ in 3D} \\ + T(\mathbf{r}, t) &=& T_0 + \end{matrix} + \right. +\end{align} +$$ diff --git a/docs/usage.md b/docs/usage.md new file mode 100644 index 0000000..2a50960 --- /dev/null +++ b/docs/usage.md @@ -0,0 +1,105 @@ +--- +parent: VERTEX-CFD v1.0 User Guide +title: Usage +nav_order: 3 +usemathjax: true +--- + +# Usage + +Once installed, VERTEX-CFD relies on two files. The first one is the 'vertexcfd' executable, and the second one is the input file for the simulation. After the installation, the executable is located in `/bin/vertexcfd`. The input file is case-specific, and there are example case files in `vertex-cfd/examples/inputs`. In this document, the input file located in `vertex-cfd/examples/inputs/incompressible/incompressible_2d_channel.xml` will be used as an example case. + +## Running a simulation +In order to run a simulation in serial, vertexcfd can be called directly as + +``` +/bin/vertexcfd --i=PATH_TO_INPUT_FILE/incompressible_2d_channel.xml +``` +To run in parallel, `mpirun` is required. An example script for the SLURM scheduler is below: +``` +#!/bin/bash +#SBATCH -N 1 +#SBATCH --ntasks-per-node=32 +#SBATCH --time=1:00:00 +#SBATCH -o output.log +#SBATCH -e error.log + +source PATH_TO_ENVIRONMENT_SCRIPT + +export OMP_PROC_BIND=true +export OMP_PLACES=threads + +mpirun /bin/vertexcfd --i=/incompressible_2d_channel.xml +``` +Once the simulation starts, the example output should look like the following: +``` +============================================================================ +Time Integration Begin +Thu Mar 31 21:46:09 2022 + + Stepper = Backward Euler + Simulation Time Range [0, 0.2] +---------------------------------------------------------------------------- + +Time Step = 1; Order = 1 +CFL = 1.000e+00; dt = 6.186e-03; Time = 0.00000e+00 + | Nonlinear | F 2-Norm | # Linear | R 2-Norm | + 0 6.65e-02 + 1 2.03e-02 1 6.45e-16 + 2 4.66e-04 1 4.25e-16 + 3 5.40e-07 1 5.36e-16 + 4 3.19e-13 1 6.58e-16 +Time step time to completion (s): 5.97e+00 + +Time Step = 2; Order = 1 +CFL = 1.000e+00; dt = 5.644e-03; Time = 6.18583e-03 + | Nonlinear | F 2-Norm | # Linear | R 2-Norm | + 0 5.73e-02 + 1 5.72e-03 1 4.68e-16 + 2 5.40e-05 1 4.01e-16 + 3 3.47e-09 1 7.18e-16 +Time step time to completion (s): 8.96e+00 + +Time Step = 3; Order = 1 +CFL = 1.000e+00; dt = 5.385e-03; Time = 1.18299e-02 + | Nonlinear | F 2-Norm | # Linear | R 2-Norm | + 0 5.37e-02 + 1 4.14e-03 1 4.17e-16 + 2 3.35e-05 1 3.47e-16 + 3 2.01e-09 1 5.54e-16 +Time step time to completion (s): 7.03e-01 +... ... +... ... +... ... +... ... +Time Step = 40; Order = 1 +CFL = 1.000e+00; dt = 4.853e-03; Time = 1.93731e-01 + | Nonlinear | F 2-Norm | # Linear | R 2-Norm | + 0 3.57e-02 + 1 1.15e-03 1 3.89e-16 + 2 1.68e-06 1 3.90e-16 + 3 1.66e-12 1 3.20e-16 +Time step time to completion (s): 1.73e+00 + 41 * (dt = 4.852e-03, new = 1.417e-03) Adjusting dt to hit final time. + +Time Step = 41; Order = 1 +CFL = 1.000e+00; dt = 1.417e-03; Time = 1.98583e-01 + | Nonlinear | F 2-Norm | # Linear | R 2-Norm | + 0 3.56e-02 + 1 3.11e-04 1 2.95e-16 + 2 3.67e-08 1 2.73e-16 + 3 4.40e-16 1 2.86e-16 +Time step time to completion (s): 6.91e+00 + +---------------------------------------------------------------------------- +Total runtime = 1.45e+02 sec + = 2.42e+00 min + = 0.04 hr +Thu Mar 31 21:51:51 2022 +Time integration complete. +============================================================================ +``` +Once the simulation is completed, the results should be ready for visualization. For the visualization, we suggest using ParaView. However, any visualization software that supports Exodus format should work. The example solution file screenshot visualized in Paraview is shown below: + +![paraview-ss](https://github.com/user-attachments/assets/75483e4a-cfec-4a51-891f-3b7c72262ba7) + diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt deleted file mode 100644 index 9ce15a4..0000000 --- a/examples/CMakeLists.txt +++ /dev/null @@ -1,80 +0,0 @@ -set(REGRESSION_XML_FILES - inputs/incompressible/incompressible_2d_backward_facing_step.xml - inputs/incompressible/incompressible_2d_channel_periodic.xml - inputs/incompressible/incompressible_2d_concentric_cylinder_convection.xml - inputs/incompressible/incompressible_2d_heated_channel.xml - inputs/incompressible/incompressible_2d_k_omega_turbulence_channel.xml - inputs/incompressible/incompressible_2d_laminar_airfoil.xml - inputs/incompressible/incompressible_2d_planar_poiseuille.xml - inputs/incompressible/incompressible_2d_planar_poiseuille_cuda.xml - inputs/incompressible/incompressible_2d_realizable_k_epsilon_turbulence_channel.xml - inputs/incompressible/incompressible_2d_rotating_cylinder_viscous.xml - inputs/incompressible/incompressible_2d_spalart_allmaras_turbulence_channel.xml - inputs/incompressible/incompressible_2d_spalart_allmaras_turbulence_heated_channel.xml - inputs/incompressible/incompressible_2d_standard_k_epsilon_turbulence_channel.xml - inputs/incompressible/incompressible_2d_taylor_green_vortex.xml - inputs/incompressible/incompressible_2d_tee_junction.xml - inputs/incompressible/incompressible_3d_channel_periodic.xml - inputs/incompressible/incompressible_2d_triangular_cavity_Re100.xml - inputs/incompressible/incompressible_3d_wale_cavity.xml - inputs/incompressible/incompressible_blunt_plate_laminar_flow_2d.xml - inputs/incompressible/incompressible_oscillating_heated_laminar_flow_2d.xml - inputs/induction_less_mhd/mhd_2d_hartmann_pb_periodic_insulating.xml - inputs/induction_less_mhd/mhd_2d_hartmann_pb_periodic_insulating_cuda.xml - inputs/full_induction_mhd/full_induction_vortex_2d_pb.xml - inputs/full_induction_mhd/divergence_advection_2d.xml - inputs/full_induction_mhd/current_sheet_2d.xml - inputs/full_induction_mhd/ldc_2d_bx_010.xml - inputs/full_induction_mhd/ldc_2d_mixed_b_050_rotated.xml - ) -file(COPY ${REGRESSION_XML_FILES} DESTINATION .) - -set(REGRESSION_EXO_FILES - mesh/incompressible/2d_backward_facing_step.exo - mesh/incompressible/2d_concentric_convection.exo - mesh/incompressible/2d_concentric_cylinders_rad10.exo - mesh/incompressible/2d_concentric_cylinders_rad20.exo - mesh/incompressible/2d_concentric_cylinders_rad40.exo - mesh/incompressible/2d_concentric_cylinders_rad80.exo - mesh/incompressible/2d_cyclinder_vertex_quad.exo - mesh/incompressible/2d_laminar_airfoil_0aoa.exo - mesh/incompressible/2d_laminar_airfoil_3aoa.exo - mesh/incompressible/2d_laminar_airfoil_8aoa.exo - mesh/incompressible/2d-short-channel-h-1-ret-180-yp-0-10.exo - mesh/incompressible/2d_tee_junction.exo - mesh/incompressible/2d_triangular_cavity.exo - mesh/incompressible/bluntplate_square.exo - mesh/incompressible/pipe_hex.exo - mesh/incompressible/turbulent_channel_mesh_one.exo - mesh/full_induction_mhd/ldc_bl_41x41_30deg.exo - mesh/full_induction_mhd/ldc_bl_81x81.exo - ) -file(COPY ${REGRESSION_EXO_FILES} DESTINATION .) - -install(FILES - inputs/incompressible/incompressible_2d_backward_facing_step.xml - inputs/incompressible/incompressible_2d_channel_periodic.xml - inputs/incompressible/incompressible_2d_concentric_cylinder_convection.xml - inputs/incompressible/incompressible_2d_laminar_airfoil.xml - inputs/incompressible/incompressible_2d_planar_poiseuille.xml - inputs/incompressible/incompressible_2d_realizable_k_epsilon_turbulence_channel.xml - inputs/incompressible/incompressible_2d_rotating_cylinder_viscous.xml - inputs/incompressible/incompressible_2d_tee_junction.xml - inputs/incompressible/incompressible_3d_channel_periodic.xml - inputs/incompressible/incompressible_3d_wale_cavity.xml - inputs/incompressible/incompressible_blunt_plate_laminar_flow_2d.xml - inputs/incompressible/incompressible_oscillating_heated_laminar_flow_2d.xml - DESTINATION examples/incompressible) - -install(FILES - mesh/incompressible/2d_backward_facing_step.exo - mesh/incompressible/2d_concentric_convection.exo - mesh/incompressible/2d_concentric_cylinders_rad40.exo - mesh/incompressible/2d_cyclinder_vertex_quad.exo - mesh/incompressible/2d_laminar_airfoil_0aoa.exo - mesh/incompressible/2d_laminar_airfoil_3aoa.exo - mesh/incompressible/2d_laminar_airfoil_8aoa.exo - mesh/incompressible/2d_tee_junction.exo - mesh/incompressible/bluntplate_square.exo - mesh/incompressible/pipe_hex.exo - DESTINATION examples/incompressible) diff --git a/examples/README.md b/examples/README.md deleted file mode 100644 index 649321b..0000000 --- a/examples/README.md +++ /dev/null @@ -1,3 +0,0 @@ -This directory contains input files in XML format that are used for regression testing but also could be used as a starting -point for the development of new input files to run with VertexCFD. The input files are stored in the directory `inputs` while -the meshes are stored in `meshes`. diff --git a/examples/inputs/full_induction_mhd/current_sheet_2d.xml b/examples/inputs/full_induction_mhd/current_sheet_2d.xml deleted file mode 100644 index 34fca4e..0000000 --- a/examples/inputs/full_induction_mhd/current_sheet_2d.xml +++ /dev/null @@ -1,383 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/inputs/full_induction_mhd/divergence_advection_2d.xml b/examples/inputs/full_induction_mhd/divergence_advection_2d.xml deleted file mode 100644 index 365a803..0000000 --- a/examples/inputs/full_induction_mhd/divergence_advection_2d.xml +++ /dev/null @@ -1,299 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/inputs/full_induction_mhd/full_induction_vortex_2d_pb.xml b/examples/inputs/full_induction_mhd/full_induction_vortex_2d_pb.xml deleted file mode 100644 index 23862b3..0000000 --- a/examples/inputs/full_induction_mhd/full_induction_vortex_2d_pb.xml +++ /dev/null @@ -1,291 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/inputs/full_induction_mhd/full_induction_vortex_2d_pb_cuda.xml b/examples/inputs/full_induction_mhd/full_induction_vortex_2d_pb_cuda.xml deleted file mode 100644 index f687cb5..0000000 --- a/examples/inputs/full_induction_mhd/full_induction_vortex_2d_pb_cuda.xml +++ /dev/null @@ -1,285 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/inputs/full_induction_mhd/ldc_2d_bx_010.xml b/examples/inputs/full_induction_mhd/ldc_2d_bx_010.xml deleted file mode 100644 index 2e1bd10..0000000 --- a/examples/inputs/full_induction_mhd/ldc_2d_bx_010.xml +++ /dev/null @@ -1,388 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/inputs/full_induction_mhd/ldc_2d_mixed_b_050_rotated.xml b/examples/inputs/full_induction_mhd/ldc_2d_mixed_b_050_rotated.xml deleted file mode 100644 index ec7cc6c..0000000 --- a/examples/inputs/full_induction_mhd/ldc_2d_mixed_b_050_rotated.xml +++ /dev/null @@ -1,441 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/inputs/incompressible/incompressible_2d_backward_facing_step.xml b/examples/inputs/incompressible/incompressible_2d_backward_facing_step.xml deleted file mode 100644 index ca163c5..0000000 --- a/examples/inputs/incompressible/incompressible_2d_backward_facing_step.xml +++ /dev/null @@ -1,280 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/inputs/incompressible/incompressible_2d_channel.xml b/examples/inputs/incompressible/incompressible_2d_channel.xml deleted file mode 100644 index 64dec08..0000000 --- a/examples/inputs/incompressible/incompressible_2d_channel.xml +++ /dev/null @@ -1,280 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/inputs/incompressible/incompressible_2d_channel_periodic.xml b/examples/inputs/incompressible/incompressible_2d_channel_periodic.xml deleted file mode 100644 index 3687fe8..0000000 --- a/examples/inputs/incompressible/incompressible_2d_channel_periodic.xml +++ /dev/null @@ -1,269 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/inputs/incompressible/incompressible_2d_concentric_cylinder_convection.xml b/examples/inputs/incompressible/incompressible_2d_concentric_cylinder_convection.xml deleted file mode 100644 index f0031ae..0000000 --- a/examples/inputs/incompressible/incompressible_2d_concentric_cylinder_convection.xml +++ /dev/null @@ -1,274 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/inputs/incompressible/incompressible_2d_heated_channel.xml b/examples/inputs/incompressible/incompressible_2d_heated_channel.xml deleted file mode 100644 index 41ce8a2..0000000 --- a/examples/inputs/incompressible/incompressible_2d_heated_channel.xml +++ /dev/null @@ -1,310 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/inputs/incompressible/incompressible_2d_k_omega_turbulence_channel.xml b/examples/inputs/incompressible/incompressible_2d_k_omega_turbulence_channel.xml deleted file mode 100644 index c46fa16..0000000 --- a/examples/inputs/incompressible/incompressible_2d_k_omega_turbulence_channel.xml +++ /dev/null @@ -1,311 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/inputs/incompressible/incompressible_2d_laminar_airfoil.xml b/examples/inputs/incompressible/incompressible_2d_laminar_airfoil.xml deleted file mode 100644 index b8291a8..0000000 --- a/examples/inputs/incompressible/incompressible_2d_laminar_airfoil.xml +++ /dev/null @@ -1,286 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/inputs/incompressible/incompressible_2d_planar_poiseuille.xml b/examples/inputs/incompressible/incompressible_2d_planar_poiseuille.xml deleted file mode 100644 index 4898d51..0000000 --- a/examples/inputs/incompressible/incompressible_2d_planar_poiseuille.xml +++ /dev/null @@ -1,311 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/inputs/incompressible/incompressible_2d_planar_poiseuille_cuda.xml b/examples/inputs/incompressible/incompressible_2d_planar_poiseuille_cuda.xml deleted file mode 100644 index 0d94a82..0000000 --- a/examples/inputs/incompressible/incompressible_2d_planar_poiseuille_cuda.xml +++ /dev/null @@ -1,313 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/inputs/incompressible/incompressible_2d_realizable_k_epsilon_turbulence_channel.xml b/examples/inputs/incompressible/incompressible_2d_realizable_k_epsilon_turbulence_channel.xml deleted file mode 100644 index e9d9788..0000000 --- a/examples/inputs/incompressible/incompressible_2d_realizable_k_epsilon_turbulence_channel.xml +++ /dev/null @@ -1,320 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/inputs/incompressible/incompressible_2d_rotating_cylinder_viscous.xml b/examples/inputs/incompressible/incompressible_2d_rotating_cylinder_viscous.xml deleted file mode 100644 index 7b3389b..0000000 --- a/examples/inputs/incompressible/incompressible_2d_rotating_cylinder_viscous.xml +++ /dev/null @@ -1,289 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/inputs/incompressible/incompressible_2d_spalart_allmaras_turbulence_channel.xml b/examples/inputs/incompressible/incompressible_2d_spalart_allmaras_turbulence_channel.xml deleted file mode 100644 index f29e9b7..0000000 --- a/examples/inputs/incompressible/incompressible_2d_spalart_allmaras_turbulence_channel.xml +++ /dev/null @@ -1,314 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/inputs/incompressible/incompressible_2d_spalart_allmaras_turbulence_heated_channel.xml b/examples/inputs/incompressible/incompressible_2d_spalart_allmaras_turbulence_heated_channel.xml deleted file mode 100644 index 1e85c1f..0000000 --- a/examples/inputs/incompressible/incompressible_2d_spalart_allmaras_turbulence_heated_channel.xml +++ /dev/null @@ -1,366 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/inputs/incompressible/incompressible_2d_spalart_allmaras_turbulence_model.xml b/examples/inputs/incompressible/incompressible_2d_spalart_allmaras_turbulence_model.xml deleted file mode 100644 index bae9f57..0000000 --- a/examples/inputs/incompressible/incompressible_2d_spalart_allmaras_turbulence_model.xml +++ /dev/null @@ -1,298 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/inputs/incompressible/incompressible_2d_standard_k_epsilon_turbulence_channel.xml b/examples/inputs/incompressible/incompressible_2d_standard_k_epsilon_turbulence_channel.xml deleted file mode 100644 index deb52cf..0000000 --- a/examples/inputs/incompressible/incompressible_2d_standard_k_epsilon_turbulence_channel.xml +++ /dev/null @@ -1,316 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/inputs/incompressible/incompressible_2d_taylor_green_vortex.xml b/examples/inputs/incompressible/incompressible_2d_taylor_green_vortex.xml deleted file mode 100644 index 020e151..0000000 --- a/examples/inputs/incompressible/incompressible_2d_taylor_green_vortex.xml +++ /dev/null @@ -1,256 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/inputs/incompressible/incompressible_2d_tee_junction.xml b/examples/inputs/incompressible/incompressible_2d_tee_junction.xml deleted file mode 100644 index 66c08ca..0000000 --- a/examples/inputs/incompressible/incompressible_2d_tee_junction.xml +++ /dev/null @@ -1,317 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/inputs/incompressible/incompressible_2d_triangular_cavity_Re100.xml b/examples/inputs/incompressible/incompressible_2d_triangular_cavity_Re100.xml deleted file mode 100644 index 2f7ed15..0000000 --- a/examples/inputs/incompressible/incompressible_2d_triangular_cavity_Re100.xml +++ /dev/null @@ -1,275 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/inputs/incompressible/incompressible_3d_channel_periodic.xml b/examples/inputs/incompressible/incompressible_3d_channel_periodic.xml deleted file mode 100644 index 981746a..0000000 --- a/examples/inputs/incompressible/incompressible_3d_channel_periodic.xml +++ /dev/null @@ -1,257 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/inputs/incompressible/incompressible_3d_wale_cavity.xml b/examples/inputs/incompressible/incompressible_3d_wale_cavity.xml deleted file mode 100644 index 1940b7d..0000000 --- a/examples/inputs/incompressible/incompressible_3d_wale_cavity.xml +++ /dev/null @@ -1,358 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/inputs/incompressible/incompressible_blunt_plate_laminar_flow_2d.xml b/examples/inputs/incompressible/incompressible_blunt_plate_laminar_flow_2d.xml deleted file mode 100644 index 84f9873..0000000 --- a/examples/inputs/incompressible/incompressible_blunt_plate_laminar_flow_2d.xml +++ /dev/null @@ -1,277 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/inputs/incompressible/incompressible_oscillating_heated_laminar_flow_2d.xml b/examples/inputs/incompressible/incompressible_oscillating_heated_laminar_flow_2d.xml deleted file mode 100644 index 2db1085..0000000 --- a/examples/inputs/incompressible/incompressible_oscillating_heated_laminar_flow_2d.xml +++ /dev/null @@ -1,351 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/inputs/incompressible/incompressible_oscillating_laminar_flow_2d.xml b/examples/inputs/incompressible/incompressible_oscillating_laminar_flow_2d.xml deleted file mode 100644 index 845c27a..0000000 --- a/examples/inputs/incompressible/incompressible_oscillating_laminar_flow_2d.xml +++ /dev/null @@ -1,290 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/inputs/induction_less_mhd/mhd_2d_hartmann_pb_periodic_insulating.xml b/examples/inputs/induction_less_mhd/mhd_2d_hartmann_pb_periodic_insulating.xml deleted file mode 100644 index 70e9f94..0000000 --- a/examples/inputs/induction_less_mhd/mhd_2d_hartmann_pb_periodic_insulating.xml +++ /dev/null @@ -1,348 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/inputs/induction_less_mhd/mhd_2d_hartmann_pb_periodic_insulating_cuda.xml b/examples/inputs/induction_less_mhd/mhd_2d_hartmann_pb_periodic_insulating_cuda.xml deleted file mode 100644 index fa211a0..0000000 --- a/examples/inputs/induction_less_mhd/mhd_2d_hartmann_pb_periodic_insulating_cuda.xml +++ /dev/null @@ -1,344 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/inputs/simple_box_2d.xml b/examples/inputs/simple_box_2d.xml deleted file mode 100644 index 98a16b4..0000000 --- a/examples/inputs/simple_box_2d.xml +++ /dev/null @@ -1,269 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/inputs/simple_box_3d.xml b/examples/inputs/simple_box_3d.xml deleted file mode 100644 index 4e3dd41..0000000 --- a/examples/inputs/simple_box_3d.xml +++ /dev/null @@ -1,300 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/mesh/full_induction_mhd/ldc_bl_41x41_30deg.exo b/examples/mesh/full_induction_mhd/ldc_bl_41x41_30deg.exo deleted file mode 100644 index f787569..0000000 --- a/examples/mesh/full_induction_mhd/ldc_bl_41x41_30deg.exo +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:a8b99bceed3e3c2a50d3b0f67617ce2da5f234195faa9c6b6a0b07e0365e0915 -size 108692 diff --git a/examples/mesh/full_induction_mhd/ldc_bl_81x81.exo b/examples/mesh/full_induction_mhd/ldc_bl_81x81.exo deleted file mode 100644 index 294e96a..0000000 --- a/examples/mesh/full_induction_mhd/ldc_bl_81x81.exo +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:59a13417b2ab7365be74c4e2a266a12846b476e134f16c48033aee3f718f0c32 -size 343060 diff --git a/examples/mesh/incompressible/2d-short-channel-h-1-ret-180-yp-0-10.exo b/examples/mesh/incompressible/2d-short-channel-h-1-ret-180-yp-0-10.exo deleted file mode 100644 index 00a30bd..0000000 --- a/examples/mesh/incompressible/2d-short-channel-h-1-ret-180-yp-0-10.exo +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:40d56305d2e801871f9d6b2b6747791961044665062fdd749be8df3942c7c184 -size 85533 diff --git a/examples/mesh/incompressible/2d_backward_facing_step.exo b/examples/mesh/incompressible/2d_backward_facing_step.exo deleted file mode 100644 index b3181a3..0000000 --- a/examples/mesh/incompressible/2d_backward_facing_step.exo +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:f5bbd1325ca2e4b70a7294153b86550d1b04e6995dbeb9cec40e0a44f48ac98c -size 807604 diff --git a/examples/mesh/incompressible/2d_concentric_convection.exo b/examples/mesh/incompressible/2d_concentric_convection.exo deleted file mode 100644 index 6b53d1b..0000000 --- a/examples/mesh/incompressible/2d_concentric_convection.exo +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:907b99feb601f07b4564aa03b20e534171d2ac5ad338d45c44c28a41956b853f -size 114440 diff --git a/examples/mesh/incompressible/2d_concentric_cylinders_rad10.exo b/examples/mesh/incompressible/2d_concentric_cylinders_rad10.exo deleted file mode 100644 index 8dd5445..0000000 --- a/examples/mesh/incompressible/2d_concentric_cylinders_rad10.exo +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:5292f05779eecb20d7d89e8dd4cc915f7b22844529a2d944a1dc502949ea82fc -size 32520 diff --git a/examples/mesh/incompressible/2d_concentric_cylinders_rad20.exo b/examples/mesh/incompressible/2d_concentric_cylinders_rad20.exo deleted file mode 100644 index 40497c4..0000000 --- a/examples/mesh/incompressible/2d_concentric_cylinders_rad20.exo +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:e3eb195ca6df5da1da1abd5447719dc486e92322b02eeae37059e14e379a1ebe -size 115800 diff --git a/examples/mesh/incompressible/2d_concentric_cylinders_rad40.exo b/examples/mesh/incompressible/2d_concentric_cylinders_rad40.exo deleted file mode 100644 index 322f85e..0000000 --- a/examples/mesh/incompressible/2d_concentric_cylinders_rad40.exo +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:c09ec0c85aff8fedbae871b30076ea75c8d064688d94fab41975225b31134a92 -size 440760 diff --git a/examples/mesh/incompressible/2d_concentric_cylinders_rad80.exo b/examples/mesh/incompressible/2d_concentric_cylinders_rad80.exo deleted file mode 100644 index 75b6096..0000000 --- a/examples/mesh/incompressible/2d_concentric_cylinders_rad80.exo +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:78adbb59b0d2be47ade1464ef08a18451aa8df44754c7c5d1cf3e6ccb1e96eb4 -size 1724280 diff --git a/examples/mesh/incompressible/2d_cyclinder_vertex_quad.exo b/examples/mesh/incompressible/2d_cyclinder_vertex_quad.exo deleted file mode 100644 index f5045b2..0000000 --- a/examples/mesh/incompressible/2d_cyclinder_vertex_quad.exo +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:27835ca20522b75584d300c8d2747a801430a8c118d91165279c87c1d556539b -size 1335072 diff --git a/examples/mesh/incompressible/2d_laminar_airfoil_0aoa.exo b/examples/mesh/incompressible/2d_laminar_airfoil_0aoa.exo deleted file mode 100755 index ebd9540..0000000 --- a/examples/mesh/incompressible/2d_laminar_airfoil_0aoa.exo +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:e386ffd07c9a0ff97fc16c6043104dbf146bb7c7c92d9952a4c5a74097e42aef -size 5807180 diff --git a/examples/mesh/incompressible/2d_laminar_airfoil_3aoa.exo b/examples/mesh/incompressible/2d_laminar_airfoil_3aoa.exo deleted file mode 100755 index 898c587..0000000 --- a/examples/mesh/incompressible/2d_laminar_airfoil_3aoa.exo +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:28d404461eaa20c2d324b7631fabc706929bfaefe33d32a248e9e8eb8e1f1f4e -size 5802516 diff --git a/examples/mesh/incompressible/2d_laminar_airfoil_8aoa.exo b/examples/mesh/incompressible/2d_laminar_airfoil_8aoa.exo deleted file mode 100755 index 6bee685..0000000 --- a/examples/mesh/incompressible/2d_laminar_airfoil_8aoa.exo +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:7c3ed907ac09b3aa6be93e6c70ab677eed62c45f5673214b1a36a15058dcc47c -size 5807400 diff --git a/examples/mesh/incompressible/2d_tee_junction.exo b/examples/mesh/incompressible/2d_tee_junction.exo deleted file mode 100644 index b1608fa..0000000 --- a/examples/mesh/incompressible/2d_tee_junction.exo +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:130df07f9f3fcd2cfdee171b034e60fddddd0a95690b38a2eb9ae6bacc8f3a88 -size 536206 diff --git a/examples/mesh/incompressible/2d_triangular_cavity.exo b/examples/mesh/incompressible/2d_triangular_cavity.exo deleted file mode 100644 index ae981b3..0000000 --- a/examples/mesh/incompressible/2d_triangular_cavity.exo +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:8dcadea201bb981a6f483d4fe3921ee581198f61f7a573d9437c10f068aa4f3d -size 485914 diff --git a/examples/mesh/incompressible/bluntplate_square.exo b/examples/mesh/incompressible/bluntplate_square.exo deleted file mode 100644 index f5fd934..0000000 --- a/examples/mesh/incompressible/bluntplate_square.exo +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:65bec41d3dbcc6fbf1a61660179ffb2d1196b3a2b1e3452e45f0630dea609b63 -size 2182090 diff --git a/examples/mesh/incompressible/half_turbulent_channel_mesh_one.exo b/examples/mesh/incompressible/half_turbulent_channel_mesh_one.exo deleted file mode 100644 index 9099d06..0000000 --- a/examples/mesh/incompressible/half_turbulent_channel_mesh_one.exo +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:a2e8de4e176d80387ddbaf3517eb07dc3d896b430cc0752d84ad64ee28626f04 -size 262423 diff --git a/examples/mesh/incompressible/pipe_hex.exo b/examples/mesh/incompressible/pipe_hex.exo deleted file mode 100644 index ec5992f..0000000 --- a/examples/mesh/incompressible/pipe_hex.exo +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:d0666e8146b5dbc0600039a8795534d4396a368486068b910612adef16bf652d -size 642600 diff --git a/examples/mesh/incompressible/turbulent_channel_mesh_one.exo b/examples/mesh/incompressible/turbulent_channel_mesh_one.exo deleted file mode 100644 index 7b92bfa..0000000 --- a/examples/mesh/incompressible/turbulent_channel_mesh_one.exo +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:9dc06435d9af34f80c265f7de6ba87094ffcd81451ccff75fda44a2703e1dcda -size 485823 diff --git a/examples/mesh/test_mesh_manager.exo b/examples/mesh/test_mesh_manager.exo deleted file mode 100644 index 3d42b52..0000000 --- a/examples/mesh/test_mesh_manager.exo +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:2b6554f737d7ec75d77972f526fd524fa105192b689d59b5afcac37aa90b1d02 -size 163997 diff --git a/examples/post_processing/lambda-2-contour.py b/examples/post_processing/lambda-2-contour.py deleted file mode 100644 index 620c698..0000000 --- a/examples/post_processing/lambda-2-contour.py +++ /dev/null @@ -1,85 +0,0 @@ -# Script for creating a lambda-2 contour for LES turbulence visualization. -# Also calculates the vorticity field for coloring the isosurface. - -# For details on the lambda-2 criterion, see pp. 76-77 in: -# J. Jeong and F. Hussain, “On the identification of a vortex,” -# Journal of Fluid Mechanics, vol. 285, pp. 69–94, 1995, -# doi: 10.1017/S0022112095000462. - -# Script generated using ParaView version 5.11.0 - -################################################################################ - -# USAGE: -# 1. Open a ParaView instance and load desired solution file -# 2. Import this script to Paraview by going to Macros -> Import new macro... -# and then selecting this script in the browser. -# 3. Run the macro by going to Macros -> lambda-2-contour -# 4. You can then view a contour of the lambda-2 parameter in the pipeline -# browser, and optionally color by the vorticity magnitude. - -################################################################################ - -# Import the simple module from ParaView -from paraview.simple import * -# Disable automatic camera reset on 'Show' -paraview.simple._DisableFirstRenderCameraReset() - -# Find source file -solutionFile = FindSource('*.exo') - -# Merge blocks to allow manipulation of .exo data -mergeBlocks1 = MergeBlocks(registrationName='MergeBlocks1', Input=solutionFile) - -UpdatePipeline(time=100.0, proxy=mergeBlocks1) - -# Merge velocity components into vector -mergeVectorComponents1 = MergeVectorComponents( - registrationName='MergeVectorComponents1', Input=mergeBlocks1) -mergeVectorComponents1.XArray = 'velocity_0' -mergeVectorComponents1.YArray = 'velocity_1' -mergeVectorComponents1.ZArray = 'velocity_2' -mergeVectorComponents1.OutputVectorName = 'velocity' - -UpdatePipeline(time=100.0, proxy=mergeVectorComponents1) - -# Use a programmable filter to calculate lambda2 criterion -programmableFilter1 = ProgrammableFilter( - registrationName='ProgrammableFilter1', Input=mergeVectorComponents1) -programmableFilter1.Script = """import numpy as np - -vvector = inputs[0].PointData['velocity'] - -vstrain = strain(vvector) -vskew = gradient(vvector) - vstrain - -aaa = matmul(vstrain, vstrain) + matmul(vskew, vskew) - -lambdas = np.linalg.eigvals(aaa) -lambdas = np.real(lambdas ) -lambda2 = sort(lambdas)[:,1] - -output.DeepCopy(inputs[0].VTKObject) -output.PointData.append(lambda2, 'lambda2')""" -programmableFilter1.RequestInformationScript = '' -programmableFilter1.RequestUpdateExtentScript = '' -programmableFilter1.PythonPath = '' - -UpdatePipeline(time=100.0, proxy=programmableFilter1) - -# Calculate vorticity field -calculator1 = Calculator(registrationName='Calculator1', - Input=programmableFilter1) -calculator1.AttributeType = 'Cell Data' -calculator1.ResultArrayName = 'vorticity' -calculator1.Function = '(GRAD_velocity_2Y - GRAD_velocity_1Z) * iHat + (GRAD_velocity_0Z - GRAD_velocity_2X) * jHat + (GRAD_velocity_1X - GRAD_velocity_0Y) * kHat' - -UpdatePipeline(time=100.0, proxy=calculator1) - -# Contour by lambda2 = 0 -contour1 = Contour(registrationName='Contour1', Input=calculator1) -contour1.ContourBy = ['POINTS', 'lambda2'] -contour1.Isosurfaces = [0.0] -contour1.PointMergeMethod = 'Uniform Binning' - -UpdatePipeline(time=100.0, proxy=contour1) diff --git a/index.md b/index.md new file mode 100644 index 0000000..5e186f9 --- /dev/null +++ b/index.md @@ -0,0 +1,44 @@ +--- +layout: default +title: Home +nav_order: 1 +permalink: / +--- + +![Alt text](docs/figures/vertex_cfd_heated_flow_logo.png) + +An open-source CFD code for multiphysics modeling and simulation with a focus on fusion applications. +{: .fs-6 .fw-300 } + +[User Guide](docs/index.html){: .btn .btn-primary .fs-5 .mb-4 .mb-md-0 .mr-2 } +[View it on GitHub](https://github.com/ORNL/VERTEX-CFD){: .btn .fs-5 .mb-4 .mb-md-0 } + +--- + +## Contributing +We encourage you to contribute to VERTEX-CFD! Please review the [how to contribute](docs/contribution.md) page. + +#### Contributors +- [Marco Delchini](https://www.ornl.gov/staff-profile/marc-olivier-delchini) +- [Kellis Kincaid](https://www.ornl.gov/staff-profile/kellis-c-kincaid) +- [Furkan Oz](https://www.ornl.gov/staff-profile/furkan-oz) +- [Kalyan Gottiparthi](https://www.ornl.gov/staff-profile/kalyan-c-gottiparthi) +- [Jason W. DeGraw](https://www.ornl.gov/staff-profile/jason-w-degraw) +- [Doug Stefanski](https://www.ornl.gov/staff-profile/douglas-l-stefanski) +- [Filipe L. Brandao](https://www.ornl.gov/staff-profile/filipe-leite-brandao) +- [Ryan Savery](https://impact.ornl.gov/en/persons/ryan-savery) + +## Citing +If you use VERTEX-CFD in your work, please cite the Zenodo DOI [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.14907174.svg)](https://doi.org/10.5281/zenodo.14907174) of the version you used as a software citation: +```bibtex +@software{vertex-cfd, + author = {AUTHORS}, + title = {VERTEX-CFD: Release 1.0}, + month = jun, + year = 2024, + publisher = {Zenodo}, + version = {1.0.0}, + doi = {DOI_NUMBER}, + url = {DOI_URL} +} +``` diff --git a/regression_test/exodiff_file.txt b/regression_test/exodiff_file.txt deleted file mode 100644 index 6e32eda..0000000 --- a/regression_test/exodiff_file.txt +++ /dev/null @@ -1,4 +0,0 @@ -DEFAULT TOLERANCE relative 1.E-8 absolute 1.E-7 floor 1.E-14 -COORDINATES absolute 1.E-12 -TIME STEPS absolute 1.E-14 -NODAL VARIABLES absolute 1.E-8 diff --git a/regression_test/pytest.ini b/regression_test/pytest.ini deleted file mode 100644 index 3296dd3..0000000 --- a/regression_test/pytest.ini +++ /dev/null @@ -1,8 +0,0 @@ -[pytest] -markers = - push: marks tests that are to be run after pushing to branch (deselect with '-m "not push"') - daily: marks tests that are to be run daily (deselect with '-m "not daily"') - weekly: marks tests that are to be run weekly (deselect with '-m "not weekly"') - incompressible: marks tests for incompressible model. - mhd: marks for mhd model. - gpu: marks for regression tests to run on GPU node. diff --git a/regression_test/rename_variables_exodus.py.in b/regression_test/rename_variables_exodus.py.in deleted file mode 100644 index a2a13c7..0000000 --- a/regression_test/rename_variables_exodus.py.in +++ /dev/null @@ -1,153 +0,0 @@ -# Import Python modules -import sys -import glob -import argparse -import os -from os import path - -# Description: -# This Python script implements logic to rename nodal and element variables -# in Exodus files. The values remain un-changed. The changes in the Exodus -# files are performed in place. Files to update are to be specified at the -# command line. See documentation in the Wiki page under Software quality -# assurance for further details. - -# Adding trilinos folder to the system path and import exodus3 -sys.path.insert( - 0, '@TRILINOS_LIB@') -import exodus3 as exodus - -# Argument parser -parser = argparse.ArgumentParser( - description='Replace field names in Exodus files') -parser.add_argument('-v', - '--verbose', - action='store_true', - help='more verbose output') -parser.add_argument('files', - nargs='+', - help='exodus file(s) to modify', - metavar='file') -parser.add_argument('-n', - '--node', - nargs=2, - action='append', - help='node variable', - metavar=('old-name', 'new-name')) -parser.add_argument('-e', - '--element', - nargs=2, - action='append', - help='element variable', - metavar=('old-name', 'new-name')) -args = parser.parse_args() - -# Assign variable based on parsed arguments -nodal_list = args.node -elem_list = args.element -if nodal_list is None and elem_list is None: - print("\nPlease provide a list of node or element fields to replace.\n") - parser.print_help() - sys.exit() -filename_list = args.files - -# Collect all Exodus files specified at the command line -for f in filename_list: - if not os.path.isfile(f): - sys.exit(f"ERROR: The file '{f}' is not found.") - - -# Verbose function (used when --verbose flag is passed to command line) -def print_verbose(msg): - if args.verbose: - print(msg) - - -# Funtion to replace fields -def replace_field(exo, field_list, field_type): - print_verbose(f"\n\tLoop over {field_type} fields to replace:") - # Set `exo_put_node` function and field type - exo_put_node = lambda: None - if field_type == "nodal": - exo_put_node = exo.put_node_variable_name - field_type = "EX_NODAL" - elif field_type == "element": - exo_put_node = exo.put_element_variable_name - field_type = "EX_ELEM_BLOCK" - else: - exo.close() - sys.exit( - f"\t\tError: Current field type '{field_type}' is not supported. Field type options are 'nodal' or 'element'." - ) - - # Loop over fields to replace - exo_field_list = exo.get_variable_names(field_type) - field_not_found = [] - for old_field, new_field in field_list: - print_verbose(f"\n\t\t\tField to replace: {old_field}...") - found = False - # Look for exact match - if old_field in exo_field_list: - index = exo_field_list.index(old_field) + 1 - exo_put_node(new_field, index) - found = True - print_verbose( - f"\t\t\t...Field {old_field} found with index {index} and replaced with {new_field}." - ) - if not found: - field_not_found.append(old_field) - print_verbose(f"\t\t\t...WARNING: field {old_field} not found.") - if field_not_found: - print_verbose( - f"\n\t\tWARNING: List of field(s) not found in the Exodus file {exo.fileName}:" - ) - for old_field in field_not_found: - print_verbose(f"\t\t- {old_field}") - - # Return list of fields not found - return field_not_found - - -# Loop over file list -full_report = {} -sep = 100 * "*" -for filename in filename_list: - print("\n" + sep) - - # Create exodus object from file - exo = exodus.exodus(filename, mode='a') - - nodal_field_not_found = None - elem_field_not_found = None - - try: - # Nodal fields - if nodal_list is not None: - nodal_field_not_found = replace_field(exo, nodal_list, "nodal") - - # Element fields - if elem_list is not None: - elem_field_not_found = replace_field(exo, elem_list, "element") - finally: - # Close exodus object - exo.close() - - # Store data in report (dictionary) - full_report[filename] = {} - if nodal_field_not_found is not None: - full_report[filename]["nodal"] = nodal_field_not_found - if elem_field_not_found is not None: - full_report[filename]["element"] = elem_field_not_found - -# Print full report -print("\n" + sep) -print("Full report:") -for filename in filename_list: - print(f"\tFile name: {filename}") - for key, values in full_report[filename].items(): - if values: - print("\t\t" + key + " variables not updated:") - for v in values: - print(f"\t\t - {v}") - else: - print("\t\tall " + key + " variables updated.") diff --git a/regression_test/test_incompressible/test_cavity/gold/incompressible_2d_triangular_cavity_Re100_solution.exo b/regression_test/test_incompressible/test_cavity/gold/incompressible_2d_triangular_cavity_Re100_solution.exo deleted file mode 100644 index 4f57cb5..0000000 --- a/regression_test/test_incompressible/test_cavity/gold/incompressible_2d_triangular_cavity_Re100_solution.exo +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:9291bb12ce740d707a9cab981467d99678af8ff088fe5e3ee007053e9bf53852 -size 1274912 diff --git a/regression_test/test_incompressible/test_cavity/gold/incompressible_2d_triangular_cavity_Re400_solution.exo b/regression_test/test_incompressible/test_cavity/gold/incompressible_2d_triangular_cavity_Re400_solution.exo deleted file mode 100644 index 28e175b..0000000 --- a/regression_test/test_incompressible/test_cavity/gold/incompressible_2d_triangular_cavity_Re400_solution.exo +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:9f58f9193002e8726c3fb3d66bc5d87b0c6f5767f76aa2dff9824f38693a5071 -size 1274912 diff --git a/regression_test/test_incompressible/test_cavity/gold/incompressible_2d_triangular_cavity_Re800_solution.exo b/regression_test/test_incompressible/test_cavity/gold/incompressible_2d_triangular_cavity_Re800_solution.exo deleted file mode 100644 index 886c330..0000000 --- a/regression_test/test_incompressible/test_cavity/gold/incompressible_2d_triangular_cavity_Re800_solution.exo +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:7077218589ce653a2a0f8f3cc7f3c775c4511c392588bb3890b451097bce68c9 -size 1274912 diff --git a/regression_test/test_incompressible/test_cavity/test_cavity.py b/regression_test/test_incompressible/test_cavity/test_cavity.py deleted file mode 100644 index 1403c4b..0000000 --- a/regression_test/test_incompressible/test_cavity/test_cavity.py +++ /dev/null @@ -1,100 +0,0 @@ -import sys -import os -import pytest - -import vertexcfd_test - - -class TestCavity: - # setup method for class - @classmethod - def setup_class(self): - """ setup any state specific to the execution of the - given class (which usually contains tests).""" - print('\n***************** Setup class method *******************') - - # Class variables (to not change) - self.mesh_file_path = vertexcfd_test.mesh_file_path - self.input_file_path = vertexcfd_test.input_file_path - self.vertexcfd_exec = vertexcfd_test.vertexcfd_exec - self.exodiff_exec = vertexcfd_test.exodiff_exec - self.main_path = vertexcfd_test.main_path - self.no_exodiff_file = None - - # Change working directory to test directory - self.test_path = os.path.dirname(os.path.realpath(__file__)) - os.chdir(self.test_path) - - # teardown method for class - @classmethod - def teardown_class(self): - """ teardown any state that was previously - setup with a call to setup_class.""" - print('\n****************** Teardown class method ******************') - # Change working directory back to main directory - os.chdir(vertexcfd_test.main_path) - - # setup method for each function - def setup_method(self): - """ setup test.""" - print('\nSetup method') - # Initialize input file, mesh file and output file names - self.input_file = None - self.mesh_file = None - self.output_file = None - - # teardown method for each function - def teardown_method(self): - """ teardown test.""" - print('\nTeardown method') - # Delete input file, mesh file and output file - vertexcfd_test.clean_working_directory(self) - - ############################################################################# - ############################################################################# - ############################################################################# - @pytest.mark.push - @pytest.mark.daily - @pytest.mark.weekly - @pytest.mark.incompressible - def test_2d_triangular_cavity(self, request): - # Parameters - mark_expr = request.config.option.markexpr - vertexcfd_options = () - copy_xml_file = False - - # default parameters to be used on 'push' - base_input_file = "incompressible_2d_triangular_cavity" - self.input_file = base_input_file + "_Re100.xml" - source_input_file = self.input_file - output_name = base_input_file + "_Re100_solution.exo" - nu = 0.8 - - if ("daily" in mark_expr): - self.input_file = base_input_file + "_Re400.xml" - output_name = base_input_file + "_Re400_solution.exo" - nu = 0.2 - elif ("weekly" in mark_expr): - self.input_file = base_input_file + "_Re800.xml" - output_name = base_input_file + "_Re800_solution.exo" - nu = 0.1 - - xml_args_to_replace_list = [] - xml_args_to_replace_list.append( - vertexcfd_test.xml_args_to_replace('Parameter', 'name', - 'Kinematic viscosity', nu)) - xml_args_to_replace_list.append( - vertexcfd_test.xml_args_to_replace('Parameter', 'name', - 'Exodus Output File', - output_name)) - - vertexcfd_test.create_xml_file_from_base_file( - self, source_input_file, xml_args_to_replace_list) - - # Parameters for exodiff executables - exodiff_options = () - - #### The following code should not be modified #### - # Run VertexCFD and call exodiff to compare to gold file - vertexcfd_test.run_test(self, vertexcfd_options, exodiff_options, - copy_xml_file) diff --git a/regression_test/test_incompressible/test_pipe_flow/exodiff_file.txt b/regression_test/test_incompressible/test_pipe_flow/exodiff_file.txt deleted file mode 100644 index fb64a95..0000000 --- a/regression_test/test_incompressible/test_pipe_flow/exodiff_file.txt +++ /dev/null @@ -1,4 +0,0 @@ -DEFAULT TOLERANCE relative 1.E-8 absolute 1.E-7 floor 1.E-14 -COORDINATES absolute 1.E-12 -TIME STEPS absolute 1.E-8 -NODAL VARIABLES absolute 1.E-8 diff --git a/regression_test/test_incompressible/test_pipe_flow/gold/incompressible_2d_channel_periodic_solution.exo b/regression_test/test_incompressible/test_pipe_flow/gold/incompressible_2d_channel_periodic_solution.exo deleted file mode 100644 index d8b3664..0000000 --- a/regression_test/test_incompressible/test_pipe_flow/gold/incompressible_2d_channel_periodic_solution.exo +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:a4fa171ad1cb4cb9bc294c82c08c75b6642abdf2d0e0dc26d449e92ac23a5827 -size 688136 diff --git a/regression_test/test_incompressible/test_pipe_flow/gold/incompressible_2d_heated_channel_solution.exo b/regression_test/test_incompressible/test_pipe_flow/gold/incompressible_2d_heated_channel_solution.exo deleted file mode 100644 index 04b556f..0000000 --- a/regression_test/test_incompressible/test_pipe_flow/gold/incompressible_2d_heated_channel_solution.exo +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:829352490118d2033883d361f46406a73f65b7c153dae48d80c9e18f3476cd9b -size 932072 diff --git a/regression_test/test_incompressible/test_pipe_flow/gold/incompressible_3d_channel_periodic_solution.exo b/regression_test/test_incompressible/test_pipe_flow/gold/incompressible_3d_channel_periodic_solution.exo deleted file mode 100644 index 37abcf7..0000000 --- a/regression_test/test_incompressible/test_pipe_flow/gold/incompressible_3d_channel_periodic_solution.exo +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:ea85bc3f661ac006dd92a7ac8caf972e8bcf4811fec3d349a0f5f9d43cf39809 -size 4714436 diff --git a/regression_test/test_incompressible/test_pipe_flow/test_pipe_flow.py b/regression_test/test_incompressible/test_pipe_flow/test_pipe_flow.py deleted file mode 100644 index 68e5b11..0000000 --- a/regression_test/test_incompressible/test_pipe_flow/test_pipe_flow.py +++ /dev/null @@ -1,168 +0,0 @@ -import sys -import os -import pytest -import re - -import vertexcfd_test - - -class TestPipeFlow: - # setup method for class - @classmethod - def setup_class(self): - """ setup any state specific to the execution of the - given class (which usually contains tests).""" - print('\n***************** Setup class method *******************') - - # Class variables (to not change) - self.mesh_file_path = vertexcfd_test.mesh_file_path - self.input_file_path = vertexcfd_test.input_file_path - self.vertexcfd_exec = vertexcfd_test.vertexcfd_exec - self.exodiff_exec = vertexcfd_test.exodiff_exec - self.main_path = vertexcfd_test.main_path - self.no_exodiff_file = None - - # Change working directory to test directory - self.test_path = os.path.dirname(os.path.realpath(__file__)) - os.chdir(self.test_path) - - # teardown method for class - @classmethod - def teardown_class(self): - """ teardown any state that was previously - setup with a call to setup_class.""" - print('\n****************** Teardown class method ******************') - # Change working directory back to main directory - os.chdir(vertexcfd_test.main_path) - - # setup method for each function - def setup_method(self): - """ setup test.""" - print('\nSetup method') - # Initialize input file, mesh file and output file names - self.input_file = None - self.mesh_file = None - self.output_file = None - - # teardown method for each function - def teardown_method(self): - """ teardown test.""" - print('\nTeardown method') - # Delete input file, mesh file and output file - vertexcfd_test.clean_working_directory(self) - - ############################################################################# - ############################################################################# - ############################################################################# - - # Check inlet conditions (velocity and temperature) - def check_inlet_conditions(self, capfd): - # Get captured test output for parsing - fd_out, fd_err = capfd.readouterr() - - # Let pytest re-capture the output - sys.stdout.write(fd_out) - sys.stderr.write(fd_err) - - pattern = re.compile(' Inlet - velocity_0 = (.+)\n') - vels = [float(t) for t in pattern.findall(fd_out)] - pattern = re.compile(' Inlet - temperature = (.+)\n') - temps = [float(t) for t in pattern.findall(fd_out)] - - # Expected velocity and temperature values - vel_exp = [0.000600000000, 0.000600000000] - temp_exp = [4.0, 4.047127939785872] - - # Assert values - assert len(vels) == 2 - assert len(temps) == 2 - - for i in range(0, 2): - assert vels[i] == pytest.approx(vel_exp[i], rel=1.0e-8) - assert temps[i] == pytest.approx(temp_exp[i], rel=1.0e-8) - - # Check probe values - def check_probe_values(self, capfd): - # Get captured test output for parsing - fd_out, fd_err = capfd.readouterr() - - # Let pytest re-capture the output - sys.stdout.write(fd_out) - sys.stderr.write(fd_err) - - pattern = re.compile(' Probe Upper 1 - temperature = (.+)\n') - pb1 = [float(t) for t in pattern.findall(fd_out)] - pattern = re.compile(' Probe Upper 2 - temperature = (.+)\n') - pb2 = [float(t) for t in pattern.findall(fd_out)] - pattern = re.compile(' Probe Right 1 - temperature = (.+)\n') - pb3 = [float(t) for t in pattern.findall(fd_out)] - - # Expected velocity and temperature values - pb1_exp = [20.0, 20.65956051875808] - pb2_exp = [20.0, 20.03234994314487] - pb3_exp = [ - 20.0, 20.00184327050597, 20.00184327047455, 20.00184327047455 - ] - - # Assert values - assert len(pb1) == 2 - assert len(pb2) == 2 - assert len(pb3) == 4 - - for i in range(0, 2): - assert pb1[i] == pytest.approx(pb1_exp[i], rel=1.0e-8) - assert pb2[i] == pytest.approx(pb2_exp[i], rel=1.0e-8) - - for i in range(0, 4): - assert pb3[i] == pytest.approx(pb3_exp[i], rel=1.0e-8) - - @pytest.mark.push - @pytest.mark.incompressible - def test_2d_flow(self): - #### Parameters to edit for each function #### - # Parameters for VertexCFD run - self.input_file = "incompressible_2d_channel_periodic.xml" - vertexcfd_options = () - - # Parameters for exodiff executables - exodiff_options = () - - #### The following code should not be modified #### - # Run VertexCFD and call exodiff to compare to gold file - vertexcfd_test.run_test(self, vertexcfd_options, exodiff_options) - - @pytest.mark.push - @pytest.mark.incompressible - def test_2d_heated_flow(self, capfd): - #### Parameters to edit for each function #### - # Parameters for VertexCFD run - self.input_file = "incompressible_2d_heated_channel.xml" - vertexcfd_options = () - - # Parameters for exodiff executables - exodiff_options = () - - #### The following code should not be modified #### - # Run VertexCFD and call exodiff to compare to gold file - vertexcfd_test.run_test(self, vertexcfd_options, exodiff_options) - - # Check surface-averaged values - self.check_inlet_conditions(capfd) - - # Check probe values - self.check_probe_values(capfd) - - @pytest.mark.daily - @pytest.mark.incompressible - def test_3d_flow(self): - #### Parameters to edit for each function #### - # Parameters for VertexCFD run - self.input_file = "incompressible_3d_channel_periodic.xml" - vertexcfd_options = () - - # Parameters for exodiff executables - exodiff_options = () - - #### The following code should not be modified #### - # Run VertexCFD and call exodiff to compare to gold file - vertexcfd_test.run_test(self, vertexcfd_options, exodiff_options) diff --git a/regression_test/test_induction_less_mhd_solver/test_hartmann_problem/exodiff_file.txt b/regression_test/test_induction_less_mhd_solver/test_hartmann_problem/exodiff_file.txt deleted file mode 100644 index f382805..0000000 --- a/regression_test/test_induction_less_mhd_solver/test_hartmann_problem/exodiff_file.txt +++ /dev/null @@ -1,4 +0,0 @@ -DEFAULT TOLERANCE relative 1.E-8 absolute 1.E-7 floor 1.E-14 -COORDINATES absolute 1.E-12 -TIME STEPS absolute 1.E-10 -NODAL VARIABLES absolute 1.E-8 diff --git a/regression_test/test_induction_less_mhd_solver/test_hartmann_problem/gold/mhd_2d_hartmann_pb_periodic_insulating_cuda_re_100_ha_100_p_1_solution.exo b/regression_test/test_induction_less_mhd_solver/test_hartmann_problem/gold/mhd_2d_hartmann_pb_periodic_insulating_cuda_re_100_ha_100_p_1_solution.exo deleted file mode 100644 index 80a7a26..0000000 --- a/regression_test/test_induction_less_mhd_solver/test_hartmann_problem/gold/mhd_2d_hartmann_pb_periodic_insulating_cuda_re_100_ha_100_p_1_solution.exo +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:19687bf2f2317bbef602e82ce76be7e3dff391a0ade0127afff2bbb8b04a2eeb -size 3054729 diff --git a/regression_test/test_induction_less_mhd_solver/test_hartmann_problem/gold/mhd_2d_hartmann_pb_periodic_insulating_cuda_re_100_ha_100_p_2_solution.exo b/regression_test/test_induction_less_mhd_solver/test_hartmann_problem/gold/mhd_2d_hartmann_pb_periodic_insulating_cuda_re_100_ha_100_p_2_solution.exo deleted file mode 100644 index 67891bb..0000000 --- a/regression_test/test_induction_less_mhd_solver/test_hartmann_problem/gold/mhd_2d_hartmann_pb_periodic_insulating_cuda_re_100_ha_100_p_2_solution.exo +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:bdd5575b572639601a54a0fe835bee7f560472c0cd0e93120467eda6e7c3e518 -size 3054729 diff --git a/regression_test/test_induction_less_mhd_solver/test_hartmann_problem/gold/mhd_2d_hartmann_pb_periodic_insulating_cuda_re_100_ha_1_p_1_solution.exo b/regression_test/test_induction_less_mhd_solver/test_hartmann_problem/gold/mhd_2d_hartmann_pb_periodic_insulating_cuda_re_100_ha_1_p_1_solution.exo deleted file mode 100644 index cc54b94..0000000 --- a/regression_test/test_induction_less_mhd_solver/test_hartmann_problem/gold/mhd_2d_hartmann_pb_periodic_insulating_cuda_re_100_ha_1_p_1_solution.exo +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:44fee22de9a33ff53e7eab978f0fe3d3f29451e8f73188c36f61644914941d1b -size 120329 diff --git a/regression_test/test_induction_less_mhd_solver/test_hartmann_problem/gold/mhd_2d_hartmann_pb_periodic_insulating_cuda_re_100_ha_1_p_2_solution.exo b/regression_test/test_induction_less_mhd_solver/test_hartmann_problem/gold/mhd_2d_hartmann_pb_periodic_insulating_cuda_re_100_ha_1_p_2_solution.exo deleted file mode 100644 index 6faad60..0000000 --- a/regression_test/test_induction_less_mhd_solver/test_hartmann_problem/gold/mhd_2d_hartmann_pb_periodic_insulating_cuda_re_100_ha_1_p_2_solution.exo +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:42c1b54b1ac7dafb722b90d788a6a07421447499795fe90c0ba71b9ac16a63bd -size 120329 diff --git a/regression_test/test_induction_less_mhd_solver/test_hartmann_problem/gold/mhd_2d_hartmann_pb_periodic_insulating_re_100_ha_100_p_1_solution.exo b/regression_test/test_induction_less_mhd_solver/test_hartmann_problem/gold/mhd_2d_hartmann_pb_periodic_insulating_re_100_ha_100_p_1_solution.exo deleted file mode 100644 index 2f8addb..0000000 --- a/regression_test/test_induction_less_mhd_solver/test_hartmann_problem/gold/mhd_2d_hartmann_pb_periodic_insulating_re_100_ha_100_p_1_solution.exo +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:b152c425f7ac87cbeae91e73a119216b346ea3ee069e536a993bf246094817db -size 3326668 diff --git a/regression_test/test_induction_less_mhd_solver/test_hartmann_problem/gold/mhd_2d_hartmann_pb_periodic_insulating_re_100_ha_100_p_2_solution.exo b/regression_test/test_induction_less_mhd_solver/test_hartmann_problem/gold/mhd_2d_hartmann_pb_periodic_insulating_re_100_ha_100_p_2_solution.exo deleted file mode 100644 index 289a411..0000000 --- a/regression_test/test_induction_less_mhd_solver/test_hartmann_problem/gold/mhd_2d_hartmann_pb_periodic_insulating_re_100_ha_100_p_2_solution.exo +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:1d23e3e20a1bc59acee9969cc95f93963ff3c9760605bb98d886a442ce000994 -size 3326668 diff --git a/regression_test/test_induction_less_mhd_solver/test_hartmann_problem/gold/mhd_2d_hartmann_pb_periodic_insulating_re_100_ha_1_p_1_solution.exo b/regression_test/test_induction_less_mhd_solver/test_hartmann_problem/gold/mhd_2d_hartmann_pb_periodic_insulating_re_100_ha_1_p_1_solution.exo deleted file mode 100644 index 895759b..0000000 --- a/regression_test/test_induction_less_mhd_solver/test_hartmann_problem/gold/mhd_2d_hartmann_pb_periodic_insulating_re_100_ha_1_p_1_solution.exo +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:c5cc41cfac806cecee3735729ce01e80974ee6ab0c7b4f9fb5f526dc67b7d938 -size 129819 diff --git a/regression_test/test_induction_less_mhd_solver/test_hartmann_problem/gold/mhd_2d_hartmann_pb_periodic_insulating_re_100_ha_1_p_2_solution.exo b/regression_test/test_induction_less_mhd_solver/test_hartmann_problem/gold/mhd_2d_hartmann_pb_periodic_insulating_re_100_ha_1_p_2_solution.exo deleted file mode 100644 index fceb4b6..0000000 --- a/regression_test/test_induction_less_mhd_solver/test_hartmann_problem/gold/mhd_2d_hartmann_pb_periodic_insulating_re_100_ha_1_p_2_solution.exo +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:29fa41c77db59a2b854d1ec9c4fbf5afb7bf0388e8734fa07a9441c6dbc82054 -size 129819 diff --git a/regression_test/test_induction_less_mhd_solver/test_hartmann_problem/test_hartmann_problem.py b/regression_test/test_induction_less_mhd_solver/test_hartmann_problem/test_hartmann_problem.py deleted file mode 100644 index b7ad072..0000000 --- a/regression_test/test_induction_less_mhd_solver/test_hartmann_problem/test_hartmann_problem.py +++ /dev/null @@ -1,159 +0,0 @@ -import sys -import os -import pytest - -import vertexcfd_test - - -class TestHartmannProblem: - # setup method for class - @classmethod - def setup_class(self): - """ setup any state specific to the execution of the - given class (which usually contains tests).""" - print('\n***************** Setup class method *******************') - - # Class variables (to not change) - self.mesh_file_path = vertexcfd_test.mesh_file_path - self.input_file_path = vertexcfd_test.input_file_path - self.vertexcfd_exec = vertexcfd_test.vertexcfd_exec - self.exodiff_exec = vertexcfd_test.exodiff_exec - self.main_path = vertexcfd_test.main_path - self.no_exodiff_file = None - - # Change working directory to test directory - self.test_path = os.path.dirname(os.path.realpath(__file__)) - os.chdir(self.test_path) - - # teardown method for class - @classmethod - def teardown_class(self): - """ teardown any state that was previously - setup with a call to setup_class.""" - print('\n****************** Teardown class method ******************') - # Change working directory back to main directory - os.chdir(vertexcfd_test.main_path) - - # setup method for each function - def setup_method(self): - """ setup test.""" - print('\nSetup method') - # Initialize input file, mesh file and output file names - self.input_file = None - self.mesh_file = None - self.output_file = None - - # teardown method for each function - def teardown_method(self): - """ teardown test.""" - print('\nTeardown method') - # Delete input file, mesh file and output file - vertexcfd_test.clean_working_directory(self) - - ############################################################################# - ############################################################################# - ############################################################################# - @pytest.mark.push - @pytest.mark.weekly - @pytest.mark.mhd - @pytest.mark.gpu - def test_2d_hartmann_problem(self, request): - #### Parameters to edit for each function #### - # CPU or GPU - run_gpu = False - markers = request.config.option.markexpr.split() - if ('gpu' in markers): - run_gpu = True - - # Set polynomial order based on marker: p = 1 on push and gpu, and p = 2 on weekly - p = 1 - ha = 1 - if ('gpu' in markers and 'push' in markers): - p = 2 - ha = 1 - elif ('gpu' in markers and 'weekly' in markers): - p = 1 - ha = 100 - elif ('weekly' in markers): - p = 2 - ha = 100 - - # Parameters for VertexCFD run - vertexcfd_options = () - - # Input file and output file - copy_xml_file = False - base_input_file = "mhd_2d_hartmann_pb_periodic_insulating" - if run_gpu: - base_input_file += "_cuda" - source_input_file = base_input_file + ".xml" - name = "_re_100_ha_" + str(ha) + "_p_" + str(p) - base_input_file = source_input_file.split(".xml")[0] - self.input_file = base_input_file + name + ".xml" - output_name = base_input_file + name + "_solution.exo" - - # Set parameter values - momentum_source = None - ext_magn_field = None - nx = None - ny = None - if ha == 1: - momentum_source = "{0.04194528049, 0.0}" - ext_magn_field = "{0.0, 0.1, 0.0}" - nx = 8 - ny = 32 - elif ha == 100: - momentum_source = "{101.010101, 0.0}" - ext_magn_field = "{0.0, 10.0, 0.0}" - nx = 64 - ny = 256 - - # Update parameters in input file - xml_args_to_replace_list = [] - - xml_args_to_replace_list.append( - vertexcfd_test.xml_args_to_replace('Parameter', 'name', - 'Exodus Output File', - output_name)) - - xml_args_to_replace_list.append( - vertexcfd_test.xml_args_to_replace('Parameter', 'name', - 'Momentum Source', - momentum_source)) - - xml_args_to_replace_list.append( - vertexcfd_test.xml_args_to_replace( - 'Parameter', 'name', 'External Magnetic Field Value', - ext_magn_field)) - - xml_args_to_replace_list.append( - vertexcfd_test.xml_args_to_replace('Parameter', 'name', - 'X Elements', nx)) - - xml_args_to_replace_list.append( - vertexcfd_test.xml_args_to_replace('Parameter', 'name', - 'Y Elements', ny)) - - xml_args_to_replace_list.append( - vertexcfd_test.xml_args_to_replace('Parameter', 'name', - 'Basis Order', p)) - - xml_args_to_replace_list.append( - vertexcfd_test.xml_args_to_replace('Parameter', 'name', - 'Integration Order', 2 * p)) - - vertexcfd_test.create_xml_file_from_base_file(self, - source_input_file, - xml_args_to_replace_list, - restart=False) - - # Parameters for exodiff executables - exodiff_options = () - - #### The following code should not be modified #### - # Run VertexCFD and call exodiff to compare to gold file - vertexcfd_test.run_test(self, - vertexcfd_options, - exodiff_options, - copy_xml_file, - run_gpu=run_gpu) diff --git a/regression_test/test_taylor_green_vortex/test_taylor_green_vortex.py b/regression_test/test_taylor_green_vortex/test_taylor_green_vortex.py deleted file mode 100644 index 8a84e9e..0000000 --- a/regression_test/test_taylor_green_vortex/test_taylor_green_vortex.py +++ /dev/null @@ -1,155 +0,0 @@ -import sys -import os -import pytest - -import vertexcfd_test - - -class TestTaylorGreenVortex: - # setup method for class - @classmethod - def setup_class(self): - """ setup any state specific to the execution of the - given class (which usually contains tests).""" - print('\n***************** Setup class method *******************') - - # Class variables (to not change) - self.mesh_file_path = vertexcfd_test.mesh_file_path - self.input_file_path = vertexcfd_test.input_file_path - self.vertexcfd_exec = vertexcfd_test.vertexcfd_exec - self.exodiff_exec = vertexcfd_test.exodiff_exec - self.main_path = vertexcfd_test.main_path - self.no_exodiff_file = None - - # Change working directory to test directory - self.test_path = os.path.dirname(os.path.realpath(__file__)) - os.chdir(self.test_path) - - # Gold values for L1/L2 error norms - self.ref_error_norms = [[ - None, - [ - 3.1354940494154192e-03, 4.8827471008265188e-03, - 4.8827471008264806e-03 - ], - [ - 6.1898331388840358e-04, 9.5931336430924428e-04, - 9.5931336430924038e-04 - ] - ], - [ - None, - [ - 7.2363659991042098e-04, - 1.0898079401035921e-03, - 1.0898079401035173e-03 - ], - [ - 1.4131616203283908e-04, - 2.1968921759816913e-04, - 2.1968921759815726e-04 - ] - ], - [ - None, - [ - 1.1253018483846534e-04, - 1.8455771918065726e-04, - 1.8455771918063306e-04 - ], - [ - 2.2227805982151793e-05, - 4.0783845770510348e-05, - 4.0783845770502603e-05 - ] - ]] - - # teardown method for class - @classmethod - def teardown_class(self): - """ teardown any state that was previously - setup with a call to setup_class.""" - print('\n****************** Teardown class method ******************') - # Change working directory back to main directory - os.chdir(vertexcfd_test.main_path) - - # setup method for each function - def setup_method(self): - """ setup test.""" - print('\nSetup method') - # Initialize input file, mesh file and output file names - self.input_file = None - self.mesh_file = None - self.output_file = None - - # teardown method for each function - def teardown_method(self): - """ teardown test.""" - print('\nTeardown method') - # Delete input file, mesh file and output file - #vertexcfd_test.clean_working_directory(self) - - ############################################################################# - ############################################################################# - ############################################################################# - @pytest.mark.push - @pytest.mark.daily - @pytest.mark.weekly - @pytest.mark.incompressible - def test_2d_mesh_convergence_laminar(self, request, capfd): - #### Parameters to edit for each function #### - # Parameters for VertexCFD run - copy_xml_file = False - restart = False - exodiff_options = None - base_input_file = "incompressible_2d_taylor_green_vortex" - final_time = 50 - source_input_file = base_input_file + ".xml" - - # Parameters for mesh convergence study - mark_expr = request.config.option.markexpr - xy_list = [20] - if (mark_expr == 'weekly'): - xy_list = [20, 40] - elif (mark_expr == 'weekly'): - xy_list = [20, 40, 80] - errors = [] - - # Loop over all elements of 'xy_list' - for i in range(0, len(xy_list)): - xy = xy_list[i] - self.input_file = base_input_file + "_" + str( - final_time) + "_" + str(final_time) + "_" + str(xy) + ".xml" - output_name = base_input_file + "_" + str(final_time) + "_" + str( - xy) + "_solution.exo" - - xml_args_to_replace_list = [] - xml_args_to_replace_list.append( - vertexcfd_test.xml_args_to_replace('Parameter', 'name', - 'X Elements', xy)) - xml_args_to_replace_list.append( - vertexcfd_test.xml_args_to_replace('Parameter', 'name', - 'Y Elements', xy)) - xml_args_to_replace_list.append( - vertexcfd_test.xml_args_to_replace('Parameter', 'name', - 'Final Time', final_time)) - xml_args_to_replace_list.append( - vertexcfd_test.xml_args_to_replace('Parameter', 'name', - 'Exodus Output File', - output_name)) - - vertexcfd_test.create_xml_file_from_base_file( - self, source_input_file, xml_args_to_replace_list, restart) - - # Clear replacing parameter list - xml_args_to_replace_list.clear() - - vertexcfd_options = () - - # Run VertexCFD (note that there is no comparison to gold file here) - vertexcfd_test.run_test(self, vertexcfd_options, exodiff_options, - copy_xml_file) - - # Compare error norms to gold values - vertexcfd_test.compare_error_norms(self.ref_error_norms[i], capfd, - 1.0e-10) diff --git a/regression_test/vertexcfd_test.py.in b/regression_test/vertexcfd_test.py.in deleted file mode 100644 index 622b21e..0000000 --- a/regression_test/vertexcfd_test.py.in +++ /dev/null @@ -1,552 +0,0 @@ -import os -import sys -import shutil -import subprocess -import glob -import xml.etree.ElementTree as ET -from collections import namedtuple -import json -import math -import pytest -import re - -############################################## -############## Global variables ############## -############################################## - -#### User dependent variables #### -# List objects to store executables and paths -exec_list_check = [] -path_list_check = [] - -# Absolute path with exodiff executable (Make sure to use the same Trilinos -# path as in the CMake file for consistency), and path to Workbench directory -exodiff_exec = "@EXODIFF_PATH@" -exec_list_check.append(exodiff_exec) - -### Variables that should not be modified #### - -# Main working directory -main_path = os.path.dirname(os.path.realpath(__file__)) -path_list_check.append(main_path) -parent_main_path = os.path.normpath(os.path.join(main_path, os.pardir)) - -# Absolute path with mesh files -mesh_file_path = "examples" -mesh_file_path = os.path.join(parent_main_path, mesh_file_path) -path_list_check.append(mesh_file_path) - -# Absolute path with input files -input_file_path = "examples" -input_file_path = os.path.join(parent_main_path, input_file_path) -path_list_check.append(input_file_path) - -# Absolute path with VertexCFD executable -vertexcfd_exec = os.path.join(parent_main_path, "src/vertexcfd") -exec_list_check.append(vertexcfd_exec) - -# Declare tuples that is used to substitute values in XML files. -# Defaults are give right-to-left, so optional entries appear on -# the right and 'parent' is the only optional entry. -xml_args_to_replace = namedtuple( - 'xml_args_to_replace', - ('tag', 'attribute', 'attribute_entry', 'new_value', 'parent'), - defaults=('', )) - -# Check if all executables are valid -for exec in exec_list_check: - if not os.access(exec, os.X_OK): - print(f"Error: executable {exec} is not valid.") - -# Check if all paths are valid -for d in path_list_check: - if not os.path.exists(d): - raise FileNotFoundError(f"{d} folder does not exist!") - -# Output variables -print( - "\n\n============================= Global variables =============================" -) -print("Mesh file absolute path: ", mesh_file_path) -print("Input file absolute path: ", input_file_path) -print("VertexCFD executable absolute path: ", vertexcfd_exec) -print("Exodiff executable absolute path: ", exodiff_exec) -print( - "=============================================================================\n" -) - -############################################## -############## Global functions ############## -############################################## - - -# Search a value in a XML file and return value if found, 'None' else. -def search_value_through_xml_file(xml, tag, attribute, key_word): - # find all tags with key word 'key_word' - keyword_list = xml.findall(f'.//{tag}[@{attribute}="{key_word}"]') - # Extract all entries and store them in a list to return. If empty, - # 'None' is returned. - if keyword_list: - return [entry.get('value') for entry in keyword_list] - - -# Find all tags with attribute="value" and set new_attribute="new_value". -# If parent is provided, only find tags within a with name="parent". -def modify_xml_tag(xml, - name, - attribute, - value, - new_attribute, - new_value, - parent=''): - """ - Find all tags with attribute="value" and set new_attribute="new_value". - If parent is provided, only find tags within a with name="parent". - """ - if parent: - parent = f'ParameterList[@name="{parent}"]/' - tags = xml.findall(f'.//{parent}{name}[@{attribute}="{value}"]') - if tags: - for tag in tags: - tag.set(new_attribute, str(new_value)) - else: - raise Exception(f'Tag <{tag}> with {attribute}="{value}" not found.') - - -# Read XML file -def read_xml_from_file(file_name): - return ET.parse(file_name) - - -# Write XML data to a XML file -def write_xml_to_file(xml, file_name): - xml.write(file_name) - - -# To handle restart capabilities: this function will set the `Read Restart File` to True -# and will add the restart file to the XML input file to read from. -def read_restart_file(self, xml_args_to_replace_list): - restart_dir = "restart" - # Look for a `restart_dir` directory in the test directory - if not os.path.isdir(restart_dir): - msg = "The restart directory {} could not be find in the test directory." - sys.exit(msg.format(restart_dir)) - - # Check if the `restart_dir` directory contains the restart files needed - base = self.input_file.split(".xml")[0] - data_file = base + "_read.data" - dofmap_file = base + "_read.dofmap" - if not os.path.isfile(os.path.join(restart_dir, data_file)): - msg = "The restart directory does not contain the restart file {}." - sys.exit(msg.format(data_file)) - if not os.path.isfile(os.path.join(restart_dir, dofmap_file)): - msg = "The restart directory does not contain the restart file {}." - sys.exit(msg.format(dofmap_file)) - - # Set `Read Restart File` to `True` - xml_args_to_replace_list.append( - xml_args_to_replace('Parameter', 'name', 'Read Restart', 'true')) - - # Append parameters to the list of entries to modify in the XML file - data_file_path = os.path.join(restart_dir, data_file) - xml_args_to_replace_list.append( - xml_args_to_replace('Parameter', 'name', 'Restart Data File Name', - data_file_path)) - - dofmap_file_path = os.path.join(restart_dir, dofmap_file) - xml_args_to_replace_list.append( - xml_args_to_replace('Parameter', 'name', 'Restart DOF Map File Name', - dofmap_file_path)) - - -# Generate a input file mesh from a base file XML input file by -# searching all entries in 'list_old_value' and replacing them with 'list_new_value'. -def create_xml_file_from_base_file(self, - base_input_file, - xml_args_to_replace_list, - restart=False): - # Read base input file - new_xml = read_xml_from_file( - os.path.join(self.input_file_path, base_input_file)) - - # If restart is set to True, add restart entries to `xml_args_to_replace_list` - if restart: - read_restart_file(self, xml_args_to_replace_list) - - # Loop over different parameters - for replacement_args in xml_args_to_replace_list: - tag = replacement_args.tag - if replacement_args.tag == "Parameter": - new_attribute = "value" - elif replacement_args.tag == "Parameter name": - tag = "Parameter" - new_attribute = "name" - elif replacement_args.tag == "ParameterList": - new_attribute = "name" - else: - print( - "Error: the tag name should be either 'Parameter' " - "(to change the value of a parameter entry), " - "'Parameter name' (to change the name of a parameter), " - "or 'ParameterList' (to change the name of a parameter list).") - sys.exit() - - modify_xml_tag(new_xml, tag, replacement_args.attribute, - replacement_args.attribute_entry, new_attribute, - replacement_args.new_value, replacement_args.parent) - - # Write new input file - write_xml_to_file(new_xml, self.input_file) - - -# Delete file by name -def delete_file(self, file_name): - if os.path.exists(file_name): - try: - os.remove(file_name) - except OSError as e: - print("Error: cannot delete %s : %s" % (file_name, e.strerror)) - raise e - else: - print("File %s does not exist in %s." % (file_name, self.test_path)) - - -# Copy file to a given path -def copy_file(file_path, file_name, dest_path): - shutil.copy(os.path.join(file_path, file_name), dest_path) - - -# Get input file name, mesh type and mesh file, and output file name -def setup_input_file(self, copy_xml_file): - # Check if working directory contains an 'exodiff_file.txt' file. If not - # use the default one. - exodiff_file = "exodiff_file.txt" - if not (os.path.isfile(exodiff_file)): - self.no_exodiff_file = True - shutil.copy(os.path.join(self.main_path, exodiff_file), self.test_path) - else: - self.no_exodiff_file = False - - # Copy XML file to working directory - if copy_xml_file: - copy_file(self.input_file_path, self.input_file, self.test_path) - - # Read in input file - xml = read_xml_from_file(self.input_file) - - # Extract Exodus filenames from XML file - self.output_file = search_value_through_xml_file(xml, 'Parameter', 'name', - 'Exodus Output File')[0] - - mesh_input_type = search_value_through_xml_file(xml, 'Parameter', 'name', - 'Mesh Input Type')[0] - if mesh_input_type == "Inline": - self.mesh_file = "Inline" - else: - self.mesh_file = search_value_through_xml_file(xml, 'Parameter', - 'name', 'File Name')[0] - - # Copy mesh file to working directory if not Inline mesh type - if not self.mesh_file == "Inline": - try: - shutil.copy(os.path.join(self.mesh_file_path, self.mesh_file), - self.test_path) - except OSError as e: - print("Error: cannot copy %s : %s" % (self.mesh_file, e.strerror)) - - -# Copy files of failed regression tests to an artifact directory -def copy_file_artifact_directory(self, exodiff_step): - print("\n\nMove files to artifact directory:") - # Create sub-working directory in the artifact directory - test_dir_name = os.path.basename(os.path.normpath(self.test_path)) - test_dir_name = os.path.join("regression_failures", test_dir_name) - fail_test_path = os.path.join(parent_main_path, test_dir_name) - os.makedirs(fail_test_path, exist_ok=True) - # List of files to move (XML, exodiff_test.txt and Exodus solution files) - file_list = [self.input_file, self.output_file] - if exodiff_step: - file_list.append(self.output_file.rstrip(".exo") + "_diff.exo") - file_list.append("exodiff_file.txt") - # Copy files to artifact directory - for f in file_list: - new_f = os.path.join(fail_test_path, f) - if os.path.isfile(new_f): - os.remove(new_f) - old_f = os.path.join(self.test_path, f) - if os.path.isfile(old_f): - shutil.copy(old_f, new_f) - print(f" Copied file {old_f}.") - print("\n\n") - - -# Function to call subprocess run -def subprocess_run(command): - subprocess.run(command, shell=False, stderr=subprocess.STDOUT, check=True) - - -# Run VertexCFD code -def run_vertexcfd(self, vertexcfd_options, run_serial, run_gpu): - # Build command to run VertexCFD (same command for Tpetra and Epetra linear algebra solver) - command = ["mpirun"] - if not run_gpu: - command.append("--map-by") - if not run_serial: - command.append(os.environ.get("MAP_STRING")) - else: - command.append("ppr:1:node:pe=1") - else: - command.extend(["-np", "2"]) - command.append(self.vertexcfd_exec) - command.append("--i=" + self.input_file) - # vertexcfd_options is an empty list by default - command.extend(vertexcfd_options) - # Run VertexCFD - try: - subprocess_run(command) - except Exception: - copy_file_artifact_directory(self, exodiff_step=False) - raise - - -# Build the exodiff command to be exectuted to compare the gold -# file and the solution file. It will create a `diff` file if -# `create_diff` is set to True. -def build_exodiff_command(self, exodiff_options, create_diff): - # Parameters - file_name = "exodiff_file.txt" - test_output_file = self.output_file - gold_output_file = getattr(self, 'gold_file', self.output_file) - test_gold_path = os.path.join(self.test_path, "gold") - base_file = self.output_file.rstrip(".exo") - # Build command to run exodiff - command = [self.exodiff_exec] - command.extend(exodiff_options) - if not create_diff: - command.append("-file") - command.append(os.path.join(self.test_path, file_name)) - command.append(os.path.join(self.test_path, test_output_file)) - command.append(os.path.join(test_gold_path, gold_output_file)) - if create_diff: - command.append(os.path.join(self.test_path, base_file + "_diff.exo")) - return command - - -# Run 'exodiff' executable. 'create_diff' adds a third Exodus file -# to compute the difference between the gold file and the solution file. -def run_exodiff(self, exodiff_options): - # Run exodiff - try: - # Assemble exodiff command line - command = build_exodiff_command(self, - exodiff_options, - create_diff=False) - subprocess_run(command) - except: - # Assemble command line to create a `diff` Exodus file from - # the `exodiff` executable - command = build_exodiff_command(self, - exodiff_options, - create_diff=True) - try: - subprocess_run(command) - except: - print("Warning: failed to create solution diff file") - - # Copy files to artifact directory and re-raise error - copy_file_artifact_directory(self, exodiff_step=True) - raise - - -# Clean working directory by deleting input file, output file, -# mesh file and exodiff file if any. -def clean_working_directory(self): - print("\nClean working directory:") - # List of files to remove (always present in working directory) - file_list_remove = [self.input_file] - file_list_remove.append(self.output_file) - # Remove file in 'file_list_remove' - for file in file_list_remove: - delete_file(self, file) - - # Remove exodiff file - if self.no_exodiff_file: - exodiff_file = "exodiff_file.txt" - delete_file(self, exodiff_file) - - # Remove Exodus file (mesh file) if not Inline mesh type - if not self.mesh_file == "Inline": - delete_file(self, self.mesh_file) - - # Remove block of files with same format - block_list_remove = ['*.data'] - block_list_remove.append('*.dofmap') - - for block in block_list_remove: - file_list = glob.glob(block) - for file_name in file_list: - delete_file(self, file_name) - - -# Run test by calling all above functions -def run_test(self, - vertexcfd_options, - exodiff_options, - copy_xml_file=True, - run_serial=False, - run_gpu=False): - # Get input file, mesh file and output file - setup_input_file(self, copy_xml_file) - - # Run VertexCFD job - run_vertexcfd(self, vertexcfd_options, run_serial, run_gpu) - - # Check against gold file using exodiff. NOTE: 'command' has to be passed - # as a string here with shell=True to get it to run. - if (exodiff_options is not None): - run_exodiff(self, exodiff_options) - - -# Assert two JSON files (output file and gold file) -def assert_json_files(self, gold_file_path): - # Read in output json file - with open(self.output_file, "r") as f: - json_file = json.loads(f.read()) - - # Read in gold json file - with open(gold_file_path, "r") as g: - gold_json_file = json.loads(g.read()) - - # Assert json files - assert json_file == gold_json_file - - -# Compute convergence order -def convergence_order(error1, error2, ncell1, ncell2): - return math.log((error1 / error2), (ncell2 / ncell1)) - - -# Compare convergence order between reference and vertexcfd result -def compare_convergence(error1, - error2, - reference, - num1, - num2, - rel_tol=1e-12, - abs_tol=0.0): - for p in (1, 2): - for err1, err2, ref in zip(error1[p], error2[p], reference[p]): - assert ref == pytest.approx(convergence_order( - err1, err2, num1, num2), - rel=rel_tol, - abs=abs_tol) - - -# Compare error norms between expected value and vertexcfd result -def compare_error_norms(expected, capfd, rel_tol=1e-12, abs_tol=0.0): - - # Get captured test output for parsing - fd_out, fd_err = capfd.readouterr() - - # Let pytest re-capture the output - sys.stdout.write(fd_out) - sys.stderr.write(fd_err) - - num_expected = len(expected[1]) - - # Regular expression for the final integrated error norms header. - # This will capture the order of the norm. - header_pattern = r'^Final (?:Temporal/)?Spatial Integrated L([12]) Error Norms:' - # Regular expression for a single error norm, capturing value. - error_pattern = r'\n \w+ = (.+)' - # Combine to capture the expected number of error norms. - pattern = re.compile(header_pattern + error_pattern * num_expected, - re.MULTILINE) - - errors = [None] * 3 - for p, *err in pattern.findall(fd_out): - p = int(p) - errors[p] = [float(i) for i in err] - - # Compare L1, L2 Error Norm with expected values - for p in (1, 2): - for err, exp in zip(errors[p], expected[p]): - if exp == 0.0: - assert err == pytest.approx(exp, abs=1e-12) - else: - assert err == pytest.approx(exp, rel=rel_tol, abs=abs_tol) - - return errors - - -# Log-log plot of L1/L2 error norms with number of cells -def error_norm_plot(comp_error, ref_error, comp_ncell, ref_ncell, head_string, - coordinate): - import matplotlib.pyplot as plt - - font = { - 'size': 16, - } - - # Plot label function - def label(var): - return r'$\left\Vert {0} - \overline{{{0}}}\right\Vert^{{p=1,2}}$'.format( - var) - - # Reorganize data. - L1_comp_error = [row[1] for row in comp_error] - L2_comp_error = [row[2] for row in comp_error] - L1_ref_error = [row[1] for row in ref_error] - L2_ref_error = [row[2] for row in ref_error] - - nvar = len(L1_comp_error[0]) - - L1_comp = [] - L2_comp = [] - L1_ref = [] - L2_ref = [] - for i in range(nvar): - L1_comp.append([row[i] for row in L1_comp_error]) - L2_comp.append([row[i] for row in L2_comp_error]) - L1_ref.append([row[i] for row in L1_ref_error]) - L2_ref.append([row[i] for row in L2_ref_error]) - - # variale and file names - var_name = [0] * nvar - file_name = [0] * nvar - - var_name[0] = label(r'\rho') - var_name[1] = label(r'\rho E') - file_name[0] = 'rho.png' - file_name[1] = 'rhoE.png' - if coordinate == 'Cartesian': - var_name[2] = label(r'\rho U_x') - var_name[3] = label(r'\rho U_y') - file_name[2] = 'rhoU_x.png' - file_name[3] = 'rhoU_y.png' - if nvar == 5: - var_name[nvar - 1] = label(r'\rho U_z') - file_name[nvar - 1] = 'rhoU_z.png' - elif coordinate == 'RZ': - var_name[2] = label(r'\rho U_r') - var_name[3] = label(r'\rho U_z') - file_name[2] = 'rhoU_r.png' - file_name[3] = 'rhoU_z.png' - if nvar == 5: - var_name[nvar - 1] = label(r'\rho U_\theta') - file_name[nvar - 1] = 'rhoU_theta.png' - - # Plot L1/L2 errors for each variables - for i in range(nvar): - if (L1_ref[i][0] == 0.0 or L2_ref[i][0] == 0.0): - continue - plt.loglog(ref_ncell, L1_ref[i], 'ro-', label='L1 ref error') - plt.loglog(ref_ncell, L2_ref[i], 'r^-', label='L2 ref error') - plt.loglog(comp_ncell, L1_comp[i], 'bo-', label='L1 comp error') - plt.loglog(comp_ncell, L2_comp[i], 'b^-', label='L2 comp error') - plt.ylabel(var_name[i], fontdict=font) - plt.xlabel('N', fontdict=font) - plt.xlim([ref_ncell[0] / 2, ref_ncell[-1] * 2]) - plt.legend(loc='upper right') - plt.savefig(head_string + file_name[i]) - plt.close() diff --git a/src/boundary_conditions/VertexCFD_BCStrategy_BoundaryFluxBase.cpp b/src/boundary_conditions/VertexCFD_BCStrategy_BoundaryFluxBase.cpp deleted file mode 100644 index bd06967..0000000 --- a/src/boundary_conditions/VertexCFD_BCStrategy_BoundaryFluxBase.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_BCStrategy_BoundaryFluxBase.hpp" -#include "VertexCFD_BCStrategy_BoundaryFluxBase_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_NUMSPACEDIM( - VertexCFD::BoundaryCondition::BoundaryFluxBase) diff --git a/src/boundary_conditions/VertexCFD_BCStrategy_BoundaryFluxBase.hpp b/src/boundary_conditions/VertexCFD_BCStrategy_BoundaryFluxBase.hpp deleted file mode 100644 index e764c03..0000000 --- a/src/boundary_conditions/VertexCFD_BCStrategy_BoundaryFluxBase.hpp +++ /dev/null @@ -1,128 +0,0 @@ -#ifndef VERTEXCFD_BOUNDARYCONDITION_BOUNDARYFLUXBASE_HPP -#define VERTEXCFD_BOUNDARYCONDITION_BOUNDARYFLUXBASE_HPP - -#include -#include -#include -#include -#include - -#include -#include -#include - -#include - -namespace VertexCFD -{ -namespace BoundaryCondition -{ -//---------------------------------------------------------------------------// -template -class BoundaryFluxBase : public panzer::BCStrategy, - public panzer::GlobalDataAcceptorDefaultImpl, - public panzer::EvaluatorWithBaseImpl -{ - public: - // Space dimension - static constexpr int num_space_dim = NumSpaceDim; - - BoundaryFluxBase(const panzer::BC& bc, - const Teuchos::RCP& global_data); - - virtual void setup(const panzer::PhysicsBlock& side_pb, - const Teuchos::ParameterList& user_data) - = 0; - - virtual void buildAndRegisterEvaluators( - PHX::FieldManager& fm, - const panzer::PhysicsBlock& side_pb, - const panzer::ClosureModelFactory_TemplateManager& factory, - const Teuchos::ParameterList& models, - const Teuchos::ParameterList& user_data) const - = 0; - - virtual void buildAndRegisterScatterEvaluators( - PHX::FieldManager& fm, - const panzer::PhysicsBlock& side_pb, - const panzer::LinearObjFactory& lof, - const Teuchos::ParameterList& user_data) const - = 0; - - virtual void buildAndRegisterGatherAndOrientationEvaluators( - PHX::FieldManager& fm, - const panzer::PhysicsBlock& side_pb, - const panzer::LinearObjFactory& lof, - const Teuchos::ParameterList& user_data) const - = 0; - - virtual void postRegistrationSetup(typename panzer::Traits::SetupData d, - PHX::FieldManager& vm) - = 0; - - virtual void evaluateFields(typename panzer::Traits::EvalData d) = 0; - - // Local members - void initialize(const panzer::PhysicsBlock& side_pb, - std::unordered_map& dof_eq_map); - - auto getIntegrationBasis(const panzer::PhysicsBlock& side_pb, - const std::string& dof_name) const; - - void registerDOFsGradient(PHX::FieldManager& fm, - const panzer::PhysicsBlock& side_pb, - const std::string& dof_name) const; - - void registerSideNormals(PHX::FieldManager& fm, - const panzer::PhysicsBlock& side_pb) const; - - void registerConvectionTypeFluxOperator( - std::pair dof_eq_pair, - std::unordered_map>& eq_vct_map, - const std::string& closure_name, - PHX::FieldManager& fm, - const panzer::PhysicsBlock& side_pb, - const double& multiplier) const; - - void registerPenaltyAndViscousGradientOperator( - std::pair dof_eq_pair, - PHX::FieldManager& fm, - const panzer::PhysicsBlock& side_pb, - const Teuchos::ParameterList& user_params) const; - - void registerViscousTypeFluxOperator( - std::pair dof_eq_pair, - std::unordered_map>& eq_vct_map, - const std::string closure_name, - PHX::FieldManager& fm, - const panzer::PhysicsBlock& side_pb, - const double& multiplier) const; - - void registerResidual( - std::pair dof_eq_pair, - std::unordered_map>& eq_vct_map, - PHX::FieldManager& fm, - const panzer::PhysicsBlock& side_pb) const; - - void registerScatterOperator( - std::pair dof_eq_pair, - PHX::FieldManager& fm, - const panzer::PhysicsBlock& side_pb, - const panzer::LinearObjFactory& lof) const; - - auto integrationRule() const { return _ir; } - - protected: - std::unordered_map bnd_prefix; - - private: - int _integration_order; - Teuchos::RCP _ir; -}; - -//---------------------------------------------------------------------------// - -} // end namespace BoundaryCondition -} // end namespace VertexCFD - -#endif // end VERTEXCFD_BOUNDARYCONDITION_BOUNDARYFLUXBASE_HPP diff --git a/src/boundary_conditions/VertexCFD_BCStrategy_BoundaryFluxBase_impl.hpp b/src/boundary_conditions/VertexCFD_BCStrategy_BoundaryFluxBase_impl.hpp deleted file mode 100644 index 162bf3d..0000000 --- a/src/boundary_conditions/VertexCFD_BCStrategy_BoundaryFluxBase_impl.hpp +++ /dev/null @@ -1,347 +0,0 @@ -#ifndef VERTEXCFD_BOUNDARYCONDITION_BOUNDARYFLUXBASE_IMPL_HPP -#define VERTEXCFD_BOUNDARYCONDITION_BOUNDARYFLUXBASE_IMPL_HPP - -#include "VertexCFD_BoundaryState_ViscousGradient.hpp" -#include "VertexCFD_BoundaryState_ViscousPenaltyParameter.hpp" -#include "VertexCFD_Integrator_BoundaryGradBasisDotVector.hpp" - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include - -namespace VertexCFD -{ -namespace BoundaryCondition -{ -//---------------------------------------------------------------------------// -template -BoundaryFluxBase::BoundaryFluxBase( - const panzer::BC& bc, const Teuchos::RCP& global_data) - : panzer::BCStrategy(bc) - , panzer::GlobalDataAcceptorDefaultImpl(global_data) -{ - // Initialize `bnd_prefix` to use with second-order flux - bnd_prefix.insert({"BOUNDARY_", "BOUNDARY_"}); - bnd_prefix.insert({"PENALTY_BOUNDARY_", "PENALTY_"}); - bnd_prefix.insert({"SYMMETRY_BOUNDARY_", "SYMMETRY_"}); -} - -//---------------------------------------------------------------------------// -// Initialize class members -template -void BoundaryFluxBase::initialize( - const panzer::PhysicsBlock& side_pb, - std::unordered_map& /**dof_eq_map**/) -{ - // Integration rule and integration order - const auto& irules = side_pb.getIntegrationRules(); - if (irules.size() != 1) - { - throw std::runtime_error( - "BCStrategy BoundaryFluxBis too many integration rules"); - } - _integration_order = irules.begin()->second->order(); - _ir = Teuchos::rcp( - new panzer::IntegrationRule(_integration_order, side_pb.cellData())); -} - -//---------------------------------------------------------------------------// -// Get integration basis for a variable with name `dof_name`. -template -auto BoundaryFluxBase::getIntegrationBasis( - const panzer::PhysicsBlock& side_pb, const std::string& dof_name) const -{ - const auto& dof_basis_pair = side_pb.getProvidedDOFs(); - Teuchos::RCP basis; - for (auto it = dof_basis_pair.begin(); it != dof_basis_pair.end(); ++it) - { - if (it->first == dof_name) - basis = it->second; - } - return panzer::basisIRLayout(basis, *_ir); -} - -//---------------------------------------------------------------------------// -// Register degree of freedom and gradients for a variable with name `dof_name` -template -void BoundaryFluxBase::registerDOFsGradient( - PHX::FieldManager& fm, - const panzer::PhysicsBlock& side_pb, - const std::string& dof_name) const -{ - // Degree of freedom (DOF) - const auto basis_layout = this->getIntegrationBasis(side_pb, dof_name); - Teuchos::ParameterList dof_params; - dof_params.set("Name", dof_name); - dof_params.set>("Basis", basis_layout); - dof_params.set>("IR", _ir); - const auto dof_op - = Teuchos::rcp(new panzer::DOF(dof_params)); - this->template registerEvaluator(fm, dof_op); - - // Gradient - dof_params.set("Gradient Name", "GRAD_" + dof_name); - const auto gd_op = Teuchos::rcp( - new panzer::DOFGradient(dof_params)); - this->template registerEvaluator(fm, gd_op); -} - -//---------------------------------------------------------------------------// -// Register side nornal evaluator -template -void BoundaryFluxBase::registerSideNormals( - PHX::FieldManager& fm, - const panzer::PhysicsBlock& side_pb) const -{ - std::stringstream normal_params_name; - normal_params_name << "Side Normal:" << side_pb.cellData().side(); - Teuchos::ParameterList normal_params(normal_params_name.str()); - normal_params.set("Name", "Side Normal"); - normal_params.set("Side ID", side_pb.cellData().side()); - normal_params.set>("IR", _ir); - normal_params.set("Normalize", true); - const auto normal_op = Teuchos::rcp( - new panzer::Normals(normal_params)); - this->template registerEvaluator(fm, normal_op); -} - -//---------------------------------------------------------------------------// -template -void BoundaryFluxBase::registerConvectionTypeFluxOperator( - std::pair dof_eq_pair, - std::unordered_map>& eq_res_map, - const std::string& closure_name, - PHX::FieldManager& fm, - const panzer::PhysicsBlock& side_pb, - const double& multiplier) const -{ - // Local variables - const std::string eq_name = dof_eq_pair.first; - const std::string dof_name = dof_eq_pair.second; - const std::string normal_dot_name = "Normal Dot Flux " + eq_name; - - // Register dot product evaluator - const std::string flux_name = "BOUNDARY_" + closure_name + "_FLUX_" - + eq_name; - const auto normal_dot_flux_op - = panzer::buildEvaluator_DotProduct( - normal_dot_name, *_ir, "Side Normal", flux_name); - this->template registerEvaluator(fm, normal_dot_flux_op); - - // Convective flux integral. - const auto basis_layout = this->getIntegrationBasis(side_pb, dof_name); - std::string residual_name = closure_name + "_BOUNDARY_RESIDUAL_" + eq_name; - const auto convective_flux_op = Teuchos::rcp( - new panzer::Integrator_BasisTimesScalar( - panzer::EvaluatorStyle::EVALUATES, - residual_name, - normal_dot_name, - *basis_layout, - *_ir, - multiplier)); - this->template registerEvaluator(fm, convective_flux_op); - - // Add residual name to `eq_res_map` - eq_res_map[eq_name].push_back(residual_name); -} - -//---------------------------------------------------------------------------// -// Register closure models used for the symmetric penalty method -template -void BoundaryFluxBase::registerPenaltyAndViscousGradientOperator( - std::pair dof_eq_pair, - PHX::FieldManager& fm, - const panzer::PhysicsBlock& side_pb, - const Teuchos::ParameterList& user_params) const -{ - // Local variables - const std::string eq_name = dof_eq_pair.first; - const std::string dof_name = dof_eq_pair.second; - const auto basis_layout = this->getIntegrationBasis(side_pb, dof_name); - - // Create viscous penalty parameter. - const auto viscous_penalty_op - = Teuchos::rcp(new ViscousPenaltyParameter( - *_ir, *(basis_layout->getBasis()), dof_name, user_params)); - this->template registerEvaluator(fm, viscous_penalty_op); - - // Create boundary gradients. - const auto viscous_gradient_op = Teuchos::rcp( - new ViscousGradient(*_ir, dof_name)); - this->template registerEvaluator(fm, viscous_gradient_op); -} - -//---------------------------------------------------------------------------// -// Register Laplace-type operators -template -void BoundaryFluxBase::registerViscousTypeFluxOperator( - std::pair dof_eq_pair, - std::unordered_map>& eq_res_map, - const std::string closure_name, - PHX::FieldManager& fm, - const panzer::PhysicsBlock& side_pb, - const double& multiplier) const -{ - const std::string eq_name = dof_eq_pair.first; - const std::string dof_name = dof_eq_pair.second; - const auto basis_layout = this->getIntegrationBasis(side_pb, dof_name); - - // Symmetric interior penalty method residual 1. - // FIXME: The dot product evaluator is not on the device in - // Trilinos 13.0.1 - std::string normal_dot_viscous_name = "Normal Dot " + closure_name - + " Flux " + eq_name; - std::string flux_name = "BOUNDARY_" + closure_name + "_FLUX_" + eq_name; - auto normal_dot_viscous_flux_op - = panzer::buildEvaluator_DotProduct( - normal_dot_viscous_name, *_ir, "Side Normal", flux_name); - this->template registerEvaluator(fm, normal_dot_viscous_flux_op); - - std::string bnd_resid = closure_name + "_BOUNDARY_RESIDUAL_" + eq_name; - auto bnd_op = Teuchos::rcp( - new panzer::Integrator_BasisTimesScalar( - panzer::EvaluatorStyle::EVALUATES, - bnd_resid, - normal_dot_viscous_name, - *basis_layout, - *_ir, - -multiplier)); - this->template registerEvaluator(fm, bnd_op); - eq_res_map[eq_name].push_back(bnd_resid); - - // Symmetric interior penalty method residual 2. - std::string penalty_bnd_resid = "PENALTY_BOUNDARY_RESIDUAL_" + eq_name; - auto bnd_penalty_op = Teuchos::rcp( - new Integrator::BoundaryGradBasisDotVector( - panzer::EvaluatorStyle::EVALUATES, - penalty_bnd_resid, - "PENALTY_BOUNDARY_" + closure_name + "_FLUX_" + eq_name, - *basis_layout, - *_ir, - -multiplier)); - this->template registerEvaluator(fm, bnd_penalty_op); - eq_res_map[eq_name].push_back(penalty_bnd_resid); - - // Symmetric interior penalty method residual 3. - // FIXME: The dot product evaluator is not on the device in - // Trilinos 13.0.1 - std::string normal_dot_scaled_penalty_viscous_name - = "Normal Dot Scaled Penalty " + closure_name + " Flux " + eq_name; - std::string scaled_penalty_flux_name = "SYMMETRY_BOUNDARY_" + closure_name - + "_FLUX_" + eq_name; - auto normal_dot_scaled_penalty_viscous_flux_op - = panzer::buildEvaluator_DotProduct( - normal_dot_scaled_penalty_viscous_name, - *_ir, - "Side Normal", - scaled_penalty_flux_name); - this->template registerEvaluator( - fm, normal_dot_scaled_penalty_viscous_flux_op); - - std::string scaled_penalty_bnd_resid = "SYMMETRY_BOUNDARY_RESIDUAL_" - + eq_name; - auto scaled_bnd_penalty_op = Teuchos::rcp( - new panzer::Integrator_BasisTimesScalar( - panzer::EvaluatorStyle::EVALUATES, - scaled_penalty_bnd_resid, - normal_dot_scaled_penalty_viscous_name, - *basis_layout, - *_ir, - multiplier)); - this->template registerEvaluator(fm, scaled_bnd_penalty_op); - eq_res_map[eq_name].push_back(scaled_penalty_bnd_resid); -} - -//---------------------------------------------------------------------------// -// Register residuals collected in `eq_res_map` for each equation. -template -void BoundaryFluxBase::registerResidual( - std::pair dof_eq_pair, - std::unordered_map>& eq_res_map, - PHX::FieldManager& fm, - const panzer::PhysicsBlock& side_pb) const -{ - // Local variables - const std::string eq_name = dof_eq_pair.first; - const std::string dof_name = dof_eq_pair.second; - const auto basis_layout = this->getIntegrationBasis(side_pb, dof_name); - - // Initialize residual vector - auto residuals = Teuchos::rcp(new std::vector); - for (auto& res : eq_res_map[eq_name]) - residuals->push_back(res); - - // Register residuals - Teuchos::ParameterList sum_params; - sum_params.set("Sum Name", "BOUNDARY_RESIDUAL_" + eq_name); - sum_params.set("Values Names", residuals); - sum_params.set("Data Layout", basis_layout->getBasis()->functional); - auto sum_op = Teuchos::rcp( - new panzer::SumStatic( - sum_params)); - this->template registerEvaluator(fm, sum_op); -} - -//---------------------------------------------------------------------------// -// Register and scatter residual for each equation -template -void BoundaryFluxBase::registerScatterOperator( - std::pair dof_eq_pair, - PHX::FieldManager& fm, - const panzer::PhysicsBlock& side_pb, - const panzer::LinearObjFactory& lof) const -{ - const auto& dof_basis_pair = side_pb.getProvidedDOFs(); - const std::string& eq_name = dof_eq_pair.first; - const std::string& dof_name = dof_eq_pair.second; - - Teuchos::RCP basis; - for (auto it = dof_basis_pair.begin(); it != dof_basis_pair.end(); ++it) - { - if (it->first == dof_name) - basis = it->second; - } - - std::string residual_name = "BOUNDARY_RESIDUAL_" + eq_name; - Teuchos::ParameterList p("Scatter: " + residual_name + " to " + eq_name); - - std::string scatter_field_name - = "Dummy Scatter: " + this->m_bc.identifier() + residual_name; - p.set("Scatter Name", scatter_field_name); - p.set("Basis", basis); - - auto residual_names = Teuchos::rcp(new std::vector); - residual_names->push_back(residual_name); - p.set("Dependent Names", residual_names); - - auto names_map = Teuchos::rcp(new std::map); - names_map->insert( - std::pair(residual_name, dof_name)); - p.set("Dependent Map", names_map); - - auto scatter_op = lof.buildScatter(p); - - this->template registerEvaluator(fm, scatter_op); - - // Require variables - auto dummy_layout = Teuchos::rcp(new PHX::MDALayout(0)); - PHX::Tag tag(scatter_field_name, dummy_layout); - fm.template requireField(tag); -} -//---------------------------------------------------------------------------// - -} // end namespace BoundaryCondition -} // end namespace VertexCFD - -#endif // end VERTEXCFD_BOUNDARYCONDITION_BOUNDARYFLUXBASE_IMPL_HPP diff --git a/src/boundary_conditions/VertexCFD_BCStrategy_Factory.hpp b/src/boundary_conditions/VertexCFD_BCStrategy_Factory.hpp deleted file mode 100644 index 52b3758..0000000 --- a/src/boundary_conditions/VertexCFD_BCStrategy_Factory.hpp +++ /dev/null @@ -1,87 +0,0 @@ -#ifndef VERTEXCFD_BOUNDARYCONDITION_FACTORY_HPP -#define VERTEXCFD_BOUNDARYCONDITION_FACTORY_HPP - -#include "VertexCFD_BCStrategy_IncompressibleBoundaryFlux.hpp" -#include "VertexCFD_BCStrategy_StrongDirichletMMS.hpp" - -#include -#include -#include -#include - -#include - -namespace VertexCFD -{ -namespace BoundaryCondition -{ -//---------------------------------------------------------------------------// -namespace Impl -{ -template class Strategy, int... Dims> -class TemplateBuilder -{ - public: - TemplateBuilder(const panzer::BC& bc, - const Teuchos::RCP& global_data) - : _bc(bc) - , _global_data(global_data) - { - } - - template - Teuchos::RCP build() const - { - Strategy* ptr - = new Strategy(_bc, _global_data); - return Teuchos::rcp(ptr); - } - - private: - const panzer::BC& _bc; - const Teuchos::RCP _global_data; -}; -} // namespace Impl - -//---------------------------------------------------------------------------// -template -class Factory : public panzer::BCStrategyFactory -{ - public: - Teuchos::RCP> - buildBCStrategy( - const panzer::BC& bc, - const Teuchos::RCP& global_data) const override - { - auto template_manager = Teuchos::rcp( - new panzer::BCStrategy_TemplateManager{}); - - const auto& bc_strategy = bc.strategy(); - - if (bc_strategy == "IncompressibleBoundaryFlux") - { - Impl::TemplateBuilder builder( - bc, global_data); - template_manager->buildObjects(builder); - } - else if (bc_strategy == "StrongDirichletMMS") - { - Impl::TemplateBuilder builder(bc, global_data); - template_manager->buildObjects(builder); - } - else - { - throw std::runtime_error("BC strategy not valid"); - } - - // Return the manager. - return template_manager; - } -}; - -//---------------------------------------------------------------------------// - -} // end namespace BoundaryCondition -} // end namespace VertexCFD - -#endif // VERTEXCFD_BOUNDARYCONDITION_FACTORY_HPP diff --git a/src/boundary_conditions/VertexCFD_BCStrategy_IncompressibleBoundaryFlux.cpp b/src/boundary_conditions/VertexCFD_BCStrategy_IncompressibleBoundaryFlux.cpp deleted file mode 100644 index 2ac15fd..0000000 --- a/src/boundary_conditions/VertexCFD_BCStrategy_IncompressibleBoundaryFlux.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_BCStrategy_IncompressibleBoundaryFlux.hpp" -#include "VertexCFD_BCStrategy_IncompressibleBoundaryFlux_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_NUMSPACEDIM( - VertexCFD::BoundaryCondition::IncompressibleBoundaryFlux) diff --git a/src/boundary_conditions/VertexCFD_BCStrategy_IncompressibleBoundaryFlux.hpp b/src/boundary_conditions/VertexCFD_BCStrategy_IncompressibleBoundaryFlux.hpp deleted file mode 100644 index d0fe34d..0000000 --- a/src/boundary_conditions/VertexCFD_BCStrategy_IncompressibleBoundaryFlux.hpp +++ /dev/null @@ -1,82 +0,0 @@ -#ifndef VERTEXCFD_BOUNDARYCONDITION_INCOMPRESSIBLEBOUNDARYFLUX_HPP -#define VERTEXCFD_BOUNDARYCONDITION_INCOMPRESSIBLEBOUNDARYFLUX_HPP - -#include "VertexCFD_BCStrategy_BoundaryFluxBase.hpp" - -#include -#include -#include -#include -#include - -#include -#include -#include - -#include - -#include - -namespace VertexCFD -{ -namespace BoundaryCondition -{ -//---------------------------------------------------------------------------// -template -class IncompressibleBoundaryFlux - : public BoundaryFluxBase -{ - public: - IncompressibleBoundaryFlux( - const panzer::BC& bc, - const Teuchos::RCP& global_data); - - static constexpr int num_space_dim = NumSpaceDim; - - void setup(const panzer::PhysicsBlock& side_pb, - const Teuchos::ParameterList& user_data) override; - - void buildAndRegisterEvaluators( - PHX::FieldManager& fm, - const panzer::PhysicsBlock& side_pb, - const panzer::ClosureModelFactory_TemplateManager& factory, - const Teuchos::ParameterList& models, - const Teuchos::ParameterList& user_data) const override; - - void buildAndRegisterScatterEvaluators( - PHX::FieldManager& fm, - const panzer::PhysicsBlock& side_pb, - const panzer::LinearObjFactory& lof, - const Teuchos::ParameterList& user_data) const override; - - void buildAndRegisterGatherAndOrientationEvaluators( - PHX::FieldManager& fm, - const panzer::PhysicsBlock& side_pb, - const panzer::LinearObjFactory& lof, - const Teuchos::ParameterList& user_data) const override; - - void postRegistrationSetup(typename panzer::Traits::SetupData d, - PHX::FieldManager& vm) override; - - void evaluateFields(typename panzer::Traits::EvalData d) override; - - private: - std::unordered_map _equ_dof_ns_pair; - std::unordered_map _equ_dof_ep_pair; - std::unordered_map _equ_dof_tm_pair; - std::unordered_map _equ_dof_fim_pair; - bool _build_viscous_flux; - bool _build_temp_equ; - bool _build_ind_less_equ; - bool _turbulence_model; - bool _build_full_induction_model; - std::string _turbulence_model_name; - std::string _continuity_model_name; -}; - -//---------------------------------------------------------------------------// - -} // end namespace BoundaryCondition -} // end namespace VertexCFD - -#endif // end VERTEXCFD_BOUNDARYCONDITION_INCOMPRESSIBLEBOUNDARYFLUX_HPP diff --git a/src/boundary_conditions/VertexCFD_BCStrategy_StrongDirichletMMS.hpp b/src/boundary_conditions/VertexCFD_BCStrategy_StrongDirichletMMS.hpp deleted file mode 100644 index 25dfec6..0000000 --- a/src/boundary_conditions/VertexCFD_BCStrategy_StrongDirichletMMS.hpp +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef VERTEXCFD_BOUNDARYCONDITION_STORNGDIRICHLETMMS_HPP -#define VERTEXCFD_BOUNDARYCONDITION_STORNGDIRICHLETMMS_HPP - -#include -#include -#include -#include - -#include - -#include - -#include - -namespace VertexCFD -{ -namespace BoundaryCondition -{ -//---------------------------------------------------------------------------// -template -class StrongDirichletMMS - : public panzer::BCStrategy_Dirichlet_DefaultImpl -{ - public: - StrongDirichletMMS(const panzer::BC& bc, - const Teuchos::RCP& global_data); - - void setup(const panzer::PhysicsBlock& side_pb, - const Teuchos::ParameterList& user_data) override; - - void buildAndRegisterEvaluators( - PHX::FieldManager& fm, - const panzer::PhysicsBlock& pb, - const panzer::ClosureModelFactory_TemplateManager& factory, - const Teuchos::ParameterList& models, - const Teuchos::ParameterList& user_data) const override; - - private: - std::vector _dofs; -}; - -//---------------------------------------------------------------------------// - -} // end namespace BoundaryCondition -} // end namespace VertexCFD - -#include "VertexCFD_BCStrategy_StrongDirichletMMS_impl.hpp" - -#endif // end VERTEXCFD_BOUNDARYCONDITION_STORNGDIRICHLETMMS_HPP diff --git a/src/boundary_conditions/VertexCFD_BCStrategy_StrongDirichletMMS_impl.hpp b/src/boundary_conditions/VertexCFD_BCStrategy_StrongDirichletMMS_impl.hpp deleted file mode 100644 index 0077d2b..0000000 --- a/src/boundary_conditions/VertexCFD_BCStrategy_StrongDirichletMMS_impl.hpp +++ /dev/null @@ -1,60 +0,0 @@ -#ifndef VERTEXCFD_BOUNDARYCONDITION_STORNGDIRICHLETMMS_IMPL_HPP -#define VERTEXCFD_BOUNDARYCONDITION_STORNGDIRICHLETMMS_IMPL_HPP - -#include - -namespace VertexCFD -{ -namespace BoundaryCondition -{ -//---------------------------------------------------------------------------// -template -StrongDirichletMMS::StrongDirichletMMS( - const panzer::BC& bc, const Teuchos::RCP& global_data) - : panzer::BCStrategy_Dirichlet_DefaultImpl(bc, global_data) -{ - if (this->m_bc.strategy() != "StrongDirichletMMS") - { - throw std::runtime_error("StrongDirichletMMS BC name incorrect"); - } -} - -//---------------------------------------------------------------------------// -template -void StrongDirichletMMS::setup(const panzer::PhysicsBlock& side_pb, - const Teuchos::ParameterList&) -{ - _dofs = side_pb.getProvidedDOFs(); - for (auto& dof : _dofs) - { - this->addDOF(dof.first); - this->addTarget("StrongDirichletMMS_" + dof.first, dof.first); - } -} - -//---------------------------------------------------------------------------// -template -void StrongDirichletMMS::buildAndRegisterEvaluators( - PHX::FieldManager& fm, - const panzer::PhysicsBlock&, - const panzer::ClosureModelFactory_TemplateManager&, - const Teuchos::ParameterList&, - const Teuchos::ParameterList&) const -{ - for (auto& dof : _dofs) - { - Teuchos::ParameterList p("BC MMS Strong Dirichlet"); - p.set("Source Name", dof.first); - p.set("Destination Name", "StrongDirichletMMS_" + dof.first); - p.set("Data Layout", dof.second->functional); - auto op = Teuchos::rcp(new panzer::Copy(p)); - this->template registerEvaluator(fm, op); - } -} - -//---------------------------------------------------------------------------// - -} // end namespace BoundaryCondition -} // end namespace VertexCFD - -#endif // end VERTEXCFD_BOUNDARYCONDITION_STORNGDIRICHLETMMS_IMPL_HPP diff --git a/src/boundary_conditions/VertexCFD_BoundaryState_MethodManufacturedSolution.cpp b/src/boundary_conditions/VertexCFD_BoundaryState_MethodManufacturedSolution.cpp deleted file mode 100644 index f7fde9f..0000000 --- a/src/boundary_conditions/VertexCFD_BoundaryState_MethodManufacturedSolution.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_BoundaryState_MethodManufacturedSolution.hpp" -#include "VertexCFD_BoundaryState_MethodManufacturedSolution_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS_NUMSPACEDIM( - VertexCFD::BoundaryCondition::MethodManufacturedSolution) diff --git a/src/boundary_conditions/VertexCFD_BoundaryState_MethodManufacturedSolution.hpp b/src/boundary_conditions/VertexCFD_BoundaryState_MethodManufacturedSolution.hpp deleted file mode 100644 index 7cc0b8f..0000000 --- a/src/boundary_conditions/VertexCFD_BoundaryState_MethodManufacturedSolution.hpp +++ /dev/null @@ -1,78 +0,0 @@ -#ifndef VERTEXCFD_BOUNDARYSTATE_METHODMANUFACTUREDSOLUTION_HPP -#define VERTEXCFD_BOUNDARYSTATE_METHODMANUFACTUREDSOLUTION_HPP - -#include -#include - -#include -#include -#include -#include - -#include - -#include - -namespace VertexCFD -{ -namespace BoundaryCondition -{ -//---------------------------------------------------------------------------// -// Strong boundary condition for MMS -//---------------------------------------------------------------------------// -template -class MethodManufacturedSolution - : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - static constexpr int num_space_dim = NumSpaceDim; - static constexpr int num_coeff = 2 * (num_space_dim + 1); - - MethodManufacturedSolution(const panzer::IntegrationRule& ir); - - void postRegistrationSetup(typename Traits::SetupData sd, - PHX::FieldManager& fm) override; - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - PHX::MDField - _boundary_lagrange_pressure; - Kokkos::Array, - num_space_dim> - _boundary_velocity; - PHX::MDField _boundary_temperature; - - PHX::MDField - _boundary_grad_lagrange_pressure; - Kokkos::Array< - PHX::MDField, - num_space_dim> - _boundary_grad_velocity; - PHX::MDField - _boundary_grad_temperature; - - private: - int _ir_degree; - int _ir_index; - - Kokkos::Array _phi_coeff; - Kokkos::Array, num_space_dim> _vel_coeff; - Kokkos::Array _T_coeff; - - PHX::MDField _ip_coords; -}; - -//---------------------------------------------------------------------------// - -} // end namespace BoundaryCondition -} // end namespace VertexCFD - -#include "VertexCFD_BoundaryState_MethodManufacturedSolution_impl.hpp" - -#endif // VERTEXCFD_BOUNDARYSTATE_METHODMANUFACTUREDSOLUTION_HPP diff --git a/src/boundary_conditions/VertexCFD_BoundaryState_ViscousGradient.cpp b/src/boundary_conditions/VertexCFD_BoundaryState_ViscousGradient.cpp deleted file mode 100644 index 32191a6..0000000 --- a/src/boundary_conditions/VertexCFD_BoundaryState_ViscousGradient.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_BoundaryState_ViscousGradient.hpp" -#include "VertexCFD_BoundaryState_ViscousGradient_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS( - VertexCFD::BoundaryCondition::ViscousGradient) diff --git a/src/boundary_conditions/VertexCFD_BoundaryState_ViscousGradient.hpp b/src/boundary_conditions/VertexCFD_BoundaryState_ViscousGradient.hpp deleted file mode 100644 index 3a321f8..0000000 --- a/src/boundary_conditions/VertexCFD_BoundaryState_ViscousGradient.hpp +++ /dev/null @@ -1,54 +0,0 @@ -#ifndef VERTEXCFD_BOUNDARYSTATE_VISCOUSGRADIENT_HPP -#define VERTEXCFD_BOUNDARYSTATE_VISCOUSGRADIENT_HPP - -#include "Panzer_PureBasis.hpp" -#include -#include - -#include -#include -#include -#include - -#include - -namespace VertexCFD -{ -namespace BoundaryCondition -{ -//---------------------------------------------------------------------------// -template -class ViscousGradient : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - - ViscousGradient(const panzer::IntegrationRule& ir, - const std::string& dof_name); - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - PHX::MDField _grad; - PHX::MDField - _scaled_grad; - - private: - int _num_space_dim; - PHX::MDField _dof; - PHX::MDField _bnd_dof; - PHX::MDField _penalty_param; - PHX::MDField - _normals; -}; - -//---------------------------------------------------------------------------// - -} // end namespace BoundaryCondition -} // end namespace VertexCFD - -#endif // VERTEXCFD_BOUNDARYSTATE_VISCOUSGRADIENT_HPP diff --git a/src/boundary_conditions/VertexCFD_BoundaryState_ViscousPenaltyParameter.cpp b/src/boundary_conditions/VertexCFD_BoundaryState_ViscousPenaltyParameter.cpp deleted file mode 100644 index 5ab277b..0000000 --- a/src/boundary_conditions/VertexCFD_BoundaryState_ViscousPenaltyParameter.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_BoundaryState_ViscousPenaltyParameter.hpp" -#include "VertexCFD_BoundaryState_ViscousPenaltyParameter_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS( - VertexCFD::BoundaryCondition::ViscousPenaltyParameter) diff --git a/src/boundary_conditions/VertexCFD_BoundaryState_ViscousPenaltyParameter.hpp b/src/boundary_conditions/VertexCFD_BoundaryState_ViscousPenaltyParameter.hpp deleted file mode 100644 index f768e4d..0000000 --- a/src/boundary_conditions/VertexCFD_BoundaryState_ViscousPenaltyParameter.hpp +++ /dev/null @@ -1,61 +0,0 @@ -#ifndef VERTEXCFD_BOUNDARYSTATE_VISCOUSPENALTYPARAMETER_HPP -#define VERTEXCFD_BOUNDARYSTATE_VISCOUSPENALTYPARAMETER_HPP - -#include "Panzer_PureBasis.hpp" -#include -#include - -#include -#include -#include -#include - -#include - -#include - -namespace VertexCFD -{ -namespace BoundaryCondition -{ -//---------------------------------------------------------------------------// -template -class ViscousPenaltyParameter : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - - ViscousPenaltyParameter(const panzer::IntegrationRule& ir, - const panzer::PureBasis& basis, - const std::string& dof_name, - const Teuchos::ParameterList& user_params); - - void postRegistrationSetup(typename Traits::SetupData sd, - PHX::FieldManager& fm) override; - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - PHX::MDField _penalty_param; - - private: - std::string _dof_name; - std::string _basis_name; - int _num_space_dim; - int _basis_index; - double _penalty; - - PHX::MDField - _ip_gradients; -}; - -//---------------------------------------------------------------------------// - -} // end namespace BoundaryCondition -} // end namespace VertexCFD - -#endif // VERTEXCFD_BOUNDARYSTATE_VISCOUSPENALTYPARAMETER_HPP diff --git a/src/boundary_conditions/VertexCFD_Integrator_BoundaryGradBasisDotVector.cpp b/src/boundary_conditions/VertexCFD_Integrator_BoundaryGradBasisDotVector.cpp deleted file mode 100644 index 6f49146..0000000 --- a/src/boundary_conditions/VertexCFD_Integrator_BoundaryGradBasisDotVector.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_Integrator_BoundaryGradBasisDotVector.hpp" -#include "VertexCFD_Integrator_BoundaryGradBasisDotVector_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS( - VertexCFD::Integrator::BoundaryGradBasisDotVector) diff --git a/src/boundary_conditions/VertexCFD_Integrator_BoundaryGradBasisDotVector.hpp b/src/boundary_conditions/VertexCFD_Integrator_BoundaryGradBasisDotVector.hpp deleted file mode 100644 index d977d84..0000000 --- a/src/boundary_conditions/VertexCFD_Integrator_BoundaryGradBasisDotVector.hpp +++ /dev/null @@ -1,103 +0,0 @@ -#ifndef VERTEXCFD_INTEGRATOR_BOUNDARYGRADBASISDOTVECTOR_HPP -#define VERTEXCFD_INTEGRATOR_BOUNDARYGRADBASISDOTVECTOR_HPP - -#include -#include - -#include -#include - -#include - -//---------------------------------------------------------------------------// -// Special boundary integration operator for the penalty term of the boundary -// flux. Only the gradient tangential to the surface of the boundary side is -// used. -// -// NOTE: The normal vectors used by this evaluator to compute the tangential -// gradient are expected to be unit normals. -//---------------------------------------------------------------------------// -namespace VertexCFD -{ -namespace Integrator -{ -template -class BoundaryGradBasisDotVector - : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - BoundaryGradBasisDotVector(const panzer::EvaluatorStyle& eval_style, - const std::string& res_name, - const std::string& flux_name, - const panzer::BasisIRLayout& basis, - const panzer::IntegrationRule& ir, - const double& multiplier = 1, - const std::vector& fm_names - = std::vector{}); - - void postRegistrationSetup(typename Traits::SetupData d, - PHX::FieldManager& fm); - - void evaluateFields(typename Traits::EvalData d); - - // Regular memory version. - template - struct FieldMultTag - { - }; - - template - KOKKOS_INLINE_FUNCTION void operator()( - const FieldMultTag& tag, - const Kokkos::TeamPolicy::member_type& team) const; - - // Shared memory version. - template - struct SharedFieldMultTag - { - }; - - template - KOKKOS_INLINE_FUNCTION void operator()( - const SharedFieldMultTag& tag, - const Kokkos::TeamPolicy::member_type& team) const; - - private: - Teuchos::RCP getValidParameters() const; - - using ScalarT = typename EvalType::ScalarT; - using scratch_view - = Kokkos::View::type, - typename PHX::exec_space::scratch_memory_space, - Kokkos::MemoryUnmanaged>; - - const panzer::EvaluatorStyle _eval_style; - double _multiplier; - std::string _basis_name; - std::size_t _basis_index; - - PHX::MDField _field; - PHX::MDField - _boundary_grad_basis; - - std::vector> - _field_mults; - Kokkos::View::type, - PHX::Device>*> - _kokkos_field_mults; - - PHX::MDField _vector; - PHX::MDField _normals; - PHX::MDField - _grad_basis; -}; - -//---------------------------------------------------------------------------// - -} // end namespace Integrator -} // end namespace VertexCFD - -#endif // VERTEXCFD_INTEGRATOR_BOUNDARYGRADBASISDOTVECTOR_HPP diff --git a/src/boundary_conditions/VertexCFD_Integrator_BoundaryGradBasisDotVector_impl.hpp b/src/boundary_conditions/VertexCFD_Integrator_BoundaryGradBasisDotVector_impl.hpp deleted file mode 100644 index 2e3a5f5..0000000 --- a/src/boundary_conditions/VertexCFD_Integrator_BoundaryGradBasisDotVector_impl.hpp +++ /dev/null @@ -1,429 +0,0 @@ -#ifndef VERTEXCFD_INTEGRATOR_BOUNDARYGRADBASISDOTVECTOR_IMPL_HPP -#define VERTEXCFD_INTEGRATOR_BOUNDARYGRADBASISDOTVECTOR_IMPL_HPP - -#include -#include -#include -#include - -namespace VertexCFD -{ -namespace Integrator -{ -//---------------------------------------------------------------------------// -template -BoundaryGradBasisDotVector::BoundaryGradBasisDotVector( - const panzer::EvaluatorStyle& eval_style, - const std::string& res_name, - const std::string& flux_name, - const panzer::BasisIRLayout& basis, - const panzer::IntegrationRule& ir, - const double& multiplier, - const std::vector& fm_names) - : _eval_style(eval_style) - , _multiplier(multiplier) - , _basis_name(basis.name()) - , _field(res_name, basis.functional) - , _boundary_grad_basis("boundary_grad_basis", basis.basis_grad) - , _vector(flux_name, ir.dl_vector) - , _normals("Side Normal", ir.dl_vector) -{ - if (res_name == "") - { - throw std::invalid_argument( - "Error: BoundaryGradBasisDotVector called with an empty residual " - "name."); - } - if (flux_name == "") - { - throw std::invalid_argument( - "Error: BoundaryGradBasisDotVector called with an empty flux " - "name."); - } - - if (!basis.getBasis()->supportsGrad()) - { - std::string msg = "Error: BoundaryGradBasisDotVector: Basis of type " - + basis.getBasis()->name() - + " does not support the gradient operator."; - throw std::logic_error(msg); - } - - if (_eval_style == panzer::EvaluatorStyle::CONTRIBUTES) - { - this->addContributedField(_field); - } - else - { - this->addEvaluatedField(_field); - } - - this->addEvaluatedField(_boundary_grad_basis); - - this->addDependentField(_vector); - this->addDependentField(_normals); - - // Add the dependent field multipliers and expand them into kokkos views - // so we can have an arbitrary number of them on device. - const int num_name = fm_names.size(); - _field_mults.resize(num_name); - _kokkos_field_mults - = Kokkos::View::type, - PHX::Device>*>( - "GradBasisDotVector::KokkosFieldMultipliers", num_name); - for (int i = 0; i < num_name; ++i) - { - _field_mults[i] - = PHX::MDField( - fm_names[i], ir.dl_scalar); - this->addDependentField(_field_mults[i]); - } - - std::string n("BoundaryGradBasisDotVector ("); - if (_eval_style == panzer::EvaluatorStyle::CONTRIBUTES) - { - n += "CONTRIBUTES"; - } - else - { - n += "EVALUATES"; - } - n += "): " + _field.fieldTag().name(); - this->setName(n); -} - -//---------------------------------------------------------------------------// -template -void BoundaryGradBasisDotVector::postRegistrationSetup( - typename Traits::SetupData sd, PHX::FieldManager& /* fm */) -{ - for (std::size_t i = 0; i < _field_mults.size(); ++i) - { - _kokkos_field_mults(i) = _field_mults[i].get_static_view(); - } - PHX::Device().fence(); - - _basis_index - = panzer::getBasisIndex(_basis_name, (*sd.worksets_)[0], this->wda); -} - -//---------------------------------------------------------------------------// -template -template -KOKKOS_INLINE_FUNCTION void -BoundaryGradBasisDotVector::operator()( - const FieldMultTag& /* tag */, - const Kokkos::TeamPolicy::member_type& team) const -{ - const int cell = team.league_rank(); - - // Create the boundary gradients. - const int num_qp(_vector.extent(1)); - const int num_dim(_vector.extent(2)); - const int num_bases(_grad_basis.extent(1)); - ScalarT n_dot_grad; - for (int qp = 0; qp < num_qp; ++qp) - { - for (int basis = 0; basis < num_bases; ++basis) - { - n_dot_grad = 0.0; - for (int dim = 0; dim < num_dim; ++dim) - { - n_dot_grad += _normals(cell, qp, dim) - * _grad_basis(cell, basis, qp, dim); - } - for (int dim = 0; dim < num_dim; ++dim) - { - _boundary_grad_basis(cell, basis, qp, dim) - = _grad_basis(cell, basis, qp, dim) - - _normals(cell, qp, dim) * n_dot_grad; - } - } - } - - // Initialize the evaluated field. - if (_eval_style == panzer::EvaluatorStyle::EVALUATES) - { - Kokkos::parallel_for( - Kokkos::TeamThreadRange(team, 0, num_bases), - [&](const int& basis) { _field(cell, basis) = 0.0; }); - } - - // Perform integration with the given number of field multipliers. - ScalarT tmp; - if (NUM_FIELD_MULT == 0) - { - for (int qp = 0; qp < num_qp; ++qp) - { - for (int dim = 0; dim < num_dim; ++dim) - { - tmp = _multiplier * _vector(cell, qp, dim); - Kokkos::parallel_for( - Kokkos::TeamThreadRange(team, 0, num_bases), - [&](const int& basis) { - _field(cell, basis) - += _boundary_grad_basis(cell, basis, qp, dim) * tmp; - }); - } - } - } - else if (NUM_FIELD_MULT == 1) - { - for (int qp = 0; qp < num_qp; ++qp) - { - for (int dim = 0; dim < num_dim; ++dim) - { - tmp = _multiplier * _vector(cell, qp, dim) - * _kokkos_field_mults(0)(cell, qp); - Kokkos::parallel_for( - Kokkos::TeamThreadRange(team, 0, num_bases), - [&](const int& basis) { - _field(cell, basis) - += _boundary_grad_basis(cell, basis, qp, dim) * tmp; - }); - } - } - } - else - { - const int num_field_mults(_kokkos_field_mults.extent(0)); - for (int qp = 0; qp < num_qp; ++qp) - { - ScalarT field_mults_total(1); - for (int fm = 0; fm < num_field_mults; ++fm) - field_mults_total *= _kokkos_field_mults(fm)(cell, qp); - for (int dim = 0; dim < num_dim; ++dim) - { - tmp = _multiplier * _vector(cell, qp, dim) * field_mults_total; - Kokkos::parallel_for( - Kokkos::TeamThreadRange(team, 0, num_bases), - [&](const int& basis) { - _field(cell, basis) - += _boundary_grad_basis(cell, basis, qp, dim) * tmp; - }); - } - } - } -} - -//---------------------------------------------------------------------------// -template -template -KOKKOS_INLINE_FUNCTION void -BoundaryGradBasisDotVector::operator()( - const SharedFieldMultTag& /* tag */, - const Kokkos::TeamPolicy::member_type& team) const -{ - const int cell = team.league_rank(); - const int num_qp = _vector.extent(1); - const int num_dim = _vector.extent(2); - const int num_bases = _grad_basis.extent(1); - const int fad_size = Kokkos::dimension_scalar(_field.get_view()); - - scratch_view tmp; - scratch_view tmp_field; - if (Sacado::IsADType::value) - { - tmp = scratch_view(team.team_shmem(), 1, fad_size); - tmp_field = scratch_view(team.team_shmem(), num_bases, fad_size); - } - else - { - tmp = scratch_view(team.team_shmem(), 1); - tmp_field = scratch_view(team.team_shmem(), num_bases); - } - - // Create the boundary gradients. - ScalarT n_dot_grad; - for (int qp = 0; qp < num_qp; ++qp) - { - for (int basis = 0; basis < num_bases; ++basis) - { - n_dot_grad = 0.0; - for (int dim = 0; dim < num_dim; ++dim) - { - n_dot_grad += _normals(cell, qp, dim) - * _grad_basis(cell, basis, qp, dim); - } - for (int dim = 0; dim < num_dim; ++dim) - { - _boundary_grad_basis(cell, basis, qp, dim) - = _grad_basis(cell, basis, qp, dim) - - _normals(cell, qp, dim) * n_dot_grad; - } - } - } - - // Initialize the evaluated field. - Kokkos::parallel_for(Kokkos::TeamThreadRange(team, 0, num_bases), - [&](const int& basis) { tmp_field(basis) = 0.0; }); - - // Perform integration with the given number of fields. - if (NUM_FIELD_MULT == 0) - { - for (int qp = 0; qp < num_qp; ++qp) - { - for (int dim = 0; dim < num_dim; ++dim) - { - team.team_barrier(); - tmp(0) = _multiplier * _vector(cell, qp, dim); - Kokkos::parallel_for( - Kokkos::TeamThreadRange(team, 0, num_bases), - [&](const int& basis) { - tmp_field(basis) - += _boundary_grad_basis(cell, basis, qp, dim) - * tmp(0); - }); - } - } - } - else if (NUM_FIELD_MULT == 1) - { - for (int qp = 0; qp < num_qp; ++qp) - { - for (int dim = 0; dim < num_dim; ++dim) - { - team.team_barrier(); - tmp(0) = _multiplier * _vector(cell, qp, dim) - * _kokkos_field_mults(0)(cell, qp); - Kokkos::parallel_for( - Kokkos::TeamThreadRange(team, 0, num_bases), - [&](const int& basis) { - tmp_field(basis) - += _boundary_grad_basis(cell, basis, qp, dim) - * tmp(0); - }); - } - } - } - else - { - const int num_field_mults(_kokkos_field_mults.extent(0)); - for (int qp = 0; qp < num_qp; ++qp) - { - ScalarT field_mults_total(1); // need shared mem here - for (int fm = 0; fm < num_field_mults; ++fm) - field_mults_total *= _kokkos_field_mults(fm)(cell, qp); - for (int dim = 0; dim < num_dim; ++dim) - { - team.team_barrier(); - tmp(0) = _multiplier * _vector(cell, qp, dim) - * field_mults_total; - Kokkos::parallel_for( - Kokkos::TeamThreadRange(team, 0, num_bases), - [&](const int& basis) { - tmp_field(basis) - += _boundary_grad_basis(cell, basis, qp, dim) - * tmp(0); - }); - } - } - } - - // Put values into target field - if (_eval_style == panzer::EvaluatorStyle::EVALUATES) - { - Kokkos::parallel_for( - Kokkos::TeamThreadRange(team, 0, num_bases), - [&](const int& basis) { _field(cell, basis) = tmp_field(basis); }); - } - else if (_eval_style == panzer::EvaluatorStyle::CONTRIBUTES) - { - Kokkos::parallel_for(Kokkos::TeamThreadRange(team, 0, num_bases), - [&](const int& basis) { - _field(cell, basis) += tmp_field(basis); - }); - } -} - -//---------------------------------------------------------------------------// -template -void BoundaryGradBasisDotVector::evaluateFields( - typename Traits::EvalData workset) -{ - _grad_basis = this->wda(workset).bases[_basis_index]->weighted_grad_basis; - - bool use_shared_memory = panzer::HP::inst().useSharedMemory(); - if (use_shared_memory) - { - int bytes; - if (Sacado::IsADType::value) - { - const int fad_size = Kokkos::dimension_scalar(_field.get_view()); - bytes = scratch_view::shmem_size(1, fad_size) - + scratch_view::shmem_size(_grad_basis.extent(1), fad_size); - } - else - bytes = scratch_view::shmem_size(1) - + scratch_view::shmem_size(_grad_basis.extent(1)); - - // The following if-block is for the sake of optimization depending on - // the number of field multipliers. The parallel_fors will loop over - // the cells in the Workset and execute operator()() above. - if (_field_mults.size() == 0) - { - auto policy - = panzer::HP::inst() - .teamPolicy, PHX::Device>( - workset.num_cells) - .set_scratch_size(0, Kokkos::PerTeam(bytes)); - Kokkos::parallel_for(this->getName(), policy, *this); - } - else if (_field_mults.size() == 1) - { - auto policy - = panzer::HP::inst() - .teamPolicy, PHX::Device>( - workset.num_cells) - .set_scratch_size(0, Kokkos::PerTeam(bytes)); - Kokkos::parallel_for(this->getName(), policy, *this); - } - else - { - auto policy - = panzer::HP::inst() - .teamPolicy, PHX::Device>( - workset.num_cells) - .set_scratch_size(0, Kokkos::PerTeam(bytes)); - Kokkos::parallel_for(this->getName(), policy, *this); - } - } - else - { - // The following if-block is for the sake of optimization depending on - // the number of field multipliers. The Kokkos::parallel_fors will - // loop over the cells in the Workset and execute operator()() above. - if (_field_mults.size() == 0) - { - auto policy - = panzer::HP::inst() - .teamPolicy, PHX::Device>( - workset.num_cells); - Kokkos::parallel_for(this->getName(), policy, *this); - } - else if (_field_mults.size() == 1) - { - auto policy - = panzer::HP::inst() - .teamPolicy, PHX::Device>( - workset.num_cells); - Kokkos::parallel_for(this->getName(), policy, *this); - } - else - { - auto policy - = panzer::HP::inst() - .teamPolicy, PHX::Device>( - workset.num_cells); - Kokkos::parallel_for(this->getName(), policy, *this); - } - } -} - -//---------------------------------------------------------------------------// - -} // end namespace Integrator -} // end namespace VertexCFD - -#endif // VERTEXCFD_INTEGRATOR_BOUNDARYGRADBASISDOTVECTOR_IMPL_HPP diff --git a/src/boundary_conditions/unit_test/CMakeLists.txt b/src/boundary_conditions/unit_test/CMakeLists.txt deleted file mode 100644 index d524aa9..0000000 --- a/src/boundary_conditions/unit_test/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -set(TEST_HARNESS_DIR ${CMAKE_SOURCE_DIR}/src/test_harness) -include(${TEST_HARNESS_DIR}/TestHarness.cmake) - -VertexCFD_add_tests( - LIBS VertexCFD - NAMES - ViscousGradient - ViscousPenaltyParameter - MethodManufacturedSolutionBC - ) diff --git a/src/boundary_conditions/unit_test/tstMethodManufacturedSolutionBC.cpp b/src/boundary_conditions/unit_test/tstMethodManufacturedSolutionBC.cpp deleted file mode 100644 index f96d24a..0000000 --- a/src/boundary_conditions/unit_test/tstMethodManufacturedSolutionBC.cpp +++ /dev/null @@ -1,350 +0,0 @@ -#include - -#include "boundary_conditions/VertexCFD_BoundaryState_MethodManufacturedSolution.hpp" -#include "utils/VertexCFD_Utils_Constants.hpp" - -#include - -#include - -#include -#include - -#include - -#include - -#include - -//---------------------------------------------------------------------------// -// TESTS -//---------------------------------------------------------------------------//¬ -namespace VertexCFD -{ -namespace Test -{ -//---------------------------------------------------------------------------// -template -void testEval() -{ - // Test fixture - constexpr int num_space_dim = NumSpaceDim; - constexpr int num_coeff = num_space_dim * 2 + 2; - const int integration_order = 1; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - - // Set non-trivial coordinates for the quadrature point - Kokkos::Array x; - x[0] = 0.1; - x[1] = 0.2; - auto ip_coord_view - = test_fixture.int_values->ip_coordinates.get_static_view(); - auto ip_coord_mirror = Kokkos::create_mirror(ip_coord_view); - ip_coord_mirror(0, 0, 0) = x[0]; - ip_coord_mirror(0, 0, 1) = x[1]; - if (num_space_dim == 3) - { - x[2] = 0.3; - ip_coord_mirror(0, 0, 2) = x[2]; - } - Kokkos::deep_copy(ip_coord_view, ip_coord_mirror); - - // Create mms evaluator. - auto mms_eval = Teuchos::rcp( - new BoundaryCondition:: - MethodManufacturedSolution( - *test_fixture.ir)); - test_fixture.registerEvaluator(mms_eval); - - // Function used for the MMS - using std::cos; - using std::sin; - using VertexCFD::Constants::pi; - - // function = B + A * sin(2*pi*f_x*(x-phi_x)) * sin(2*pi*f_y*(x-phi_y)) - // * sin(2*pi*f_z*(z-phi_z)) for 3D - auto set_function = [=](const Kokkos::Array coeff, - const Kokkos::Array x) { - double val = coeff[0] * sin(2.0 * pi * coeff[2] * (x[0] - coeff[3])) - * sin(2.0 * pi * coeff[4] * (x[1] - coeff[5])); - double return_val - = num_space_dim == 2 - ? val + coeff[1] - : val * sin(2.0 * pi * coeff[6] * (x[2] - coeff[7])) - + coeff[1]; - return return_val; - }; - - // function = A * 2*pi*f_x* cos(2*pi*f_x*(x-phi_x)) * - // sin(2*pi*f_y*(y-phi_y)) - // * sin(2*pi*f_z*(z-phi_z)) for 3D - auto set_gradX_function = [=](const Kokkos::Array coeff, - const Kokkos::Array x) { - double val = coeff[0] * 2.0 * pi * coeff[2] - * cos(2.0 * pi * coeff[2] * (x[0] - coeff[3])) - * sin(2.0 * pi * coeff[4] * (x[1] - coeff[5])); - double return_val - = num_space_dim == 2 - ? val - : val * sin(2.0 * pi * coeff[6] * (x[2] - coeff[7])); - - return return_val; - }; - - // function = A * sin(2*pi*f_x*(x-phi_x)) * 2*pi*f_y* - // cos(2*pi*f_y*(y-phi_y)) - // * sin(2*pi*f_z*(z-phi_z)) for 3D - auto set_gradY_function = [=](const Kokkos::Array coeff, - const Kokkos::Array x) { - double val = coeff[0] * 2.0 * pi * coeff[4] - * sin(2.0 * pi * coeff[2] * (x[0] - coeff[3])) - * cos(2.0 * pi * coeff[4] * (x[1] - coeff[5])); - double return_val - = num_space_dim == 2 - ? val - : val * sin(2.0 * pi * coeff[6] * (x[2] - coeff[7])); - - return return_val; - }; - - // function = A * sin(2*pi*f_x*(x-phi_x)) * sin(2*pi*f_y*(y-phi_y)) - // * 2*pi*f_Z * cos(2*pi*f_z*(z-phi_z)) for 3D - auto set_gradZ_function = [=](const Kokkos::Array coeff, - const Kokkos::Array x) { - return coeff[0] * 2.0 * pi * coeff[6] - * sin(2.0 * pi * coeff[2] * (x[0] - coeff[3])) - * sin(2.0 * pi * coeff[4] * (x[1] - coeff[5])) - * cos(2.0 * pi * coeff[6] * (x[2] - coeff[7])); - }; - - // Coefficients to be used with the above function to compute reference - // values for each primitive variable and gradients. They are hard coded in - // the source code - Kokkos::Array phi_coeff; - Kokkos::Array, num_space_dim> vel_coeff; - Kokkos::Array T_coeff; - - phi_coeff[0] = 0.0125; - phi_coeff[1] = 1.0; - phi_coeff[2] = 0.25; - phi_coeff[3] = 0.5; - phi_coeff[4] = 0.125; - phi_coeff[5] = 0.0; - - vel_coeff[0][0] = 0.0125; - vel_coeff[0][1] = 0.08; - vel_coeff[0][2] = 0.125; - vel_coeff[0][3] = 0.0; - vel_coeff[0][4] = 0.125; - vel_coeff[0][5] = 0.25; - - vel_coeff[1][0] = 0.0375; - vel_coeff[1][1] = 1.125; - vel_coeff[1][2] = 0.25; - vel_coeff[1][3] = 0.0; - vel_coeff[1][4] = 0.375; - vel_coeff[1][5] = 0.5; - - T_coeff[0] = 0.0625; - T_coeff[1] = 1.0; - T_coeff[2] = 0.375; - T_coeff[3] = 0.25; - T_coeff[4] = 0.25; - T_coeff[5] = 0.5; - - if (num_space_dim == 3) - { - phi_coeff[6] = 0.375; - phi_coeff[7] = 1.0; - - vel_coeff[0][6] = 0.25; - vel_coeff[0][7] = 0.0; - - vel_coeff[1][6] = 0.25; - vel_coeff[1][7] = 0.5; - - vel_coeff[2][0] = 0.025; - vel_coeff[2][1] = 0.0; - vel_coeff[2][2] = 0.125; - vel_coeff[2][3] = 1.0; - vel_coeff[2][4] = 0.25; - vel_coeff[2][5] = 0.25; - vel_coeff[2][6] = 0.25; - vel_coeff[2][7] = 0.25; - - T_coeff[6] = 0.125; - T_coeff[7] = 0.5; - } - - // Add required test fields. - test_fixture.registerTestField( - mms_eval->_boundary_lagrange_pressure); - test_fixture.registerTestField(mms_eval->_boundary_temperature); - - test_fixture.registerTestField( - mms_eval->_boundary_grad_lagrange_pressure); - for (int dim = 0; dim < num_space_dim; ++dim) - { - test_fixture.registerTestField( - mms_eval->_boundary_velocity[dim]); - test_fixture.registerTestField( - mms_eval->_boundary_grad_velocity[dim]); - } - test_fixture.registerTestField( - mms_eval->_boundary_grad_temperature); - - // Evaluate MMS BC. - test_fixture.evaluate(); - - // Check the BC value for all scalars. - auto boundary_lagrange_pressure_result - = test_fixture.getTestFieldData( - mms_eval->_boundary_lagrange_pressure); - auto boundary_velocity_0_result = test_fixture.getTestFieldData( - mms_eval->_boundary_velocity[0]); - auto boundary_velocity_1_result = test_fixture.getTestFieldData( - mms_eval->_boundary_velocity[1]); - auto boundary_temperature_result = test_fixture.getTestFieldData( - mms_eval->_boundary_temperature); - - auto boundary_grad_lagrange_pressure_result - = test_fixture.getTestFieldData( - mms_eval->_boundary_grad_lagrange_pressure); - auto boundary_grad_velocity_0_result - = test_fixture.getTestFieldData( - mms_eval->_boundary_grad_velocity[0]); - auto boundary_grad_velocity_1_result - = test_fixture.getTestFieldData( - mms_eval->_boundary_grad_velocity[1]); - auto boundary_grad_temperature_result - = test_fixture.getTestFieldData( - mms_eval->_boundary_grad_temperature); - - // Compute reference values using ideal gas equation of state for pressure - // and specific total energy - const double phi_ref = set_function(phi_coeff, x); - const double u_ref = set_function(vel_coeff[0], x); - const double v_ref = set_function(vel_coeff[1], x); - const double T_ref = set_function(T_coeff, x); - Kokkos::Array vel_ref; - for (int dim = 0; dim < num_space_dim; ++dim) - vel_ref[dim] = set_function(vel_coeff[dim], x); - - const double phi_gradX_ref = set_gradX_function(phi_coeff, x); - const double phi_gradY_ref = set_gradY_function(phi_coeff, x); - const double u_gradX_ref = set_gradX_function(vel_coeff[0], x); - const double u_gradY_ref = set_gradY_function(vel_coeff[0], x); - const double v_gradX_ref = set_gradX_function(vel_coeff[1], x); - const double v_gradY_ref = set_gradY_function(vel_coeff[1], x); - const double T_gradX_ref = set_gradX_function(T_coeff, x); - const double T_gradY_ref = set_gradY_function(T_coeff, x); - - int num_point = boundary_lagrange_pressure_result.extent(1); - - for (int qp = 0; qp < num_point; ++qp) - { - EXPECT_DOUBLE_EQ(phi_ref, - fieldValue(boundary_lagrange_pressure_result, 0, qp)); - EXPECT_DOUBLE_EQ(u_ref, fieldValue(boundary_velocity_0_result, 0, qp)); - EXPECT_DOUBLE_EQ(v_ref, fieldValue(boundary_velocity_1_result, 0, qp)); - EXPECT_DOUBLE_EQ(T_ref, fieldValue(boundary_temperature_result, 0, qp)); - - EXPECT_DOUBLE_EQ( - phi_gradX_ref, - fieldValue(boundary_grad_lagrange_pressure_result, 0, qp, 0)); - EXPECT_DOUBLE_EQ( - phi_gradY_ref, - fieldValue(boundary_grad_lagrange_pressure_result, 0, qp, 1)); - EXPECT_DOUBLE_EQ(u_gradX_ref, - fieldValue(boundary_grad_velocity_0_result, 0, qp, 0)); - EXPECT_DOUBLE_EQ(u_gradY_ref, - fieldValue(boundary_grad_velocity_0_result, 0, qp, 1)); - EXPECT_DOUBLE_EQ(v_gradX_ref, - fieldValue(boundary_grad_velocity_1_result, 0, qp, 0)); - EXPECT_DOUBLE_EQ(v_gradY_ref, - fieldValue(boundary_grad_velocity_1_result, 0, qp, 1)); - EXPECT_DOUBLE_EQ( - T_gradX_ref, - fieldValue(boundary_grad_temperature_result, 0, qp, 0)); - EXPECT_DOUBLE_EQ( - T_gradY_ref, - fieldValue(boundary_grad_temperature_result, 0, qp, 1)); - } - - if (num_space_dim == 3) - { - auto boundary_velocity_2_result - = test_fixture.getTestFieldData( - mms_eval->_boundary_velocity[2]); - auto boundary_grad_velocity_2_result - = test_fixture.getTestFieldData( - mms_eval->_boundary_grad_velocity[2]); - - const double w_ref = set_function(vel_coeff[2], x); - const double phi_gradZ_ref = set_gradZ_function(phi_coeff, x); - const double u_gradZ_ref = set_gradZ_function(vel_coeff[0], x); - const double v_gradZ_ref = set_gradZ_function(vel_coeff[1], x); - const double w_gradX_ref = set_gradX_function(vel_coeff[2], x); - const double w_gradY_ref = set_gradY_function(vel_coeff[2], x); - const double w_gradZ_ref = set_gradZ_function(vel_coeff[2], x); - const double T_gradZ_ref = set_gradZ_function(T_coeff, x); - - for (int qp = 0; qp < num_point; ++qp) - { - EXPECT_DOUBLE_EQ(w_ref, - fieldValue(boundary_velocity_2_result, 0, qp)); - - EXPECT_DOUBLE_EQ( - phi_gradZ_ref, - fieldValue(boundary_grad_lagrange_pressure_result, 0, qp, 2)); - EXPECT_DOUBLE_EQ( - u_gradZ_ref, - fieldValue(boundary_grad_velocity_0_result, 0, qp, 2)); - EXPECT_DOUBLE_EQ( - v_gradZ_ref, - fieldValue(boundary_grad_velocity_1_result, 0, qp, 2)); - EXPECT_DOUBLE_EQ( - w_gradX_ref, - fieldValue(boundary_grad_velocity_2_result, 0, qp, 0)); - EXPECT_DOUBLE_EQ( - w_gradY_ref, - fieldValue(boundary_grad_velocity_2_result, 0, qp, 1)); - EXPECT_DOUBLE_EQ( - w_gradZ_ref, - fieldValue(boundary_grad_velocity_2_result, 0, qp, 2)); - EXPECT_DOUBLE_EQ( - T_gradZ_ref, - fieldValue(boundary_grad_temperature_result, 0, qp, 2)); - } - } -} - -//---------------------------------------------------------------------------// -// Method of Manufactured Solution -// Residual -TEST(MethodManufacturedSolutionBC2D, residual_mms_test) -{ - testEval(); -} - -// Jacobian -TEST(MethodManufacturedSolutionBC2D, jacobian_mms_test) -{ - testEval(); -} - -TEST(MethodManufacturedSolutionBC3D, residual_mms_test) -{ - testEval(); -} - -// Jacobian -TEST(MethodManufacturedSolutionBC3D, jacobian_mms_test) -{ - testEval(); -} -//---------------------------------------------------------------------------// -} // end namespace Test -} // end namespace VertexCFD diff --git a/src/boundary_conditions/unit_test/tstViscousGradient.cpp b/src/boundary_conditions/unit_test/tstViscousGradient.cpp deleted file mode 100644 index 7e4358e..0000000 --- a/src/boundary_conditions/unit_test/tstViscousGradient.cpp +++ /dev/null @@ -1,169 +0,0 @@ -#include - -#include - -#include - -#include -#include - -#include - -#include - -#include - -//---------------------------------------------------------------------------// -// TESTS -//---------------------------------------------------------------------------// -namespace VertexCFD -{ -namespace Test -{ -//---------------------------------------------------------------------------// -// Test data dependencies. -template -struct Dependencies : public PHX::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - using scalar_type = typename EvalType::ScalarT; - - PHX::MDField _dof; - PHX::MDField _bnd_dof; - - PHX::MDField _penalty_param; - - PHX::MDField _normals; - - Dependencies(const panzer::IntegrationRule& ir) - : _dof("lagrange_pressure", ir.dl_scalar) - , _bnd_dof("BOUNDARY_lagrange_pressure", ir.dl_scalar) - , _penalty_param("viscous_penalty_parameter_lagrange_pressure", - ir.dl_scalar) - , _normals("Side Normal", ir.dl_vector) - { - this->addEvaluatedField(_dof); - this->addEvaluatedField(_bnd_dof); - this->addEvaluatedField(_penalty_param); - this->addEvaluatedField(_normals); - - this->setName("Viscous Gradient Unit Test Dependencies"); - } - - void evaluateFields(typename panzer::Traits::EvalData d) override - { - Kokkos::parallel_for( - "viscous gradient test dependencies", - Kokkos::RangePolicy(0, d.num_cells), - *this); - } - - KOKKOS_INLINE_FUNCTION void operator()(const int c) const - { - const int num_point = _dof.extent(1); - const int num_space_dim = _normals.extent(2); - for (int qp = 0; qp < num_point; ++qp) - { - // Set scalar variables - _dof(c, qp) = 0.1 * (qp + 1); - _bnd_dof(c, qp) = 1.2 * (qp + 1); - _penalty_param(c, qp) = 2.1 * (qp + 1); - - // Set normal vector - for (int dim = 0; dim < num_space_dim; ++dim) - { - _normals(c, qp, dim) = (dim + 1) * (dim * num_point + 1) * 0.2 - * (qp + 1); - } - } - } -}; - -//---------------------------------------------------------------------------// -template -void testEval(const int num_space_dim) -{ - // Test fixture - const int integration_order = 2; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - - // Create dependencies - auto dep_eval = Teuchos::rcp(new Dependencies(*test_fixture.ir)); - test_fixture.registerEvaluator(dep_eval); - - // Create viscous_gradient evaluator. - const std::string& dof_name = "lagrange_pressure"; - auto viscous_gradient_eval = Teuchos::rcp( - new BoundaryCondition::ViscousGradient( - *test_fixture.ir, dof_name)); - test_fixture.registerEvaluator(viscous_gradient_eval); - - // Add required test fields. - test_fixture.registerTestField(viscous_gradient_eval->_grad); - test_fixture.registerTestField( - viscous_gradient_eval->_scaled_grad); - - // Evaluate viscous_gradient. - test_fixture.evaluate(); - - // Check viscous_gradient - auto boundary_grad_result = test_fixture.getTestFieldData( - viscous_gradient_eval->_grad); - auto boundary_scaled_grad_result = test_fixture.getTestFieldData( - viscous_gradient_eval->_scaled_grad); - - int num_point = boundary_grad_result.extent(1); - - // Loop over quadrature points and mesh dimension - for (int qp = 0; qp < num_point; ++qp) - { - // Initialize variables to calculate reference values - const double u = 0.1 * (qp + 1); - const double u_bnd = 1.2 * (qp + 1); - const double delta = 2.1 * (qp + 1); - - // Compare to reference values - for (int dim = 0; dim < num_space_dim; ++dim) - { - const double n = (dim + 1) * (dim * num_point + 1) * 0.2 * (qp + 1); - EXPECT_DOUBLE_EQ(n * (u - u_bnd), - fieldValue(boundary_grad_result, 0, qp, dim)); - EXPECT_DOUBLE_EQ( - delta * n * (u - u_bnd), - fieldValue(boundary_scaled_grad_result, 0, qp, dim)); - } - } -} - -//---------------------------------------------------------------------------// -// 2-D: viscousGradient residual -TEST(ViscousGradient2D, residual_viscous_gradient_test) -{ - testEval(2); -} - -// 2-D: viscousGradient jacobian -TEST(ViscousGradient2D, jacobian_viscous_gradient_test) -{ - testEval(2); -} - -//---------------------------------------------------------------------------// -// 3-D: viscousGradient residual -TEST(ViscousGradient3D, residual_viscous_gradient_test) -{ - testEval(3); -} - -// 3-D: viscousGradient jacobian -TEST(ViscousGradient3D, jacobian_viscous_gradient_test) -{ - testEval(3); -} - -//---------------------------------------------------------------------------// - -} // end namespace Test -} // end namespace VertexCFD diff --git a/src/boundary_conditions/unit_test/tstViscousPenaltyParameter.cpp b/src/boundary_conditions/unit_test/tstViscousPenaltyParameter.cpp deleted file mode 100644 index 77c7fdb..0000000 --- a/src/boundary_conditions/unit_test/tstViscousPenaltyParameter.cpp +++ /dev/null @@ -1,129 +0,0 @@ -#include - -#include - -#include -#include - -#include - -#include - -#include - -#include - -//---------------------------------------------------------------------------// -// TESTS -//---------------------------------------------------------------------------// -namespace VertexCFD -{ -namespace Test -{ -//---------------------------------------------------------------------------// -template -void testEval(int num_space_dim) -{ - // Test fixture - const int integration_order = 2; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - - // Parameter list for penalty factors - Teuchos::ParameterList user_params; - user_params.sublist("Penalty Parameters").set("Energy Equation", 5.0); - - // Initial gradient of basis functions (one cell) and compute reference - // values 'h_ref' - int num_basis = test_fixture.workset->bases[0]->grad_basis.extent(1); - int num_point = test_fixture.workset->bases[0]->grad_basis.extent(2); - EXPECT_EQ((num_space_dim - 1) * 4, num_point); - std::array one_over_h_ref; - auto grad_basis_view - = test_fixture.workset->bases[0]->grad_basis.get_static_view(); - auto grad_basis_mirror = Kokkos::create_mirror(grad_basis_view); - for (int qp = 0; qp < num_point; ++qp) - { - one_over_h_ref[qp] = 0.0; - for (int basis = 0; basis < num_basis; basis++) - { - double one_over_h2_ref_basis = 0.0; - for (int dim = 0; dim < num_space_dim; dim++) - { - const double one_over_h2_ref_basis_dim - = 0.5 * (basis + 1) * (dim + 1 + num_space_dim) * (qp + 1); - grad_basis_mirror(0, basis, qp, dim) - = one_over_h2_ref_basis_dim; - one_over_h2_ref_basis += one_over_h2_ref_basis_dim - * one_over_h2_ref_basis_dim; - } - - one_over_h_ref[qp] += sqrt(one_over_h2_ref_basis); - } - } - Kokkos::deep_copy(grad_basis_view, grad_basis_mirror); - - // Create viscous penalty parameter evaluator. - const std::string& dof_name = "temperature"; - auto viscous_penalty_param = Teuchos::rcp( - new BoundaryCondition::ViscousPenaltyParameter( - *test_fixture.ir, - *(test_fixture.workset->bases[0]->basis_layout->getBasis()), - dof_name, - user_params)); - test_fixture.registerEvaluator(viscous_penalty_param); - - // Add required test fields. - test_fixture.registerTestField( - viscous_penalty_param->_penalty_param); - - // Evaluate viscous penalty parameter. - test_fixture.evaluate(); - - // Check viscous penalty parameter - auto boundary_penalty_param_result - = test_fixture.getTestFieldData( - viscous_penalty_param->_penalty_param); - - int num_point_rslt = boundary_penalty_param_result.extent(1); - - // Loop over quadrature points - for (int qp = 0; qp < num_point_rslt; ++qp) - { - // Compare to reference values - EXPECT_DOUBLE_EQ(5.0 * one_over_h_ref[qp], - fieldValue(boundary_penalty_param_result, 0, qp)); - } -} - -//---------------------------------------------------------------------------// -// 2-D: viscousPenaltyParameter residual -TEST(ViscousPenaltyParameter2D, residual_viscous_penalty_parameter_test) -{ - testEval(2); -} - -// 2-D: viscousPenaltyParameter jacobian -TEST(ViscousPenaltyParameter2D, jacobian_viscous_penalty_parameter_test) -{ - testEval(2); -} - -//---------------------------------------------------------------------------// -// 3-D: viscousPenaltyParameter residual -TEST(ViscousPenaltyParameter3D, residual_viscous_penalty_parameter_test) -{ - testEval(3); -} - -// 3-D: viscousPenaltyParameter jacobian -TEST(ViscousPenaltyParameter3D, jacobian_viscous_penalty_parameter_test) -{ - testEval(3); -} - -//---------------------------------------------------------------------------// - -} // end namespace Test -} // end namespace VertexCFD diff --git a/src/closure_models/VertexCFD_ClosureModelFactory.cpp b/src/closure_models/VertexCFD_ClosureModelFactory.cpp deleted file mode 100644 index 50df56f..0000000 --- a/src/closure_models/VertexCFD_ClosureModelFactory.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_ClosureModelFactory.hpp" -#include "VertexCFD_ClosureModelFactory_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_NUMSPACEDIM( - VertexCFD::ClosureModel::Factory) diff --git a/src/closure_models/VertexCFD_ClosureModelFactory.hpp b/src/closure_models/VertexCFD_ClosureModelFactory.hpp deleted file mode 100644 index e7d377e..0000000 --- a/src/closure_models/VertexCFD_ClosureModelFactory.hpp +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef VERTEXCFD_CLOSUREMODELFACTORY_HPP -#define VERTEXCFD_CLOSUREMODELFACTORY_HPP - -#include - -#include - -namespace VertexCFD -{ -namespace ClosureModel -{ -//---------------------------------------------------------------------------// -template -class Factory : public panzer::ClosureModelFactory -{ - public: - Teuchos::RCP>>> - buildClosureModels(const std::string& model_id, - const Teuchos::ParameterList& model_params, - const panzer::FieldLayoutLibrary& fl, - const Teuchos::RCP& ir, - const Teuchos::ParameterList& default_params, - const Teuchos::ParameterList& user_params, - const Teuchos::RCP& global_data, - PHX::FieldManager& fm) const override; -}; - -//---------------------------------------------------------------------------// - -} // end namespace ClosureModel -} // end namespace VertexCFD - -#endif // end VERTEXCFD_CLOSUREMODELFACTORY_HPP diff --git a/src/closure_models/VertexCFD_ClosureModelFactory_Hessian2d.cpp b/src/closure_models/VertexCFD_ClosureModelFactory_Hessian2d.cpp deleted file mode 100644 index ae102e7..0000000 --- a/src/closure_models/VertexCFD_ClosureModelFactory_Hessian2d.cpp +++ /dev/null @@ -1,4 +0,0 @@ -#include "VertexCFD_ClosureModelFactory.hpp" -#include "VertexCFD_ClosureModelFactory_impl.hpp" - -template class VertexCFD::ClosureModel::Factory; diff --git a/src/closure_models/VertexCFD_ClosureModelFactory_Hessian3d.cpp b/src/closure_models/VertexCFD_ClosureModelFactory_Hessian3d.cpp deleted file mode 100644 index ff3057a..0000000 --- a/src/closure_models/VertexCFD_ClosureModelFactory_Hessian3d.cpp +++ /dev/null @@ -1,4 +0,0 @@ -#include "VertexCFD_ClosureModelFactory.hpp" -#include "VertexCFD_ClosureModelFactory_impl.hpp" - -template class VertexCFD::ClosureModel::Factory; diff --git a/src/closure_models/VertexCFD_ClosureModelFactory_Jacobian2d.cpp b/src/closure_models/VertexCFD_ClosureModelFactory_Jacobian2d.cpp deleted file mode 100644 index 2d3647f..0000000 --- a/src/closure_models/VertexCFD_ClosureModelFactory_Jacobian2d.cpp +++ /dev/null @@ -1,4 +0,0 @@ -#include "VertexCFD_ClosureModelFactory.hpp" -#include "VertexCFD_ClosureModelFactory_impl.hpp" - -template class VertexCFD::ClosureModel::Factory; diff --git a/src/closure_models/VertexCFD_ClosureModelFactory_Jacobian3d.cpp b/src/closure_models/VertexCFD_ClosureModelFactory_Jacobian3d.cpp deleted file mode 100644 index 0b4bec9..0000000 --- a/src/closure_models/VertexCFD_ClosureModelFactory_Jacobian3d.cpp +++ /dev/null @@ -1,4 +0,0 @@ -#include "VertexCFD_ClosureModelFactory.hpp" -#include "VertexCFD_ClosureModelFactory_impl.hpp" - -template class VertexCFD::ClosureModel::Factory; diff --git a/src/closure_models/VertexCFD_ClosureModelFactory_Residual2d.cpp b/src/closure_models/VertexCFD_ClosureModelFactory_Residual2d.cpp deleted file mode 100644 index 70e2aa8..0000000 --- a/src/closure_models/VertexCFD_ClosureModelFactory_Residual2d.cpp +++ /dev/null @@ -1,4 +0,0 @@ -#include "VertexCFD_ClosureModelFactory.hpp" -#include "VertexCFD_ClosureModelFactory_impl.hpp" - -template class VertexCFD::ClosureModel::Factory; diff --git a/src/closure_models/VertexCFD_ClosureModelFactory_Residual3d.cpp b/src/closure_models/VertexCFD_ClosureModelFactory_Residual3d.cpp deleted file mode 100644 index 17fec5f..0000000 --- a/src/closure_models/VertexCFD_ClosureModelFactory_Residual3d.cpp +++ /dev/null @@ -1,4 +0,0 @@ -#include "VertexCFD_ClosureModelFactory.hpp" -#include "VertexCFD_ClosureModelFactory_impl.hpp" - -template class VertexCFD::ClosureModel::Factory; diff --git a/src/closure_models/VertexCFD_ClosureModelFactory_Tangent2d.cpp b/src/closure_models/VertexCFD_ClosureModelFactory_Tangent2d.cpp deleted file mode 100644 index 8803640..0000000 --- a/src/closure_models/VertexCFD_ClosureModelFactory_Tangent2d.cpp +++ /dev/null @@ -1,4 +0,0 @@ -#include "VertexCFD_ClosureModelFactory.hpp" -#include "VertexCFD_ClosureModelFactory_impl.hpp" - -template class VertexCFD::ClosureModel::Factory; diff --git a/src/closure_models/VertexCFD_ClosureModelFactory_Tangent3d.cpp b/src/closure_models/VertexCFD_ClosureModelFactory_Tangent3d.cpp deleted file mode 100644 index e842429..0000000 --- a/src/closure_models/VertexCFD_ClosureModelFactory_Tangent3d.cpp +++ /dev/null @@ -1,4 +0,0 @@ -#include "VertexCFD_ClosureModelFactory.hpp" -#include "VertexCFD_ClosureModelFactory_impl.hpp" - -template class VertexCFD::ClosureModel::Factory; diff --git a/src/closure_models/VertexCFD_ClosureModelFactory_TemplateBuilder.hpp b/src/closure_models/VertexCFD_ClosureModelFactory_TemplateBuilder.hpp deleted file mode 100644 index 7a4796a..0000000 --- a/src/closure_models/VertexCFD_ClosureModelFactory_TemplateBuilder.hpp +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef VERTEXCFD_CLOSUREMODELFACTORY_TEMPLATEBUILDER_HPP -#define VERTEXCFD_CLOSUREMODELFACTORY_TEMPLATEBUILDER_HPP - -#include "VertexCFD_ClosureModelFactory.hpp" - -#include - -#include - -namespace VertexCFD -{ -namespace ClosureModel -{ -//---------------------------------------------------------------------------// -template -class FactoryTemplateBuilder -{ - public: - template - Teuchos::RCP build() const - { - auto closure_factory = Teuchos::rcp(new Factory{}); - return Teuchos::rcp_static_cast( - closure_factory); - } -}; - -//---------------------------------------------------------------------------// - -} // end namespace ClosureModel -} // end namespace VertexCFD - -#endif // end VERTEXCFD_CLOSUREMODELFACTORY_TEMPLATEBUILDER_HPP diff --git a/src/closure_models/VertexCFD_ClosureModelFactory_impl.hpp b/src/closure_models/VertexCFD_ClosureModelFactory_impl.hpp deleted file mode 100644 index c47ba00..0000000 --- a/src/closure_models/VertexCFD_ClosureModelFactory_impl.hpp +++ /dev/null @@ -1,297 +0,0 @@ -#ifndef VERTEXCFD_CLOSUREMODELFACTORY_IMPL_HPP -#define VERTEXCFD_CLOSUREMODELFACTORY_IMPL_HPP - -#include "VertexCFD_Closure_ElementLength.hpp" -#include "VertexCFD_Closure_ExternalMagneticField.hpp" -#include "VertexCFD_Closure_MeasureElementLength.hpp" -#include "VertexCFD_Closure_MethodManufacturedSolution.hpp" -#include "VertexCFD_Closure_MethodManufacturedSolutionSource.hpp" -#include "VertexCFD_Closure_MetricTensor.hpp" -#include "VertexCFD_Closure_MetricTensorElementLength.hpp" -#include "VertexCFD_Closure_SingularValueElementLength.hpp" -#include "VertexCFD_Closure_VectorFieldDivergence.hpp" -#include "VertexCFD_Closure_WallDistance.hpp" - -#include "full_induction_mhd_solver/closure_models/VertexCFD_FullInductionClosureModelFactory.hpp" -#include "incompressible_solver/closure_models/VertexCFD_IncompressibleClosureModelFactory.hpp" -#include "induction_less_mhd_solver/closure_models/VertexCFD_InductionlessClosureModelFactory.hpp" -#include "turbulence_models/closure_models/VertexCFD_TurbulenceClosureModelFactory.hpp" - -#include "utils/VertexCFD_Utils_VectorizeOutputFieldNames.hpp" - -namespace VertexCFD -{ -namespace ClosureModel -{ -//---------------------------------------------------------------------------// -template -Teuchos::RCP>>> -Factory::buildClosureModels( - const std::string& model_id, - const Teuchos::ParameterList& model_params, - const panzer::FieldLayoutLibrary&, - const Teuchos::RCP& ir, - const Teuchos::ParameterList&, - const Teuchos::ParameterList& user_params, - const Teuchos::RCP&, - PHX::FieldManager&) const -{ - auto evaluators = Teuchos::rcp( - new std::vector>>); - - constexpr int num_space_dim = NumSpaceDim; - - if (!model_params.isSublist(model_id)) - { - throw std::runtime_error("Closure model id not in list"); - } - - // Turbulence model parameters - TurbulenceFactory tm_factory; - bool use_turbulence_model = false; - const std::string turbulence_model_name - = user_params.isType("Turbulence Model") - ? user_params.get("Turbulence Model") - : "No Turbulence Model"; - - if (turbulence_model_name != "No Turbulence Model") - { - tm_factory.buildClosureModel( - ir, user_params, turbulence_model_name, evaluators); - use_turbulence_model = true; - } - - // Incompressible equation of state - // TODO: the following logic remains until factory model functions - // are added for the turbulence models. - Teuchos::ParameterList fluid_prop_list - = user_params.sublist("Fluid Properties"); - const bool build_temp_equ - = user_params.isType("Build Temperature Equation") - ? user_params.get("Build Temperature Equation") - : false; - const bool build_buoyancy_source - = user_params.isType("Build Buoyancy Source") - ? user_params.get("Build Buoyancy Source") - : false; - const bool build_full_ind_equ - = user_params.isSublist("Full Induction MHD Properties") ? true : false; - const bool build_ind_less_equ - = user_params.isType("Build Inductionless MHD Equation") - ? user_params.get("Build Inductionless MHD Equation") - : false; - fluid_prop_list.set("Build Inductionless MHD Equation", - build_ind_less_equ); - fluid_prop_list.set("Build Temperature Equation", build_temp_equ); - fluid_prop_list.set("Build Buoyancy Source", build_buoyancy_source); - FluidProperties::ConstantFluidProperties incompressible_fluidprop_params( - fluid_prop_list); - - // Incompressible factory model objects - IncompressibleFactory incomp_factory; - std::string incomp_error_msg = "None"; - - // Inductionless solver factory objects - InductionlessFactory inductionless_factory; - std::string ind_less_error_msg = "None"; - - // Full induction solver factory objects - FullInductionFactory full_induction_factory; - std::string full_ind_error_msg = "None"; - - // Closure model block in XML input file - const Teuchos::ParameterList& closure_model_list - = model_params.sublist(model_id); - for (const auto& closure_model : closure_model_list) - { - bool found_model = false; - - const auto closure_name = closure_model.first; - const auto& closure_params - = Teuchos::getValue(closure_model.second); - - if (closure_params.isType("Type")) - { - const auto closure_type = closure_params.get("Type"); - - // Incompressible factory - incomp_factory.buildClosureModel(closure_type, - ir, - user_params, - closure_params, - use_turbulence_model, - found_model, - incomp_error_msg, - evaluators); - - // Full induction MHD factory - if (build_full_ind_equ) - { - full_induction_factory.buildClosureModel(closure_type, - ir, - user_params, - closure_params, - found_model, - full_ind_error_msg, - evaluators); - } - - // Inductionless MHD factory - if (build_ind_less_equ) - { - inductionless_factory.buildClosureModel(closure_type, - ir, - user_params, - closure_params, - found_model, - ind_less_error_msg, - evaluators); - } - - if (closure_type == "ExternalMagneticField") - { - auto eval = Teuchos::rcp( - new ExternalMagneticField( - *ir, user_params)); - evaluators->push_back(eval); - found_model = true; - } - - if (closure_type == "MetricTensor") - { - auto eval = Teuchos::rcp( - new MetricTensor(*ir)); - evaluators->push_back(eval); - found_model = true; - } - - if (closure_type == "ElementLength") - { - auto eval = Teuchos::rcp( - new ElementLength(*ir)); - evaluators->push_back(eval); - found_model = true; - } - else if (closure_type == "MetricTensorElementLength") - { - auto eval = Teuchos::rcp( - new MetricTensorElementLength( - *ir)); - evaluators->push_back(eval); - found_model = true; - } - else if (closure_type == "MeasureElementLength") - { - auto eval = Teuchos::rcp( - new MeasureElementLength(*ir)); - evaluators->push_back(eval); - found_model = true; - } - else if (closure_type == "SingularValueElementLength") - { - const auto method - = closure_params.get("Element Length Method"); - auto eval = Teuchos::rcp( - new SingularValueElementLength( - *ir, method)); - evaluators->push_back(eval); - found_model = true; - } - - if (closure_type == "MethodManufacturedSolution") - { - auto eval = Teuchos::rcp( - new MethodManufacturedSolution(*ir)); - evaluators->push_back(eval); - found_model = true; - } - - if (closure_type == "MethodManufacturedSolutionSource") - { - bool build_viscous_flux = false; - if (user_params.isType("Build Viscous Flux")) - { - build_viscous_flux - = user_params.get("Build Viscous Flux"); - } - auto eval = Teuchos::rcp( - new MethodManufacturedSolutionSource( - *ir, - build_viscous_flux, - incompressible_fluidprop_params)); - evaluators->push_back(eval); - found_model = true; - } - - if (closure_type == "WallDistance") - { - auto eval = Teuchos::rcp( - new WallDistance( - *ir, - user_params.get>("MeshManage" - "r"), - closure_params)); - evaluators->push_back(eval); - found_model = true; - } - - if (std::string::npos != closure_type.find("VectorFieldDivergence")) - { - const auto field_names - = closure_params.get("Field Names"); - std::vector tokens; - panzer::StringTokenizer(tokens, field_names, ",", true); - for (auto& field : tokens) - { - auto eval = Teuchos::rcp( - new VectorFieldDivergence( - *ir, field, closure_type)); - evaluators->push_back(eval); - } - found_model = true; - } - } - - if (!found_model) - { - std::string msg = "Closure model " + closure_name - + " failed to build.\n"; - msg += "The closure models implemented in VertexCFD are:\n"; - msg += "MeasureElementLength\n"; - msg += "MethodManufacturedSolution\n"; - msg += "MethodManufacturedSolutionSource\n"; - msg += "MetricTensor\n"; - msg += "MetricTensorElementLength\n"; - msg += "SingularValueElementLength\n"; - msg += "ThermalConductivity\n"; - msg += "VectorFieldDivergence\n"; - msg += "AbsVectorFieldDivergence\n"; - msg += "=================================\n"; - msg += "Incompressible closure models:\n"; - msg += incomp_error_msg; - msg += "=================================\n"; - msg += "Full induction MHD closure models:\n"; - msg += full_ind_error_msg; - msg += "=================================\n"; - msg += "Inductionless MHD closure models:\n"; - msg += ind_less_error_msg; - - throw std::runtime_error(msg); - } - } - - return evaluators; -} - -//---------------------------------------------------------------------------// - -} // end namespace ClosureModel -} // end namespace VertexCFD - -#endif // end VERTEXCFD_CLOSUREMODELFACTORY_IMPL_HPP diff --git a/src/closure_models/VertexCFD_Closure_ConstantScalarField.cpp b/src/closure_models/VertexCFD_Closure_ConstantScalarField.cpp deleted file mode 100644 index d46d054..0000000 --- a/src/closure_models/VertexCFD_Closure_ConstantScalarField.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_Closure_ConstantScalarField.hpp" -#include "VertexCFD_Closure_ConstantScalarField_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS( - VertexCFD::ClosureModel::ConstantScalarField) diff --git a/src/closure_models/VertexCFD_Closure_ConstantScalarField.hpp b/src/closure_models/VertexCFD_Closure_ConstantScalarField.hpp deleted file mode 100644 index dceb683..0000000 --- a/src/closure_models/VertexCFD_Closure_ConstantScalarField.hpp +++ /dev/null @@ -1,51 +0,0 @@ -#ifndef VERTEXCFD_CLOSURE_CONSTANTSCALARFIELD_HPP -#define VERTEXCFD_CLOSURE_CONSTANTSCALARFIELD_HPP - -#include -#include - -#include -#include -#include -#include - -#include - -#include - -namespace VertexCFD -{ -namespace ClosureModel -{ -//---------------------------------------------------------------------------// -// Closure model to assign a constant value to a named scalar field -//---------------------------------------------------------------------------// -template -class ConstantScalarField : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - - ConstantScalarField(const panzer::IntegrationRule& ir, - const std::string& field_name, - const double field_value); - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - PHX::MDField _scalar_field; - - private: - double _field_value; -}; - -//---------------------------------------------------------------------------// - -} // end namespace ClosureModel -} // end namespace VertexCFD - -#endif // end VERTEXCFD_CLOSURE_CONSTANTSCALARFIELD_HPP diff --git a/src/closure_models/VertexCFD_Closure_ElementLength.cpp b/src/closure_models/VertexCFD_Closure_ElementLength.cpp deleted file mode 100644 index 77f53aa..0000000 --- a/src/closure_models/VertexCFD_Closure_ElementLength.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_Closure_ElementLength.hpp" -#include "VertexCFD_Closure_ElementLength_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS( - VertexCFD::ClosureModel::ElementLength) diff --git a/src/closure_models/VertexCFD_Closure_ElementLength.hpp b/src/closure_models/VertexCFD_Closure_ElementLength.hpp deleted file mode 100644 index 9790280..0000000 --- a/src/closure_models/VertexCFD_Closure_ElementLength.hpp +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef VERTEXCFD_CLOSURE_ELEMENTLENGTH_HPP -#define VERTEXCFD_CLOSURE_ELEMENTLENGTH_HPP - -#include -#include - -#include -#include -#include -#include - -#include - -namespace VertexCFD -{ -namespace ClosureModel -{ -//---------------------------------------------------------------------------// -// Element length (dimensional) evaluator. -//---------------------------------------------------------------------------// -template -class ElementLength : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - - ElementLength(const panzer::IntegrationRule& ir, - const std::string& prefix = ""); - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - public: - PHX::MDField _element_length; - - private: - PHX::MDField - _grad_basis; -}; - -//---------------------------------------------------------------------------// - -} // end namespace ClosureModel -} // end namespace VertexCFD - -#endif // end VERTEXCFD_CLOSURE_ELEMENTLENGTH_HPP diff --git a/src/closure_models/VertexCFD_Closure_ExternalFields.cpp b/src/closure_models/VertexCFD_Closure_ExternalFields.cpp deleted file mode 100644 index a885cf4..0000000 --- a/src/closure_models/VertexCFD_Closure_ExternalFields.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_Closure_ExternalFields.hpp" -#include "VertexCFD_Closure_ExternalFields_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS( - VertexCFD::ClosureModel::ExternalFields) diff --git a/src/closure_models/VertexCFD_Closure_ExternalFields.hpp b/src/closure_models/VertexCFD_Closure_ExternalFields.hpp deleted file mode 100644 index db5b267..0000000 --- a/src/closure_models/VertexCFD_Closure_ExternalFields.hpp +++ /dev/null @@ -1,69 +0,0 @@ -#ifndef VERTEXCFD_CLOSURE_EXTERNALFIELDS_HPP -#define VERTEXCFD_CLOSURE_EXTERNALFIELDS_HPP - -#include - -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include - -#include -#include - -namespace VertexCFD -{ -namespace ClosureModel -{ -//---------------------------------------------------------------------------// -// Add external fields from another physics manager as a closure model. This -// will gather the fields and put them at the basis points. -//---------------------------------------------------------------------------// -template -class ExternalFields : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - - ExternalFields(const std::string& evaluator_name, - const Teuchos::RCP>& - external_fields_manager, - const std::vector& external_field_names, - const Teuchos::RCP& basis); - - void postRegistrationSetup(typename Traits::SetupData d, - PHX::FieldManager& fm); - - void evaluateFields(typename Traits::EvalData d); - - private: - int _num_field; - - public: - std::vector> - _external_fields; - - private: - Teuchos::RCP _global_indexer; - std::vector _field_ids; - Kokkos::View _ghosted_field_data; - Kokkos::View _scratch_lids; - std::vector> _scratch_offsets; -}; - -//---------------------------------------------------------------------------// - -} // end namespace ClosureModel -} // namespace VertexCFD - -#endif // end VERTEXCFD_CLOSURE_EXTERNALFIELDS_HPP diff --git a/src/closure_models/VertexCFD_Closure_ExternalFields_impl.hpp b/src/closure_models/VertexCFD_Closure_ExternalFields_impl.hpp deleted file mode 100644 index db0b7fc..0000000 --- a/src/closure_models/VertexCFD_Closure_ExternalFields_impl.hpp +++ /dev/null @@ -1,105 +0,0 @@ -#ifndef VERTEXCFD_CLOSURE_EXTERNALFIELDS_IMPL_HPP -#define VERTEXCFD_CLOSURE_EXTERNALFIELDS_IMPL_HPP - -#include - -namespace VertexCFD -{ -namespace ClosureModel -{ -//---------------------------------------------------------------------------// -template -ExternalFields::ExternalFields( - const std::string& evaluator_name, - const Teuchos::RCP>& - external_fields_manager, - const std::vector& external_field_names, - const Teuchos::RCP& basis) - : _num_field(external_field_names.size()) - , _external_fields(_num_field) - , _global_indexer(external_fields_manager->globalIndexer()) - , _field_ids(_num_field) - , _ghosted_field_data(external_fields_manager->ghostedFieldData()) -{ - // Setup evaluator data. - for (int f = 0; f < _num_field; ++f) - { - _external_fields[f] - = PHX::MDField( - external_field_names[f], basis->functional); - this->addEvaluatedField(_external_fields[f]); - } - this->setName(evaluator_name); - - // Get the field ids. - for (int f = 0; f < _num_field; ++f) - { - _field_ids[f] = _global_indexer->getFieldNum(external_field_names[f]); - } -} - -//---------------------------------------------------------------------------// -template -void ExternalFields::postRegistrationSetup( - typename Traits::SetupData d, PHX::FieldManager&) -{ - // Setup scratch data for reading the vector data. - _scratch_offsets.resize(_num_field); - const auto& workset_0 = (*d.worksets_)[0]; - auto block_id = this->wda(workset_0).block_id; - - for (int f = 0; f < _num_field; ++f) - { - const auto& offsets - = _global_indexer->getGIDFieldOffsets(block_id, _field_ids[f]); - _scratch_offsets[f] = Kokkos::View( - "external_field_offsets", offsets.size()); - auto offsets_mirror = Kokkos::create_mirror(_scratch_offsets[f]); - for (std::size_t i = 0; i < offsets.size(); ++i) - { - offsets_mirror(i) = offsets[i]; - } - Kokkos::deep_copy(_scratch_offsets[f], offsets_mirror); - } - - _scratch_lids = Kokkos::View( - "lids", - _external_fields[0].extent(0), - _global_indexer->getElementBlockGIDCount(block_id)); -} - -//---------------------------------------------------------------------------// -template -void ExternalFields::evaluateFields(typename Traits::EvalData d) -{ - // Get the local ids. - _global_indexer->getElementLIDs(this->wda(d).cell_local_ids_k, - _scratch_lids); - - // Extract the data. - auto lids = _scratch_lids; - auto field_data = _ghosted_field_data; - for (int f = 0; f < _num_field; ++f) - { - auto offsets = _scratch_offsets[f]; - auto gather_field = _external_fields[f].get_static_view(); - Kokkos::parallel_for( - Kokkos::RangePolicy(0, d.num_cells), - KOKKOS_LAMBDA(const int cell) { - int num_basis = offsets.extent(0); - for (int basis = 0; basis < num_basis; ++basis) - { - auto offset = offsets(basis); - auto lid = lids(cell, offset); - gather_field(cell, basis) = field_data(lid); - } - }); - } -} - -//---------------------------------------------------------------------------// - -} // end namespace ClosureModel -} // end namespace VertexCFD - -#endif // end VERTEXCFD_CLOSURE_EXTERNALFIELDS_IMPL_HPP diff --git a/src/closure_models/VertexCFD_Closure_ExternalMagneticField.cpp b/src/closure_models/VertexCFD_Closure_ExternalMagneticField.cpp deleted file mode 100644 index 35e5672..0000000 --- a/src/closure_models/VertexCFD_Closure_ExternalMagneticField.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_Closure_ExternalMagneticField.hpp" -#include "VertexCFD_Closure_ExternalMagneticField_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS( - VertexCFD::ClosureModel::ExternalMagneticField) diff --git a/src/closure_models/VertexCFD_Closure_MeasureElementLength.cpp b/src/closure_models/VertexCFD_Closure_MeasureElementLength.cpp deleted file mode 100644 index 237e21d..0000000 --- a/src/closure_models/VertexCFD_Closure_MeasureElementLength.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_Closure_MeasureElementLength.hpp" -#include "VertexCFD_Closure_MeasureElementLength_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS( - VertexCFD::ClosureModel::MeasureElementLength) diff --git a/src/closure_models/VertexCFD_Closure_MeasureElementLength.hpp b/src/closure_models/VertexCFD_Closure_MeasureElementLength.hpp deleted file mode 100644 index 52c285b..0000000 --- a/src/closure_models/VertexCFD_Closure_MeasureElementLength.hpp +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef VERTEXCFD_CLOSURE_MEASUREELEMENTLENGTH_HPP -#define VERTEXCFD_CLOSURE_MEASUREELEMENTLENGTH_HPP - -#include -#include - -#include -#include -#include -#include - -#include - -namespace VertexCFD -{ -namespace ClosureModel -{ -//---------------------------------------------------------------------------// -template -class MeasureElementLength : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - - PHX::MDField _element_length; - - MeasureElementLength(const panzer::IntegrationRule& ir, - const std::string& prefix = ""); - - void postRegistrationSetup(typename Traits::SetupData sd, - PHX::FieldManager& fm) override; - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - private: - int _ir_degree; - int _ir_index; - - PHX::MDField _cell_det; -}; - -//---------------------------------------------------------------------------// - -} // end namespace ClosureModel -} // end namespace VertexCFD - -#endif // end VERTEXCFD_CLOSURE_MEASUREELEMENTLENGTH_HPP diff --git a/src/closure_models/VertexCFD_Closure_MethodManufacturedSolution.cpp b/src/closure_models/VertexCFD_Closure_MethodManufacturedSolution.cpp deleted file mode 100644 index 3a32951..0000000 --- a/src/closure_models/VertexCFD_Closure_MethodManufacturedSolution.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_Closure_MethodManufacturedSolution.hpp" -#include "VertexCFD_Closure_MethodManufacturedSolution_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS_NUMSPACEDIM( - VertexCFD::ClosureModel::MethodManufacturedSolution) diff --git a/src/closure_models/VertexCFD_Closure_MethodManufacturedSolution.hpp b/src/closure_models/VertexCFD_Closure_MethodManufacturedSolution.hpp deleted file mode 100644 index 83e136b..0000000 --- a/src/closure_models/VertexCFD_Closure_MethodManufacturedSolution.hpp +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef VERTEXCFD_CLOSURE_METHODMANUFACTUREDSOLUTION_HPP -#define VERTEXCFD_CLOSURE_METHODMANUFACTUREDSOLUTION_HPP - -#include -#include - -#include -#include -#include -#include - -#include - -namespace VertexCFD -{ -namespace ClosureModel -{ -//---------------------------------------------------------------------------// -// Assumed MMS solution to be compared to computational solution. -//---------------------------------------------------------------------------// -template -class MethodManufacturedSolution - : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - static constexpr int num_space_dim = NumSpaceDim; - static constexpr int num_coeff = 2 * (num_space_dim + 1); - - MethodManufacturedSolution(const panzer::IntegrationRule& ir); - - void postRegistrationSetup(typename Traits::SetupData sd, - PHX::FieldManager& fm) override; - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - PHX::MDField _lagrange_pressure; - Kokkos::Array, num_space_dim> - _velocity; - PHX::MDField _temperature; - - private: - int _ir_degree; - int _ir_index; - - PHX::MDField _ip_coords; - - Kokkos::Array _phi_coeff; - Kokkos::Array, num_space_dim> _vel_coeff; - Kokkos::Array _T_coeff; -}; - -//---------------------------------------------------------------------------// - -} // namespace ClosureModel -} // end namespace VertexCFD - -#endif // VERTEXCFD_CLOSURE_METHODMANUFACTUREDSOLUTION_HPP diff --git a/src/closure_models/VertexCFD_Closure_MethodManufacturedSolutionSource.hpp b/src/closure_models/VertexCFD_Closure_MethodManufacturedSolutionSource.hpp deleted file mode 100644 index 0612e10..0000000 --- a/src/closure_models/VertexCFD_Closure_MethodManufacturedSolutionSource.hpp +++ /dev/null @@ -1,77 +0,0 @@ -#ifndef VERTEXCFD_CLOSURE_METHODMANUFACTUREDSOLUTIONSOURCE_HPP -#define VERTEXCFD_CLOSURE_METHODMANUFACTUREDSOLUTIONSOURCE_HPP - -#include "incompressible_solver/fluid_properties/VertexCFD_ConstantFluidProperties.hpp" - -#include -#include - -#include -#include -#include -#include - -#include - -namespace VertexCFD -{ -namespace ClosureModel -{ -//---------------------------------------------------------------------------// -template -class MethodManufacturedSolutionSource - : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - static constexpr int num_space_dim = NumSpaceDim; - static constexpr int num_coeff = 2 * (num_space_dim + 1); - static constexpr int num_conserve = num_space_dim + 2; - - MethodManufacturedSolutionSource( - const panzer::IntegrationRule& ir, - const bool build_viscous_flux, - const FluidProperties::ConstantFluidProperties& fluid_prop); - - void postRegistrationSetup(typename Traits::SetupData sd, - PHX::FieldManager& fm) override; - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()(const int cell) const; - - template - KOKKOS_INLINE_FUNCTION T - set_function(const Kokkos::Array& coeff, - const Kokkos::Array& x) const; - - PHX::MDField _continuity_mms_source; - Kokkos::Array, - num_space_dim> - _momentum_mms_source; - PHX::MDField _energy_mms_source; - - private: - int _ir_degree; - int _ir_index; - - PHX::MDField _ip_coords; - - Kokkos::Array _phi_coeff; - Kokkos::Array, num_space_dim> _vel_coeff; - Kokkos::Array _T_coeff; - - bool _build_viscous_flux; - double _rho; - double _nu; - double _kappa; -}; - -//---------------------------------------------------------------------------// - -} // end namespace ClosureModel -} // end namespace VertexCFD - -#endif // end VERTEXCFD_CLOSURE_METHODMANUFACTUREDSOLUTIONSOURCE_HPP diff --git a/src/closure_models/VertexCFD_Closure_MethodManufacturedSolutionSource_Hessian.cpp b/src/closure_models/VertexCFD_Closure_MethodManufacturedSolutionSource_Hessian.cpp deleted file mode 100644 index 5e1e620..0000000 --- a/src/closure_models/VertexCFD_Closure_MethodManufacturedSolutionSource_Hessian.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include - -#include "VertexCFD_Closure_MethodManufacturedSolutionSource.hpp" -#include "VertexCFD_Closure_MethodManufacturedSolutionSource_impl.hpp" - -template class VertexCFD::ClosureModel:: - MethodManufacturedSolutionSource; -template class VertexCFD::ClosureModel:: - MethodManufacturedSolutionSource; diff --git a/src/closure_models/VertexCFD_Closure_MethodManufacturedSolutionSource_Jacobian.cpp b/src/closure_models/VertexCFD_Closure_MethodManufacturedSolutionSource_Jacobian.cpp deleted file mode 100644 index 783c8a7..0000000 --- a/src/closure_models/VertexCFD_Closure_MethodManufacturedSolutionSource_Jacobian.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include - -#include "VertexCFD_Closure_MethodManufacturedSolutionSource.hpp" -#include "VertexCFD_Closure_MethodManufacturedSolutionSource_impl.hpp" - -template class VertexCFD::ClosureModel:: - MethodManufacturedSolutionSource; -template class VertexCFD::ClosureModel:: - MethodManufacturedSolutionSource; diff --git a/src/closure_models/VertexCFD_Closure_MethodManufacturedSolutionSource_Residual.cpp b/src/closure_models/VertexCFD_Closure_MethodManufacturedSolutionSource_Residual.cpp deleted file mode 100644 index c1760ba..0000000 --- a/src/closure_models/VertexCFD_Closure_MethodManufacturedSolutionSource_Residual.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include - -#include "VertexCFD_Closure_MethodManufacturedSolutionSource.hpp" -#include "VertexCFD_Closure_MethodManufacturedSolutionSource_impl.hpp" - -template class VertexCFD::ClosureModel:: - MethodManufacturedSolutionSource; -template class VertexCFD::ClosureModel:: - MethodManufacturedSolutionSource; diff --git a/src/closure_models/VertexCFD_Closure_MethodManufacturedSolutionSource_Tangent.cpp b/src/closure_models/VertexCFD_Closure_MethodManufacturedSolutionSource_Tangent.cpp deleted file mode 100644 index a14501f..0000000 --- a/src/closure_models/VertexCFD_Closure_MethodManufacturedSolutionSource_Tangent.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include - -#include "VertexCFD_Closure_MethodManufacturedSolutionSource.hpp" -#include "VertexCFD_Closure_MethodManufacturedSolutionSource_impl.hpp" - -template class VertexCFD::ClosureModel:: - MethodManufacturedSolutionSource; -template class VertexCFD::ClosureModel:: - MethodManufacturedSolutionSource; diff --git a/src/closure_models/VertexCFD_Closure_MetricTensor.cpp b/src/closure_models/VertexCFD_Closure_MetricTensor.cpp deleted file mode 100644 index ed16d57..0000000 --- a/src/closure_models/VertexCFD_Closure_MetricTensor.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_Closure_MetricTensor.hpp" -#include "VertexCFD_Closure_MetricTensor_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS( - VertexCFD::ClosureModel::MetricTensor) diff --git a/src/closure_models/VertexCFD_Closure_MetricTensor.hpp b/src/closure_models/VertexCFD_Closure_MetricTensor.hpp deleted file mode 100644 index bf5c0fe..0000000 --- a/src/closure_models/VertexCFD_Closure_MetricTensor.hpp +++ /dev/null @@ -1,59 +0,0 @@ -#ifndef VERTEXCFD_CLOSURE_METRICTENSOR_HPP -#define VERTEXCFD_CLOSURE_METRICTENSOR_HPP - -#include -#include -#include - -#include -#include -#include -#include - -#include - -namespace VertexCFD -{ -namespace ClosureModel -{ -//---------------------------------------------------------------------------// -template -class MetricTensor : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - - PHX::MDField - _metric_tensor; - - MetricTensor(const panzer::IntegrationRule& ir); - - void postRegistrationSetup(typename Traits::SetupData sd, - PHX::FieldManager& fm) override; - - void evaluateFields(typename Traits::EvalData workset) override; - - template - KOKKOS_INLINE_FUNCTION void - operator()(std::integral_constant, - const int cell, - const int point) const; - - private: - const int _ir_degree; - const int _num_topo_dim; - int _ir_index; - - PHX::MDField - _jacobian; - - Kokkos::View _element_map; -}; - -//---------------------------------------------------------------------------// - -} // end namespace ClosureModel -} // end namespace VertexCFD - -#endif // end VERTEXCFD_CLOSURE_METRICTENSOR_HPP diff --git a/src/closure_models/VertexCFD_Closure_MetricTensorElementLength.cpp b/src/closure_models/VertexCFD_Closure_MetricTensorElementLength.cpp deleted file mode 100644 index 18b53b7..0000000 --- a/src/closure_models/VertexCFD_Closure_MetricTensorElementLength.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_Closure_MetricTensorElementLength.hpp" -#include "VertexCFD_Closure_MetricTensorElementLength_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS( - VertexCFD::ClosureModel::MetricTensorElementLength) diff --git a/src/closure_models/VertexCFD_Closure_MetricTensorElementLength.hpp b/src/closure_models/VertexCFD_Closure_MetricTensorElementLength.hpp deleted file mode 100644 index baa416e..0000000 --- a/src/closure_models/VertexCFD_Closure_MetricTensorElementLength.hpp +++ /dev/null @@ -1,48 +0,0 @@ -#ifndef VERTEXCFD_CLOSURE_METRICTENSORELEMENTLENGTH_HPP -#define VERTEXCFD_CLOSURE_METRICTENSORELEMENTLENGTH_HPP - -#include -#include - -#include -#include -#include -#include - -#include - -namespace VertexCFD -{ -namespace ClosureModel -{ -//---------------------------------------------------------------------------// -template -class MetricTensorElementLength - : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - - PHX::MDField _element_length; - - MetricTensorElementLength(const panzer::IntegrationRule& ir, - const std::string& prefix = ""); - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - private: - PHX::MDField - _metric_tensor; -}; - -//---------------------------------------------------------------------------// - -} // end namespace ClosureModel -} // end namespace VertexCFD - -#endif // end VERTEXCFD_CLOSURE_METRICTENSORELEMENTLENGTH_HPP diff --git a/src/closure_models/VertexCFD_Closure_SingularValueElementLength.cpp b/src/closure_models/VertexCFD_Closure_SingularValueElementLength.cpp deleted file mode 100644 index 9ae15da..0000000 --- a/src/closure_models/VertexCFD_Closure_SingularValueElementLength.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_Closure_SingularValueElementLength.hpp" -#include "VertexCFD_Closure_SingularValueElementLength_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS( - VertexCFD::ClosureModel::SingularValueElementLength) diff --git a/src/closure_models/VertexCFD_Closure_SingularValueElementLength.hpp b/src/closure_models/VertexCFD_Closure_SingularValueElementLength.hpp deleted file mode 100644 index a54cba1..0000000 --- a/src/closure_models/VertexCFD_Closure_SingularValueElementLength.hpp +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef VERTEXCFD_CLOSURE_SINGULARVALUEELEMENTLENGTH_HPP -#define VERTEXCFD_CLOSURE_SINGULARVALUEELEMENTLENGTH_HPP - -#include -#include - -#include -#include -#include -#include - -#include - -namespace VertexCFD -{ -namespace ClosureModel -{ -//---------------------------------------------------------------------------// -template -class SingularValueElementLength - : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - - PHX::MDField _element_length; - - SingularValueElementLength(const panzer::IntegrationRule& ir, - const std::string& method, - const std::string& prefix = ""); - - void postRegistrationSetup(typename Traits::SetupData sd, - PHX::FieldManager& fm) override; - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - private: - int _ir_degree; - int _ir_index; - - enum class Method - { - Min, - Max - }; - Method _method; - - PHX::MDField - _cell_jac; -}; - -//---------------------------------------------------------------------------// - -} // end namespace ClosureModel -} // end namespace VertexCFD - -#endif // end VERTEXCFD_CLOSURE_SINGULARVALUEELEMENTLENGTH_HPP diff --git a/src/closure_models/VertexCFD_Closure_VectorFieldDivergence.cpp b/src/closure_models/VertexCFD_Closure_VectorFieldDivergence.cpp deleted file mode 100644 index 6db6511..0000000 --- a/src/closure_models/VertexCFD_Closure_VectorFieldDivergence.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "closure_models/VertexCFD_Closure_VectorFieldDivergence.hpp" -#include "closure_models/VertexCFD_Closure_VectorFieldDivergence_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS_NUMSPACEDIM( - VertexCFD::ClosureModel::VectorFieldDivergence) diff --git a/src/closure_models/VertexCFD_Closure_VectorFieldDivergence.hpp b/src/closure_models/VertexCFD_Closure_VectorFieldDivergence.hpp deleted file mode 100644 index cd56a5e..0000000 --- a/src/closure_models/VertexCFD_Closure_VectorFieldDivergence.hpp +++ /dev/null @@ -1,58 +0,0 @@ -#ifndef VERTEXCFD_CLOSURE_VECTORFIELDDIVERGENCE_HPP -#define VERTEXCFD_CLOSURE_VECTORFIELDDIVERGENCE_HPP - -#include -#include - -#include -#include -#include -#include - -#include - -#include - -namespace VertexCFD -{ -namespace ClosureModel -{ -//---------------------------------------------------------------------------// -// Closure to compute divergence of a vector field -//---------------------------------------------------------------------------// -template -class VectorFieldDivergence : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - static constexpr int num_space_dim = NumSpaceDim; - - VectorFieldDivergence(const panzer::IntegrationRule& ir, - const std::string& field_name, - const std::string& closure_name); - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - private: - int _num_grad_dim; - bool _use_abs; - Kokkos::Array< - PHX::MDField, - num_space_dim> - _grad_vector_field; - - public: - PHX::MDField _vector_field_divergence; -}; - -//---------------------------------------------------------------------------// - -} // end namespace ClosureModel -} // end namespace VertexCFD - -#endif // end VERTEXCFD_CLOSURE_VECTORFIELDDIVERGENCE_HPP diff --git a/src/closure_models/VertexCFD_Closure_WallDistance.cpp b/src/closure_models/VertexCFD_Closure_WallDistance.cpp deleted file mode 100644 index 5721d52..0000000 --- a/src/closure_models/VertexCFD_Closure_WallDistance.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_Closure_WallDistance.hpp" -#include "VertexCFD_Closure_WallDistance_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS_NUMSPACEDIM( - VertexCFD::ClosureModel::WallDistance) diff --git a/src/closure_models/VertexCFD_Closure_WallDistance.hpp b/src/closure_models/VertexCFD_Closure_WallDistance.hpp deleted file mode 100644 index 6450b92..0000000 --- a/src/closure_models/VertexCFD_Closure_WallDistance.hpp +++ /dev/null @@ -1,105 +0,0 @@ -#ifndef VERTEXCFD_CLOSURE_WALLDISTANCE_HPP -#define VERTEXCFD_CLOSURE_WALLDISTANCE_HPP - -#include -#include - -#include -#include - -#include -#include -#include -#include - -#include -#include - -#include - -#include "Panzer_CommonArrayFactories.hpp" -#include -#include -#include - -namespace VertexCFD -{ -namespace ClosureModel -{ -//---------------------------------------------------------------------------// -// Wall Distance evaluator. -//---------------------------------------------------------------------------// -template -class WallDistance : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - struct EvaluateTag - { - }; - struct RegistrationTag - { - }; - - using scalar_type = typename EvalType::ScalarT; - static constexpr int num_space_dim = NumSpaceDim; - - WallDistance(const panzer::IntegrationRule& ir, - Teuchos::RCP mesh_manager, - const Teuchos::ParameterList closure_params); - - void postRegistrationSetup(typename Traits::SetupData sd, - PHX::FieldManager& fm) override; - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()(EvaluateTag, const int cell) const; - - KOKKOS_INLINE_FUNCTION - void operator()(RegistrationTag, const int cell) const; - - public: - // Panzer field for storing wall distance - PHX::MDField _distance; - - private: - // Integration rule cubature degree needed for getting integration point - // coordinates - double _ir_degree; - - // Integration rule index needed for getting integration point coordinates - double _ir_index; - - // number of worksets - int _number_worksets; - - // current workset, needed for accessing _distance_vector in - // PostRegistration Setup and EvaluateFields - std::size_t _current_workset = 0; - - // Field of the coordinates of the integration points - PHX::MDField _ip_coords; - - Teuchos::RCP _topology; - unsigned _key; - - // View for storing the vector of global side data - Kokkos::View _sides; - - // View for storing the distance field across all worksets - Kokkos::View _distance_vector; - - // View for storing the surface normal of global sides - Kokkos::View _normals; - - // Vector which stores the workset_id for each workset - std::vector _workset_id; -}; - -//---------------------------------------------------------------------------// - -} // end namespace ClosureModel -} // end namespace VertexCFD - -#endif // end VERTEXCFD_CLOSURE_WALLDISTANCE_HPP diff --git a/src/closure_models/unit_test/CMakeLists.txt b/src/closure_models/unit_test/CMakeLists.txt deleted file mode 100644 index caeaa5d..0000000 --- a/src/closure_models/unit_test/CMakeLists.txt +++ /dev/null @@ -1,26 +0,0 @@ -set(TEST_HARNESS_DIR ${CMAKE_SOURCE_DIR}/src/test_harness) -include(${TEST_HARNESS_DIR}/TestHarness.cmake) - -VertexCFD_add_tests( - LIBS VertexCFD - NAMES - ClosureModelFactoryTestHarness - ElementLength - ExternalMagneticField - MetricTensor - MetricTensorElementLength - MethodManufacturedSolution - MethodManufacturedSolutionSource - MeasureElementLength - SingularValueElementLength - WallDistance - VectorFieldDivergence - ConstantScalarField - ) - -VertexCFD_add_tests( - MPI - LIBS VertexCFD - NAMES - ExternalFields - ) diff --git a/src/closure_models/unit_test/doc/MethodManufacuredSolution2D_reference.py b/src/closure_models/unit_test/doc/MethodManufacuredSolution2D_reference.py deleted file mode 100644 index c9f43ea..0000000 --- a/src/closure_models/unit_test/doc/MethodManufacuredSolution2D_reference.py +++ /dev/null @@ -1,41 +0,0 @@ -from math import * - -# gas properties -gamma = 1.5 -univ_gas_const = 2.0 -mmw = 3.0 -R = univ_gas_const / mmw -one_over_gm1 = 1.0 / (gamma - 1.0) - -# coefficient of sinusoidal mms function -rho_coeff = [0.0125, 0.25, 0.125, 0.5, 0.0, 1.0] -u_coeff = [0.0125, 0.125, 0.125, 0.0, 0.25, 0.08] -v_coeff = [0.0375, 0.25, 0.375, 0.0, 0.5, 1.125] -w_coeff = [0.025, 0.125, 0.25, 1.0, 0.25, 0.0] -T_coeff = [0.0625, 0.375, 0.25, 0.25, 0.5, 1.0] - -# evaluation points -x = 0.5 -y = 0.5 - -# mms solution -# f = A * sin( 2*pi*f_x * ( x - phi_x ) ) * sin( 2*pi*f_y * ( y - phi_y ) ) + B -rho = rho_coeff[0] * sin(2.0 * pi * rho_coeff[1] * (x - rho_coeff[3])) * sin( - 2.0 * pi * rho_coeff[2] * (y - rho_coeff[4])) + rho_coeff[5] - -u = u_coeff[0] * sin(2.0 * pi * u_coeff[1] * - (x - u_coeff[3])) * sin(2.0 * pi * u_coeff[2] * - (y - u_coeff[4])) + u_coeff[5] - -v = v_coeff[0] * sin(2.0 * pi * v_coeff[1] * - (x - v_coeff[3])) * sin(2.0 * pi * v_coeff[2] * - (y - v_coeff[4])) + v_coeff[5] - -T = T_coeff[0] * sin(2.0 * pi * T_coeff[1] * - (x - T_coeff[3])) * sin(2.0 * pi * T_coeff[2] * - (y - T_coeff[4])) + T_coeff[5] - -print("rho: ", rho) -print("u: ", u) -print("v: ", v) -print("T: ", T) diff --git a/src/closure_models/unit_test/doc/MethodManufacuredSolution3D_reference.py b/src/closure_models/unit_test/doc/MethodManufacuredSolution3D_reference.py deleted file mode 100644 index c000063..0000000 --- a/src/closure_models/unit_test/doc/MethodManufacuredSolution3D_reference.py +++ /dev/null @@ -1,54 +0,0 @@ -from math import * - -# gas properties -gamma = 1.5 -univ_gas_const = 2.0 -mmw = 3.0 -R = univ_gas_const / mmw -one_over_gm1 = 1.0 / (gamma - 1.0) - -# coefficient of sinusoidal mms function -rho_coeff = [0.0125, 0.25, 0.125, 0.375, 0.5, 0.0, 1.0, 1.0] -u_coeff = [0.0125, 0.125, 0.125, 0.25, 0.0, 0.25, 0.0, 0.08] -v_coeff = [0.0375, 0.25, 0.375, 0.25, 0.0, 0.5, 0.5, 1.125] -w_coeff = [0.025, 0.125, 0.25, 0.25, 1.0, 0.25, 0.25, 0.0] -T_coeff = [0.0625, 0.375, 0.25, 0.125, 0.25, 0.5, 0.5, 1.0] - -# evaluation points -x = 0.5 -y = 0.5 -z = 0.5 - -# mms solution -# f = A * sin( 2*pi*f_x * ( x - phi_x ) ) * sin( 2*pi*f_y * ( y - phi_y ) ) -# * sin( 2*pi*f_z * ( z - phi_z ) ) + B -rho = rho_coeff[0] * sin(2.0 * pi * rho_coeff[1] * (x - rho_coeff[4])) * sin( - 2.0 * pi * rho_coeff[2] * - (y - rho_coeff[5])) * sin(2.0 * pi * rho_coeff[3] * - (z - rho_coeff[6])) + rho_coeff[7] - -u = u_coeff[0] * sin(2.0 * pi * u_coeff[1] * (x - u_coeff[4])) * sin( - 2.0 * pi * u_coeff[2] * - (y - u_coeff[5])) * sin(2.0 * pi * u_coeff[3] * - (z - u_coeff[6])) + u_coeff[7] - -v = v_coeff[0] * sin(2.0 * pi * v_coeff[1] * (x - v_coeff[4])) * sin( - 2.0 * pi * v_coeff[2] * - (y - v_coeff[5])) * sin(2.0 * pi * v_coeff[3] * - (z - v_coeff[6])) + v_coeff[7] - -w = w_coeff[0] * sin(2.0 * pi * w_coeff[1] * (x - w_coeff[4])) * sin( - 2.0 * pi * w_coeff[2] * - (y - w_coeff[5])) * sin(2.0 * pi * w_coeff[3] * - (z - w_coeff[6])) + w_coeff[7] - -T = T_coeff[0] * sin(2.0 * pi * T_coeff[1] * (x - T_coeff[4])) * sin( - 2.0 * pi * T_coeff[2] * - (y - T_coeff[5])) * sin(2.0 * pi * T_coeff[3] * - (z - T_coeff[6])) + T_coeff[7] - -print("rho: ", rho) -print("u: ", u) -print("v: ", v) -print("w: ", w) -print("T: ", T) diff --git a/src/closure_models/unit_test/doc/MethodManufacuredSolutionSource2D_reference.nb b/src/closure_models/unit_test/doc/MethodManufacuredSolutionSource2D_reference.nb deleted file mode 100644 index f23da02..0000000 --- a/src/closure_models/unit_test/doc/MethodManufacuredSolutionSource2D_reference.nb +++ /dev/null @@ -1,858 +0,0 @@ -(* Content-type: application/vnd.wolfram.mathematica *) - -(*** Wolfram Notebook File ***) -(* http://www.wolfram.com/nb *) - -(* CreatedBy='Mathematica 12.1' *) - -(*CacheID: 234*) -(* Internal cache information: -NotebookFileLineBreakTest -NotebookFileLineBreakTest -NotebookDataPosition[ 158, 7] -NotebookDataLength[ 29430, 850] -NotebookOptionsPosition[ 26845, 811] -NotebookOutlinePosition[ 27241, 827] -CellTagsIndexPosition[ 27198, 824] -WindowFrame->Normal*) - -(* Beginning of Notebook Content *) -Notebook[{ -Cell[BoxData[{ - RowBox[{"Remove", "[", "\"\\"", "]"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{"(*", " ", - RowBox[{"material", " ", "property"}], "*)"}], "`"}]}], "Input", - CellChangeTimes->{{3.848745445279336*^9, 3.848745464753326*^9}, { - 3.8487475808945*^9, 3.848747630926712*^9}, 3.848747792303294*^9, { - 3.848765311373025*^9, 3.848765314592247*^9}}, - EmphasizeSyntaxErrors->True, - CellLabel-> - "In[165]:=",ExpressionUUID->"4467992d-fdba-4959-a6bf-6d08d2779d83"], - -Cell[BoxData[{ - RowBox[{ - RowBox[{"mu", " ", "=", " ", "4.0"}], ";"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{"gamma", " ", "=", " ", "1.5"}], ";"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{"univgas", " ", "=", " ", "2.0"}], ";"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{"mmw", " ", "=", " ", "3.0"}], ";"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{ - RowBox[{"kappa", " ", "=", " ", "5.0"}], ";"}], - "\[IndentingNewLine]"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{"oneovergm1", " ", "=", " ", - RowBox[{"1.0", "/", - RowBox[{"(", - RowBox[{"gamma", "-", "1.0"}], ")"}]}]}], ";"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{ - RowBox[{"R", " ", "=", " ", - RowBox[{"univgas", "/", "mmw"}]}], ";"}], "\[IndentingNewLine]", - "\[IndentingNewLine]", - RowBox[{"(*", " ", - RowBox[{"coefficients", " ", "of", " ", "function"}], " ", - "*)"}]}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{"rhocoeff", " ", "=", " ", - RowBox[{"ConstantArray", "[", - RowBox[{"0", ",", "6"}], "]"}]}], ";"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{"ucoeff", " ", "=", - RowBox[{"ConstantArray", "[", - RowBox[{"0", ",", "6"}], "]"}]}], ";"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{"vcoeff", " ", "=", " ", - RowBox[{"ConstantArray", "[", - RowBox[{"0", ",", "6"}], "]"}]}], ";"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{ - RowBox[{"Tcoeff", " ", "=", " ", - RowBox[{"ConstantArray", "[", - RowBox[{"0", ",", "6"}], "]"}]}], ";"}], - "\[IndentingNewLine]"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{ - RowBox[{"rhocoeff", "[", - RowBox[{"[", "1", "]"}], "]"}], "=", "0.0125"}], ";"}], "\n", - RowBox[{ - RowBox[{ - RowBox[{"rhocoeff", "[", - RowBox[{"[", "2", "]"}], "]"}], "=", "0.25"}], ";"}], "\n", - RowBox[{ - RowBox[{ - RowBox[{"rhocoeff", "[", - RowBox[{"[", "3", "]"}], "]"}], "=", "0.125"}], ";"}], "\n", - RowBox[{ - RowBox[{ - RowBox[{"rhocoeff", "[", - RowBox[{"[", "4", "]"}], "]"}], "=", "0.5"}], ";"}], "\n", - RowBox[{ - RowBox[{ - RowBox[{"rhocoeff", "[", - RowBox[{"[", "5", "]"}], "]"}], "=", "0.0"}], - ";"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{ - RowBox[{ - RowBox[{"rhocoeff", "[", - RowBox[{"[", "6", "]"}], "]"}], "=", "1.0"}], ";"}], - "\[IndentingNewLine]"}], "\n", - RowBox[{ - RowBox[{ - RowBox[{"ucoeff", "[", - RowBox[{"[", "1", "]"}], "]"}], "=", "0.0125"}], ";"}], "\n", - RowBox[{ - RowBox[{ - RowBox[{"ucoeff", "[", - RowBox[{"[", "2", "]"}], "]"}], "=", "0.125"}], ";"}], "\n", - RowBox[{ - RowBox[{ - RowBox[{"ucoeff", "[", - RowBox[{"[", "3", "]"}], "]"}], "=", "0.125"}], ";"}], "\n", - RowBox[{ - RowBox[{ - RowBox[{"ucoeff", "[", - RowBox[{"[", "4", "]"}], "]"}], "=", "0.0"}], ";"}], "\n", - RowBox[{ - RowBox[{ - RowBox[{"ucoeff", "[", - RowBox[{"[", "5", "]"}], "]"}], "=", "0.25"}], ";"}], "\n", - RowBox[{ - RowBox[{ - RowBox[{ - RowBox[{"ucoeff", "[", - RowBox[{"[", "6", "]"}], "]"}], "=", "0.08"}], ";"}], - "\n"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{ - RowBox[{"vcoeff", "[", - RowBox[{"[", "1", "]"}], "]"}], "=", "0.0375"}], ";"}], "\n", - RowBox[{ - RowBox[{ - RowBox[{"vcoeff", "[", - RowBox[{"[", "2", "]"}], "]"}], "=", "0.25"}], ";"}], "\n", - RowBox[{ - RowBox[{ - RowBox[{"vcoeff", "[", - RowBox[{"[", "3", "]"}], "]"}], "=", "0.375"}], ";"}], "\n", - RowBox[{ - RowBox[{ - RowBox[{"vcoeff", "[", - RowBox[{"[", "4", "]"}], "]"}], "=", "0.0"}], ";"}], "\n", - RowBox[{ - RowBox[{ - RowBox[{"vcoeff", "[", - RowBox[{"[", "5", "]"}], "]"}], "=", "0.5"}], ";"}], "\n", - RowBox[{ - RowBox[{ - RowBox[{ - RowBox[{"vcoeff", "[", - RowBox[{"[", "6", "]"}], "]"}], "=", "1.125"}], ";"}], - "\[IndentingNewLine]"}], "\n", - RowBox[{ - RowBox[{ - RowBox[{"Tcoeff", "[", - RowBox[{"[", "1", "]"}], "]"}], "=", "0.0625"}], ";"}], "\n", - RowBox[{ - RowBox[{ - RowBox[{"Tcoeff", "[", - RowBox[{"[", "2", "]"}], "]"}], "=", "0.375"}], ";"}], "\n", - RowBox[{ - RowBox[{ - RowBox[{"Tcoeff", "[", - RowBox[{"[", "3", "]"}], "]"}], "=", "0.25"}], ";"}], "\n", - RowBox[{ - RowBox[{ - RowBox[{"Tcoeff", "[", - RowBox[{"[", "4", "]"}], "]"}], "=", "0.25"}], ";"}], "\n", - RowBox[{ - RowBox[{ - RowBox[{"Tcoeff", "[", - RowBox[{"[", "5", "]"}], "]"}], "=", "0.5"}], ";"}], "\n", - RowBox[{ - RowBox[{ - RowBox[{ - RowBox[{"Tcoeff", "[", - RowBox[{"[", "6", "]"}], "]"}], "=", "1.0"}], ";"}], - "\[IndentingNewLine]", "\[IndentingNewLine]", - RowBox[{"(*", " ", - RowBox[{"non", "-", - RowBox[{"conservative", " ", "variables"}]}], " ", - "*)"}]}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{"rho", " ", "=", " ", - RowBox[{ - RowBox[{ - RowBox[{"rhocoeff", "[", - RowBox[{"[", "1", "]"}], "]"}], "*", - RowBox[{"Sin", "[", - RowBox[{"2.0", "*", "Pi", "*", - RowBox[{"rhocoeff", "[", - RowBox[{"[", "2", "]"}], "]"}], "*", - RowBox[{"(", - RowBox[{"x", "-", - RowBox[{"rhocoeff", "[", - RowBox[{"[", "4", "]"}], "]"}]}], ")"}]}], "]"}], "*", - RowBox[{"Sin", "[", - RowBox[{"2.0", "*", "Pi", "*", - RowBox[{"rhocoeff", "[", - RowBox[{"[", "3", "]"}], "]"}], "*", - RowBox[{"(", - RowBox[{"y", "-", - RowBox[{"rhocoeff", "[", - RowBox[{"[", "5", "]"}], "]"}]}], ")"}]}], "]"}]}], "+", - RowBox[{"rhocoeff", "[", - RowBox[{"[", "6", "]"}], "]"}]}]}], ";"}]}], "Input", - CellChangeTimes->CompressedData[" -1:eJxTTMoPSmViYGAQAWIQfcs1evXTNW8cjSVWbQfRHlUiR0H0QyfzEyB6yoP9 -r0B0z2PP1yD6w8WWryD6UMVvgWdAek3DYg0QPW2/kDmIrnPNsQbRy2L3uIHo -9gsF3iBaNboBTEdWzQwG0XLdWdEgOslGKAFE7zrwPRGs7wJTFoh+tYApH0QL -PH9VD6Jf//sOpt9qfW0D0SJmEHqZvHc/iF5ivW46iM7K7XJ4DqSbl74A0ykK -Jx+8ANJGLM7PQXQkp/j59yD/qm+/CaLfBYq+BtFMa2I+gug/2x+0fATSl04J -dYFox0/9k78D6VqDhWD67J4PTGe3vnFM60xmBtEA9Q/CBw== - "], - CellLabel-> - "In[166]:=",ExpressionUUID->"dcc5d53d-2af9-432b-b6d1-6486fec9185d"], - -Cell[BoxData[{ - RowBox[{ - RowBox[{"vel0", " ", "=", " ", - RowBox[{ - RowBox[{ - RowBox[{"ucoeff", "[", - RowBox[{"[", "1", "]"}], "]"}], "*", - RowBox[{"Sin", "[", - RowBox[{"2.0", "*", "Pi", "*", - RowBox[{"ucoeff", "[", - RowBox[{"[", "2", "]"}], "]"}], "*", - RowBox[{"(", - RowBox[{"x", "-", - RowBox[{"ucoeff", "[", - RowBox[{"[", "4", "]"}], "]"}]}], ")"}]}], "]"}], "*", - RowBox[{"Sin", "[", - RowBox[{"2.0", "*", "Pi", "*", - RowBox[{"ucoeff", "[", - RowBox[{"[", "3", "]"}], "]"}], "*", - RowBox[{"(", - RowBox[{"y", "-", - RowBox[{"ucoeff", "[", - RowBox[{"[", "5", "]"}], "]"}]}], ")"}]}], "]"}]}], "+", - RowBox[{"ucoeff", "[", - RowBox[{"[", "6", "]"}], "]"}]}]}], ";"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{"vel1", " ", "=", " ", - RowBox[{ - RowBox[{ - RowBox[{"vcoeff", "[", - RowBox[{"[", "1", "]"}], "]"}], "*", - RowBox[{"Sin", "[", - RowBox[{"2.0", "*", "Pi", "*", - RowBox[{"vcoeff", "[", - RowBox[{"[", "2", "]"}], "]"}], "*", - RowBox[{"(", - RowBox[{"x", "-", - RowBox[{"vcoeff", "[", - RowBox[{"[", "4", "]"}], "]"}]}], ")"}]}], "]"}], "*", - RowBox[{"Sin", "[", - RowBox[{"2.0", "*", "Pi", "*", - RowBox[{"vcoeff", "[", - RowBox[{"[", "3", "]"}], "]"}], "*", - RowBox[{"(", - RowBox[{"y", "-", - RowBox[{"vcoeff", "[", - RowBox[{"[", "5", "]"}], "]"}]}], ")"}]}], "]"}]}], "+", - RowBox[{"vcoeff", "[", - RowBox[{"[", "6", "]"}], "]"}]}]}], ";"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{"T", " ", "=", " ", - RowBox[{ - RowBox[{ - RowBox[{"Tcoeff", "[", - RowBox[{"[", "1", "]"}], "]"}], "*", - RowBox[{"Sin", "[", - RowBox[{"2.0", "*", "Pi", "*", - RowBox[{"Tcoeff", "[", - RowBox[{"[", "2", "]"}], "]"}], "*", - RowBox[{"(", - RowBox[{"x", "-", - RowBox[{"Tcoeff", "[", - RowBox[{"[", "4", "]"}], "]"}]}], ")"}]}], "]"}], "*", - RowBox[{"Sin", "[", - RowBox[{"2.0", "*", "Pi", "*", - RowBox[{"Tcoeff", "[", - RowBox[{"[", "3", "]"}], "]"}], "*", - RowBox[{"(", - RowBox[{"y", "-", - RowBox[{"Tcoeff", "[", - RowBox[{"[", "5", "]"}], "]"}]}], ")"}]}], "]"}]}], "+", - RowBox[{"Tcoeff", "[", - RowBox[{"[", "6", "]"}], "]"}]}]}], ";"}]}], "Input", - CellChangeTimes->{{3.848746226610272*^9, 3.848746278034956*^9}, { - 3.8487508556958323`*^9, 3.848750861646223*^9}, {3.848750906883363*^9, - 3.8487509120131273`*^9}, {3.8487699966809177`*^9, 3.848769997749824*^9}}, - CellLabel-> - "In[202]:=",ExpressionUUID->"4a41c371-f128-4acb-986f-9fa3f019e3b3"], - -Cell[BoxData[{ - RowBox[{ - RowBox[{"p", "=", - RowBox[{"rho", "*", "R", "*", "T"}]}], ";"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{ - RowBox[{"e", " ", "=", " ", - RowBox[{ - RowBox[{"p", "/", "rho"}], " ", "*", " ", "oneovergm1"}]}], ";"}], - "\[IndentingNewLine]", "\[IndentingNewLine]", - RowBox[{"(*", " ", - RowBox[{"convection", " ", "flux"}], " ", - "*)"}]}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{"convcont0", "=", - RowBox[{"rho", "*", "vel0"}]}], ";"}], "\n", - RowBox[{ - RowBox[{"convmom00", "=", - RowBox[{ - RowBox[{"rho", "*", "vel0", "*", "vel0"}], "+", "p"}]}], ";"}], "\n", - RowBox[{ - RowBox[{"convmom10", "=", - RowBox[{"rho", "*", "vel0", "*", "vel1"}]}], ";"}], "\n", - RowBox[{ - RowBox[{ - RowBox[{"convener0", "=", - RowBox[{ - RowBox[{"(", - RowBox[{ - RowBox[{"rho", "*", - RowBox[{"(", - RowBox[{"e", "+", - RowBox[{"0.5", "*", - RowBox[{"(", - RowBox[{ - RowBox[{"vel0", "*", "vel0"}], "+", - RowBox[{"vel1", "*", "vel1"}]}], ")"}]}]}], ")"}]}], "+", "p"}], - ")"}], "*", "vel0"}]}], ";"}], "\n"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{"convcont1", "=", - RowBox[{"rho", "*", "vel1"}]}], ";"}], "\n", - RowBox[{ - RowBox[{"convmom01", "=", - RowBox[{"rho", "*", "vel0", "*", "vel1"}]}], ";"}], "\n", - RowBox[{ - RowBox[{"convmom11", "=", - RowBox[{ - RowBox[{"rho", "*", "vel1", "*", "vel1"}], "+", "p"}]}], ";"}], "\n", - RowBox[{ - RowBox[{"convener1", "=", - RowBox[{ - RowBox[{"(", - RowBox[{ - RowBox[{"rho", "*", - RowBox[{"(", - RowBox[{"e", "+", - RowBox[{"0.5", "*", - RowBox[{"(", - RowBox[{ - RowBox[{"vel0", "*", "vel0"}], "+", - RowBox[{"vel1", "*", "vel1"}]}], ")"}]}]}], ")"}]}], "+", "p"}], - ")"}], "*", "vel1"}]}], ";"}]}], "Input", - CellChangeTimes->{{3.848746962514339*^9, 3.848746979291951*^9}, { - 3.848747286562456*^9, 3.848747299308403*^9}}, - CellLabel-> - "In[205]:=",ExpressionUUID->"01f7c5dd-5b69-47be-8753-e24d14b2285b"], - -Cell[BoxData[ - RowBox[{"\[IndentingNewLine]", - RowBox[{ - RowBox[{ - RowBox[{"gradu00", " ", "=", " ", - RowBox[{"D", "[", - RowBox[{"vel0", ",", "x"}], "]"}]}], ";"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{"gradu01", " ", "=", " ", - RowBox[{"D", "[", - RowBox[{"vel0", ",", "y"}], "]"}]}], ";"}]}]}]], "Input", - CellChangeTimes->{{3.848747831394905*^9, 3.848747876991654*^9}, { - 3.848769199265695*^9, 3.848769202931725*^9}, {3.848769256002901*^9, - 3.848769258425282*^9}}, - CellLabel-> - "In[215]:=",ExpressionUUID->"e60d27cd-143c-4af1-ba1b-f25168f64c0e"], - -Cell[BoxData[{ - RowBox[{ - RowBox[{"gradu10", " ", "=", " ", - RowBox[{"D", "[", - RowBox[{"vel1", ",", "x"}], "]"}]}], ";"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{"gradu11", " ", "=", " ", - RowBox[{"D", "[", - RowBox[{"vel1", ",", "y"}], "]"}]}], ";"}]}], "Input", - CellChangeTimes->{{3.84874788420791*^9, 3.848747891102584*^9}, { - 3.848769206947481*^9, 3.84876921399562*^9}, {3.848769263241959*^9, - 3.848769265952162*^9}}, - CellLabel-> - "In[217]:=",ExpressionUUID->"9fe74626-97e8-415d-985b-18c87bd949eb"], - -Cell[BoxData[ - RowBox[{"\[IndentingNewLine]", - RowBox[{ - RowBox[{ - RowBox[{"trgradu", "=", - RowBox[{ - RowBox[{"1.0", "/", "3.0"}], "*", - RowBox[{"(", - RowBox[{"gradu00", "+", "gradu11"}], ")"}]}]}], ";"}], "\n", - "\[IndentingNewLine]", - RowBox[{ - RowBox[{"tau00", "=", - RowBox[{"2.0", "*", "mu", "*", - RowBox[{"(", - RowBox[{"gradu00", "-", "trgradu"}], ")"}]}]}], ";"}], "\n", - RowBox[{ - RowBox[{"tau01", "=", - RowBox[{"mu", "*", - RowBox[{"(", - RowBox[{"gradu01", "+", "gradu10"}], ")"}]}]}], ";"}], "\n", - RowBox[{ - RowBox[{"tau10", "=", - RowBox[{"mu", "*", - RowBox[{"(", - RowBox[{"gradu10", "+", "gradu01"}], ")"}]}]}], ";"}], "\n", - RowBox[{ - RowBox[{"tau11", "=", - RowBox[{"2.0", "*", "mu", "*", - RowBox[{"(", - RowBox[{"gradu11", "-", "trgradu"}], ")"}]}]}], ";"}]}]}]], "Input", - CellChangeTimes->{{3.8487478960690517`*^9, 3.848747913329102*^9}}, - CellLabel-> - "In[219]:=",ExpressionUUID->"3d4a9929-9fd3-4791-a148-b6d4af575913"], - -Cell[BoxData[{ - RowBox[{ - RowBox[{"gradT0", " ", "=", " ", - RowBox[{"D", "[", - RowBox[{"T", ",", "x"}], "]"}]}], ";"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{"gradT1", " ", "=", " ", - RowBox[{"D", "[", - RowBox[{"T", ",", "y"}], "]"}]}], ";"}]}], "Input", - CellChangeTimes->{ - 3.8487478931723633`*^9, {3.8487479274187183`*^9, 3.848747945619481*^9}, { - 3.848769220349659*^9, 3.848769225427722*^9}, {3.848769268337512*^9, - 3.848769270804284*^9}}, - CellLabel-> - "In[224]:=",ExpressionUUID->"90d01278-1ed2-4278-9896-dd1be1a82d89"], - -Cell[BoxData[ - RowBox[{ - RowBox[{"(*", " ", - RowBox[{"viscous", " ", "flux"}], " ", "*)"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{ - RowBox[{"visccont0", "=", "0.0"}], ";"}], "\n", - RowBox[{ - RowBox[{"viscmom00", "=", "tau00"}], ";"}], "\n", - RowBox[{ - RowBox[{"viscmom10", "=", "tau01"}], ";"}], "\n", - RowBox[{ - RowBox[{"viscener0", "=", - RowBox[{ - RowBox[{"vel0", "*", "tau00"}], "+", - RowBox[{"vel1", "*", "tau01"}], " ", "-", - RowBox[{"kappa", "*", "gradT0"}]}]}], ";"}], "\[IndentingNewLine]", - "\n", - RowBox[{ - RowBox[{"visccont1", "=", "0.0"}], ";"}], "\n", - RowBox[{ - RowBox[{"viscmom01", "=", "tau10"}], ";"}], "\n", - RowBox[{ - RowBox[{"viscmom11", "=", "tau11"}], ";"}], "\n", - RowBox[{ - RowBox[{"viscener1", "=", - RowBox[{ - RowBox[{"vel0", "*", "tau10"}], "+", - RowBox[{"vel1", "*", "tau11"}], "-", - RowBox[{"kappa", "*", "gradT1"}]}]}], ";"}]}]}]], "Input", - CellChangeTimes->{{3.848747960288867*^9, 3.848748006260416*^9}, { - 3.848748099191264*^9, 3.8487481026806517`*^9}, {3.853420051521824*^9, - 3.853420055696653*^9}, {3.853420098619451*^9, 3.8534200987593403`*^9}}, - CellLabel-> - "In[226]:=",ExpressionUUID->"e52ab23b-2d72-46e9-9813-f9ead716a4e4"], - -Cell[BoxData[ - RowBox[{"\[IndentingNewLine]", - RowBox[{"(*", " ", - RowBox[{"total", " ", "flux", " ", "scoure"}], " ", "*)"}], - "\[IndentingNewLine]", - RowBox[{ - RowBox[{ - RowBox[{"fluxcont0", "=", - RowBox[{"convcont0", "-", "visccont0"}]}], ";"}], "\n", - RowBox[{ - RowBox[{"fluxmom00", "=", - RowBox[{"convmom00", "-", "viscmom00"}]}], ";"}], "\n", - RowBox[{ - RowBox[{"fluxmom10", "=", - RowBox[{"convmom10", "-", "viscmom10"}]}], ";"}], "\n", - RowBox[{ - RowBox[{"fluxener0", "=", - RowBox[{"convener0", "-", "viscener0"}]}], ";"}], "\n", - RowBox[{ - RowBox[{"fluxcont1", "=", - RowBox[{"convcont1", "-", "visccont1"}]}], ";"}], "\n", - RowBox[{ - RowBox[{"fluxmom01", "=", - RowBox[{"convmom01", "-", "viscmom01"}]}], ";"}], "\n", - RowBox[{ - RowBox[{"fluxmom11", "=", - RowBox[{"convmom11", "-", "viscmom11"}]}], ";"}], "\n", - RowBox[{ - RowBox[{"fluxener1", "=", - RowBox[{"convener1", "-", "viscener1"}]}], ";"}], "\[IndentingNewLine]", - "\[IndentingNewLine]", - RowBox[{"(*", " ", - RowBox[{"convective", " ", "flux", " ", "scoure"}], " ", "*)"}], - "\[IndentingNewLine]", - RowBox[{ - RowBox[{"fluxconvcont0", "=", "convcont0"}], ";"}], "\n", - RowBox[{ - RowBox[{"fluxconvmom00", "=", "convmom00"}], ";"}], "\n", - RowBox[{ - RowBox[{"fluxconvmom10", "=", "convmom10"}], ";"}], "\n", - RowBox[{ - RowBox[{"fluxconvener0", "=", "convener0"}], ";"}], "\n", - RowBox[{ - RowBox[{"fluxconvcont1", "=", "convcont1"}], ";"}], "\n", - RowBox[{ - RowBox[{"fluxconvmom01", "=", "convmom01"}], ";"}], "\n", - RowBox[{ - RowBox[{"fluxconvmom11", "=", "convmom11"}], ";"}], "\n", - RowBox[{ - RowBox[{"fluxconvener1", "=", "convener1"}], ";"}], - "\[IndentingNewLine]"}]}]], "Input", - CellChangeTimes->{{3.8487481055919733`*^9, 3.848748139478759*^9}, - 3.8534131670114393`*^9, {3.853413260070479*^9, 3.8534132802449408`*^9}, { - 3.85341412952063*^9, 3.8534141793792057`*^9}, {3.8534185439381237`*^9, - 3.853418590788804*^9}, {3.8534216590998907`*^9, 3.8534216660116463`*^9}, { - 3.8535057753777847`*^9, 3.853505778439568*^9}}, - CellLabel-> - "In[234]:=",ExpressionUUID->"937d0cc3-6511-4003-bc5a-cd6cd4274e1f"], - -Cell[BoxData[ - RowBox[{"\[IndentingNewLine]", - RowBox[{"(*", " ", - RowBox[{ - "compute", " ", "source", " ", "terms", " ", "by", " ", "this", " ", "MMS", - " ", "plugged", " ", "into", " ", "NS", " ", "eq"}], " ", "*)"}], - "\[IndentingNewLine]", - RowBox[{ - RowBox[{"contsrc", " ", "=", " ", - RowBox[{ - RowBox[{"Grad", "[", - RowBox[{"fluxcont0", ",", - RowBox[{"{", "x", "}"}]}], "]"}], " ", "+", - RowBox[{"Grad", "[", - RowBox[{"fluxcont1", ",", - RowBox[{"{", "y", "}"}]}], "]"}]}]}], ";"}]}]], "Input", - CellChangeTimes->{{3.848748142883045*^9, 3.848748248678442*^9}, - 3.853412763643166*^9, {3.8534216004392*^9, 3.853421600567239*^9}}, - CellLabel-> - "In[250]:=",ExpressionUUID->"e4d025b4-8308-44f1-a925-4e3a1e1b7aab"], - -Cell[BoxData[ - RowBox[{ - RowBox[{"mom0src", " ", "=", " ", - RowBox[{ - RowBox[{"Grad", "[", - RowBox[{"fluxmom00", ",", - RowBox[{"{", "x", "}"}]}], "]"}], " ", "+", - RowBox[{"Grad", "[", - RowBox[{"fluxmom01", ",", - RowBox[{"{", "y", "}"}]}], "]"}]}]}], ";"}]], "Input", - CellChangeTimes->{{3.8487482383018436`*^9, 3.848748269490571*^9}, { - 3.8534216051933327`*^9, 3.85342160527468*^9}}, - CellLabel-> - "In[251]:=",ExpressionUUID->"5873ca8f-5ac0-44d5-b0dc-c3aa73c9976f"], - -Cell[BoxData[ - RowBox[{ - RowBox[{"mom1src", " ", "=", " ", - RowBox[{ - RowBox[{"Grad", "[", - RowBox[{"fluxmom10", ",", - RowBox[{"{", "x", "}"}]}], "]"}], " ", "+", - RowBox[{"Grad", "[", - RowBox[{"fluxmom11", ",", - RowBox[{"{", "y", "}"}]}], "]"}]}]}], ";"}]], "Input", - CellChangeTimes->{{3.848748282245516*^9, 3.848748288384053*^9}, { - 3.853421609249914*^9, 3.853421615012842*^9}}, - CellLabel-> - "In[252]:=",ExpressionUUID->"c641f2ca-6faa-4856-a473-2399e7b93399"], - -Cell[BoxData[{ - RowBox[{ - RowBox[{ - RowBox[{"enersrc", " ", "=", " ", - RowBox[{ - RowBox[{"Grad", "[", - RowBox[{"fluxener0", ",", - RowBox[{"{", "x", "}"}]}], "]"}], " ", "+", - RowBox[{"Grad", "[", - RowBox[{"fluxener1", ",", - RowBox[{"{", "y", "}"}]}], "]"}]}]}], ";"}], "\[IndentingNewLine]", - "\[IndentingNewLine]", - RowBox[{"(*", " ", - RowBox[{ - "compute", " ", "convective", " ", "source", " ", "terms", " ", "by", " ", - "this", " ", "MMS", " ", "plugged", " ", "into", " ", "NS", " ", "eq"}], - " ", "*)"}]}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{"convcontsrc", " ", "=", " ", - RowBox[{ - RowBox[{"Grad", "[", - RowBox[{"fluxconvcont0", ",", - RowBox[{"{", "x", "}"}]}], "]"}], "+", - RowBox[{"Grad", "[", - RowBox[{"fluxconvcont1", ",", - RowBox[{"{", "y", "}"}]}], "]"}]}]}], ";"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{"convmom0src", " ", "=", " ", - RowBox[{ - RowBox[{"Grad", "[", - RowBox[{"fluxconvmom00", ",", - RowBox[{"{", "x", "}"}]}], "]"}], " ", "+", - RowBox[{"Grad", "[", - RowBox[{"fluxconvmom01", ",", - RowBox[{"{", "y", "}"}]}], "]"}]}]}], ";"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{"convmom1src", " ", "=", " ", - RowBox[{ - RowBox[{"Grad", "[", - RowBox[{"fluxconvmom10", ",", - RowBox[{"{", "x", "}"}]}], "]"}], " ", "+", - RowBox[{"Grad", "[", - RowBox[{"fluxconvmom11", ",", - RowBox[{"{", "y", "}"}]}], "]"}]}]}], ";"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{"convenersrc", " ", "=", " ", - RowBox[{ - RowBox[{"Grad", "[", - RowBox[{"fluxconvener0", ",", - RowBox[{"{", "x", "}"}]}], "]"}], " ", "+", - RowBox[{"Grad", "[", - RowBox[{"fluxconvener1", ",", - RowBox[{"{", "y", "}"}]}], "]"}]}]}], ";"}]}], "Input", - CellChangeTimes->{{3.848748293923893*^9, 3.8487483403101597`*^9}, { - 3.853412983976652*^9, 3.853413038864058*^9}, 3.853413162608437*^9, { - 3.853416937575151*^9, 3.85341697486716*^9}, {3.853417163333325*^9, - 3.853417294278317*^9}, {3.853418598325819*^9, 3.853418620311182*^9}, { - 3.853421618995813*^9, 3.85342161967478*^9}, {3.853505755600286*^9, - 3.85350576867237*^9}}, - CellLabel-> - "In[253]:=",ExpressionUUID->"c7b79fc9-fdd2-4604-88f5-5cb6b6767542"], - -Cell[BoxData[ - RowBox[{ - RowBox[{"testvals", " ", "=", " ", - RowBox[{"{", - RowBox[{ - RowBox[{"x", "\[Rule]", "0.5"}], ",", " ", - RowBox[{"y", "\[Rule]", "0.5"}]}], "}"}]}], ";"}]], "Input", - CellChangeTimes->{{3.848768648468796*^9, 3.8487686688884172`*^9}, - 3.8535057187739477`*^9}, - CellLabel-> - "In[258]:=",ExpressionUUID->"cbf531c1-0700-43d8-be24-0921976c2046"], - -Cell[CellGroupData[{ - -Cell[BoxData[ - RowBox[{"\[IndentingNewLine]", "\[IndentingNewLine]", - RowBox[{ - RowBox[{"NumberForm", "[", - RowBox[{ - RowBox[{"contsrc", "/.", "testvals"}], ",", "16"}], "]"}], - "\[IndentingNewLine]", - RowBox[{"NumberForm", "[", - RowBox[{ - RowBox[{"mom0src", "/.", "testvals"}], ",", "16"}], "]"}], - "\[IndentingNewLine]", - RowBox[{"NumberForm", "[", - RowBox[{ - RowBox[{"mom1src", "/.", "testvals"}], ",", "16"}], "]"}], - "\[IndentingNewLine]", - RowBox[{"NumberForm", "[", - RowBox[{ - RowBox[{"enersrc", "/.", "testvals"}], ",", "16"}], "]"}], - "\[IndentingNewLine]", "\[IndentingNewLine]", - RowBox[{"NumberForm", "[", - RowBox[{ - RowBox[{"convcontsrc", "/.", "testvals"}], ",", "16"}], "]"}], - "\[IndentingNewLine]", - RowBox[{"NumberForm", "[", - RowBox[{ - RowBox[{"convmom0src", "/.", "testvals"}], ",", "16"}], "]"}], - "\[IndentingNewLine]", - RowBox[{"NumberForm", "[", - RowBox[{ - RowBox[{"convmom1src", "/.", "testvals"}], ",", "16"}], "]"}], - "\[IndentingNewLine]", - RowBox[{"NumberForm", "[", - RowBox[{ - RowBox[{"convenersrc", "/.", "testvals"}], ",", "16"}], - "]"}]}]}]], "Input", - CellChangeTimes->{{3.848752863176736*^9, 3.848752874011384*^9}, { - 3.848752905424728*^9, 3.84875290832469*^9}, {3.8487657731951227`*^9, - 3.848765795363201*^9}, 3.848768642408615*^9, {3.848768675758319*^9, - 3.848768679176118*^9}, {3.853412771710568*^9, 3.853412830306747*^9}, { - 3.853505709321966*^9, 3.853505730153659*^9}, {3.85350580692212*^9, - 3.853505807722196*^9}}, - CellLabel-> - "In[259]:=",ExpressionUUID->"bf442d50-8053-48e4-941e-fed131a4770b"], - -Cell[BoxData[ - TagBox[ - RowBox[{"{", - InterpretationBox["\<\"0.06485567288359178\"\>", - 0.06485567288359177, - AutoDelete->True], "}"}], - NumberForm[#, 16]& ]], "Output", - CellChangeTimes->{3.853505850711261*^9}, - CellLabel-> - "Out[259]//NumberForm=",ExpressionUUID->"312901ee-07bf-480f-b544-\ -6cbb162c0045"], - -Cell[BoxData[ - TagBox[ - RowBox[{"{", - InterpretationBox["\<\"-0.1109339876576471\"\>", - -0.11093398765764714`, - AutoDelete->True], "}"}], - NumberForm[#, 16]& ]], "Output", - CellChangeTimes->{3.8535058507131147`*^9}, - CellLabel-> - "Out[260]//NumberForm=",ExpressionUUID->"4e471ea3-bd14-4aeb-ad55-\ -ddcfbb5f5996"], - -Cell[BoxData[ - TagBox[ - RowBox[{"{", - InterpretationBox["\<\"0.1702966657887896\"\>", - 0.17029666578878958`, - AutoDelete->True], "}"}], - NumberForm[#, 16]& ]], "Output", - CellChangeTimes->{3.8535058507140007`*^9}, - CellLabel-> - "Out[261]//NumberForm=",ExpressionUUID->"7c0217b3-6fa8-4000-96b9-\ -c2d95b266f4e"], - -Cell[BoxData[ - TagBox[ - RowBox[{"{", - InterpretationBox["\<\"0.3321719304832673\"\>", - 0.3321719304832673, - AutoDelete->True], "}"}], - NumberForm[#, 16]& ]], "Output", - CellChangeTimes->{3.853505850715164*^9}, - CellLabel-> - "Out[262]//NumberForm=",ExpressionUUID->"5e69f283-6d6e-4ec6-9a91-\ -5484792ce295"], - -Cell[BoxData[ - TagBox[ - RowBox[{"{", - InterpretationBox["\<\"0.06485567288359178\"\>", - 0.06485567288359177, - AutoDelete->True], "}"}], - NumberForm[#, 16]& ]], "Output", - CellChangeTimes->{3.8535058507163677`*^9}, - CellLabel-> - "Out[263]//NumberForm=",ExpressionUUID->"55c392a7-cd70-4146-be2a-\ -751c146294b0"], - -Cell[BoxData[ - TagBox[ - RowBox[{"{", - InterpretationBox["\<\"0.01454690044742203\"\>", - 0.014546900447422031`, - AutoDelete->True], "}"}], - NumberForm[#, 16]& ]], "Output", - CellChangeTimes->{3.853505850717545*^9}, - CellLabel-> - "Out[264]//NumberForm=",ExpressionUUID->"869c1f73-a65f-4e17-9d56-\ -2b8688b5a6eb"], - -Cell[BoxData[ - TagBox[ - RowBox[{"{", - InterpretationBox["\<\"0.1796124151976149\"\>", - 0.17961241519761492`, - AutoDelete->True], "}"}], - NumberForm[#, 16]& ]], "Output", - CellChangeTimes->{3.853505850719009*^9}, - CellLabel-> - "Out[265]//NumberForm=",ExpressionUUID->"eca6f441-c7ce-4939-b42d-\ -37411420ceec"], - -Cell[BoxData[ - TagBox[ - RowBox[{"{", - InterpretationBox["\<\"0.3731078016877022\"\>", - 0.3731078016877022, - AutoDelete->True], "}"}], - NumberForm[#, 16]& ]], "Output", - CellChangeTimes->{3.8535058507202187`*^9}, - CellLabel-> - "Out[266]//NumberForm=",ExpressionUUID->"17d7d742-5131-44f8-8c5a-\ -ac0b8316abfe"] -}, Open ]] -}, -WindowSize->{1398, 747}, -WindowMargins->{{Automatic, -142}, {1, Automatic}}, -FrontEndVersion->"12.1 for Mac OS X x86 (64-bit) (March 18, 2020)", -StyleDefinitions->"Default.nb", -ExpressionUUID->"0bc88581-0d53-4791-969d-68de77380196" -] -(* End of Notebook Content *) - -(* Internal cache information *) -(*CellTagsOutline -CellTagsIndex->{} -*) -(*CellTagsIndex -CellTagsIndex->{} -*) -(*NotebookFileOutline -Notebook[{ -Cell[558, 20, 488, 10, 52, "Input",ExpressionUUID->"4467992d-fdba-4959-a6bf-6d08d2779d83"], -Cell[1049, 32, 5918, 186, 955, "Input",ExpressionUUID->"dcc5d53d-2af9-432b-b6d1-6486fec9185d"], -Cell[6970, 220, 2757, 77, 73, "Input",ExpressionUUID->"4a41c371-f128-4acb-986f-9fa3f019e3b3"], -Cell[9730, 299, 2096, 65, 283, "Input",ExpressionUUID->"01f7c5dd-5b69-47be-8753-e24d14b2285b"], -Cell[11829, 366, 592, 15, 73, "Input",ExpressionUUID->"e60d27cd-143c-4af1-ba1b-f25168f64c0e"], -Cell[12424, 383, 528, 13, 52, "Input",ExpressionUUID->"9fe74626-97e8-415d-985b-18c87bd949eb"], -Cell[12955, 398, 1063, 32, 157, "Input",ExpressionUUID->"3d4a9929-9fd3-4791-a148-b6d4af575913"], -Cell[14021, 432, 553, 14, 52, "Input",ExpressionUUID->"90d01278-1ed2-4278-9896-dd1be1a82d89"], -Cell[14577, 448, 1270, 34, 220, "Input",ExpressionUUID->"e52ab23b-2d72-46e9-9813-f9ead716a4e4"], -Cell[15850, 484, 2239, 57, 451, "Input",ExpressionUUID->"937d0cc3-6511-4003-bc5a-cd6cd4274e1f"], -Cell[18092, 543, 774, 19, 73, "Input",ExpressionUUID->"e4d025b4-8308-44f1-a925-4e3a1e1b7aab"], -Cell[18869, 564, 501, 13, 30, "Input",ExpressionUUID->"5873ca8f-5ac0-44d5-b0dc-c3aa73c9976f"], -Cell[19373, 579, 498, 13, 30, "Input",ExpressionUUID->"c641f2ca-6faa-4856-a473-2399e7b93399"], -Cell[19874, 594, 2293, 60, 157, "Input",ExpressionUUID->"c7b79fc9-fdd2-4604-88f5-5cb6b6767542"], -Cell[22170, 656, 385, 10, 30, "Input",ExpressionUUID->"cbf531c1-0700-43d8-be24-0921976c2046"], -Cell[CellGroupData[{ -Cell[22580, 670, 1665, 42, 241, "Input",ExpressionUUID->"bf442d50-8053-48e4-941e-fed131a4770b"], -Cell[24248, 714, 319, 10, 45, "Output",ExpressionUUID->"312901ee-07bf-480f-b544-6cbb162c0045"], -Cell[24570, 726, 323, 10, 45, "Output",ExpressionUUID->"4e471ea3-bd14-4aeb-ad55-ddcfbb5f5996"], -Cell[24896, 738, 321, 10, 45, "Output",ExpressionUUID->"7c0217b3-6fa8-4000-96b9-c2d95b266f4e"], -Cell[25220, 750, 317, 10, 45, "Output",ExpressionUUID->"5e69f283-6d6e-4ec6-9a91-5484792ce295"], -Cell[25540, 762, 321, 10, 45, "Output",ExpressionUUID->"55c392a7-cd70-4146-be2a-751c146294b0"], -Cell[25864, 774, 321, 10, 45, "Output",ExpressionUUID->"869c1f73-a65f-4e17-9d56-2b8688b5a6eb"], -Cell[26188, 786, 319, 10, 45, "Output",ExpressionUUID->"eca6f441-c7ce-4939-b42d-37411420ceec"], -Cell[26510, 798, 319, 10, 45, "Output",ExpressionUUID->"17d7d742-5131-44f8-8c5a-ac0b8316abfe"] -}, Open ]] -} -] -*) - diff --git a/src/closure_models/unit_test/doc/MethodManufacuredSolutionSource3D_reference.nb b/src/closure_models/unit_test/doc/MethodManufacuredSolutionSource3D_reference.nb deleted file mode 100644 index 4f2efb6..0000000 --- a/src/closure_models/unit_test/doc/MethodManufacuredSolutionSource3D_reference.nb +++ /dev/null @@ -1,1292 +0,0 @@ -(* Content-type: application/vnd.wolfram.mathematica *) - -(*** Wolfram Notebook File ***) -(* http://www.wolfram.com/nb *) - -(* CreatedBy='Mathematica 12.1' *) - -(*CacheID: 234*) -(* Internal cache information: -NotebookFileLineBreakTest -NotebookFileLineBreakTest -NotebookDataPosition[ 158, 7] -NotebookDataLength[ 45124, 1284] -NotebookOptionsPosition[ 42325, 1243] -NotebookOutlinePosition[ 42723, 1259] -CellTagsIndexPosition[ 42680, 1256] -WindowFrame->Normal*) - -(* Beginning of Notebook Content *) -Notebook[{ -Cell[BoxData[{ - RowBox[{"Remove", "[", "\"\\"", "]"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{"(*", " ", - RowBox[{"material", " ", "property"}], "*)"}], "`"}]}], "Input", - CellChangeTimes->{{3.848745445279336*^9, 3.848745464753326*^9}, { - 3.8487475808945*^9, 3.848747630926712*^9}, 3.848747792303294*^9, { - 3.848765311373025*^9, 3.848765314592247*^9}}, - EmphasizeSyntaxErrors->True, - CellLabel-> - "In[1191]:=",ExpressionUUID->"4467992d-fdba-4959-a6bf-6d08d2779d83"], - -Cell[BoxData[{ - RowBox[{ - RowBox[{"mu", " ", "=", " ", "4.0"}], ";"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{"gamma", " ", "=", " ", "1.5"}], ";"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{"univgas", " ", "=", " ", "2.0"}], ";"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{"mmw", " ", "=", " ", "3.0"}], ";"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{ - RowBox[{"kappa", " ", "=", " ", "5.0"}], ";"}], - "\[IndentingNewLine]"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{"oneovergm1", " ", "=", " ", - RowBox[{"1.0", "/", - RowBox[{"(", - RowBox[{"gamma", "-", "1.0"}], ")"}]}]}], ";"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{ - RowBox[{"R", " ", "=", " ", - RowBox[{"univgas", "/", "mmw"}]}], ";"}], "\[IndentingNewLine]", - "\[IndentingNewLine]", - RowBox[{"(*", " ", - RowBox[{"coefficients", " ", "of", " ", "function"}], " ", - "*)"}]}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{"rhocoeff", " ", "=", " ", - RowBox[{"ConstantArray", "[", - RowBox[{"0", ",", "8"}], "]"}]}], ";"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{"ucoeff", " ", "=", - RowBox[{"ConstantArray", "[", - RowBox[{"0", ",", "8"}], "]"}]}], ";"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{"vcoeff", " ", "=", " ", - RowBox[{"ConstantArray", "[", - RowBox[{"0", ",", "8"}], "]"}]}], ";"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{"wcoeff", " ", "=", " ", - RowBox[{"ConstantArray", "[", - RowBox[{"0", ",", "8"}], "]"}]}], ";"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{ - RowBox[{"Tcoeff", " ", "=", " ", - RowBox[{"ConstantArray", "[", - RowBox[{"0", ",", "8"}], "]"}]}], ";"}], - "\[IndentingNewLine]"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{ - RowBox[{"rhocoeff", "[", - RowBox[{"[", "1", "]"}], "]"}], "=", "0.0125"}], ";"}], "\n", - RowBox[{ - RowBox[{ - RowBox[{"rhocoeff", "[", - RowBox[{"[", "2", "]"}], "]"}], "=", "0.25"}], ";"}], "\n", - RowBox[{ - RowBox[{ - RowBox[{"rhocoeff", "[", - RowBox[{"[", "3", "]"}], "]"}], "=", "0.125"}], ";"}], "\n", - RowBox[{ - RowBox[{ - RowBox[{"rhocoeff", "[", - RowBox[{"[", "4", "]"}], "]"}], "=", "0.375"}], - ";"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{ - RowBox[{"rhocoeff", "[", - RowBox[{"[", "5", "]"}], "]"}], "=", "0.5"}], ";"}], "\n", - RowBox[{ - RowBox[{ - RowBox[{"rhocoeff", "[", - RowBox[{"[", "6", "]"}], "]"}], "=", "0.0"}], - ";"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{ - RowBox[{"rhocoeff", "[", - RowBox[{"[", "7", "]"}], "]"}], "=", "1.0"}], - ";"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{ - RowBox[{ - RowBox[{"rhocoeff", "[", - RowBox[{"[", "8", "]"}], "]"}], "=", "1.0"}], ";"}], - "\n"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{ - RowBox[{"ucoeff", "[", - RowBox[{"[", "1", "]"}], "]"}], "=", "0.0125"}], ";"}], "\n", - RowBox[{ - RowBox[{ - RowBox[{"ucoeff", "[", - RowBox[{"[", "2", "]"}], "]"}], "=", "0.125"}], ";"}], "\n", - RowBox[{ - RowBox[{ - RowBox[{"ucoeff", "[", - RowBox[{"[", "3", "]"}], "]"}], "=", "0.125"}], ";"}], "\n", - RowBox[{ - RowBox[{ - RowBox[{"ucoeff", "[", - RowBox[{"[", "4", "]"}], "]"}], "=", "0.25"}], - ";"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{ - RowBox[{"ucoeff", "[", - RowBox[{"[", "5", "]"}], "]"}], "=", "0.0"}], ";"}], "\n", - RowBox[{ - RowBox[{ - RowBox[{"ucoeff", "[", - RowBox[{"[", "6", "]"}], "]"}], "=", "0.25"}], ";"}], "\n", - RowBox[{ - RowBox[{ - RowBox[{"ucoeff", "[", - RowBox[{"[", "7", "]"}], "]"}], "=", "0.0"}], - ";"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{ - RowBox[{ - RowBox[{"ucoeff", "[", - RowBox[{"[", "8", "]"}], "]"}], "=", "0.08"}], ";"}], - "\n"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{ - RowBox[{"vcoeff", "[", - RowBox[{"[", "1", "]"}], "]"}], "=", "0.0375"}], ";"}], "\n", - RowBox[{ - RowBox[{ - RowBox[{"vcoeff", "[", - RowBox[{"[", "2", "]"}], "]"}], "=", "0.25"}], ";"}], "\n", - RowBox[{ - RowBox[{ - RowBox[{"vcoeff", "[", - RowBox[{"[", "3", "]"}], "]"}], "=", "0.375"}], ";"}], "\n", - RowBox[{ - RowBox[{ - RowBox[{"vcoeff", "[", - RowBox[{"[", "4", "]"}], "]"}], "=", "0.25"}], - ";"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{ - RowBox[{"vcoeff", "[", - RowBox[{"[", "5", "]"}], "]"}], "=", "0.0"}], ";"}], "\n", - RowBox[{ - RowBox[{ - RowBox[{"vcoeff", "[", - RowBox[{"[", "6", "]"}], "]"}], "=", "0.5"}], ";"}], "\n", - RowBox[{ - RowBox[{ - RowBox[{"vcoeff", "[", - RowBox[{"[", "7", "]"}], "]"}], "=", "0.5"}], - ";"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{ - RowBox[{ - RowBox[{"vcoeff", "[", - RowBox[{"[", "8", "]"}], "]"}], "=", "1.125"}], ";"}], - "\[IndentingNewLine]"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{ - RowBox[{"wcoeff", "[", - RowBox[{"[", "1", "]"}], "]"}], "=", "0.025"}], ";"}], "\n", - RowBox[{ - RowBox[{ - RowBox[{"wcoeff", "[", - RowBox[{"[", "2", "]"}], "]"}], "=", "0.125"}], ";"}], "\n", - RowBox[{ - RowBox[{ - RowBox[{"wcoeff", "[", - RowBox[{"[", "3", "]"}], "]"}], "=", "0.25"}], ";"}], "\n", - RowBox[{ - RowBox[{ - RowBox[{"wcoeff", "[", - RowBox[{"[", "4", "]"}], "]"}], "=", "0.25"}], - ";"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{ - RowBox[{"wcoeff", "[", - RowBox[{"[", "5", "]"}], "]"}], "=", "1.0"}], ";"}], "\n", - RowBox[{ - RowBox[{ - RowBox[{"wcoeff", "[", - RowBox[{"[", "6", "]"}], "]"}], "=", "0.25"}], ";"}], "\n", - RowBox[{ - RowBox[{ - RowBox[{"wcoeff", "[", - RowBox[{"[", "7", "]"}], "]"}], "=", "0.25"}], - ";"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{ - RowBox[{ - RowBox[{"wcoeff", "[", - RowBox[{"[", "8", "]"}], "]"}], "=", "0.0"}], ";"}], - "\[IndentingNewLine]"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{ - RowBox[{"Tcoeff", "[", - RowBox[{"[", "1", "]"}], "]"}], "=", "0.0625"}], ";"}], "\n", - RowBox[{ - RowBox[{ - RowBox[{"Tcoeff", "[", - RowBox[{"[", "2", "]"}], "]"}], "=", "0.375"}], ";"}], "\n", - RowBox[{ - RowBox[{ - RowBox[{"Tcoeff", "[", - RowBox[{"[", "3", "]"}], "]"}], "=", "0.25"}], ";"}], "\n", - RowBox[{ - RowBox[{ - RowBox[{"Tcoeff", "[", - RowBox[{"[", "4", "]"}], "]"}], "=", "0.125"}], - ";"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{ - RowBox[{"Tcoeff", "[", - RowBox[{"[", "5", "]"}], "]"}], "=", "0.25"}], ";"}], "\n", - RowBox[{ - RowBox[{ - RowBox[{"Tcoeff", "[", - RowBox[{"[", "6", "]"}], "]"}], "=", "0.5"}], ";"}], "\n", - RowBox[{ - RowBox[{ - RowBox[{"Tcoeff", "[", - RowBox[{"[", "7", "]"}], "]"}], "=", "0.5"}], - ";"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{ - RowBox[{ - RowBox[{"Tcoeff", "[", - RowBox[{"[", "8", "]"}], "]"}], "=", "1.0"}], ";"}], - "\[IndentingNewLine]", "\[IndentingNewLine]", - RowBox[{"(*", " ", - RowBox[{"non", "-", - RowBox[{"conservative", " ", "variables"}]}], " ", - "*)"}]}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{"rho", " ", "=", " ", - RowBox[{ - RowBox[{ - RowBox[{"rhocoeff", "[", - RowBox[{"[", "1", "]"}], "]"}], "*", - RowBox[{"Sin", "[", - RowBox[{"2.0", "*", "Pi", "*", - RowBox[{"rhocoeff", "[", - RowBox[{"[", "2", "]"}], "]"}], "*", - RowBox[{"(", - RowBox[{"x", "-", - RowBox[{"rhocoeff", "[", - RowBox[{"[", "5", "]"}], "]"}]}], ")"}]}], "]"}], "*", - RowBox[{"Sin", "[", - RowBox[{"2.0", "*", "Pi", "*", - RowBox[{"rhocoeff", "[", - RowBox[{"[", "3", "]"}], "]"}], "*", - RowBox[{"(", - RowBox[{"y", "-", - RowBox[{"rhocoeff", "[", - RowBox[{"[", "6", "]"}], "]"}]}], ")"}]}], "]"}], "*", - RowBox[{"Sin", "[", - RowBox[{"2.0", "*", "Pi", "*", - RowBox[{"rhocoeff", "[", - RowBox[{"[", "4", "]"}], "]"}], "*", - RowBox[{"(", - RowBox[{"z", "-", - RowBox[{"rhocoeff", "[", - RowBox[{"[", "7", "]"}], "]"}]}], ")"}]}], "]"}]}], "+", - RowBox[{"rhocoeff", "[", - RowBox[{"[", "8", "]"}], "]"}]}]}], ";"}]}], "Input", - CellChangeTimes->CompressedData[" -1:eJxTTMoPSmViYGAQB2IQfcs1evXTNW8cjSVWbQfRHlUiR0H0QyfzEyB6yoP9 -r0B0z2PP1yD6w8WWryD6UMVvgWdAek3DYg0QPW2/kDmIrnPNsQbRy2L3uIHo -9gsF3iBaNboBTEdWzQwG0XLdWdEgOslGKAFE7zrwPRGs7wJTFoh+tYApH0QL -PH9VD6Jf//sOpt9qfW0D0SJmEHqZvHc/iF5ivW46iM7K7XJ4DqSbl74A0ykK -Jx+8ANJGLM7PQXQkp/j59yD/qm+/CaLfBYq+BtFMa2I+gug/2x+0fATSl04J -dYFox0/9k78D6VqDhWD67J4PTGe3vnFM60xmBtGzela72dx+46iS/MkTRM8O -f/oIRB+YF/UYRCsE7/kIoiveffoEogHyRt45 - "], - CellLabel-> - "In[1192]:=",ExpressionUUID->"dcc5d53d-2af9-432b-b6d1-6486fec9185d"], - -Cell[BoxData[{ - RowBox[{ - RowBox[{"vel0", " ", "=", - RowBox[{ - RowBox[{ - RowBox[{"ucoeff", "[", - RowBox[{"[", "1", "]"}], "]"}], "*", - RowBox[{"Sin", "[", - RowBox[{"2.0", "*", "Pi", "*", - RowBox[{"ucoeff", "[", - RowBox[{"[", "2", "]"}], "]"}], "*", - RowBox[{"(", - RowBox[{"x", "-", - RowBox[{"ucoeff", "[", - RowBox[{"[", "5", "]"}], "]"}]}], ")"}]}], "]"}], "*", - RowBox[{"Sin", "[", - RowBox[{"2.0", "*", "Pi", "*", - RowBox[{"ucoeff", "[", - RowBox[{"[", "3", "]"}], "]"}], "*", - RowBox[{"(", - RowBox[{"y", "-", - RowBox[{"ucoeff", "[", - RowBox[{"[", "6", "]"}], "]"}]}], ")"}]}], "]"}], "*", - RowBox[{"Sin", "[", - RowBox[{"2.0", "*", "Pi", "*", - RowBox[{"ucoeff", "[", - RowBox[{"[", "4", "]"}], "]"}], "*", - RowBox[{"(", - RowBox[{"z", "-", - RowBox[{"ucoeff", "[", - RowBox[{"[", "7", "]"}], "]"}]}], ")"}]}], "]"}]}], "+", - RowBox[{"ucoeff", "[", - RowBox[{"[", "8", "]"}], "]"}]}]}], ";"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{"vel1", " ", "=", - RowBox[{ - RowBox[{ - RowBox[{"vcoeff", "[", - RowBox[{"[", "1", "]"}], "]"}], "*", - RowBox[{"Sin", "[", - RowBox[{"2.0", "*", "Pi", "*", - RowBox[{"vcoeff", "[", - RowBox[{"[", "2", "]"}], "]"}], "*", - RowBox[{"(", - RowBox[{"x", "-", - RowBox[{"vcoeff", "[", - RowBox[{"[", "5", "]"}], "]"}]}], ")"}]}], "]"}], "*", - RowBox[{"Sin", "[", - RowBox[{"2.0", "*", "Pi", "*", - RowBox[{"vcoeff", "[", - RowBox[{"[", "3", "]"}], "]"}], "*", - RowBox[{"(", - RowBox[{"y", "-", - RowBox[{"vcoeff", "[", - RowBox[{"[", "6", "]"}], "]"}]}], ")"}]}], "]"}], "*", - RowBox[{"Sin", "[", - RowBox[{"2.0", "*", "Pi", "*", - RowBox[{"vcoeff", "[", - RowBox[{"[", "4", "]"}], "]"}], "*", - RowBox[{"(", - RowBox[{"z", "-", - RowBox[{"vcoeff", "[", - RowBox[{"[", "7", "]"}], "]"}]}], ")"}]}], "]"}]}], "+", - RowBox[{"vcoeff", "[", - RowBox[{"[", "8", "]"}], "]"}]}]}], ";"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{"vel2", " ", "=", - RowBox[{ - RowBox[{ - RowBox[{"wcoeff", "[", - RowBox[{"[", "1", "]"}], "]"}], "*", - RowBox[{"Sin", "[", - RowBox[{"2.0", "*", "Pi", "*", - RowBox[{"wcoeff", "[", - RowBox[{"[", "2", "]"}], "]"}], "*", - RowBox[{"(", - RowBox[{"x", "-", - RowBox[{"wcoeff", "[", - RowBox[{"[", "5", "]"}], "]"}]}], ")"}]}], "]"}], "*", - RowBox[{"Sin", "[", - RowBox[{"2.0", "*", "Pi", "*", - RowBox[{"wcoeff", "[", - RowBox[{"[", "3", "]"}], "]"}], "*", - RowBox[{"(", - RowBox[{"y", "-", - RowBox[{"wcoeff", "[", - RowBox[{"[", "6", "]"}], "]"}]}], ")"}]}], "]"}], "*", - RowBox[{"Sin", "[", - RowBox[{"2.0", "*", "Pi", "*", - RowBox[{"wcoeff", "[", - RowBox[{"[", "4", "]"}], "]"}], "*", - RowBox[{"(", - RowBox[{"z", "-", - RowBox[{"wcoeff", "[", - RowBox[{"[", "7", "]"}], "]"}]}], ")"}]}], "]"}]}], "+", - RowBox[{"wcoeff", "[", - RowBox[{"[", "8", "]"}], "]"}]}]}], ";"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{"T", " ", "=", " ", - RowBox[{ - RowBox[{ - RowBox[{"Tcoeff", "[", - RowBox[{"[", "1", "]"}], "]"}], "*", - RowBox[{"Sin", "[", - RowBox[{"2.0", "*", "Pi", "*", - RowBox[{"Tcoeff", "[", - RowBox[{"[", "2", "]"}], "]"}], "*", - RowBox[{"(", - RowBox[{"x", "-", - RowBox[{"Tcoeff", "[", - RowBox[{"[", "5", "]"}], "]"}]}], ")"}]}], "]"}], "*", - RowBox[{"Sin", "[", - RowBox[{"2.0", "*", "Pi", "*", - RowBox[{"Tcoeff", "[", - RowBox[{"[", "3", "]"}], "]"}], "*", - RowBox[{"(", - RowBox[{"y", "-", - RowBox[{"Tcoeff", "[", - RowBox[{"[", "6", "]"}], "]"}]}], ")"}]}], "]"}], "*", - RowBox[{"Sin", "[", - RowBox[{"2.0", "*", "Pi", "*", - RowBox[{"Tcoeff", "[", - RowBox[{"[", "4", "]"}], "]"}], "*", - RowBox[{"(", - RowBox[{"z", "-", - RowBox[{"Tcoeff", "[", - RowBox[{"[", "7", "]"}], "]"}]}], ")"}]}], "]"}]}], "+", - RowBox[{"Tcoeff", "[", - RowBox[{"[", "8", "]"}], "]"}]}]}], ";"}]}], "Input", - CellChangeTimes->{{3.848746226610272*^9, 3.848746278034956*^9}, { - 3.8487508556958323`*^9, 3.848750861646223*^9}, {3.848750906883363*^9, - 3.8487509120131273`*^9}, {3.8487699966809177`*^9, 3.848769997749824*^9}, - 3.873038934710096*^9, {3.873041903481428*^9, - 3.873041904771916*^9}},ExpressionUUID->"4a41c371-f128-4acb-986f-\ -9fa3f019e3b3"], - -Cell[BoxData[{ - RowBox[{ - RowBox[{"p", "=", - RowBox[{"rho", "*", "R", "*", "T"}]}], ";"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{ - RowBox[{"e", " ", "=", " ", - RowBox[{ - RowBox[{"p", "/", "rho"}], " ", "*", " ", "oneovergm1"}]}], ";"}], - "\[IndentingNewLine]", "\[IndentingNewLine]", - RowBox[{"(*", " ", - RowBox[{"convection", " ", "flux"}], " ", - "*)"}]}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{"convcont0", "=", - RowBox[{"rho", "*", "vel0"}]}], ";"}], "\n", - RowBox[{ - RowBox[{"convmom00", "=", - RowBox[{ - RowBox[{"rho", "*", "vel0", "*", "vel0"}], "+", "p"}]}], ";"}], "\n", - RowBox[{ - RowBox[{"convmom01", "=", - RowBox[{"rho", "*", "vel0", "*", "vel1"}]}], ";"}], "\n", - RowBox[{ - RowBox[{"convmom02", "=", - RowBox[{"rho", "*", "vel0", "*", "vel2"}]}], ";"}], "\[IndentingNewLine]", - - RowBox[{ - RowBox[{ - RowBox[{"convener0", "=", - RowBox[{ - RowBox[{"(", - RowBox[{ - RowBox[{"rho", "*", - RowBox[{"(", - RowBox[{"e", "+", - RowBox[{"0.5", "*", - RowBox[{"(", - RowBox[{ - RowBox[{"vel0", "*", "vel0"}], "+", - RowBox[{"vel1", "*", "vel1"}], "+", - RowBox[{"vel2", "*", "vel2"}]}], ")"}]}]}], ")"}]}], "+", "p"}], - ")"}], "*", "vel0"}]}], ";"}], "\[IndentingNewLine]"}], "\n", - RowBox[{ - RowBox[{"convcont1", "=", - RowBox[{"rho", "*", "vel1"}]}], ";"}], "\n", - RowBox[{ - RowBox[{"convmom10", "=", - RowBox[{"rho", "*", "vel1", "*", "vel0"}]}], ";"}], "\n", - RowBox[{ - RowBox[{"convmom11", "=", - RowBox[{ - RowBox[{"rho", "*", "vel1", "*", "vel1"}], "+", "p"}]}], ";"}], "\n", - RowBox[{ - RowBox[{"convmom12", "=", - RowBox[{"rho", "*", "vel1", "*", "vel2"}]}], ";"}], "\[IndentingNewLine]", - - RowBox[{ - RowBox[{ - RowBox[{"convener1", "=", - RowBox[{ - RowBox[{"(", - RowBox[{ - RowBox[{"rho", "*", - RowBox[{"(", - RowBox[{"e", "+", - RowBox[{"0.5", "*", - RowBox[{"(", - RowBox[{ - RowBox[{"vel0", "*", "vel0"}], "+", - RowBox[{"vel1", "*", "vel1"}], "+", - RowBox[{"vel2", "*", "vel2"}]}], ")"}]}]}], ")"}]}], "+", "p"}], - ")"}], "*", "vel1"}]}], ";"}], - "\[IndentingNewLine]"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{"convcont2", "=", - RowBox[{"rho", "*", "vel2"}]}], ";"}], "\n", - RowBox[{ - RowBox[{"convmom20", "=", - RowBox[{"rho", "*", "vel2", "*", "vel0"}]}], ";"}], "\n", - RowBox[{ - RowBox[{"convmom21", "=", - RowBox[{"rho", "*", "vel2", "*", "vel1"}]}], ";"}], "\n", - RowBox[{ - RowBox[{"convmom22", "=", - RowBox[{ - RowBox[{"rho", "*", "vel2", "*", "vel2"}], " ", "+", " ", "p"}]}], - ";"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{"convener2", "=", - RowBox[{ - RowBox[{"(", - RowBox[{ - RowBox[{"rho", "*", - RowBox[{"(", - RowBox[{"e", "+", - RowBox[{"0.5", "*", - RowBox[{"(", - RowBox[{ - RowBox[{"vel0", "*", "vel0"}], "+", - RowBox[{"vel1", "*", "vel1"}], "+", - RowBox[{"vel2", "*", "vel2"}]}], ")"}]}]}], ")"}]}], "+", "p"}], - ")"}], "*", "vel2"}]}], ";"}]}], "Input", - CellChangeTimes->{{3.848746962514339*^9, 3.848746979291951*^9}, { - 3.848747286562456*^9, 3.848747299308403*^9}, {3.873038955833394*^9, - 3.873039044655115*^9}, {3.873039107695705*^9, 3.873039109150676*^9}, { - 3.873039139170364*^9, 3.87303921638381*^9}, {3.8730399770625353`*^9, - 3.873039980801319*^9}}, - CellLabel-> - "In[1249]:=",ExpressionUUID->"01f7c5dd-5b69-47be-8753-e24d14b2285b"], - -Cell[BoxData[ - RowBox[{"\[IndentingNewLine]", - RowBox[{ - RowBox[{ - RowBox[{"gradu00", " ", "=", " ", - RowBox[{"D", "[", - RowBox[{"vel0", ",", "x"}], "]"}]}], ";"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{"gradu01", " ", "=", " ", - RowBox[{"D", "[", - RowBox[{"vel0", ",", "y"}], "]"}]}], ";"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{"gradu02", " ", "=", " ", - RowBox[{"D", "[", - RowBox[{"vel0", ",", "z"}], "]"}]}], ";"}]}]}]], "Input", - CellChangeTimes->{{3.848747831394905*^9, 3.848747876991654*^9}, { - 3.848769199265695*^9, 3.848769202931725*^9}, {3.848769256002901*^9, - 3.848769258425282*^9}, {3.873039247850809*^9, 3.8730392518064137`*^9}}, - CellLabel-> - "In[1266]:=",ExpressionUUID->"e60d27cd-143c-4af1-ba1b-f25168f64c0e"], - -Cell[BoxData[{ - RowBox[{ - RowBox[{"gradu10", " ", "=", " ", - RowBox[{"D", "[", - RowBox[{"vel1", ",", "x"}], "]"}]}], ";"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{"gradu11", " ", "=", " ", - RowBox[{"D", "[", - RowBox[{"vel1", ",", "y"}], "]"}]}], ";"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{ - RowBox[{"gradu12", " ", "=", " ", - RowBox[{"D", "[", - RowBox[{"vel1", ",", "z"}], "]"}]}], ";"}], - "\[IndentingNewLine]"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{"gradu20", " ", "=", " ", - RowBox[{"D", "[", - RowBox[{"vel2", ",", "x"}], "]"}]}], ";"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{"gradu21", " ", "=", " ", - RowBox[{"D", "[", - RowBox[{"vel2", ",", "y"}], "]"}]}], ";"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{"gradu22", " ", "=", " ", - RowBox[{"D", "[", - RowBox[{"vel2", ",", "z"}], "]"}]}], - ";"}], "\[IndentingNewLine]"}], "Input", - CellChangeTimes->{{3.84874788420791*^9, 3.848747891102584*^9}, { - 3.848769206947481*^9, 3.84876921399562*^9}, {3.848769263241959*^9, - 3.848769265952162*^9}, {3.873039257315653*^9, 3.873039275795073*^9}, { - 3.8730399230667343`*^9, 3.873039923736637*^9}, 3.873041612217534*^9}, - CellLabel-> - "In[1269]:=",ExpressionUUID->"9fe74626-97e8-415d-985b-18c87bd949eb"], - -Cell[BoxData[ - RowBox[{"\[IndentingNewLine]", - RowBox[{ - RowBox[{ - RowBox[{"trgradu", "=", - RowBox[{ - RowBox[{"1.0", "/", "3.0"}], "*", - RowBox[{"(", - RowBox[{"gradu00", "+", "gradu11", "+", "gradu22"}], ")"}]}]}], ";"}], - "\n", "\[IndentingNewLine]", - RowBox[{ - RowBox[{"tau00", "=", - RowBox[{"2.0", "*", "mu", "*", - RowBox[{"(", - RowBox[{"gradu00", "-", "trgradu"}], ")"}]}]}], ";"}], "\n", - RowBox[{ - RowBox[{"tau11", "=", - RowBox[{"2.0", "*", "mu", "*", - RowBox[{"(", - RowBox[{"gradu11", "-", "trgradu"}], ")"}]}]}], ";"}], - "\[IndentingNewLine]", - RowBox[{ - RowBox[{"tau22", "=", - RowBox[{"2.0", "*", "mu", "*", - RowBox[{"(", - RowBox[{"gradu22", "-", "trgradu"}], ")"}]}]}], ";"}], - "\[IndentingNewLine]", "\[IndentingNewLine]", - RowBox[{ - RowBox[{"tau01", "=", - RowBox[{"mu", "*", - RowBox[{"(", - RowBox[{"gradu01", "+", "gradu10"}], ")"}]}]}], ";"}], "\n", - RowBox[{ - RowBox[{"tau02", "=", - RowBox[{"mu", "*", - RowBox[{"(", - RowBox[{"gradu02", "+", "gradu20"}], ")"}]}]}], ";"}], - "\[IndentingNewLine]", - RowBox[{ - RowBox[{"tau10", "=", - RowBox[{"mu", "*", - RowBox[{"(", - RowBox[{"gradu10", "+", "gradu01"}], ")"}]}]}], ";"}], "\n", - RowBox[{ - RowBox[{"tau12", "=", - RowBox[{"mu", "*", - RowBox[{"(", - RowBox[{"gradu12", "+", "gradu21"}], ")"}]}]}], ";"}], - "\[IndentingNewLine]", - RowBox[{ - RowBox[{"tau20", "=", - RowBox[{"mu", "*", - RowBox[{"(", - RowBox[{"gradu20", "+", "gradu02"}], ")"}]}]}], ";"}], - "\[IndentingNewLine]", - RowBox[{ - RowBox[{"tau21", "=", - RowBox[{"mu", "*", - RowBox[{"(", - RowBox[{"gradu21", "+", "gradu12"}], ")"}]}]}], ";"}], - "\[IndentingNewLine]"}]}]], "Input", - CellChangeTimes->{{3.8487478960690517`*^9, 3.848747913329102*^9}, { - 3.8730392822142572`*^9, 3.8730393803925533`*^9}}, - CellLabel-> - "In[1275]:=",ExpressionUUID->"3d4a9929-9fd3-4791-a148-b6d4af575913"], - -Cell[BoxData[{ - RowBox[{ - RowBox[{"gradT0", " ", "=", " ", - RowBox[{"D", "[", - RowBox[{"T", ",", "x"}], "]"}]}], ";"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{"gradT1", " ", "=", " ", - RowBox[{"D", "[", - RowBox[{"T", ",", "y"}], "]"}]}], ";"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{"gradT2", " ", "=", " ", - RowBox[{"D", "[", - RowBox[{"T", ",", "z"}], "]"}]}], ";"}]}], "Input", - CellChangeTimes->{ - 3.8487478931723633`*^9, {3.8487479274187183`*^9, 3.848747945619481*^9}, { - 3.848769220349659*^9, 3.848769225427722*^9}, {3.848769268337512*^9, - 3.848769270804284*^9}, {3.8730393865659924`*^9, 3.8730393908509207`*^9}}, - CellLabel-> - "In[1285]:=",ExpressionUUID->"90d01278-1ed2-4278-9896-dd1be1a82d89"], - -Cell[BoxData[ - RowBox[{ - RowBox[{"(*", " ", - RowBox[{"viscous", " ", "flux"}], " ", "*)"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{ - RowBox[{"visccont0", "=", "0.0"}], ";"}], "\n", - RowBox[{ - RowBox[{"viscmom00", "=", "tau00"}], ";"}], "\n", - RowBox[{ - RowBox[{"viscmom01", "=", "tau01"}], ";"}], "\n", - RowBox[{ - RowBox[{"viscmom02", "=", "tau02"}], ";"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{"viscener0", "=", - RowBox[{ - RowBox[{"vel0", "*", "tau00"}], "+", - RowBox[{"vel1", "*", "tau01"}], "+", - RowBox[{"vel2", "*", "tau02"}], " ", "-", - RowBox[{"kappa", "*", "gradT0"}]}]}], ";"}], "\n", - "\[IndentingNewLine]", - RowBox[{ - RowBox[{"visccont1", "=", "0.0"}], ";"}], "\n", - RowBox[{ - RowBox[{"viscmom10", "=", "tau10"}], ";"}], "\n", - RowBox[{ - RowBox[{"viscmom11", "=", "tau11"}], ";"}], "\n", - RowBox[{ - RowBox[{"viscmom12", "=", "tau12"}], ";"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{"viscener1", "=", - RowBox[{ - RowBox[{"vel0", "*", "tau10"}], "+", - RowBox[{"vel1", "*", "tau11"}], "+", - RowBox[{"vel2", "*", "tau12"}], "-", - RowBox[{"kappa", "*", "gradT1"}]}]}], ";"}], "\[IndentingNewLine]", - "\[IndentingNewLine]", - RowBox[{ - RowBox[{"visccont2", "=", "0.0"}], ";"}], "\n", - RowBox[{ - RowBox[{"viscmom20", "=", "tau20"}], ";"}], "\n", - RowBox[{ - RowBox[{"viscmom21", "=", "tau21"}], ";"}], "\n", - RowBox[{ - RowBox[{"viscmom22", "=", "tau22"}], ";"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{"viscener2", "=", - RowBox[{ - RowBox[{"vel0", "*", "tau20"}], "+", - RowBox[{"vel1", "*", "tau21"}], "+", - RowBox[{"vel2", "*", "tau22"}], " ", "-", - RowBox[{"kappa", "*", "gradT2"}]}]}], ";"}]}]}]], "Input", - CellChangeTimes->{{3.848747960288867*^9, 3.848748006260416*^9}, { - 3.848748099191264*^9, 3.8487481026806517`*^9}, {3.853420051521824*^9, - 3.853420055696653*^9}, {3.853420098619451*^9, 3.8534200987593403`*^9}, { - 3.873039404333919*^9, 3.873039513137635*^9}}, - CellLabel-> - "In[1288]:=",ExpressionUUID->"e52ab23b-2d72-46e9-9813-f9ead716a4e4"], - -Cell[BoxData[ - RowBox[{"\[IndentingNewLine]", - RowBox[{"(*", " ", - RowBox[{"total", " ", "flux", " ", "scoure"}], " ", "*)"}], - "\[IndentingNewLine]", - RowBox[{ - RowBox[{ - RowBox[{"fluxcont0", "=", - RowBox[{"convcont0", "-", "visccont0"}]}], ";"}], "\n", - RowBox[{ - RowBox[{"fluxmom00", "=", - RowBox[{"convmom00", "-", "viscmom00"}]}], ";"}], "\n", - RowBox[{ - RowBox[{"fluxmom10", "=", - RowBox[{"convmom10", "-", "viscmom10"}]}], ";"}], "\n", - RowBox[{ - RowBox[{"fluxmom20", "=", - RowBox[{"convmom20", "-", "viscmom20"}]}], ";"}], "\[IndentingNewLine]", - - RowBox[{ - RowBox[{"fluxener0", "=", - RowBox[{"convener0", "-", "viscener0"}]}], ";"}], "\n", - "\[IndentingNewLine]", - RowBox[{ - RowBox[{"fluxcont1", "=", - RowBox[{"convcont1", "-", "visccont1"}]}], ";"}], "\n", - RowBox[{ - RowBox[{"fluxmom01", "=", - RowBox[{"convmom01", "-", "viscmom01"}]}], ";"}], "\n", - RowBox[{ - RowBox[{"fluxmom11", "=", - RowBox[{"convmom11", "-", "viscmom11"}]}], ";"}], "\n", - RowBox[{ - RowBox[{"fluxmom21", "=", - RowBox[{"convmom21", "-", "viscmom21"}]}], ";"}], "\[IndentingNewLine]", - - RowBox[{ - RowBox[{"fluxener1", "=", - RowBox[{"convener1", "-", "viscener1"}]}], ";"}], "\[IndentingNewLine]", - "\[IndentingNewLine]", - RowBox[{ - RowBox[{"fluxcont2", "=", - RowBox[{"convcont2", "-", "visccont2"}]}], ";"}], "\n", - RowBox[{ - RowBox[{"fluxmom02", "=", - RowBox[{"convmom02", "-", "viscmom02"}]}], ";"}], "\n", - RowBox[{ - RowBox[{"fluxmom12", "=", - RowBox[{"convmom12", "-", "viscmom12"}]}], ";"}], "\n", - RowBox[{ - RowBox[{"fluxmom22", "=", - RowBox[{"convmom22", "-", "viscmom22"}]}], ";"}], "\[IndentingNewLine]", - - RowBox[{ - RowBox[{"fluxener2", "=", - RowBox[{"convener2", "-", "viscener2"}]}], ";"}], "\[IndentingNewLine]", - "\[IndentingNewLine]", - RowBox[{"(*", " ", - RowBox[{"convective", " ", "flux", " ", "scoure"}], " ", "*)"}], - "\[IndentingNewLine]", - RowBox[{ - RowBox[{"fluxconvcont0", "=", "convcont0"}], ";"}], "\n", - RowBox[{ - RowBox[{"fluxconvmom00", "=", "convmom00"}], ";"}], "\n", - RowBox[{ - RowBox[{"fluxconvmom10", "=", "convmom10"}], ";"}], "\n", - RowBox[{ - RowBox[{"fluxconvmom20", "=", "convmom20"}], ";"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{"fluxconvener0", "=", "convener0"}], ";"}], "\n", - "\[IndentingNewLine]", - RowBox[{ - RowBox[{"fluxconvcont1", "=", "convcont1"}], ";"}], "\n", - RowBox[{ - RowBox[{"fluxconvmom01", "=", "convmom01"}], ";"}], "\n", - RowBox[{ - RowBox[{"fluxconvmom11", "=", "convmom11"}], ";"}], "\n", - RowBox[{ - RowBox[{"fluxconvmom21", "=", "convmom21"}], ";"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{"fluxconvener1", "=", "convener1"}], ";"}], "\[IndentingNewLine]", - "\[IndentingNewLine]", - RowBox[{ - RowBox[{"fluxconvcont2", "=", "convcont2"}], ";"}], "\n", - RowBox[{ - RowBox[{"fluxconvmom02", "=", "convmom02"}], ";"}], "\n", - RowBox[{ - RowBox[{"fluxconvmom12", "=", "convmom12"}], ";"}], "\n", - RowBox[{ - RowBox[{"fluxconvmom22", "=", "convmom22"}], ";"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{"fluxconvener2", "=", "convener2"}], ";"}], - "\[IndentingNewLine]"}]}]], "Input", - CellChangeTimes->{{3.8487481055919733`*^9, 3.848748139478759*^9}, - 3.8534131670114393`*^9, {3.853413260070479*^9, 3.8534132802449408`*^9}, { - 3.85341412952063*^9, 3.8534141793792057`*^9}, {3.8534185439381237`*^9, - 3.853418590788804*^9}, {3.8534216590998907`*^9, 3.8534216660116463`*^9}, { - 3.8535057753777847`*^9, 3.853505778439568*^9}, {3.873039553375629*^9, - 3.873039688454216*^9}}, - CellLabel-> - "In[1303]:=",ExpressionUUID->"937d0cc3-6511-4003-bc5a-cd6cd4274e1f"], - -Cell[BoxData[ - RowBox[{"\[IndentingNewLine]", - RowBox[{"(*", " ", - RowBox[{ - "compute", " ", "source", " ", "terms", " ", "by", " ", "this", " ", "MMS", - " ", "plugged", " ", "into", " ", "NS", " ", "eq"}], " ", "*)"}], - "\[IndentingNewLine]", - RowBox[{ - RowBox[{"contsrc", " ", "=", " ", - RowBox[{ - RowBox[{"Grad", "[", - RowBox[{"fluxcont0", ",", - RowBox[{"{", "x", "}"}]}], "]"}], " ", "+", - RowBox[{"Grad", "[", - RowBox[{"fluxcont1", ",", - RowBox[{"{", "y", "}"}]}], "]"}], "+", - RowBox[{"Grad", "[", - RowBox[{"fluxcont2", ",", - RowBox[{"{", "z", "}"}]}], "]"}]}]}], ";"}]}]], "Input", - CellChangeTimes->{{3.848748142883045*^9, 3.848748248678442*^9}, - 3.853412763643166*^9, {3.8534216004392*^9, 3.853421600567239*^9}, { - 3.873039696705966*^9, 3.873039717087324*^9}}, - CellLabel-> - "In[1333]:=",ExpressionUUID->"e4d025b4-8308-44f1-a925-4e3a1e1b7aab"], - -Cell[BoxData[ - RowBox[{ - RowBox[{"mom0src", " ", "=", " ", - RowBox[{ - RowBox[{"Grad", "[", - RowBox[{"fluxmom00", ",", - RowBox[{"{", "x", "}"}]}], "]"}], " ", "+", - RowBox[{"Grad", "[", - RowBox[{"fluxmom01", ",", - RowBox[{"{", "y", "}"}]}], "]"}], "+", - RowBox[{"Grad", "[", - RowBox[{"fluxmom02", ",", - RowBox[{"{", "z", "}"}]}], "]"}]}]}], ";"}]], "Input", - CellChangeTimes->{{3.8487482383018436`*^9, 3.848748269490571*^9}, { - 3.8534216051933327`*^9, 3.85342160527468*^9}, {3.8730397108342743`*^9, - 3.8730397243434258`*^9}}, - CellLabel-> - "In[1334]:=",ExpressionUUID->"5873ca8f-5ac0-44d5-b0dc-c3aa73c9976f"], - -Cell[BoxData[{ - RowBox[{ - RowBox[{"mom1src", " ", "=", " ", - RowBox[{ - RowBox[{"Grad", "[", - RowBox[{"fluxmom10", ",", - RowBox[{"{", "x", "}"}]}], "]"}], " ", "+", - RowBox[{"Grad", "[", - RowBox[{"fluxmom11", ",", - RowBox[{"{", "y", "}"}]}], "]"}], "+", - RowBox[{"Grad", "[", - RowBox[{"fluxmom12", ",", - RowBox[{"{", "z", "}"}]}], "]"}]}]}], ";"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{"mom2src", " ", "=", " ", - RowBox[{ - RowBox[{"Grad", "[", - RowBox[{"fluxmom20", ",", - RowBox[{"{", "x", "}"}]}], "]"}], " ", "+", - RowBox[{"Grad", "[", - RowBox[{"fluxmom21", ",", - RowBox[{"{", "y", "}"}]}], "]"}], "+", - RowBox[{"Grad", "[", - RowBox[{"fluxmom22", ",", - RowBox[{"{", "z", "}"}]}], "]"}]}]}], ";"}]}], "Input", - CellChangeTimes->{{3.848748282245516*^9, 3.848748288384053*^9}, { - 3.853421609249914*^9, 3.853421615012842*^9}, {3.873039726583364*^9, - 3.873039767094389*^9}}, - CellLabel-> - "In[1335]:=",ExpressionUUID->"c641f2ca-6faa-4856-a473-2399e7b93399"], - -Cell[BoxData[{ - RowBox[{ - RowBox[{ - RowBox[{"enersrc", " ", "=", " ", - RowBox[{ - RowBox[{"Grad", "[", - RowBox[{"fluxener0", ",", - RowBox[{"{", "x", "}"}]}], "]"}], " ", "+", - RowBox[{"Grad", "[", - RowBox[{"fluxener1", ",", - RowBox[{"{", "y", "}"}]}], "]"}], "+", - RowBox[{"Grad", "[", - RowBox[{"fluxener2", ",", - RowBox[{"{", "z", "}"}]}], "]"}]}]}], ";"}], "\[IndentingNewLine]", - "\[IndentingNewLine]", - RowBox[{"(*", " ", - RowBox[{ - "compute", " ", "convective", " ", "source", " ", "terms", " ", "by", " ", - "this", " ", "MMS", " ", "plugged", " ", "into", " ", "NS", " ", "eq"}], - " ", "*)"}]}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{"convcontsrc", " ", "=", " ", - RowBox[{ - RowBox[{"Grad", "[", - RowBox[{"fluxconvcont0", ",", - RowBox[{"{", "x", "}"}]}], "]"}], "+", - RowBox[{"Grad", "[", - RowBox[{"fluxconvcont1", ",", - RowBox[{"{", "y", "}"}]}], "]"}], "+", - RowBox[{"Grad", "[", - RowBox[{"fluxconvcont2", ",", - RowBox[{"{", "z", "}"}]}], "]"}]}]}], ";"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{"convmom0src", " ", "=", " ", - RowBox[{ - RowBox[{"Grad", "[", - RowBox[{"fluxconvmom00", ",", - RowBox[{"{", "x", "}"}]}], "]"}], " ", "+", - RowBox[{"Grad", "[", - RowBox[{"fluxconvmom01", ",", - RowBox[{"{", "y", "}"}]}], "]"}], "+", - RowBox[{"Grad", "[", - RowBox[{"fluxconvmom02", ",", - RowBox[{"{", "z", "}"}]}], "]"}]}]}], ";"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{"convmom1src", " ", "=", " ", - RowBox[{ - RowBox[{"Grad", "[", - RowBox[{"fluxconvmom10", ",", - RowBox[{"{", "x", "}"}]}], "]"}], " ", "+", - RowBox[{"Grad", "[", - RowBox[{"fluxconvmom11", ",", - RowBox[{"{", "y", "}"}]}], "]"}], "+", - RowBox[{"Grad", "[", - RowBox[{"fluxconvmom12", ",", - RowBox[{"{", "z", "}"}]}], "]"}]}]}], ";"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{"convmom2src", " ", "=", " ", - RowBox[{ - RowBox[{"Grad", "[", - RowBox[{"fluxconvmom20", ",", - RowBox[{"{", "x", "}"}]}], "]"}], " ", "+", - RowBox[{"Grad", "[", - RowBox[{"fluxconvmom21", ",", - RowBox[{"{", "y", "}"}]}], "]"}], "+", - RowBox[{"Grad", "[", - RowBox[{"fluxconvmom22", ",", - RowBox[{"{", "z", "}"}]}], "]"}]}]}], ";"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{"convenersrc", " ", "=", " ", - RowBox[{ - RowBox[{"Grad", "[", - RowBox[{"fluxconvener0", ",", - RowBox[{"{", "x", "}"}]}], "]"}], " ", "+", - RowBox[{"Grad", "[", - RowBox[{"fluxconvener1", ",", - RowBox[{"{", "y", "}"}]}], "]"}], "+", - RowBox[{"Grad", "[", - RowBox[{"fluxconvener2", ",", - RowBox[{"{", "z", "}"}]}], "]"}]}]}], ";"}]}], "Input", - CellChangeTimes->{{3.848748293923893*^9, 3.8487483403101597`*^9}, { - 3.853412983976652*^9, 3.853413038864058*^9}, 3.853413162608437*^9, { - 3.853416937575151*^9, 3.85341697486716*^9}, {3.853417163333325*^9, - 3.853417294278317*^9}, {3.853418598325819*^9, 3.853418620311182*^9}, { - 3.853421618995813*^9, 3.85342161967478*^9}, {3.853505755600286*^9, - 3.85350576867237*^9}, {3.873039772050819*^9, 3.8730397766636133`*^9}, { - 3.873039826217679*^9, 3.8730399020648727`*^9}}, - CellLabel-> - "In[1337]:=",ExpressionUUID->"c7b79fc9-fdd2-4604-88f5-5cb6b6767542"], - -Cell[BoxData[ - RowBox[{ - RowBox[{"testvals", " ", "=", " ", - RowBox[{"{", - RowBox[{ - RowBox[{"x", "\[Rule]", "0.5"}], ",", " ", - RowBox[{"y", "\[Rule]", "0.5"}], ",", " ", - RowBox[{"z", "\[Rule]", "0.5"}]}], "}"}]}], ";"}]], "Input", - CellChangeTimes->{{3.848768648468796*^9, 3.8487686688884172`*^9}, - 3.8535057187739477`*^9, {3.8730398601207523`*^9, 3.873039863408111*^9}}, - CellLabel-> - "In[1343]:=",ExpressionUUID->"cbf531c1-0700-43d8-be24-0921976c2046"], - -Cell[CellGroupData[{ - -Cell[BoxData[ - RowBox[{"\[IndentingNewLine]", "\[IndentingNewLine]", - RowBox[{ - RowBox[{"NumberForm", "[", - RowBox[{ - RowBox[{"contsrc", "/.", "testvals"}], ",", "16"}], "]"}], - "\[IndentingNewLine]", - RowBox[{"NumberForm", "[", - RowBox[{ - RowBox[{"mom0src", "/.", "testvals"}], ",", "16"}], "]"}], - "\[IndentingNewLine]", - RowBox[{"NumberForm", "[", - RowBox[{ - RowBox[{"mom1src", "/.", "testvals"}], ",", "16"}], "]"}], - "\[IndentingNewLine]", - RowBox[{"NumberForm", "[", - RowBox[{ - RowBox[{"mom2src", "/.", "testvals"}], ",", "16"}], "]"}], - "\[IndentingNewLine]", - RowBox[{"NumberForm", "[", - RowBox[{ - RowBox[{"enersrc", "/.", "testvals"}], ",", "16"}], "]"}], - "\[IndentingNewLine]", "\[IndentingNewLine]", - RowBox[{"NumberForm", "[", - RowBox[{ - RowBox[{"convcontsrc", "/.", "testvals"}], ",", "16"}], "]"}], - "\[IndentingNewLine]", - RowBox[{"NumberForm", "[", - RowBox[{ - RowBox[{"convmom0src", "/.", "testvals"}], ",", "16"}], "]"}], - "\[IndentingNewLine]", - RowBox[{"NumberForm", "[", - RowBox[{ - RowBox[{"convmom1src", "/.", "testvals"}], ",", "16"}], "]"}], - "\[IndentingNewLine]", - RowBox[{"NumberForm", "[", - RowBox[{ - RowBox[{"convmom2src", "/.", "testvals"}], ",", "16"}], "]"}], - "\[IndentingNewLine]", - RowBox[{"NumberForm", "[", - RowBox[{ - RowBox[{"convenersrc", "/.", "testvals"}], ",", "16"}], - "]"}]}]}]], "Input", - CellChangeTimes->{{3.848752863176736*^9, 3.848752874011384*^9}, { - 3.848752905424728*^9, 3.84875290832469*^9}, {3.8487657731951227`*^9, - 3.848765795363201*^9}, 3.848768642408615*^9, {3.848768675758319*^9, - 3.848768679176118*^9}, {3.853412771710568*^9, 3.853412830306747*^9}, { - 3.853505709321966*^9, 3.853505730153659*^9}, {3.85350580692212*^9, - 3.853505807722196*^9}, {3.873039872506875*^9, 3.8730398747109547`*^9}, { - 3.8730399067207212`*^9, 3.873039908946208*^9}}, - CellLabel-> - "In[1344]:=",ExpressionUUID->"bf442d50-8053-48e4-941e-fed131a4770b"], - -Cell[BoxData[ - TagBox[ - RowBox[{"{", - InterpretationBox["\<\"-0.004621895004700585\"\>", - -0.004621895004700585, - AutoDelete->True], "}"}], - NumberForm[#, 16]& ]], "Output", - CellChangeTimes->{ - 3.853505850711261*^9, {3.873039914424315*^9, 3.873039927911124*^9}, - 3.873039987336241*^9, 3.8730401589823513`*^9, {3.87304026077766*^9, - 3.873040282452457*^9}, 3.873041617431982*^9}, - CellLabel-> - "Out[1344]//NumberForm=",ExpressionUUID->"510023f0-8695-4149-aa11-\ -13f2306d8668"], - -Cell[BoxData[ - TagBox[ - RowBox[{"{", - InterpretationBox["\<\"-0.00509066713414899\"\>", - -0.005090667134148991, - AutoDelete->True], "}"}], - NumberForm[#, 16]& ]], "Output", - CellChangeTimes->{ - 3.853505850711261*^9, {3.873039914424315*^9, 3.873039927911124*^9}, - 3.873039987336241*^9, 3.8730401589823513`*^9, {3.87304026077766*^9, - 3.873040282452457*^9}, 3.873041617434058*^9}, - CellLabel-> - "Out[1345]//NumberForm=",ExpressionUUID->"027caf61-93aa-413f-9e99-\ -adf812864b32"], - -Cell[BoxData[ - TagBox[ - RowBox[{"{", - InterpretationBox["\<\"0.01507826268348906\"\>", - 0.015078262683489059`, - AutoDelete->True], "}"}], - NumberForm[#, 16]& ]], "Output", - CellChangeTimes->{ - 3.853505850711261*^9, {3.873039914424315*^9, 3.873039927911124*^9}, - 3.873039987336241*^9, 3.8730401589823513`*^9, {3.87304026077766*^9, - 3.873040282452457*^9}, 3.873041617435268*^9}, - CellLabel-> - "Out[1346]//NumberForm=",ExpressionUUID->"e821e49b-ae90-42f3-a805-\ -8a3d26579bc5"], - -Cell[BoxData[ - TagBox[ - RowBox[{"{", - InterpretationBox["\<\"-0.1749456755521264\"\>", - -0.17494567555212637`, - AutoDelete->True], "}"}], - NumberForm[#, 16]& ]], "Output", - CellChangeTimes->{ - 3.853505850711261*^9, {3.873039914424315*^9, 3.873039927911124*^9}, - 3.873039987336241*^9, 3.8730401589823513`*^9, {3.87304026077766*^9, - 3.873040282452457*^9}, 3.873041617436906*^9}, - CellLabel-> - "Out[1347]//NumberForm=",ExpressionUUID->"8096696f-0249-4f4c-8e56-\ -c39734d7b1f0"], - -Cell[BoxData[ - TagBox[ - RowBox[{"{", - InterpretationBox["\<\"0.0104778831052318\"\>", - 0.010477883105231796`, - AutoDelete->True], "}"}], - NumberForm[#, 16]& ]], "Output", - CellChangeTimes->{ - 3.853505850711261*^9, {3.873039914424315*^9, 3.873039927911124*^9}, - 3.873039987336241*^9, 3.8730401589823513`*^9, {3.87304026077766*^9, - 3.873040282452457*^9}, 3.873041617438293*^9}, - CellLabel-> - "Out[1348]//NumberForm=",ExpressionUUID->"91b4610b-a721-4f6b-87bd-\ -8ce2919a7871"], - -Cell[BoxData[ - TagBox[ - RowBox[{"{", - InterpretationBox["\<\"-0.004621895004700585\"\>", - -0.004621895004700585, - AutoDelete->True], "}"}], - NumberForm[#, 16]& ]], "Output", - CellChangeTimes->{ - 3.853505850711261*^9, {3.873039914424315*^9, 3.873039927911124*^9}, - 3.873039987336241*^9, 3.8730401589823513`*^9, {3.87304026077766*^9, - 3.873040282452457*^9}, 3.873041617439692*^9}, - CellLabel-> - "Out[1349]//NumberForm=",ExpressionUUID->"d599fede-982d-4506-bc2e-\ -ba45a00d33ae"], - -Cell[BoxData[ - TagBox[ - RowBox[{"{", - InterpretationBox["\<\"-0.001970095500617289\"\>", - -0.001970095500617289, - AutoDelete->True], "}"}], - NumberForm[#, 16]& ]], "Output", - CellChangeTimes->{ - 3.853505850711261*^9, {3.873039914424315*^9, 3.873039927911124*^9}, - 3.873039987336241*^9, 3.8730401589823513`*^9, {3.87304026077766*^9, - 3.873040282452457*^9}, 3.873041617440896*^9}, - CellLabel-> - "Out[1350]//NumberForm=",ExpressionUUID->"68209bbf-a48f-4122-8481-\ -31733e9f9e9d"], - -Cell[BoxData[ - TagBox[ - RowBox[{"{", - InterpretationBox["\<\"-0.005199631880288158\"\>", - -0.005199631880288158, - AutoDelete->True], "}"}], - NumberForm[#, 16]& ]], "Output", - CellChangeTimes->{ - 3.853505850711261*^9, {3.873039914424315*^9, 3.873039927911124*^9}, - 3.873039987336241*^9, 3.8730401589823513`*^9, {3.87304026077766*^9, - 3.873040282452457*^9}, 3.8730416174422703`*^9}, - CellLabel-> - "Out[1351]//NumberForm=",ExpressionUUID->"dd69c10e-7b10-46ef-968f-\ -f17e3f8713ea"], - -Cell[BoxData[ - TagBox[ - RowBox[{"{", - InterpretationBox["\<\"-0.005749127851644679\"\>", - -0.005749127851644679, - AutoDelete->True], "}"}], - NumberForm[#, 16]& ]], "Output", - CellChangeTimes->{ - 3.853505850711261*^9, {3.873039914424315*^9, 3.873039927911124*^9}, - 3.873039987336241*^9, 3.8730401589823513`*^9, {3.87304026077766*^9, - 3.873040282452457*^9}, 3.8730416174434557`*^9}, - CellLabel-> - "Out[1352]//NumberForm=",ExpressionUUID->"10fea2f3-d466-41a4-a2f3-\ -3e985c3966f4"], - -Cell[BoxData[ - TagBox[ - RowBox[{"{", - InterpretationBox["\<\"-0.01193110189893135\"\>", - -0.01193110189893135, - AutoDelete->True], "}"}], - NumberForm[#, 16]& ]], "Output", - CellChangeTimes->{ - 3.853505850711261*^9, {3.873039914424315*^9, 3.873039927911124*^9}, - 3.873039987336241*^9, 3.8730401589823513`*^9, {3.87304026077766*^9, - 3.873040282452457*^9}, 3.873041617444722*^9}, - CellLabel-> - "Out[1353]//NumberForm=",ExpressionUUID->"05870f19-f015-4ac2-995e-\ -6828011ecb5d"] -}, Open ]] -}, -WindowSize->{1830, 1137}, -WindowMargins->{{Automatic, 2150}, {Automatic, 36}}, -FrontEndVersion->"12.1 for Mac OS X x86 (64-bit) (March 18, 2020)", -StyleDefinitions->"Default.nb", -ExpressionUUID->"0bc88581-0d53-4791-969d-68de77380196" -] -(* End of Notebook Content *) - -(* Internal cache information *) -(*CellTagsOutline -CellTagsIndex->{} -*) -(*CellTagsIndex -CellTagsIndex->{} -*) -(*NotebookFileOutline -Notebook[{ -Cell[558, 20, 489, 10, 52, "Input",ExpressionUUID->"4467992d-fdba-4959-a6bf-6d08d2779d83"], -Cell[1050, 32, 8495, 275, 1333, "Input",ExpressionUUID->"dcc5d53d-2af9-432b-b6d1-6486fec9185d"], -Cell[9548, 309, 4772, 134, 94, "Input",ExpressionUUID->"4a41c371-f128-4acb-986f-9fa3f019e3b3"], -Cell[14323, 445, 3595, 109, 451, "Input",ExpressionUUID->"01f7c5dd-5b69-47be-8753-e24d14b2285b"], -Cell[17921, 556, 790, 19, 94, "Input",ExpressionUUID->"e60d27cd-143c-4af1-ba1b-f25168f64c0e"], -Cell[18714, 577, 1283, 33, 178, "Input",ExpressionUUID->"9fe74626-97e8-415d-985b-18c87bd949eb"], -Cell[20000, 612, 2065, 64, 304, "Input",ExpressionUUID->"3d4a9929-9fd3-4791-a148-b6d4af575913"], -Cell[22068, 678, 741, 18, 73, "Input",ExpressionUUID->"90d01278-1ed2-4278-9896-dd1be1a82d89"], -Cell[22812, 698, 2155, 57, 388, "Input",ExpressionUUID->"e52ab23b-2d72-46e9-9813-f9ead716a4e4"], -Cell[24970, 757, 3806, 100, 829, "Input",ExpressionUUID->"937d0cc3-6511-4003-bc5a-cd6cd4274e1f"], -Cell[28779, 859, 932, 23, 73, "Input",ExpressionUUID->"e4d025b4-8308-44f1-a925-4e3a1e1b7aab"], -Cell[29714, 884, 659, 17, 30, "Input",ExpressionUUID->"5873ca8f-5ac0-44d5-b0dc-c3aa73c9976f"], -Cell[30376, 903, 1059, 29, 52, "Input",ExpressionUUID->"c641f2ca-6faa-4856-a473-2399e7b93399"], -Cell[31438, 934, 3354, 88, 178, "Input",ExpressionUUID->"c7b79fc9-fdd2-4604-88f5-5cb6b6767542"], -Cell[34795, 1024, 483, 11, 30, "Input",ExpressionUUID->"cbf531c1-0700-43d8-be24-0921976c2046"], -Cell[CellGroupData[{ -Cell[35303, 1039, 2042, 51, 283, "Input",ExpressionUUID->"bf442d50-8053-48e4-941e-fed131a4770b"], -Cell[37348, 1092, 494, 13, 45, "Output",ExpressionUUID->"510023f0-8695-4149-aa11-13f2306d8668"], -Cell[37845, 1107, 493, 13, 45, "Output",ExpressionUUID->"027caf61-93aa-413f-9e99-adf812864b32"], -Cell[38341, 1122, 492, 13, 45, "Output",ExpressionUUID->"e821e49b-ae90-42f3-a805-8a3d26579bc5"], -Cell[38836, 1137, 492, 13, 45, "Output",ExpressionUUID->"8096696f-0249-4f4c-8e56-c39734d7b1f0"], -Cell[39331, 1152, 491, 13, 45, "Output",ExpressionUUID->"91b4610b-a721-4f6b-87bd-8ce2919a7871"], -Cell[39825, 1167, 494, 13, 45, "Output",ExpressionUUID->"d599fede-982d-4506-bc2e-ba45a00d33ae"], -Cell[40322, 1182, 494, 13, 45, "Output",ExpressionUUID->"68209bbf-a48f-4122-8481-31733e9f9e9d"], -Cell[40819, 1197, 496, 13, 45, "Output",ExpressionUUID->"dd69c10e-7b10-46ef-968f-f17e3f8713ea"], -Cell[41318, 1212, 496, 13, 45, "Output",ExpressionUUID->"10fea2f3-d466-41a4-a2f3-3e985c3966f4"], -Cell[41817, 1227, 492, 13, 45, "Output",ExpressionUUID->"05870f19-f015-4ac2-995e-6828011ecb5d"] -}, Open ]] -} -] -*) - diff --git a/src/closure_models/unit_test/doc/external_magnetic_field.py b/src/closure_models/unit_test/doc/external_magnetic_field.py deleted file mode 100644 index 9a86902..0000000 --- a/src/closure_models/unit_test/doc/external_magnetic_field.py +++ /dev/null @@ -1,10 +0,0 @@ -from math import * - -x = 0.2 -y = 0.3 -r2 = x * x + y * y -B_magn = 1.3 - -print("Bx: ", -y * B_magn / r2) -print("By: ", x * B_magn / r2) -print("Bz: ", 0.0) diff --git a/src/closure_models/unit_test/doc/singularValue_reference.py b/src/closure_models/unit_test/doc/singularValue_reference.py deleted file mode 100644 index c6b9212..0000000 --- a/src/closure_models/unit_test/doc/singularValue_reference.py +++ /dev/null @@ -1,34 +0,0 @@ -# Import Python module to caculcate the singular values -import numpy -from numpy import array -from scipy.linalg import svd -from decimal import * - - -# Function to compute the singular values of the matrix A. -# It prints the eigenvalues and starts with the maximum eigenvalue -def compute_singular_values(A): - U, s, VT = svd(A) - for l in s: - print("Singular values: %.17f" % l) - - -# qp = 0 -print("\033[1mCompute singular values for qp = 0:\033[0m") -J = array([[4.0, 0.0], [0.0, 9.0]]) -compute_singular_values(J) - -# qp = 1 -print("\n\033[1mCompute singular values for qp = 1:\033[0m") -J = array([[2.0, 6.0], [6.0, 2.0]]) -compute_singular_values(J) - -# qp = 2 -print("\n\033[1mCompute singular values for qp = 2:\033[0m") -J = array([[-0.2, 0.3], [0.4, 0.5]]) -compute_singular_values(J) - -# qp = 3 -print("\n\033[1mCompute singular values for qp = 3:\033[0m") -J = array([[2.0, -2.0], [-2.0, 2.0]]) -compute_singular_values(J) diff --git a/src/closure_models/unit_test/tstClampField.cpp b/src/closure_models/unit_test/tstClampField.cpp deleted file mode 100644 index d40d1df..0000000 --- a/src/closure_models/unit_test/tstClampField.cpp +++ /dev/null @@ -1,146 +0,0 @@ -#include "VertexCFD_ClosureModelFactoryTestHarness.hpp" -#include "VertexCFD_EvaluatorTestHarness.hpp" - -#include "closure_models/VertexCFD_Closure_ClampField.hpp" - -#include - -//---------------------------------------------------------------------------// -// TESTS -//---------------------------------------------------------------------------// -namespace VertexCFD -{ -namespace Test -{ -//---------------------------------------------------------------------------// -// Test field. -template -struct TestField : public PHX::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - using scalar_type = typename EvalType::ScalarT; - - double _f; - - PHX::MDField _field; - - TestField(const panzer::IntegrationRule& ir, const double f) - : _f(f) - , _field("test_field", ir.dl_scalar) - { - this->addEvaluatedField(_field); - this->setName("Clamp Field unit test dependency"); - } - - void evaluateFields(typename panzer::Traits::EvalData /*d*/) override - { - _field.deep_copy(_f); - } -}; - -//---------------------------------------------------------------------------// -template -void testEval(const double f, - const double min, - const double max, - const double tol, - const double exp) -{ - // Setup test fixture. - static constexpr int num_space_dim = 2; - const int integration_order = 0; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - - // Create test field evaluator. - auto dep_field_eval - = Teuchos::rcp(new TestField(*test_fixture.ir, f)); - test_fixture.registerEvaluator(dep_field_eval); - - Teuchos::ParameterList clamp_params{"test_field"}; - clamp_params.set("Lower Limit", min) - .set("Upper Limit", max) - .set("Tolerance", tol); - // Create clamped field evaluator. - auto field_eval - = Teuchos::rcp(new ClosureModel::ClampField( - *test_fixture.ir, clamp_params)); - test_fixture.registerEvaluator(field_eval); - - // Add required test fields. - test_fixture.registerTestField(field_eval->_field); - - // Evaluate. - test_fixture.evaluate(); - - // Check the values. - auto result = test_fixture.getTestFieldData(field_eval->_field); - - EXPECT_DOUBLE_EQ(exp, fieldValue(result, 0, 0)); -} - -//---------------------------------------------------------------------------// -// Minimum clamp test -template -void testMinEval() -{ - const double field_value = -1.0; - testEval(field_value, 0.1, 1.1, 1.0e-16, 0.1); -} - -//---------------------------------------------------------------------------// -// Maximum clamp test -template -void testMaxEval() -{ - const double field_value = 3.5; - testEval(field_value, 0.1, 1.1, 1.0e-16, 1.1); -} - -//---------------------------------------------------------------------------// -// Mid range clamp test -template -void testMidEval() -{ - const double field_value = 0.35; - testEval(field_value, 0.1, 1.1, 1.0e-16, 0.35); -} - -//---------------------------------------------------------------------------// -TEST(ClampFieldMin, residual_test) -{ - testMinEval(); -} - -//---------------------------------------------------------------------------// -TEST(ClampFieldMin, jacobian_test) -{ - testMinEval(); -} - -//---------------------------------------------------------------------------// -TEST(ClampFieldMax, residual_test) -{ - testMaxEval(); -} - -//---------------------------------------------------------------------------// -TEST(ClampFieldMax, jacobian_test) -{ - testMaxEval(); -} -//---------------------------------------------------------------------------// -TEST(ClampFieldMid, residual_test) -{ - testMidEval(); -} - -//---------------------------------------------------------------------------// -TEST(ClampFieldMid, jacobian_test) -{ - testMidEval(); -} - -} // namespace Test -} // namespace VertexCFD diff --git a/src/closure_models/unit_test/tstClosureModelFactoryTestHarness.cpp b/src/closure_models/unit_test/tstClosureModelFactoryTestHarness.cpp deleted file mode 100644 index acba52c..0000000 --- a/src/closure_models/unit_test/tstClosureModelFactoryTestHarness.cpp +++ /dev/null @@ -1,38 +0,0 @@ -#include "VertexCFD_ClosureModelFactoryTestHarness.hpp" - -#include - -namespace VertexCFD -{ -namespace Test -{ -template -void testDefaultFixture() -{ - ClosureModelFactoryTestFixture test_fixture; - - test_fixture.user_params.sublist("Fluid Properties") - .set("Kinematic viscosity", 0.1) - .set("Artificial compressibility", 2.0); - - EXPECT_EQ("!!! UNDEFINED !!!", test_fixture.type_name); - EXPECT_EQ("!!! UNDEFINED !!!", test_fixture.eval_name); - - // The default type_name should not match any closure model and throw an - // exception. - EXPECT_THROW((test_fixture.template buildAndTest()), - std::runtime_error); -} - -TEST(ClosureModelFactoryHarness, residual_test) -{ - testDefaultFixture(); -} - -TEST(ClosureModelFactoryHarness, jacobian_test) -{ - testDefaultFixture(); -} - -} // namespace Test -} // namespace VertexCFD diff --git a/src/closure_models/unit_test/tstConstantScalarField.cpp b/src/closure_models/unit_test/tstConstantScalarField.cpp deleted file mode 100644 index f205631..0000000 --- a/src/closure_models/unit_test/tstConstantScalarField.cpp +++ /dev/null @@ -1,59 +0,0 @@ -#include "VertexCFD_EvaluatorTestHarness.hpp" -#include "closure_models/unit_test/VertexCFD_ClosureModelFactoryTestHarness.hpp" - -#include "closure_models/VertexCFD_Closure_ConstantScalarField.hpp" - -#include - -namespace VertexCFD -{ -namespace Test -{ - -template -void testEval() -{ - static constexpr int num_space_dim = 3; - const int integration_order = 1; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - - const auto& ir = *test_fixture.ir; - - const double value = 1.5; - - // Initialize and register - auto eval = Teuchos::rcp( - new ClosureModel::ConstantScalarField( - ir, "scalar_field", value)); - test_fixture.registerEvaluator(eval); - test_fixture.registerTestField(eval->_scalar_field); - test_fixture.evaluate(); - - // Evaluate test fields - const auto fv_scalar_field - = test_fixture.getTestFieldData(eval->_scalar_field); - - const int num_point = ir.num_points; - for (int qp = 0; qp < num_point; ++qp) - { - EXPECT_EQ(value, fieldValue(fv_scalar_field, 0, qp)); - } -} - -//-----------------------------------------------------------------// -TEST(ConstantScalarField, residual_test) -{ - testEval(); -} - -//-----------------------------------------------------------------// -TEST(ConstantScalarField, jacobian_test) -{ - testEval(); -} - -//-----------------------------------------------------------------// -} // namespace Test -} // namespace VertexCFD diff --git a/src/closure_models/unit_test/tstElementLength.cpp b/src/closure_models/unit_test/tstElementLength.cpp deleted file mode 100644 index 102321c..0000000 --- a/src/closure_models/unit_test/tstElementLength.cpp +++ /dev/null @@ -1,89 +0,0 @@ -#include -#include - -#include - -#include - -#include - -#include - -//---------------------------------------------------------------------------// -// TESTS -//---------------------------------------------------------------------------// -namespace VertexCFD -{ -namespace Test -{ -//---------------------------------------------------------------------------// -template -void testEval() -{ - // Setup test fixture. - int num_space_dim = 2; - int integration_order = 1; - int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - - // Create evaluator. - auto length_eval = Teuchos::rcp( - new ClosureModel::ElementLength( - *test_fixture.ir)); - test_fixture.registerEvaluator(length_eval); - - // Add required test fields. - test_fixture.registerTestField(length_eval->_element_length); - - // Evaluate metric tensor. - test_fixture.evaluate(); - - // Check the metric tensor. - auto element_length_result = test_fixture.getTestFieldData( - length_eval->_element_length); - EXPECT_EQ(1, element_length_result.extent(1)); - EXPECT_DOUBLE_EQ(1.0, fieldValue(element_length_result, 0, 0, 0)); -} - -//---------------------------------------------------------------------------// -TEST(ElementLength, residual_test) -{ - testEval(); -} - -//---------------------------------------------------------------------------// -TEST(ElementLength, jacobian_test) -{ - testEval(); -} - -//---------------------------------------------------------------------------// - -template -void testFactory() -{ - constexpr int num_space_dim = NumSpaceDim; - ClosureModelFactoryTestFixture test_fixture; - test_fixture.type_name = "ElementLength"; - test_fixture.eval_name = "Element Length"; - test_fixture.user_params.sublist("Fluid Properties") - .set("Kinematic viscosity", 0.1) - .set("Artificial compressibility", 2.0); - test_fixture.template buildAndTest< - ClosureModel::ElementLength, - num_space_dim>(); -} - -TEST(ElementLength_Factory2D, residual_test) -{ - testFactory(); -} - -TEST(ElementLength_Factory2D, jacobian_test) -{ - testFactory(); -} - -} // end namespace Test -} // end namespace VertexCFD diff --git a/src/closure_models/unit_test/tstExternalFields.cpp b/src/closure_models/unit_test/tstExternalFields.cpp deleted file mode 100644 index 2960bf4..0000000 --- a/src/closure_models/unit_test/tstExternalFields.cpp +++ /dev/null @@ -1,127 +0,0 @@ -#include - -#include -#include -#include -#include - -#include - -#include - -#include - -#include -#include - -#include - -#include - -#include - -#include - -#include -#include - -//---------------------------------------------------------------------------// -// TESTS -//---------------------------------------------------------------------------// -namespace VertexCFD -{ -namespace Test -{ -//---------------------------------------------------------------------------// -template -void testEval() -{ - // Get the MPI communicator. - auto comm = Teuchos::rcp_dynamic_cast>( - Teuchos::DefaultComm::getComm()); - - constexpr auto num_space_dim = std::integral_constant{}; - - // Parse input. Note that are relying on the fact that "simple_box_2d.xml" - // uses a quad mesh and our EvaluatorTestFixture also uses a single quad - // right now. - const std::string location = VERTEXCFD_DRIVER_TEST_INPUT_DIR; - const std::string file = "simple_box_2d.xml"; - std::string file_path = location + file; - - // Create external field data. - auto fields_manager - = Teuchos::rcp(new VertexCFD::ExternalFieldsManager( - num_space_dim, comm, file_path)); - - // Setup test fixture. - const int integration_order = 1; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - - // Use the block in the inline mesh generated in "simple_box_2d.xml". - test_fixture.workset->block_id = "eblock-0_0"; - - // If running with multiple ranks, omit the evaluator from one rank. - // All communication has already happened in the ExternalFieldsManager - // constructor above. Previously, the test would hang since the evaluator - // was doing the communication. - if (comm->getRank() == 1) - return; - - // Create an external field evaluator. - const std::string eval_name = "external_fields"; - std::vector field_names - = {"lagrange_pressure", "velocity_0", "velocity_1"}; - auto external_field_eval = Teuchos::rcp( - new ClosureModel::ExternalFields( - eval_name, - fields_manager, - field_names, - test_fixture.basis_ir_layout->getBasis())); - test_fixture.registerEvaluator(external_field_eval); - - // Add required test fields. - test_fixture.registerTestField( - external_field_eval->_external_fields[0]); - test_fixture.registerTestField( - external_field_eval->_external_fields[1]); - test_fixture.registerTestField( - external_field_eval->_external_fields[2]); - - // Evaluate external fields. - test_fixture.evaluate(); - - // Check the fields. - const auto lagrange_pressure = test_fixture.getTestFieldData( - external_field_eval->_external_fields[0]); - const auto velocity_0 = test_fixture.getTestFieldData( - external_field_eval->_external_fields[1]); - const auto velocity_1 = test_fixture.getTestFieldData( - external_field_eval->_external_fields[2]); - const int num_point = test_fixture.cardinality(); - for (int i = 0; i < num_point; ++i) - { - EXPECT_EQ(0.5, fieldValue(lagrange_pressure, 0, i)); - EXPECT_EQ(1.0, fieldValue(velocity_0, 0, i)); - EXPECT_EQ(2.0, fieldValue(velocity_1, 0, i)); - } -} - -//---------------------------------------------------------------------------// -TEST(ExternalFields, residual_test) -{ - testEval(); -} - -//---------------------------------------------------------------------------// -TEST(ExternalFields, jacobian_test) -{ - testEval(); -} - -//---------------------------------------------------------------------------// - -} // end namespace Test -} // end namespace VertexCFD diff --git a/src/closure_models/unit_test/tstMeasureElementLength.cpp b/src/closure_models/unit_test/tstMeasureElementLength.cpp deleted file mode 100644 index 59d6446..0000000 --- a/src/closure_models/unit_test/tstMeasureElementLength.cpp +++ /dev/null @@ -1,104 +0,0 @@ -#include -#include - -#include - -#include -#include - -#include -#include -#include - -#include -#include - -#include - -#include - -#include - -//---------------------------------------------------------------------------// -// TESTS -//---------------------------------------------------------------------------// -namespace VertexCFD -{ -namespace Test -{ -//---------------------------------------------------------------------------// -template -void testEval() -{ - // Setup test fixture. - int num_space_dim = 2; - const int integration_order = 2; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - - // Create evaluator. - auto measure_element_length_eval = Teuchos::rcp( - new ClosureModel::MeasureElementLength( - *test_fixture.ir)); - test_fixture.registerEvaluator(measure_element_length_eval); - - // Add required test fields. - test_fixture.registerTestField( - measure_element_length_eval->_element_length); - - // Evaluate MFEM element length. - test_fixture.evaluate(); - - // Check the MFEM element length. - auto element_length_result = test_fixture.getTestFieldData( - measure_element_length_eval->_element_length); - int num_point = element_length_result.extent(1); - for (int qp = 0; qp < num_point; ++qp) - { - EXPECT_DOUBLE_EQ(0.5, fieldValue(element_length_result, 0, qp, 0)); - EXPECT_DOUBLE_EQ(0.5, fieldValue(element_length_result, 0, qp, 1)); - } -} - -//---------------------------------------------------------------------------// -TEST(MeasureElementLength, residual_test) -{ - testEval(); -} - -//---------------------------------------------------------------------------// -TEST(MeasureElementLength, jacobian_test) -{ - testEval(); -} - -//---------------------------------------------------------------------------// - -template -void testFactory() -{ - constexpr int num_space_dim = NumSpaceDim; - ClosureModelFactoryTestFixture test_fixture; - test_fixture.type_name = "MeasureElementLength"; - test_fixture.eval_name = "Measure Element Length"; - test_fixture.user_params.sublist("Fluid Properties") - .set("Kinematic viscosity", 0.1) - .set("Artificial compressibility", 2.0); - test_fixture.template buildAndTest< - ClosureModel::MeasureElementLength, - num_space_dim>(); -} - -TEST(MeasureElementLength_Factory2D, residual_test) -{ - testFactory(); -} - -TEST(MeasureElementLength_Factory2D, jacobian_test) -{ - testFactory(); -} - -} // end namespace Test -} // end namespace VertexCFD diff --git a/src/closure_models/unit_test/tstMethodManufacturedSolution.cpp b/src/closure_models/unit_test/tstMethodManufacturedSolution.cpp deleted file mode 100644 index 5c14af2..0000000 --- a/src/closure_models/unit_test/tstMethodManufacturedSolution.cpp +++ /dev/null @@ -1,173 +0,0 @@ -#include -#include - -#include - -#include -#include - -#include -#include -#include -#include - -#include - -#include - -#include - -#include - -#include - -//---------------------------------------------------------------------------// -// TESTS -//---------------------------------------------------------------------------// -namespace VertexCFD -{ -namespace Test -{ -//---------------------------------------------------------------------------// -template -void testEval(const Kokkos::Array expected_sol) -{ - // Setup test fixture. - constexpr int num_space_dim = NumSpaceDim; - const int integration_order = 0; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - - // Create scaled MMS evaluator. - auto mms_eval = Teuchos::rcp( - new ClosureModel:: - MethodManufacturedSolution( - *test_fixture.ir)); - test_fixture.registerEvaluator(mms_eval); - - // Add required test fields. - test_fixture.registerTestField(mms_eval->_lagrange_pressure); - for (int dim = 0; dim < num_space_dim; ++dim) - test_fixture.registerTestField(mms_eval->_velocity[dim]); - test_fixture.registerTestField(mms_eval->_temperature); - - // Evaluate scaled MMS - test_fixture.evaluate(); - - // Check the values - const auto lagrange_pressure_result - = test_fixture.getTestFieldData(mms_eval->_lagrange_pressure); - const auto velocity_0_result - = test_fixture.getTestFieldData(mms_eval->_velocity[0]); - const auto velocity_1_result - = test_fixture.getTestFieldData(mms_eval->_velocity[1]); - const auto temperature_result - = test_fixture.getTestFieldData(mms_eval->_temperature); - - // Check the scaled MMS solutions - int num_point = lagrange_pressure_result.extent(1); - for (int qp = 0; qp < num_point; ++qp) - { - EXPECT_DOUBLE_EQ(expected_sol[0], - fieldValue(lagrange_pressure_result, 0, qp)); - EXPECT_DOUBLE_EQ(expected_sol[1], fieldValue(velocity_0_result, 0, qp)); - EXPECT_DOUBLE_EQ(expected_sol[2], fieldValue(velocity_1_result, 0, qp)); - EXPECT_DOUBLE_EQ(expected_sol[num_space_dim + 1], - fieldValue(temperature_result, 0, qp)); - if (num_space_dim == 3) - { - const auto velocity_2_result - = test_fixture.getTestFieldData( - mms_eval->_velocity[2]); - EXPECT_DOUBLE_EQ(expected_sol[3], - fieldValue(velocity_2_result, 0, qp)); - } - } -} - -//---------------------------------------------------------------------------// -template -void testMMS() -{ - constexpr int num_conserve = NumSpaceDim + 2; - // rho vel0 vel1 T - Kokkos::Array expected_value - = {1.0, 0.080933222925629281, 1.125, 1.0}; - // rho vel0 vel1 vel2 T - if (NumSpaceDim == 3) - { - expected_value[0] = 1.0; - expected_value[1] = 0.08065988825907122; - expected_value[2] = 1.125; - expected_value[3] = -0.0014010672786498911; - expected_value[4] = 1.0; - } - testEval(expected_value); -} - -//---------------------------------------------------------------------------// -TEST(MMS2D, residual_test) -{ - testMMS(); -} - -//---------------------------------------------------------------------------// -TEST(MMS2D, jacobian_test) -{ - testMMS(); -} - -//---------------------------------------------------------------------------// -TEST(MMS3D, residual_test) -{ - testMMS(); -} - -//---------------------------------------------------------------------------// -TEST(MMS3D, jacobian_test) -{ - testMMS(); -} -//---------------------------------------------------------------------------// - -template -void testFactory() -{ - const int num_space_dim = NumSpaceDim; - ClosureModelFactoryTestFixture test_fixture; - test_fixture.type_name = "MethodManufacturedSolution"; - test_fixture.user_params.sublist("Fluid Properties") - .set("Kinematic viscosity", 0.1) - .set("Artificial compressibility", 2.0); - if (num_space_dim == 2) - test_fixture.eval_name = "Method of Manufactured Solution 2D"; - else if (num_space_dim == 3) - test_fixture.eval_name = "Method of Manufactured Solution 3D"; - test_fixture.template buildAndTest< - ClosureModel::MethodManufacturedSolution, - num_space_dim>(); -} - -TEST(MMS_Factory2D, residual_test) -{ - testFactory(); -} - -TEST(MMS_Factory2D, jacobian_test) -{ - testFactory(); -} - -TEST(MMS_Factory3D, residual_test) -{ - testFactory(); -} - -TEST(MMS_Factory3D, jacobian_test) -{ - testFactory(); -} - -} // end namespace Test -} // end namespace VertexCFD diff --git a/src/closure_models/unit_test/tstMethodManufacturedSolutionSource.cpp b/src/closure_models/unit_test/tstMethodManufacturedSolutionSource.cpp deleted file mode 100644 index 864cb84..0000000 --- a/src/closure_models/unit_test/tstMethodManufacturedSolutionSource.cpp +++ /dev/null @@ -1,244 +0,0 @@ -#include -#include - -#include "incompressible_solver/fluid_properties/VertexCFD_ConstantFluidProperties.hpp" -#include - -#include -#include - -#include -#include -#include -#include - -#include - -#include - -#include - -#include - -#include - -//---------------------------------------------------------------------------// -// TESTS -//---------------------------------------------------------------------------// -namespace VertexCFD -{ -namespace Test -{ -//---------------------------------------------------------------------------// -template -void testEval(const bool build_viscous_flux, - const Kokkos::Array expected_sol) -{ - // Setup test fixture. - constexpr int num_space_dim = NumSpaceDim; - constexpr int num_conserve = NumSpaceDim + 2; - const int integration_order = 0; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - - // Create the param list to initialize the evaluator - Teuchos::ParameterList fluid_prop_list; - fluid_prop_list.set("Kinematic viscosity", 4.0); - fluid_prop_list.set("Artificial compressibility", 2.0); - fluid_prop_list.set("Build Temperature Equation", true); - fluid_prop_list.set("Thermal conductivity", 5.0); - fluid_prop_list.set("Specific heat capacity", 0.6); - const FluidProperties::ConstantFluidProperties fluid_prop(fluid_prop_list); - - // Create mms source evaluator. - auto mms_eval = Teuchos::rcp( - new ClosureModel::MethodManufacturedSolutionSource( - *test_fixture.ir, build_viscous_flux, fluid_prop)); - test_fixture.registerEvaluator(mms_eval); - - // Add required test fields. - test_fixture.registerTestField(mms_eval->_continuity_mms_source); - for (int dim = 0; dim < num_space_dim; ++dim) - test_fixture.registerTestField( - mms_eval->_momentum_mms_source[dim]); - test_fixture.registerTestField(mms_eval->_energy_mms_source); - - // Evaluate mms source - test_fixture.evaluate(); - - // Check the values - const auto continuity_result = test_fixture.getTestFieldData( - mms_eval->_continuity_mms_source); - const auto momentum_0_result = test_fixture.getTestFieldData( - mms_eval->_momentum_mms_source[0]); - const auto momentum_1_result = test_fixture.getTestFieldData( - mms_eval->_momentum_mms_source[1]); - const auto energy_result = test_fixture.getTestFieldData( - mms_eval->_energy_mms_source); - - // Check the mms source solutions - int num_point = continuity_result.extent(1); - for (int qp = 0; qp < num_point; ++qp) - { - EXPECT_DOUBLE_EQ(expected_sol[0], fieldValue(continuity_result, 0, qp)); - EXPECT_DOUBLE_EQ(expected_sol[1], fieldValue(momentum_0_result, 0, qp)); - EXPECT_DOUBLE_EQ(expected_sol[2], fieldValue(momentum_1_result, 0, qp)); - EXPECT_DOUBLE_EQ(expected_sol[num_conserve - 1], - fieldValue(energy_result, 0, qp)); - } - - if (num_space_dim == 3) - { - const auto momentum_2_result = test_fixture.getTestFieldData( - mms_eval->_momentum_mms_source[2]); - for (int qp = 0; qp < num_point; ++qp) - EXPECT_DOUBLE_EQ(expected_sol[num_conserve - 2], - fieldValue(momentum_2_result, 0, qp)); - } -} - -//---------------------------------------------------------------------------// -template -void testMMSSourceConvective() -{ - constexpr int num_space_dim = NumSpaceDim; - - SCOPED_TRACE("Convective"); - Kokkos::Array expected_value; - if (num_space_dim == 2) - { - expected_value[0] = 0.06485567288359177; - expected_value[1] = 0.014546900447422031; - expected_value[2] = 0.1796124151976149; - expected_value[3] = 0.3731078016877022; - } - else if (num_space_dim == 3) - { - expected_value[0] = -0.004621895004700585; - expected_value[1] = -0.001970095500617289; - expected_value[2] = -0.005199631880288158; - expected_value[3] = -0.005749127851644679; - expected_value[4] = -0.01193110189893135; - } - testEval(false, expected_value); -} - -//---------------------------------------------------------------------------// -template -void testMMSSourceConvectiveViscous() -{ - constexpr int num_space_dim = NumSpaceDim; - - SCOPED_TRACE("Convective + Viscous"); - Kokkos::Array expected_value; - if (num_space_dim == 2) - { - expected_value[0] = 0.06485567288359177; - expected_value[1] = -0.11093398765764714; - expected_value[2] = 0.17029666578878958; - expected_value[3] = 0.3321719304832673; - } - else if (num_space_dim == 3) - { - expected_value[0] = -0.004621895004700585; - expected_value[1] = -0.00509066713414899; - expected_value[2] = 0.01507826268348906; - expected_value[3] = -0.17494567555212637; - expected_value[4] = 0.010477883105231796; - } - testEval(true, expected_value); -} - -//---------------------------------------------------------------------------// -TEST(MMSConvective2D, DISABLED_residual_test) -{ - testMMSSourceConvective(); -} - -//---------------------------------------------------------------------------// -TEST(MMSConvective2D, DISABLED_jacobian_test) -{ - testMMSSourceConvective(); -} - -//---------------------------------------------------------------------------// -TEST(MMSConvectiveViscous2D, DISABLED_residual_test) -{ - testMMSSourceConvectiveViscous(); -} - -//---------------------------------------------------------------------------// -TEST(MMSConvectiveViscous2D, DISABLED_jacobian_test) -{ - testMMSSourceConvectiveViscous(); -} - -//---------------------------------------------------------------------------// -TEST(MMSConvective3D, DISABLED_residual_test) -{ - testMMSSourceConvective(); -} - -//---------------------------------------------------------------------------// -TEST(MMSConvective3D, DISABLED_jacobian_test) -{ - testMMSSourceConvective(); -} - -//---------------------------------------------------------------------------// -TEST(MMSConvectiveViscous3D, DISABLED_residual_test) -{ - testMMSSourceConvectiveViscous(); -} - -//---------------------------------------------------------------------------// -TEST(MMSConvectiveViscous3D, DISABLED_jacobian_test) -{ - testMMSSourceConvectiveViscous(); -} - -//---------------------------------------------------------------------------// -template -void testFactory() -{ - constexpr int num_space_dim = NumSpaceDim; - ClosureModelFactoryTestFixture test_fixture; - test_fixture.type_name = "MethodManufacturedSolutionSource"; - if (num_space_dim == 2) - test_fixture.eval_name = "Method of Manufactured Solution Source 2D"; - else if (num_space_dim == 3) - test_fixture.eval_name = "Method of Manufactured Solution Source 3D"; - test_fixture.user_params.sublist("Fluid Properties") - .set("Kinematic viscosity", 0.1) - .set("Artificial compressibility", 2.0); - test_fixture.template buildAndTest< - ClosureModel::MethodManufacturedSolutionSource, - num_space_dim>(); -} - -TEST(MMS_Source_Factory2D, residual_test) -{ - testFactory(); -} - -TEST(MMS_Source_Factory2D, jacobian_test) -{ - testFactory(); -} - -TEST(MMS_Source_Factory3D, residual_test) -{ - testFactory(); -} - -TEST(MMS_Source_Factory3D, jacobian_test) -{ - testFactory(); -} -} // end namespace Test -} // end namespace VertexCFD diff --git a/src/closure_models/unit_test/tstMetricTensor.cpp b/src/closure_models/unit_test/tstMetricTensor.cpp deleted file mode 100644 index b51e780..0000000 --- a/src/closure_models/unit_test/tstMetricTensor.cpp +++ /dev/null @@ -1,588 +0,0 @@ -#include -#include - -#include - -#include -#include -#include - -#include -#include - -#include - -#include - -#include -#include -#include -#include - -//---------------------------------------------------------------------------// -// TESTS -//---------------------------------------------------------------------------// -namespace VertexCFD -{ -namespace Test -{ -//---------------------------------------------------------------------------// -template -void testEval(const double (&coords)[CellTopo::node_count][CellTopo::dimension], - const double (&exp)[CellTopo::dimension][CellTopo::dimension]) -{ - constexpr int num_cell = 1; - constexpr int nodes_per_cell = CellTopo::node_count; - constexpr int num_point = 1; - constexpr int num_space_dim = CellTopo::dimension; - - EvaluatorTestFixture::host_coords_view coords_view( - "coords", num_cell, nodes_per_cell, num_space_dim); - for (int i = 0; i < nodes_per_cell; ++i) - for (int j = 0; j < num_space_dim; ++j) - coords_view(0, i, j) = coords[i][j]; - - const int integration_order = 0; - const int basis_order = 1; - EvaluatorTestFixture test_fixture(shards::getCellTopologyData(), - coords_view, - integration_order, - basis_order); - - EXPECT_EQ(nodes_per_cell, test_fixture.cardinality()); - EXPECT_EQ(num_point, test_fixture.numPoint()); - if (::testing::Test::HasFailure()) - { - GTEST_FAIL() << "Unexpected test fixture parameters"; - } - - // Create evaluator. - auto metric_tensor_eval = Teuchos::rcp( - new ClosureModel::MetricTensor( - *test_fixture.ir)); - test_fixture.registerEvaluator(metric_tensor_eval); - - // Add required test fields. - test_fixture.registerTestField( - metric_tensor_eval->_metric_tensor); - - // Evaluate metric tensor. - test_fixture.evaluate(); - - // Check the metric tensor. - auto metric_tensor_result = test_fixture.getTestFieldData( - metric_tensor_eval->_metric_tensor); - - EXPECT_EQ(num_cell, metric_tensor_result.extent(0)); - EXPECT_EQ(num_point, metric_tensor_result.extent(1)); - EXPECT_EQ(num_space_dim, metric_tensor_result.extent(2)); - if (::testing::Test::HasFailure()) - { - GTEST_FAIL() << "Unexpected metric tensor result extents"; - } - - constexpr double tol = 1.0e-14; - - for (int i = 0; i < num_space_dim; ++i) - { - for (int j = 0; j < num_space_dim; ++j) - { - // For zero exptected values, use absolute tolerance. - if (exp[i][j] < tol) - { - EXPECT_NEAR(exp[i][j], metric_tensor_result(0, 0, i, j), tol) - << "M[" << i << ", " << j << ']'; - } - // For non-zero expected values, use relative (ULP) tolerance. - else - { - EXPECT_DOUBLE_EQ(exp[i][j], metric_tensor_result(0, 0, i, j)) - << "M[" << i << ", " << j << ']'; - } - } - } -} - -//---------------------------------------------------------------------------// -// Apply a coordinate transformation given by a rotation/scaling matrix and -// displacement vector. -template -void applyTransformation(double (&coords)[N][D], - const double (&mtx)[D][D], - const double (&disp)[D]) -{ - for (int node = 0; node < N; ++node) - { - double new_coord[D]{}; - for (int i = 0; i < D; ++i) - for (int j = 0; j < D; ++j) - new_coord[i] += mtx[i][j] * coords[node][j]; - for (int i = 0; i < D; ++i) - coords[node][i] = new_coord[i] + disp[i]; - } -} - -//---------------------------------------------------------------------------// -// Test the ideal cell - all edges are length 1. -// The result should be the identity. -template -struct IdealCellTest -{ - static constexpr int N = CellTopo::node_count; - static constexpr int D = CellTopo::dimension; - - static void eval(const double (&coords)[N][D]) - { - double exp[D][D]{}; - for (int i = 0; i < D; ++i) - exp[i][i] = 1.0; - - testEval(coords, exp); - } -}; - -//---------------------------------------------------------------------------// -// Test an isotropic cell - scale, rotate, and displace the ideal cell. -// The result should be scaled but not impacted by rotation or displacement. -template -struct IsotropicCellTest -{ - static constexpr int N = CellTopo::node_count; - static constexpr int D = CellTopo::dimension; - - // Transform 1-D coordinates. - static void transformCoords(double (&coords)[N][1]) - { - // Scale by 5. - constexpr double mtx[1][1] = { - {5.0}, - }; - - // Displace. - constexpr double disp[1] = {1.0}; - - applyTransformation(coords, mtx, disp); - } - - // Transform 2-D coordinates. - static void transformCoords(double (&coords)[N][2]) - { - // Scale by 5 and rotate. - constexpr double mtx[2][2] = { - {4.0, -3.0}, - {3.0, 4.0}, - }; - - // Displace in all directions. - constexpr double disp[2] = {1.0, -2.0}; - - applyTransformation(coords, mtx, disp); - } - - // Transform 3-D coordinates. - static void transformCoords(double (&coords)[N][3]) - { - // Scale by 5 and rotate about three axes. - constexpr double mtx[3][3] = { - {0.12, -3.84, 3.2}, - {3.84, 2.12, 2.4}, - {-3.2, 2.4, 3.0}, - }; - - // Displace in all directions. - constexpr double disp[3] = {1.0, -2.0, 0.5}; - - applyTransformation(coords, mtx, disp); - } - - static void eval(double (&coords)[N][D]) - { - transformCoords(coords); - - double exp[D][D]{}; - for (int i = 0; i < D; ++i) - exp[i][i] = 25.0; - - testEval(coords, exp); - } -}; - -//---------------------------------------------------------------------------// -// Test an anisotropic cell - scale, rotate, and displace the ideal cell. -// The result should be impacted by scaling and rotation, but not displacement. -template -struct AnisotropicCellTest -{ - static constexpr int N = CellTopo::node_count; - static constexpr int D = CellTopo::dimension; - - // Transform 2-D coordinates. - static void transformCoords(double (&coords)[N][2]) - { - // Scale (anisotropically) and rotate. - constexpr double mtx[2][2] = { - {4.0, -1.5}, - {3.0, 2.0}, - }; - - // Displace in all directions. - constexpr double disp[2] = {1.0, -2.0}; - - applyTransformation(coords, mtx, disp); - } - - // Expected 2-D metric. - static void setExpected(double (&exp)[2][2]) - { - exp[0][0] = 18.25; - exp[0][1] = 9.0; - - exp[1][0] = 9.0; - exp[1][1] = 13.0; - } - - // Transform 3-D coordinates. - static void transformCoords(double (&coords)[N][3]) - { - // Scale (anisotropically) and rotate about three axes. - constexpr double mtx[3][3] = { - {0.12, -1.92, 6.4}, - {3.84, 1.06, 4.8}, - {-3.2, 1.2, 6.0}, - }; - - // Displace in all directions. - constexpr double disp[3] = {1.0, -2.0, 0.5}; - - applyTransformation(coords, mtx, disp); - } - - // Expected 3-D metric. - static void setExpected(double (&exp)[3][3]) - { - exp[0][0] = 44.6608; - exp[0][1] = 29.1456; - exp[0][2] = 35.712; - - exp[1][0] = 29.1456; - exp[1][1] = 38.9092; - exp[1][2] = 17.784; - - exp[2][0] = 35.712; - exp[2][1] = 17.784; - exp[2][2] = 47.68; - } - - static void eval(double (&coords)[N][D]) - { - transformCoords(coords); - - double exp[D][D]{}; - setExpected(exp); - - testEval(coords, exp); - } -}; - -//---------------------------------------------------------------------------// -// Test residual and Jacobian evaluations. -template -class MetricTensorTest : public ::testing::Test -{ -}; -using EvalTypes - = ::testing::Types; -class EvalTypeNames -{ - public: - template - static std::string GetName(const int i) - { - if (std::is_same()) - return "Residual"; - if (std::is_same()) - return "Jacobian"; - return std::to_string(i); - } -}; -TYPED_TEST_SUITE(MetricTensorTest, EvalTypes, EvalTypeNames); - -//---------------------------------------------------------------------------// -// Test a 1-D line. -template class CellTest> -void testLine() -{ - // Ideal line. - double coords[2][1] = { - {0.0}, - {1.0}, - }; - - CellTest>::eval(coords); -} - -TYPED_TEST(MetricTensorTest, IdealLine) -{ - testLine(); -} - -TYPED_TEST(MetricTensorTest, IsotropicLine) -{ - testLine(); -} - -//---------------------------------------------------------------------------// -// Test a 2-D triangle. -template class CellTest> -void testTriangle() -{ - // Ideal triangle. - double coords[3][2] = { - {0.0, 0.0}, - {1.0, 0.0}, - {0.5, 0.5 * std::sqrt(3.0)}, - }; - - CellTest>::eval(coords); -} - -TYPED_TEST(MetricTensorTest, IdealTriangle) -{ - testTriangle(); -} - -TYPED_TEST(MetricTensorTest, IsotropicTriangle) -{ - testTriangle(); -} - -TYPED_TEST(MetricTensorTest, AnisotropicTriangle) -{ - testTriangle(); -} - -//---------------------------------------------------------------------------// -// Test a 2-D quadrilateral. -template class CellTest> -void testQuadrilateral() -{ - // Ideal quadrilateral. - double coords[4][2] = { - {0.0, 0.0}, - {1.0, 0.0}, - {1.0, 1.0}, - {0.0, 1.0}, - }; - - CellTest>::eval(coords); -} - -TYPED_TEST(MetricTensorTest, IdealQuadrilateral) -{ - testQuadrilateral(); -} - -TYPED_TEST(MetricTensorTest, IsotropicQuadrilateral) -{ - testQuadrilateral(); -} - -TYPED_TEST(MetricTensorTest, AnisotropicQuadrilateral) -{ - testQuadrilateral(); -} - -//---------------------------------------------------------------------------// -// Test a 3-D tetrahedron. -template class CellTest> -void testTetrahedron() -{ - // Ideal tetrahedron. - double coords[4][3] = { - {0.0, 0.0, 0.0}, - {1.0, 0.0, 0.0}, - {0.5, 0.5 * std::sqrt(3.0), 0.0}, - {0.5, 0.5 / std::sqrt(3.0), std::sqrt(2.0 / 3.0)}, - }; - - CellTest>::eval(coords); -} - -TYPED_TEST(MetricTensorTest, IdealTetrahedron) -{ - testTetrahedron(); -} - -TYPED_TEST(MetricTensorTest, IsotropicTetrahedron) -{ - testTetrahedron(); -} - -TYPED_TEST(MetricTensorTest, AnisotropicTetrahedron) -{ - testTetrahedron(); -} - -//---------------------------------------------------------------------------// -// Test a 3-D hexahedron. -template class CellTest> -void testHexahedron() -{ - // Ideal hexahedron. - double coords[8][3] = { - {0.0, 0.0, 0.0}, - {1.0, 0.0, 0.0}, - {1.0, 1.0, 0.0}, - {0.0, 1.0, 0.0}, - {0.0, 0.0, 1.0}, - {1.0, 0.0, 1.0}, - {1.0, 1.0, 1.0}, - {0.0, 1.0, 1.0}, - }; - - CellTest>::eval(coords); -} - -TYPED_TEST(MetricTensorTest, IdealHexahedron) -{ - testHexahedron(); -} - -TYPED_TEST(MetricTensorTest, IsotropicHexahedron) -{ - testHexahedron(); -} - -TYPED_TEST(MetricTensorTest, AnisotropicHexahedron) -{ - testHexahedron(); -} - -//---------------------------------------------------------------------------// -// Test a 3-D pyramid. -template class CellTest> -void testPyramid() -{ - // Ideal pyramid. - double coords[5][3] = { - {0.0, 0.0, 0.0}, - {1.0, 0.0, 0.0}, - {1.0, 1.0, 0.0}, - {0.0, 1.0, 0.0}, - {0.5, 0.5, 1.0 / std::sqrt(2.0)}, - }; - - // Pyramid cells are not currently supported by panzer. - ASSERT_THROW((CellTest>::eval(coords)), - std::runtime_error); -} - -TYPED_TEST(MetricTensorTest, IdealPyramid) -{ - testPyramid(); -} - -TYPED_TEST(MetricTensorTest, IsotropicPyramid) -{ - testPyramid(); -} - -TYPED_TEST(MetricTensorTest, AnisotropicPyramid) -{ - testPyramid(); -} - -//---------------------------------------------------------------------------// -// Test a 3-D wedge. -template class CellTest> -void testWedge() -{ - // Ideal wedge. - double coords[6][3] = { - {0.0, 0.0, 0.0}, - {1.0, 0.0, 0.0}, - {0.5, 0.5 * std::sqrt(3.0), 0.0}, - {0.0, 0.0, 1.0}, - {1.0, 0.0, 1.0}, - {0.5, 0.5 * std::sqrt(3.0), 1.0}, - }; - - // Wedge cells are not currently supported by panzer. - ASSERT_THROW((CellTest>::eval(coords)), - std::runtime_error); -} - -TYPED_TEST(MetricTensorTest, IdealWedge) -{ - testWedge(); -} - -TYPED_TEST(MetricTensorTest, IsotropicWedge) -{ - testWedge(); -} - -TYPED_TEST(MetricTensorTest, AnisotropicWedge) -{ - testWedge(); -} - -//---------------------------------------------------------------------------// -// Try to construct the evaluator for an unsupported cell topology. -template -void testUnsupportedTopology() -{ - // Set up an integration_rule for an unsupported cell topology. - // ShellQuadrilateral is the only topology supported by Intrepid but not - // by this closure model. - const panzer::IntegrationDescriptor integration_desc( - 0, panzer::IntegrationDescriptor::VOLUME); - auto cell_topo = Teuchos::rcp(new shards::CellTopology( - shards::getCellTopologyData>())); - const int num_cells = 0; - auto integration_rule = Teuchos::rcp( - new panzer::IntegrationRule(integration_desc, cell_topo, num_cells)); - - using MetricTensorEval - = ClosureModel::MetricTensor; - - const std::string msg = "Invalid base cell topology: ShellQuadrilateral_4"; - ASSERT_THROW( - try { - auto metric_tensor_eval = MetricTensorEval(*integration_rule); - } catch (const std::runtime_error& e) { - EXPECT_EQ(msg, e.what()); - throw; - }, - std::runtime_error); -} - -TYPED_TEST(MetricTensorTest, UnsupportedTopology) -{ - testUnsupportedTopology(); -} - -//---------------------------------------------------------------------------// -// Test construction from the closure model factory. -template -void testFactory() -{ - constexpr int num_space_dim = 2; - ClosureModelFactoryTestFixture test_fixture; - test_fixture.type_name = "MetricTensor"; - test_fixture.eval_name = "Metric Tensor"; - test_fixture.user_params.sublist("Fluid Properties") - .set("Kinematic viscosity", 0.1) - .set("Artificial compressibility", 2.0); - test_fixture.template buildAndTest< - ClosureModel::MetricTensor, - num_space_dim>(); -} - -TYPED_TEST(MetricTensorTest, Factory) -{ - testFactory(); -} - -} // namespace Test -} // namespace VertexCFD diff --git a/src/closure_models/unit_test/tstMetricTensorElementLength.cpp b/src/closure_models/unit_test/tstMetricTensorElementLength.cpp deleted file mode 100644 index 299d5d7..0000000 --- a/src/closure_models/unit_test/tstMetricTensorElementLength.cpp +++ /dev/null @@ -1,157 +0,0 @@ -#include -#include - -#include - -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include - -#include - -#include - -#include -#include - -//---------------------------------------------------------------------------// -// TESTS -//---------------------------------------------------------------------------// -namespace VertexCFD -{ -namespace Test -{ -//---------------------------------------------------------------------------// -// Test data dependencies. -template -struct Dependencies : public PHX::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - static constexpr double _unused - = std::numeric_limits::signaling_NaN(); - - PHX::MDField - _metric_tensor; - - Dependencies(const panzer::IntegrationRule& ir) - : _metric_tensor("metric_tensor", ir.dl_tensor) - { - this->addEvaluatedField(_metric_tensor); - this->setName("Metric Tensor Element Length Unit Test Dependencies"); - } - - void evaluateFields(typename panzer::Traits::EvalData d) override - { - Kokkos::parallel_for( - "metric tensor element length test dependencies", - Kokkos::RangePolicy(0, d.num_cells), - *this); - } - - KOKKOS_INLINE_FUNCTION void operator()(const int c) const - { - const int num_point = _metric_tensor.extent(1); - const int num_space_dim = _metric_tensor.extent(2); - for (int qp = 0; qp < num_point; ++qp) - { - for (int dim_i = 0; dim_i < num_space_dim; ++dim_i) - for (int dim_j = 0; dim_j < num_space_dim; ++dim_j) - _metric_tensor(c, qp, dim_i, dim_j) = _unused; - - for (int d = 0; d < num_space_dim; ++d) - { - _metric_tensor(c, qp, d, d) = 0.0625 * (d + 1) * (d + 1); - } - } - } -}; - -//---------------------------------------------------------------------------// -template -void testEval() -{ - // Setup test fixture. - const int num_space_dim = 2; - const int integration_order = 2; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - - // Create dependencies. - auto dep_eval = Teuchos::rcp(new Dependencies(*test_fixture.ir)); - test_fixture.registerEvaluator(dep_eval); - - // Create evaluator. - auto metric_tensor_eval = Teuchos::rcp( - new ClosureModel::MetricTensorElementLength( - *test_fixture.ir)); - test_fixture.registerEvaluator(metric_tensor_eval); - - // Add required test fields. - test_fixture.registerTestField( - metric_tensor_eval->_element_length); - - // Evaluate metric tensor. - test_fixture.evaluate(); - - // Check the metric tensor. - auto element_length_result = test_fixture.getTestFieldData( - metric_tensor_eval->_element_length); - int num_point = element_length_result.extent(1); - for (int qp = 0; qp < num_point; ++qp) - { - EXPECT_DOUBLE_EQ(0.25, fieldValue(element_length_result, 0, qp, 0)); - EXPECT_DOUBLE_EQ(0.50, fieldValue(element_length_result, 0, qp, 1)); - } -} - -//---------------------------------------------------------------------------// -TEST(MetricTensorElementLength, residual_test) -{ - testEval(); -} - -//---------------------------------------------------------------------------// -TEST(MetricTensorElementLength, jacobian_test) -{ - testEval(); -} - -//---------------------------------------------------------------------------// - -template -void testFactory() -{ - constexpr int num_space_dim = NumSpaceDim; - ClosureModelFactoryTestFixture test_fixture; - test_fixture.type_name = "MetricTensorElementLength"; - test_fixture.eval_name = "Metric Tensor Element Length"; - test_fixture.user_params.sublist("Fluid Properties") - .set("Kinematic viscosity", 0.1) - .set("Artificial compressibility", 2.0); - test_fixture.template buildAndTest< - ClosureModel::MetricTensorElementLength, - num_space_dim>(); -} - -TEST(MetricTensorElementLength_Factory2D, residual_test) -{ - testFactory(); -} - -TEST(MetricTensorElementLength_Factory2D, jacobian_test) -{ - testFactory(); -} - -} // end namespace Test -} // end namespace VertexCFD diff --git a/src/closure_models/unit_test/tstSingularValueElementLength.cpp b/src/closure_models/unit_test/tstSingularValueElementLength.cpp deleted file mode 100644 index c4eb2c7..0000000 --- a/src/closure_models/unit_test/tstSingularValueElementLength.cpp +++ /dev/null @@ -1,186 +0,0 @@ -#include -#include - -#include - -#include -#include - -#include -#include -#include - -#include -#include - -#include - -#include - -#include - -//---------------------------------------------------------------------------// -// TESTS -//---------------------------------------------------------------------------// -namespace VertexCFD -{ -namespace Test -{ -//---------------------------------------------------------------------------// -template -void testEval(const std::string method) -{ - // Setup test fixture. - int num_space_dim = 2; - const int integration_order = 2; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - - // Overwrite Jacobian values with trivial values for each quadrature points - // test_fixture.int_values->jac(cell, qp, i, j) - auto jac_view = test_fixture.int_values->jac.get_static_view(); - auto jac_mirror = Kokkos::create_mirror(jac_view); - - // qp = 0 - jac_mirror(0, 0, 0, 0) = 4.0; - jac_mirror(0, 0, 0, 1) = 0.0; - jac_mirror(0, 0, 1, 0) = 0.0; - jac_mirror(0, 0, 1, 1) = 9.0; - - // qp = 1 - jac_mirror(0, 1, 0, 0) = 2.0; - jac_mirror(0, 1, 0, 1) = 6.0; - jac_mirror(0, 1, 1, 0) = 6.0; - jac_mirror(0, 1, 1, 1) = 2.0; - - // qp = 2 - jac_mirror(0, 2, 0, 0) = -0.2; - jac_mirror(0, 2, 0, 1) = 0.3; - jac_mirror(0, 2, 1, 0) = 0.4; - jac_mirror(0, 2, 1, 1) = 0.5; - - // qp = 3 - jac_mirror(0, 3, 0, 0) = 2.0; - jac_mirror(0, 3, 0, 1) = -2.0; - jac_mirror(0, 3, 1, 0) = -2.0; - jac_mirror(0, 3, 1, 1) = 2.0; - - Kokkos::deep_copy(jac_view, jac_mirror); - - // Create evaluator. - auto singular_value_element_length_eval = Teuchos::rcp( - new ClosureModel::SingularValueElementLength( - *test_fixture.ir, method)); - test_fixture.registerEvaluator( - singular_value_element_length_eval); - - // Add required test fields. - test_fixture.registerTestField( - singular_value_element_length_eval->_element_length); - - // Evaluate MFEM element length. - test_fixture.evaluate(); - - // Check the MFEM element length. - auto element_length_result = test_fixture.getTestFieldData( - singular_value_element_length_eval->_element_length); - int num_point = element_length_result.extent(1); - // Reference values 'sigma' - Kokkos::Array sigma; - sigma[0] = method == "singular_value_max" ? 9.0 : 4.0; - sigma[1] = method == "singular_value_max" ? 8.0 : 4.0; - sigma[2] = method == "singular_value_max" ? 0.65308862983900229 - : 0.33686086382216435; - sigma[3] = method == "singular_value_max" ? 4.0 : 0.0; - for (int qp = 0; qp < num_point; ++qp) - { - EXPECT_DOUBLE_EQ(sigma[qp], - fieldValue(element_length_result, 0, qp, 0)); - EXPECT_DOUBLE_EQ(sigma[qp], - fieldValue(element_length_result, 0, qp, 1)); - } -} - -template -void testCatchException(const std::string method) -{ - const std::string msg - = "Element Length Method 'None' is not a correct input.\n" - "Choose between 'singular_value_min' or 'singular_value_max'"; - - EXPECT_THROW( - try { testEval(method); } catch (const std::runtime_error& e) { - EXPECT_EQ(msg, e.what()); - throw; - }, - std::runtime_error); -} - -//---------------------------------------------------------------------------// -TEST(SingularValueElementLengthMax, residual_test) -{ - testEval("singular_value_max"); -} - -//---------------------------------------------------------------------------// -TEST(SingularValueElementLengthMin, residual_test) -{ - testEval("singular_value_min"); -} - -//---------------------------------------------------------------------------// -TEST(SingularValueElementLengthNone, residual_test) -{ - testCatchException("None"); -} - -//---------------------------------------------------------------------------// -TEST(SingularValueElementLengthMax, jacobian_test) -{ - testEval("singular_value_max"); -} - -//---------------------------------------------------------------------------// -TEST(SingularValueElementLengthMin, jacobian_test) -{ - testEval("singular_value_min"); -} - -//---------------------------------------------------------------------------// -TEST(SingularValueElementLengthNone, jacobian_test) -{ - testCatchException("None"); -} - -//---------------------------------------------------------------------------// - -template -void testFactory() -{ - constexpr int num_space_dim = NumSpaceDim; - ClosureModelFactoryTestFixture test_fixture; - test_fixture.type_name = "SingularValueElementLength"; - test_fixture.eval_name = "Singular Value Element Length"; - test_fixture.model_params.set("Element Length Method", - "singular_value_min"); - test_fixture.user_params.sublist("Fluid Properties") - .set("Kinematic viscosity", 0.1) - .set("Artificial compressibility", 2.0); - test_fixture.template buildAndTest< - ClosureModel::SingularValueElementLength, - num_space_dim>(); -} - -TEST(SingularValueElementLength_Factory2D, residual_test) -{ - testFactory(); -} - -TEST(SingularValueElementLength_Factory2D, jacobian_test) -{ - testFactory(); -} - -} // end namespace Test -} // end namespace VertexCFD diff --git a/src/closure_models/unit_test/tstVectorFieldDivergence.cpp b/src/closure_models/unit_test/tstVectorFieldDivergence.cpp deleted file mode 100644 index 98d0c5e..0000000 --- a/src/closure_models/unit_test/tstVectorFieldDivergence.cpp +++ /dev/null @@ -1,203 +0,0 @@ -#include -#include - -#include - -#include "closure_models/VertexCFD_Closure_VectorFieldDivergence.hpp" - -#include - -namespace VertexCFD -{ -namespace Test -{ -template -struct Dependencies : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - using scalar_type = typename EvalType::ScalarT; - double _nanval = std::numeric_limits::quiet_NaN(); - - Kokkos::Array< - PHX::MDField, - 3> - grad_test_field; - - Dependencies(const panzer::IntegrationRule& ir, - const std::string field_name) - { - Utils::addEvaluatedVectorField( - *this, ir.dl_vector, grad_test_field, "GRAD_" + field_name + "_"); - - this->setName("Vector Field Divergence Unit Test Dependencies"); - } - - void evaluateFields(typename panzer::Traits::EvalData d) override - { - Kokkos::parallel_for( - "vector field divergence test dependencies", - Kokkos::RangePolicy(0, d.num_cells), - *this); - } - - KOKKOS_INLINE_FUNCTION void operator()(const int c) const - { - const int num_point = grad_test_field[0].extent(1); - const int num_grad_dim = grad_test_field[0].extent(2); - for (int qp = 0; qp < num_point; ++qp) - { - const double qp1 = qp + 1.0; - for (int dim = 0; dim < num_grad_dim; ++dim) - { - const double dqp1 = qp1 * (dim + 1.0); - grad_test_field[0](c, qp, dim) = 0.375 * dqp1; - grad_test_field[1](c, qp, dim) = 0.225 * dqp1; - grad_test_field[2](c, qp, dim) - = num_grad_dim == 2 ? _nanval : 0.125 * dqp1; - } - } - } -}; - -template -void testEval(const int num_grad_dim, - const std::string& field_name, - const bool use_abs) -{ - const int integration_order = 2; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_grad_dim, integration_order, basis_order); - - auto& ir = *test_fixture.ir; - - auto deps = Teuchos::rcp(new Dependencies(ir, field_name)); - test_fixture.registerEvaluator(deps); - - const std::string closure_name = use_abs ? "AbsVectorFieldDivergence" - : "VectorFieldDivergence"; - const auto eval = Teuchos::rcp( - new ClosureModel::VectorFieldDivergence( - ir, field_name, closure_name)); - test_fixture.registerEvaluator(eval); - - test_fixture.registerTestField(eval->_vector_field_divergence); - - test_fixture.evaluate(); - - const auto div_field = test_fixture.getTestFieldData( - eval->_vector_field_divergence); - - const auto grad_test_field_0 - = test_fixture.getTestFieldData(deps->grad_test_field[0]); - const auto grad_test_field_1 - = test_fixture.getTestFieldData(deps->grad_test_field[1]); - const auto grad_test_field_2 - = test_fixture.getTestFieldData(deps->grad_test_field[2]); - - const int num_point = ir.num_points; - - // Assert values - for (int qp = 0; qp < num_point; ++qp) - { - auto exp_div = fieldValue(grad_test_field_0, 0, qp, 0) - + fieldValue(grad_test_field_1, 0, qp, 1); - if (num_grad_dim > 2) - exp_div += fieldValue(grad_test_field_2, 0, qp, 2); - if (use_abs) - exp_div = std::abs(exp_div); - EXPECT_DOUBLE_EQ(exp_div, fieldValue(div_field, 0, qp)); - } -} - -//-----------------------------------------------------------------// -TEST(Vector2DDivergence2D, residual_test) -{ - testEval(2, "foo", false); -} - -TEST(Vector2DDivergence2D, jacobian_test) -{ - testEval(2, "foo", false); -} - -//-----------------------------------------------------------------// -TEST(Vector3DDivergence2D, residual_test) -{ - testEval(2, "foo", false); -} - -TEST(Vector3DDivergence2D, jacobian_test) -{ - testEval(2, "foo", false); -} -//-----------------------------------------------------------------// -TEST(Vector3DDivergence3D, residual_test) -{ - testEval(3, "bar", false); -} - -TEST(Vector3DDivergence3D, jacobian_test) -{ - testEval(3, "bar", false); -} - -//-----------------------------------------------------------------// -TEST(Vector3DAbsDivergence3D, residual_test) -{ - testEval(3, "bar", true); -} - -TEST(Vector3DAbsDivergence3D, jacobian_test) -{ - testEval(3, "bar", true); -} -//-----------------------------------------------------------------// -template -void testFactory(const std::string& abs_pre = "") -{ - constexpr int num_grad_dim = NumGradDim; - ClosureModelFactoryTestFixture test_fixture; - test_fixture.user_params.sublist("Fluid Properties") - .set("Kinematic viscosity", 0.1) - .set("Artificial compressibility", 2.0); - test_fixture.type_name = abs_pre + "VectorFieldDivergence"; - test_fixture.eval_name = "Vector Field Divergence 2D"; - test_fixture.model_params.set("Field Names", "foo"); - test_fixture.template buildAndTest< - ClosureModel::VectorFieldDivergence, - num_grad_dim>(); -} - -TEST(VectorFieldDivergence_Factory2D, residual_test) -{ - testFactory(); -} - -TEST(VectorFieldDivergence_Factory2D, jacobian_test) -{ - testFactory(); -} - -TEST(VectorFieldDivergence_Factory3D, residual_test) -{ - testFactory(); -} - -TEST(VectorFieldDivergence_Factory3D, jacobian_test) -{ - testFactory(); -} - -TEST(VectorFieldAbsDivergence_Factory3D, residual_test) -{ - testFactory("Abs"); -} - -TEST(VectorFieldAbsDivergence_Factory3D, jacobian_test) -{ - testFactory("Abs"); -} - -} // namespace Test -} // namespace VertexCFD diff --git a/src/closure_models/unit_test/tstWallDistance.cpp b/src/closure_models/unit_test/tstWallDistance.cpp deleted file mode 100644 index 6304d0f..0000000 --- a/src/closure_models/unit_test/tstWallDistance.cpp +++ /dev/null @@ -1,222 +0,0 @@ -#include -#include - -#include "utils/VertexCFD_Utils_SmoothMath.hpp" -#include -#include - -#include -#include - -#include - -namespace VertexCFD -{ -namespace Test -{ -template -struct Dependencies : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - using scalar_type = typename EvalType::ScalarT; - - int _num_space_dim; - - PHX::MDField _exp_distance; - PHX::MDField _ip_coords; - - int _ir_degree; - - Dependencies(const panzer::IntegrationRule& ir) - : _num_space_dim(ir.spatial_dimension) - , _exp_distance("exp_distance", ir.dl_scalar) - , _ir_degree(ir.cubature_degree) - { - this->addEvaluatedField(_exp_distance); - - this->setName("Wall Distance Unit Test Dependencies"); - } - - void evaluateFields(typename panzer::Traits::EvalData d) override - { - auto _ir_index = panzer::getIntegrationRuleIndex(_ir_degree, d); - _ip_coords = d.int_rules[_ir_index]->ip_coordinates; - Kokkos::parallel_for( - "Wall Distance Unit Test Dependencies", - Kokkos::RangePolicy(0, d.num_cells), - *this); - } - - KOKKOS_INLINE_FUNCTION void operator()(const int c) const - { - const int num_point = _exp_distance.extent(1); - for (int qp = 0; qp < num_point; ++qp) - { - double y_dist = 1 - std::abs(_ip_coords(c, qp, 1)); - double z_dist = 1e8; - if (_num_space_dim == 3) - { - z_dist = 1 - std::abs(_ip_coords(c, qp, 2)); - } - _exp_distance(c, qp) = std::fmin(y_dist, z_dist); - } - } -}; - -template -void testEval(const std::string element_type) -{ - constexpr int num_space_dim = NumSpaceDim; - const int integration_order = 2; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - - auto& ir = *test_fixture.ir; - - // Construct Mesh parameters and manager - auto comm = Teuchos::rcp_dynamic_cast>( - Teuchos::DefaultComm::getComm()); - - // Make an empty parameter database and build mesh parameters. - Parameter::ParameterDatabase parameter_db(comm); - auto mesh_params = parameter_db.meshParameters(); - mesh_params->set("Mesh Input Type", "Inline"); - auto& inline_params = mesh_params->sublist("Inline"); - inline_params.set("Element Type", element_type); - auto& mesh_details = inline_params.sublist("Mesh"); - const int nelem_x = 2; - const int nelem_y = 2; - const int nelem_z = 2; - mesh_details.set("X0", 0.0); - mesh_details.set("Xf", 1.0); - mesh_details.set("X Elements", nelem_x); - mesh_details.set("Y0", -1.0); - mesh_details.set("Yf", 1.0); - mesh_details.set("Y Elements", nelem_y); - if (num_space_dim == 3) - { - mesh_details.set("Z0", -1.0); - mesh_details.set("Zf", 1.0); - mesh_details.set("Z Elements", nelem_z); - } - - Teuchos::RCP mesh_manager{ - Teuchos::rcp(new MeshManager(parameter_db, comm))}; - mesh_manager->completeMeshConstruction(); - - Teuchos::ParameterList closure_params; - closure_params.set("Wall Names", "top,bottom,front,back"); - - const auto dep_eval = Teuchos::rcp(new Dependencies(ir)); - test_fixture.registerEvaluator(dep_eval); - test_fixture.registerTestField(dep_eval->_exp_distance); - - // Initialize and register closure model - auto eval = Teuchos::rcp( - new ClosureModel::WallDistance( - ir, mesh_manager, closure_params)); - test_fixture.registerEvaluator(eval); - test_fixture.registerTestField(eval->_distance); - - test_fixture.evaluate(); - - // Evaluate and assert closure model values - auto fv_dist = test_fixture.getTestFieldData(eval->_distance); - auto fv_exp_dist - = test_fixture.getTestFieldData(dep_eval->_exp_distance); - - const int num_point = ir.num_points; - for (int qp = 0; qp < num_point; ++qp) - { - // Wall distance - EXPECT_EQ(fieldValue(fv_exp_dist, 0, qp), fieldValue(fv_dist, 0, qp)); - } -} - -//-----------------------------------------------------------------// -TEST(WallDistanceTet4, residual_test) -{ - testEval("Tet4"); -} - -//-----------------------------------------------------------------// -TEST(WallDistanceTet4, jacobian_test) -{ - testEval("Tet4"); -} - -//-----------------------------------------------------------------// -TEST(WallDistanceTri3, residual_test) -{ - testEval("Tri3"); -} - -//-----------------------------------------------------------------// -TEST(WallDistanceTri3, jacobian_test) -{ - testEval("Tri3"); -} - -//-----------------------------------------------------------------// -TEST(WallDistanceHex8, residual_test) -{ - testEval("Hex8"); -} - -//-----------------------------------------------------------------// -TEST(WallDistanceHex8, jacobian_test) -{ - testEval("Hex8"); -} - -//-----------------------------------------------------------------// -TEST(WallDistanceQuad4, residual_test) -{ - testEval("Quad4"); -} - -//-----------------------------------------------------------------// -TEST(WallDistanceQuad4, jacobian_test) -{ - testEval("Quad4"); -} - -template -void testFactory() -{ - constexpr int num_space_dim = NumSpaceDim; - ClosureModelFactoryTestFixture test_fixture; - test_fixture.type_name = "WallDistance"; - test_fixture.eval_name = "distance"; - test_fixture.user_params.sublist("Fluid Properties") - .set("Kinematic viscosity", 0.1) - .set("Artificial compressibility", 2.0); - test_fixture.model_params.set("Wall Names", "dummy"); - test_fixture.template buildAndTest< - ClosureModel::WallDistance, - num_space_dim>(); -} - -TEST(WallDistance_Factory3D, residual_test) -{ - testFactory(); -} - -TEST(WallDistance_Factory3D, jacobian_test) -{ - testFactory(); -} - -TEST(WallDistance_Factory2D, residual_test) -{ - testFactory(); -} - -TEST(WallDistance_Factory2D, jacobian_test) -{ - testFactory(); -} - -} // namespace Test -} // namespace VertexCFD diff --git a/src/drivers/VertexCFD_ExternalFieldsManager.hpp b/src/drivers/VertexCFD_ExternalFieldsManager.hpp deleted file mode 100644 index b7ce44e..0000000 --- a/src/drivers/VertexCFD_ExternalFieldsManager.hpp +++ /dev/null @@ -1,48 +0,0 @@ -#ifndef VERTEXCFD_EXTERNALFIELDSMANAGER_HPP -#define VERTEXCFD_EXTERNALFIELDSMANAGER_HPP - -#include - -#include - -#include - -#include -#include - -#include - -#include -#include - -namespace VertexCFD -{ -//---------------------------------------------------------------------------// -template -class ExternalFieldsManager -{ - public: - template - ExternalFieldsManager( - const std::integral_constant& num_space_dim, - const Teuchos::RCP>& comm, - const std::string& filename); - - Teuchos::RCP globalIndexer() const; - Kokkos::View ghostedFieldData() const; - - private: - // External global indexer (DOF manager). - Teuchos::RCP _global_indexer; - - // Gathered local field values. - Kokkos::View _ghosted_field_data; -}; - -//---------------------------------------------------------------------------// - -} // end namespace VertexCFD - -#include "VertexCFD_ExternalFieldsManager_impl.hpp" - -#endif // end VERTEXCFD_EXTERNALFIELDSMANAGER_HPP diff --git a/src/drivers/VertexCFD_ExternalFieldsManager_impl.hpp b/src/drivers/VertexCFD_ExternalFieldsManager_impl.hpp deleted file mode 100644 index aec6cef..0000000 --- a/src/drivers/VertexCFD_ExternalFieldsManager_impl.hpp +++ /dev/null @@ -1,84 +0,0 @@ -#ifndef VERTEXCFD_EXTERNALFIELDSMANAGER_IMPL_HPP -#define VERTEXCFD_EXTERNALFIELDSMANAGER_IMPL_HPP - -#include "VertexCFD_InitialConditionManager.hpp" -#include "VertexCFD_MeshManager.hpp" -#include "VertexCFD_PhysicsManager.hpp" -#include "parameters/VertexCFD_ParameterDatabase.hpp" - -#include - -#include - -namespace VertexCFD -{ -//---------------------------------------------------------------------------// -template -template -ExternalFieldsManager::ExternalFieldsManager( - const std::integral_constant& num_space_dim, - const Teuchos::RCP>& comm, - const std::string& filename) -{ - auto parameter_db - = Teuchos::rcp(new Parameter::ParameterDatabase(comm, filename)); - auto mesh_manager = Teuchos::rcp(new MeshManager(*parameter_db, comm)); - auto physics_manager = Teuchos::rcp( - new PhysicsManager(num_space_dim, parameter_db, mesh_manager)); - physics_manager->setupModel(); - - _global_indexer = physics_manager->dofManager(); - - auto ic_manager = Teuchos::rcp( - new InitialConditionManager(parameter_db, mesh_manager)); - Teuchos::RCP> solution; - Teuchos::RCP> solution_dot; - ic_manager->applyInitialConditions( - num_space_dim, *physics_manager, solution, solution_dot); - - // Create a global evaluation container for the field data. - Teuchos::RCP ged; - ged = physics_manager->linearObjectFactory()->buildReadOnlyDomainContainer(); - ged->setOwnedVector(solution); - - // Gather the ghosted vector of field data. - ged->globalToGhost(0); - - // Get the local vector data. - auto ghosted_vector - = Teuchos::rcp_dynamic_cast>( - ged->getGhostedVector()); - auto ghosted_data_host = ghosted_vector->getLocalSubVector(); - - // Thyra only provides the ghosted data via a host-side array. - // We need to copy this data to a device view so that it can be accessed - // from the device in kernel below. - _ghosted_field_data = Kokkos::View( - "ghosted_field_data", ghosted_data_host.subDim()); - auto ghost_mirror = Kokkos::create_mirror(_ghosted_field_data); - for (int i = 0; i < ghosted_data_host.subDim(); ++i) - ghost_mirror(i) = ghosted_data_host[i]; - Kokkos::deep_copy(_ghosted_field_data, ghost_mirror); -} - -//---------------------------------------------------------------------------// -template -Teuchos::RCP -ExternalFieldsManager::globalIndexer() const -{ - return _global_indexer; -} - -//---------------------------------------------------------------------------// -template -Kokkos::View -ExternalFieldsManager::ghostedFieldData() const -{ - return _ghosted_field_data; -} - -//---------------------------------------------------------------------------// - -} // end namespace VertexCFD - -#endif // end VERTEXCFD_EXTERNALFIELDSMANAGER_IMPL_HPP diff --git a/src/drivers/VertexCFD_InitialConditionManager.cpp b/src/drivers/VertexCFD_InitialConditionManager.cpp deleted file mode 100644 index f9f66f2..0000000 --- a/src/drivers/VertexCFD_InitialConditionManager.cpp +++ /dev/null @@ -1,124 +0,0 @@ -#include "VertexCFD_InitialConditionManager.hpp" - -namespace VertexCFD -{ -//---------------------------------------------------------------------------// -InitialConditionManager::InitialConditionManager( - const Teuchos::RCP& parameter_db, - const Teuchos::RCP& mesh_manager) - : _parameter_db(parameter_db) - , _mesh_manager(mesh_manager) - , _do_restart(false) - , _t_init(0.0) -{ - // Create restart reader if needed and get the starting time. - auto read_restart_params = _parameter_db->readRestartParameters(); - if (Teuchos::nonnull(read_restart_params)) - { - if (read_restart_params->isType("Read Restart")) - { - _do_restart = read_restart_params->get("Read Restart"); - } - if (_do_restart) - { - auto comm = mesh_manager->comm(); - _restart_reader = Teuchos::rcp(new VertexCFD::Mesh::RestartReader( - comm, *read_restart_params)); - _t_init = _restart_reader->initialStateTime(); - } - } -} - -//---------------------------------------------------------------------------// -double InitialConditionManager::initialTime() const -{ - return _t_init; -} - -//---------------------------------------------------------------------------// -template -void InitialConditionManager::applyInitialConditions( - const std::integral_constant&, - const PhysicsManager& physics_manager, - Teuchos::RCP>& x, - Teuchos::RCP>& x_dot) const -{ - // Initialize 'num_space_dim' with template value - constexpr int num_space_dim = NumSpaceDim; - - // Create vectors if needed. - if (Teuchos::is_null(x)) - { - x = Thyra::createMember( - physics_manager.modelEvaluator()->get_x_space()); - } - if (Teuchos::is_null(x_dot)) - { - x_dot = Thyra::createMember( - physics_manager.modelEvaluator()->get_x_space()); - } - - // Set initial conditions from restart. - if (_do_restart) - { - auto mesh = _mesh_manager->mesh(); - auto dof_manager = physics_manager.dofManager(); - _restart_reader->readSolution(mesh, dof_manager, x, x_dot); - } - - // Set initial conditions from input. - else - { - auto workset_container = physics_manager.worksetContainer(); - auto linear_object_factory = physics_manager.linearObjectFactory(); - auto physics_blocks = physics_manager.physicsBlocks(); - auto user_params = _parameter_db->userParameters(); - auto ic_params = _parameter_db->initialConditionParameters(); - bool write_graph = user_params->get("Output Graph"); - VertexCFD::InitialCondition::FactoryTemplateBuilder - ic_builder(_mesh_manager->mesh()); - panzer::ClosureModelFactory_TemplateManager ic_factory; - ic_factory.buildObjects(ic_builder); - std::map>> - phx_ic_field_managers; - panzer::setupInitialConditionFieldManagers(*workset_container, - physics_blocks, - ic_factory, - *ic_params, - *linear_object_factory, - *user_params, - write_graph, - "", - phx_ic_field_managers); - Teuchos::RCP linear_object_container - = linear_object_factory->buildLinearObjContainer(); - Teuchos::RCP> thyra_loc - = Teuchos::rcp_dynamic_cast>( - linear_object_container); - thyra_loc->set_x_th(x); - panzer::evaluateInitialCondition(*workset_container, - phx_ic_field_managers, - linear_object_container, - *linear_object_factory, - _t_init); - Thyra::assign(x_dot.ptr(), 0.0); - } -} - -//---------------------------------------------------------------------------// -// Explicit instantiation of 'applyInitialConditions' -template void InitialConditionManager::applyInitialConditions( - const std::integral_constant&, - const PhysicsManager& physics_manager, - Teuchos::RCP>& x, - Teuchos::RCP>& x_dot) const; - -template void InitialConditionManager::applyInitialConditions( - const std::integral_constant&, - const PhysicsManager& physics_manager, - Teuchos::RCP>& x, - Teuchos::RCP>& x_dot) const; - -//---------------------------------------------------------------------------// - -} // end namespace VertexCFD diff --git a/src/drivers/VertexCFD_InitialConditionManager.hpp b/src/drivers/VertexCFD_InitialConditionManager.hpp deleted file mode 100644 index c7c1795..0000000 --- a/src/drivers/VertexCFD_InitialConditionManager.hpp +++ /dev/null @@ -1,48 +0,0 @@ -#ifndef VERTEXCFD_INITIALCONDITIONMANAGER_HPP -#define VERTEXCFD_INITIALCONDITIONMANAGER_HPP - -#include "VertexCFD_MeshManager.hpp" -#include "VertexCFD_PhysicsManager.hpp" - -#include "initial_conditions/VertexCFD_InitialConditionFactory_TemplateBuilder.hpp" -#include "mesh/VertexCFD_Mesh_Restart.hpp" -#include "parameters/VertexCFD_ParameterDatabase.hpp" - -#include - -#include - -#include - -namespace VertexCFD -{ -//---------------------------------------------------------------------------// -class InitialConditionManager -{ - public: - InitialConditionManager( - const Teuchos::RCP& parameter_db, - const Teuchos::RCP& mesh_manager); - - double initialTime() const; - - template - void - applyInitialConditions(const std::integral_constant&, - const PhysicsManager& physics_manager, - Teuchos::RCP>& x, - Teuchos::RCP>& x_dot) const; - - private: - Teuchos::RCP _parameter_db; - Teuchos::RCP _mesh_manager; - Teuchos::RCP _restart_reader; - bool _do_restart; - double _t_init; -}; - -//---------------------------------------------------------------------------// - -} // end namespace VertexCFD - -#endif // end VERTEXCFD_INITIALCONDITIONMANAGER_HPP diff --git a/src/drivers/VertexCFD_MeshManager.cpp b/src/drivers/VertexCFD_MeshManager.cpp deleted file mode 100644 index bce89af..0000000 --- a/src/drivers/VertexCFD_MeshManager.cpp +++ /dev/null @@ -1,117 +0,0 @@ -#include "VertexCFD_MeshManager.hpp" -#include "mesh/VertexCFD_Mesh_StkReaderFactory.hpp" - -#include - -namespace VertexCFD -{ -//---------------------------------------------------------------------------// -MeshManager::MeshManager(const Parameter::ParameterDatabase& parameter_db, - const Teuchos::RCP>& comm) - : _comm(comm) -{ - auto mesh_params = parameter_db.meshParameters(); - - if ("File" == mesh_params->get("Mesh Input Type")) - { - _mesh_factory = Teuchos::rcp(new VertexCFD::Mesh::StkReaderFactory()); - auto file_params - = Teuchos::parameterList(mesh_params->sublist("File")); - _mesh_factory->setParameterList(file_params); - } - else if ("Inline" == mesh_params->get("Mesh Input Type")) - { - auto inline_params - = Teuchos::parameterList(mesh_params->sublist("Inline")); - - // Initialize integer to store mesh dimension - int mesh_dimension = 0; - - if ("Tri3" == inline_params->get("Element Type")) - { - _mesh_factory - = Teuchos::rcp(new panzer_stk::SquareTriMeshFactory()); - mesh_dimension = 2; - } - else if ("Quad4" == inline_params->get("Element Type")) - { - _mesh_factory - = Teuchos::rcp(new panzer_stk::SquareQuadMeshFactory()); - mesh_dimension = 2; - } - else if ("Tet4" == inline_params->get("Element Type")) - { - _mesh_factory = Teuchos::rcp(new panzer_stk::CubeTetMeshFactory()); - mesh_dimension = 3; - } - else if ("Hex8" == inline_params->get("Element Type")) - { - _mesh_factory = Teuchos::rcp(new panzer_stk::CubeHexMeshFactory()); - mesh_dimension = 3; - } - else - { - throw std::runtime_error( - "Invalid inline element type. Valid options are " - "'Tri3', " - "'Quad4', 'Tet4' and 'Hex8'"); - } - auto inline_mesh_params - = Teuchos::parameterList(inline_params->sublist("Mesh")); - - if (mesh_dimension > 1) - { - inline_mesh_params->set("X Procs", -1); - inline_mesh_params->set("Y Procs", -1); - } - if (mesh_dimension > 2) - { - inline_mesh_params->set("Z Procs", -1); - } - _mesh_factory->setParameterList(inline_mesh_params); - } - else - { - throw std::runtime_error( - "Invalid mesh input type. Valid options are 'File' and 'Inline'"); - } - - _mesh = _mesh_factory->buildUncommitedMesh(Teuchos::getRawMpiComm(*_comm)); -} - -//---------------------------------------------------------------------------// -void MeshManager::completeMeshConstruction() -{ - _mesh_factory->completeMeshConstruction(*_mesh, - Teuchos::getRawMpiComm(*_comm)); - _conn_manager = Teuchos::rcp(new panzer_stk::STKConnManager(_mesh)); -} - -//---------------------------------------------------------------------------// -Teuchos::RCP> MeshManager::comm() const -{ - return _comm; -} - -//---------------------------------------------------------------------------// -Teuchos::RCP MeshManager::mesh() const -{ - return _mesh; -} - -//---------------------------------------------------------------------------// -Teuchos::RCP -MeshManager::connectivityManager() const -{ - return _conn_manager; -} - -//---------------------------------------------------------------------------// -int MeshManager::spaceDimension() const -{ - return static_cast(_mesh->getDimension()); -} - -//---------------------------------------------------------------------------// - -} // end namespace VertexCFD diff --git a/src/drivers/VertexCFD_MeshManager.hpp b/src/drivers/VertexCFD_MeshManager.hpp deleted file mode 100644 index 86b3500..0000000 --- a/src/drivers/VertexCFD_MeshManager.hpp +++ /dev/null @@ -1,48 +0,0 @@ -#ifndef VERTEXCFD_MESHMANAGER_HPP -#define VERTEXCFD_MESHMANAGER_HPP - -#include "parameters/VertexCFD_ParameterDatabase.hpp" - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -namespace VertexCFD -{ -//---------------------------------------------------------------------------// -class MeshManager -{ - public: - MeshManager(const Parameter::ParameterDatabase& parameter_db, - const Teuchos::RCP>& comm); - - void completeMeshConstruction(); - - Teuchos::RCP> comm() const; - Teuchos::RCP mesh() const; - Teuchos::RCP connectivityManager() const; - - int spaceDimension() const; - - private: - Teuchos::RCP> _comm; - Teuchos::RCP _mesh_factory; - Teuchos::RCP _mesh; - Teuchos::RCP _conn_manager; -}; - -//---------------------------------------------------------------------------// - -} // end namespace VertexCFD - -#endif // end VERTEXCFD_MESHMANAGER_HPP diff --git a/src/drivers/VertexCFD_PhysicsManager.cpp b/src/drivers/VertexCFD_PhysicsManager.cpp deleted file mode 100644 index b1332bd..0000000 --- a/src/drivers/VertexCFD_PhysicsManager.cpp +++ /dev/null @@ -1,333 +0,0 @@ -#include "VertexCFD_PhysicsManager.hpp" -#include "boundary_conditions/VertexCFD_BCStrategy_Factory.hpp" -#include "closure_models/VertexCFD_ClosureModelFactory_TemplateBuilder.hpp" -#include "equation_sets/VertexCFD_EquationSet_Factory.hpp" -#include "linear_solvers/VertexCFD_LinearSolvers_LOWSFactoryBuilder.hpp" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -namespace VertexCFD -{ -//---------------------------------------------------------------------------// -template -PhysicsManager::PhysicsManager( - const std::integral_constant&, - const Teuchos::RCP& parameter_db, - const Teuchos::RCP& mesh_manager, - const double initial_time) - : _parameter_db(parameter_db) - , _mesh_manager(mesh_manager) - , _t_init(initial_time) - , _global_data(panzer::createGlobalData()) - , _integration_order(-1) -{ - // Initialize 'num_space_dim' with template value - constexpr int num_space_dim = NumSpaceDim; - - // Get physics communicator. - auto comm = _mesh_manager->comm(); - - // Get user parameters. - auto user_params = _parameter_db->userParameters(); - - // Map element blocks to physics blocks. - auto mesh = _mesh_manager->mesh(); - const auto block_mapping_params = _parameter_db->blockMappingParameters(); - std::map block_ids_to_physics_ids; - panzer::buildBlockIdToPhysicsIdMap(block_ids_to_physics_ids, - *block_mapping_params); - std::map> - block_ids_to_cell_topo; - for (auto itr(block_ids_to_physics_ids.begin()); - itr != block_ids_to_physics_ids.end(); - ++itr) - { - block_ids_to_cell_topo[itr->first] = mesh->getCellTopology(itr->first); - } - - // Get physics parameters. - const auto physics_params = _parameter_db->physicsParameters(); - - // Build the physics blocks. Create defaults for some options that may be - // overwritten by inputs. - const int workset_size = user_params->get("Workset Size"); - const int default_integration_order = 2; - const bool build_transient_support = true; - const std::vector tangent_param_names; - _eq_set_factory = Teuchos::rcp(new VertexCFD::EquationSet::Factory); - panzer::buildPhysicsBlocks(block_ids_to_physics_ids, - block_ids_to_cell_topo, - physics_params, - default_integration_order, - workset_size, - _eq_set_factory, - _global_data, - build_transient_support, - _physics_blocks, - tangent_param_names); - - // FIXME: Everything breaks if our integration order is not consistent, so - // just extract the actaul order from the frist physics block for - // use everywhere else. - _integration_order - = _physics_blocks.at(0)->getIntegrationRules().cbegin()->first; - - // Generate field data to complete the mesh. - const int num_physics_blocks = _physics_blocks.size(); - for (int i = 0; i < num_physics_blocks; ++i) - { - // Get a unique list of the fields names needed by the physics and add - // them to the database. - auto pb = _physics_blocks[i]; - const auto& block_fields = pb->getProvidedDOFs(); - std::set field_names( - block_fields.begin(), block_fields.end()); - for (auto field = field_names.begin(); field != field_names.end(); - ++field) - { - mesh->addSolutionField(field->first, pb->elementBlockID()); - } - } - _mesh_manager->completeMeshConstruction(); - // Generate connectivity and DOF managers. - auto conn_manager = _mesh_manager->connectivityManager(); - panzer::DOFManagerFactory dof_manager_factory; - _dof_manager = dof_manager_factory.buildGlobalIndexer( - Teuchos::opaqueWrapper(Teuchos::getRawMpiComm(*comm)), - _physics_blocks, - conn_manager); - - // Toggle on linear algebra type to construct linear object factory - const std::string lin_alg_type - = user_params->get("Linear Algebra Type", "Tpetra"); - if (lin_alg_type == "Tpetra") - { - _linear_object_factory = Teuchos::rcp( - new panzer::TpetraLinearObjFactory( - comm, _dof_manager)); - } - else if (lin_alg_type == "Epetra") - { - _linear_object_factory = Teuchos::rcp( - new panzer::BlockedEpetraLinearObjFactory( - comm, _dof_manager)); - } - else - { - throw std::runtime_error( - "Invalid linear algebra type. Valid options are 'Tpetra' and " - "'Epetra'"); - } - - // Linear solver factory. - auto linear_solver_params = parameter_db->linearSolverParameters(); - auto lows_factory = VertexCFD::LinearSolvers::LOWSFactoryBuilder::buildLOWS( - linear_solver_params); - - // Create boundary conditions. - auto bc_params = _parameter_db->boundaryConditionParameters(); - panzer::buildBCs(_boundary_conditions, *bc_params, _global_data); - - // Create model evaluator. - _model_evaluator = Teuchos::rcp( - new panzer::ModelEvaluator(_linear_object_factory, - lows_factory, - _global_data, - build_transient_support, - _t_init)); - - // Create additional factories. - _bc_factory = Teuchos::rcp( - new VertexCFD::BoundaryCondition::Factory()); - VertexCFD::ClosureModel::FactoryTemplateBuilder cm_builder; - _cm_factory = Teuchos::rcp( - new panzer::ClosureModelFactory_TemplateManager()); - _cm_factory->buildObjects(cm_builder); -} - -//---------------------------------------------------------------------------// -// Explicit instantiation of the constructor 'PhysicsManager' -template PhysicsManager::PhysicsManager( - const std::integral_constant&, - const Teuchos::RCP& parameter_db, - const Teuchos::RCP& mesh_manager, - const double initial_time); - -template PhysicsManager::PhysicsManager( - const std::integral_constant&, - const Teuchos::RCP& parameter_db, - const Teuchos::RCP& mesh_manager, - const double initial_time); - -//---------------------------------------------------------------------------// -// Add a scalar parameter and an initial value for the parameter. -int PhysicsManager::addScalarParameter(const std::string& name, - const double value) -{ - int param_id = _model_evaluator->addParameter(name, value); - _parameter_indices.emplace(name, param_id); - return param_id; -} - -//---------------------------------------------------------------------------// -// Get the index of a parameter with the given name. -int PhysicsManager::getParameterIndex(const std::string& name) const -{ - auto iter = _parameter_indices.find(name); - if (iter == _parameter_indices.end()) - { - throw std::runtime_error("Parameter not found"); - } - return iter->second; -} - -//---------------------------------------------------------------------------// -void PhysicsManager::setupModel() -{ - // Create worksets. - auto user_params = _parameter_db->userParameters(); - auto mesh = _mesh_manager->mesh(); - auto workset_factory = Teuchos::rcp(new panzer_stk::WorksetFactory(mesh)); - _workset_container = Teuchos::rcp(new panzer::WorksetContainer); - _workset_container->setFactory(workset_factory); - const int num_physics_blocks = _physics_blocks.size(); - for (int i = 0; i < num_physics_blocks; ++i) - { - auto pb = _physics_blocks[i]; - _workset_container->setNeeds(pb->elementBlockID(), - pb->getWorksetNeeds()); - } - const int workset_size = user_params->get("Workset Size"); - _workset_container->setWorksetSize(workset_size); - _workset_container->setGlobalIndexer(_dof_manager); - - // Turn on shared memory versions of Panzer kernels when available - panzer::HP::inst().setUseSharedMemory(true, true); - - // Setup model. - auto closure_params = _parameter_db->closureModelParameters(); - const bool write_graph = user_params->get("Output Graph"); - user_params->set>("MeshManager", - _mesh_manager); - _model_evaluator->setupModel(_workset_container, - _physics_blocks, - _boundary_conditions, - *_eq_set_factory, - *_bc_factory, - *_cm_factory, - *_cm_factory, - *closure_params, - *user_params, - write_graph, - ""); - - // Add scalar parameters. - auto scalar_params = _parameter_db->scalarParameters(); - if (Teuchos::nonnull(scalar_params)) - { - for (auto sp = scalar_params->begin(); sp != scalar_params->end(); ++sp) - { - auto list = scalar_params->sublist(sp->first); - addScalarParameter(list.get("Name"), - list.get("Nominal Value")); - } - } -} - -//---------------------------------------------------------------------------// -Teuchos::RCP PhysicsManager::meshManager() const -{ - return _mesh_manager; -} - -//---------------------------------------------------------------------------// -Teuchos::RCP PhysicsManager::globalData() const -{ - return _global_data; -} - -//---------------------------------------------------------------------------// -Teuchos::RCP -PhysicsManager::equationSetFactory() const -{ - return _eq_set_factory; -} - -//---------------------------------------------------------------------------// -const std::vector>& -PhysicsManager::physicsBlocks() const -{ - return _physics_blocks; -} - -//---------------------------------------------------------------------------// -int PhysicsManager::integrationOrder() const -{ - return _integration_order; -} - -//---------------------------------------------------------------------------// -Teuchos::RCP PhysicsManager::dofManager() const -{ - return _dof_manager; -} - -//---------------------------------------------------------------------------// -Teuchos::RCP> -PhysicsManager::linearObjectFactory() const -{ - return _linear_object_factory; -} - -//---------------------------------------------------------------------------// -Teuchos::RCP PhysicsManager::worksetContainer() const -{ - return _workset_container; -} - -//---------------------------------------------------------------------------// -const std::vector& PhysicsManager::boundaryConditions() const -{ - return _boundary_conditions; -} - -//---------------------------------------------------------------------------// -Teuchos::RCP -PhysicsManager::boundaryConditionFactory() const -{ - return _bc_factory; -} - -//---------------------------------------------------------------------------// -Teuchos::RCP> -PhysicsManager::closureModelFactory() const -{ - return _cm_factory; -} - -//---------------------------------------------------------------------------// -Teuchos::RCP> -PhysicsManager::modelEvaluator() const -{ - return _model_evaluator; -} - -//---------------------------------------------------------------------------// - -} // end namespace VertexCFD diff --git a/src/drivers/VertexCFD_PhysicsManager.hpp b/src/drivers/VertexCFD_PhysicsManager.hpp deleted file mode 100644 index 3a8e1ed..0000000 --- a/src/drivers/VertexCFD_PhysicsManager.hpp +++ /dev/null @@ -1,85 +0,0 @@ -#ifndef VERTEXCFD_PHYSICSMANAGER_HPP -#define VERTEXCFD_PHYSICSMANAGER_HPP - -#include "VertexCFD_MeshManager.hpp" - -#include "parameters/VertexCFD_ParameterDatabase.hpp" - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include - -namespace VertexCFD -{ -//---------------------------------------------------------------------------// -class PhysicsManager -{ - public: - template - PhysicsManager(const std::integral_constant&, - const Teuchos::RCP& parameter_db, - const Teuchos::RCP& mesh_manager, - const double initial_time = 0.0); - - // Add a scalar parameter and an initial value for the parameter. Return - // the parameter index. - int addScalarParameter(const std::string& name, const double value); - - // Get the index of a parameter with the given name. - int getParameterIndex(const std::string& name) const; - - // Setup the model after all physics responses and parameters have been - // added. - void setupModel(); - - // Data accessors. - Teuchos::RCP meshManager() const; - Teuchos::RCP globalData() const; - Teuchos::RCP equationSetFactory() const; - const std::vector>& - physicsBlocks() const; - int integrationOrder() const; - Teuchos::RCP dofManager() const; - Teuchos::RCP> - linearObjectFactory() const; - Teuchos::RCP worksetContainer() const; - const std::vector& boundaryConditions() const; - Teuchos::RCP boundaryConditionFactory() const; - Teuchos::RCP> - closureModelFactory() const; - Teuchos::RCP> modelEvaluator() const; - - private: - Teuchos::RCP _parameter_db; - Teuchos::RCP _mesh_manager; - double _t_init; - Teuchos::RCP _global_data; - Teuchos::RCP _eq_set_factory; - std::vector> _physics_blocks; - int _integration_order; - Teuchos::RCP _dof_manager; - Teuchos::RCP> _linear_object_factory; - Teuchos::RCP _workset_container; - std::vector _boundary_conditions; - Teuchos::RCP _bc_factory; - Teuchos::RCP> - _cm_factory; - Teuchos::RCP> _model_evaluator; - std::unordered_map _parameter_indices; -}; - -} // end namespace VertexCFD - -#endif // end VERTEXCFD_PHYSICSMANAGER_HPP diff --git a/src/drivers/unit_test/CMakeLists.txt b/src/drivers/unit_test/CMakeLists.txt deleted file mode 100644 index 3f4b18f..0000000 --- a/src/drivers/unit_test/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -configure_file( VertexCFD_DriverUnitTestConfig.hpp.cmakein VertexCFD_DriverUnitTestConfig.hpp ) - -set(TEST_HARNESS_DIR ${CMAKE_SOURCE_DIR}/src/test_harness) -include(${TEST_HARNESS_DIR}/TestHarness.cmake) - -VertexCFD_add_tests( - LIBS VertexCFD - NAMES - MeshManager - PhysicsManager - InitialConditionManager - ) diff --git a/src/drivers/unit_test/VertexCFD_DriverUnitTestConfig.hpp.cmakein b/src/drivers/unit_test/VertexCFD_DriverUnitTestConfig.hpp.cmakein deleted file mode 100644 index d63b08e..0000000 --- a/src/drivers/unit_test/VertexCFD_DriverUnitTestConfig.hpp.cmakein +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef VERTEXCFD_DRIVERUNITTESTCONFIG_HPP -#define VERTEXCFD_DRIVERUNITTESTCONFIG_HPP - -constexpr char VERTEXCFD_DRIVER_TEST_DATA_DIR[] = R"(@CMAKE_SOURCE_DIR@/src/drivers/unit_test/data/)"; -constexpr char VERTEXCFD_DRIVER_TEST_INPUT_DIR[] = R"(@CMAKE_SOURCE_DIR@/examples/inputs/)"; -constexpr char VERTEXCFD_DRIVER_TEST_MESH_DIR[] = R"(@CMAKE_SOURCE_DIR@/examples/mesh/)"; - -#endif // end VERTEXCFD_DRIVERUNITTESTCONFIG_HPP diff --git a/src/drivers/unit_test/data/simple_box_2d_restart.xml b/src/drivers/unit_test/data/simple_box_2d_restart.xml deleted file mode 100644 index 8584b9d..0000000 --- a/src/drivers/unit_test/data/simple_box_2d_restart.xml +++ /dev/null @@ -1,287 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/drivers/unit_test/data/simple_box_fim_3d.xml b/src/drivers/unit_test/data/simple_box_fim_3d.xml deleted file mode 100644 index 127ecfd..0000000 --- a/src/drivers/unit_test/data/simple_box_fim_3d.xml +++ /dev/null @@ -1,268 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/drivers/unit_test/tstInitialConditionManager.cpp b/src/drivers/unit_test/tstInitialConditionManager.cpp deleted file mode 100644 index 6ced86c..0000000 --- a/src/drivers/unit_test/tstInitialConditionManager.cpp +++ /dev/null @@ -1,172 +0,0 @@ -#include - -#include -#include -#include - -#include - -#include -#include -#include - -#include - -#include - -//---------------------------------------------------------------------------// -// TESTS -//---------------------------------------------------------------------------// -namespace VertexCFD -{ -namespace Test -{ -//---------------------------------------------------------------------------// -template -void testInitialConditionManager( - const Teuchos::RCP>& comm, - const Teuchos::RCP& parameter_db, - const bool restart = false) -{ - // Initialize mesh dimension - constexpr int num_space_dim = NumSpaceDim; - - // Create the mesh. - auto mesh_manager = Teuchos::rcp(new MeshManager(*parameter_db, comm)); - - // Create physics. - auto physics_manager = Teuchos::rcp( - new PhysicsManager(std::integral_constant{}, - parameter_db, - mesh_manager)); - - // Finish physics. - physics_manager->setupModel(); - - // Create initial conditions. - auto ic_manager = Teuchos::rcp( - new InitialConditionManager(parameter_db, mesh_manager)); - - // Apply initial conditions. - auto x_space = physics_manager->modelEvaluator()->get_x_space(); - Teuchos::RCP> x; - Teuchos::RCP> x_dot; - ic_manager->applyInitialConditions( - std::integral_constant{}, - *physics_manager, - x, - x_dot); - - // Check initial time. - if (restart) - { - EXPECT_EQ(0.01, ic_manager->initialTime()); - } - else - { - EXPECT_EQ(0.0, ic_manager->initialTime()); - } - - // Check initial condition. The "simple_box_Nd.xml" files have initial - // conditions of: \phi_p = 1, u = 1, v = 2, w = 3. We will use the - // 1-norm to verify this. - const int num_node - = mesh_manager->mesh()->getEntityCounts(stk::topology::NODE_RANK); - const double norm_1 = num_node * (0.5 + 3 * (NumSpaceDim - 1)); - EXPECT_EQ(norm_1, Thyra::norm_1(*x)); - EXPECT_EQ(0.0, Thyra::norm_1(*x_dot)); -} - -//---------------------------------------------------------------------------// -template -void InitialConditionManagerND() -{ - // Initialize space dimension - constexpr int num_space_dim = NumSpaceDim; - - // Get the MPI communicator. - auto comm = Teuchos::rcp_dynamic_cast>( - Teuchos::DefaultComm::getComm()); - - // Parse input. - int argc = 2; - const std::string option = "--i="; - const std::string location = VERTEXCFD_DRIVER_TEST_INPUT_DIR; - const std::string file = "simple_box_" + std::to_string(num_space_dim) - + "d.xml"; - std::string argv_str = option + location + file; - char* argv[2]; - argv[1] = &argv_str[0]; - - // Setup database. - auto parameter_db - = Teuchos::rcp(new Parameter::ParameterDatabase(comm, argc, argv)); - - // Test. - testInitialConditionManager(comm, parameter_db); -} - -//---------------------------------------------------------------------------// -TEST(InitialConditionManager2D, ic_test) -{ - InitialConditionManagerND<2>(); -} - -//---------------------------------------------------------------------------// -TEST(InitialConditionManager3D, ic_test) -{ - InitialConditionManagerND<3>(); -} - -//---------------------------------------------------------------------------// -template -void testRestartMultiD() -{ - // Space dimension - constexpr int num_space_dim = NumSpaceDim; - const std::string num_space_dim_string = std::to_string(num_space_dim); - - // Get the MPI communicator. - auto comm = Teuchos::rcp_dynamic_cast>( - Teuchos::DefaultComm::getComm()); - - // Parse input. - int argc = 2; - const std::string option = "--i="; - const std::string input_location = VERTEXCFD_DRIVER_TEST_DATA_DIR; - const std::string input_file = "simple_box_" + num_space_dim_string - + "d_restart.xml"; - std::string argv_str = option + input_location + input_file; - char* argv[2]; - argv[1] = &argv_str[0]; - - // Setup database. - auto parameter_db - = Teuchos::rcp(new Parameter::ParameterDatabase(comm, argc, argv)); - - // Update restart data parameters. In this test the initial conditions - // from the previous test were written to the restart file and thus the - // initial conditions and time from restart should be the same. - const std::string data_location = VERTEXCFD_DRIVER_TEST_DATA_DIR; - const std::string data_file = data_location + "simple_box_" - + num_space_dim_string + "d.restart.data"; - const std::string dofmap_file = data_location + "simple_box_" - + num_space_dim_string + "d.restart.dofmap"; - parameter_db->readRestartParameters()->set("Restart Data File Name", - data_file); - parameter_db->readRestartParameters()->set("Restart DOF Map File Name", - dofmap_file); - - testInitialConditionManager(comm, parameter_db, true); -} - -//---------------------------------------------------------------------------// -TEST(InitialConditionManager2D, restart_test) -{ - testRestartMultiD<2>(); -} - -//---------------------------------------------------------------------------// - -} // end namespace Test -} // end namespace VertexCFD diff --git a/src/drivers/unit_test/tstMeshManager.cpp b/src/drivers/unit_test/tstMeshManager.cpp deleted file mode 100644 index 592ac44..0000000 --- a/src/drivers/unit_test/tstMeshManager.cpp +++ /dev/null @@ -1,199 +0,0 @@ -#include - -#include -#include - -#include -#include -#include - -#include - -#include - -//---------------------------------------------------------------------------// -// TESTS -//---------------------------------------------------------------------------// -namespace VertexCFD -{ -namespace Test -{ -//---------------------------------------------------------------------------// -TEST(MeshManager, file_test) -{ - // Get the MPI communicator. - auto comm = Teuchos::rcp_dynamic_cast>( - Teuchos::DefaultComm::getComm()); - - // Make an empty parameter database and build mesh parmaeters. - Parameter::ParameterDatabase parameter_db(comm); - auto mesh_params = parameter_db.meshParameters(); - mesh_params->set("Mesh Input Type", "File"); - auto& file_params = mesh_params->sublist("File"); - std::string mesh_location = VERTEXCFD_DRIVER_TEST_MESH_DIR; - std::string mesh_file = "test_mesh_manager.exo"; - std::string filepath = mesh_location + mesh_file; - file_params.set("File Name", filepath); - file_params.set("Decomp Method", "RCB"); - - // Create the mesh. - MeshManager mesh_manager(parameter_db, comm); - mesh_manager.completeMeshConstruction(); - - // Check the mesh. - EXPECT_EQ(2, mesh_manager.spaceDimension()); - auto mesh = mesh_manager.mesh(); - EXPECT_EQ(2, mesh->getNumElementBlocks()); - - // Check the connectivity by checking the element block. - auto conn = mesh_manager.connectivityManager(); - EXPECT_EQ(2, conn->numElementBlocks()); -} - -//---------------------------------------------------------------------------// -void testInlineMesh(const std::string element_type) -{ - // Get the MPI communicator. - auto comm = Teuchos::rcp_dynamic_cast>( - Teuchos::DefaultComm::getComm()); - - // Mesh dimension based on 'element_type' entry. 'split' is - // multiplicator used to scale the number of elements when - // using triangle or tetrahedral elements - int mesh_dimension = 0; - int split = 1; - if (element_type == "Quad4" || element_type == "Tri3") - { - mesh_dimension = 2; - if (element_type == "Tri3") - split = 2; - } - else if (element_type == "Tet4" || element_type == "Hex8") - { - mesh_dimension = 3; - if (element_type == "Tet4") - split = 12; - } - - // Make an empty parameter database and build mesh parameters. - Parameter::ParameterDatabase parameter_db(comm); - auto mesh_params = parameter_db.meshParameters(); - mesh_params->set("Mesh Input Type", "Inline"); - auto& inline_params = mesh_params->sublist("Inline"); - inline_params.set("Element Type", element_type); - auto& mesh_details = inline_params.sublist("Mesh"); - const int nelem_x = 3; - const int nelem_y = nelem_x * mesh_dimension; - const int nelem_z = nelem_y * mesh_dimension; - mesh_details.set("X0", 0.0); - mesh_details.set("Xf", 1.0); - mesh_details.set("X Elements", nelem_x); - if (mesh_dimension > 1) - { - mesh_details.set("Y0", 0.0); - mesh_details.set("Yf", 1.0); - mesh_details.set("Y Elements", nelem_y); - } - if (mesh_dimension > 2) - { - mesh_details.set("Z0", 0.0); - mesh_details.set("Zf", 1.0); - mesh_details.set("Z Elements", nelem_z); - } - - // Create the mesh. - MeshManager mesh_manager(parameter_db, comm); - mesh_manager.completeMeshConstruction(); - - // Check the mesh. - EXPECT_EQ(mesh_dimension, mesh_manager.spaceDimension()); - const auto mesh = mesh_manager.mesh(); - EXPECT_EQ(1, mesh->getNumElementBlocks()); - int mesh_num_elem = split * nelem_x; - if (mesh_dimension > 1) - mesh_num_elem *= nelem_y; - if (mesh_dimension > 2) - mesh_num_elem *= nelem_z; - EXPECT_EQ(mesh_num_elem, mesh->getEntityCounts(stk::topology::ELEM_RANK)); - - // Check the connectivity by checking the element block. - auto conn = mesh_manager.connectivityManager(); - EXPECT_EQ(1, conn->numElementBlocks()); -} -//---------------------------------------------------------------------------// -TEST(MeshManager, tri3_test) -{ - testInlineMesh("Tri3"); -} -//---------------------------------------------------------------------------// -TEST(MeshManager, quad4_test) -{ - testInlineMesh("Quad4"); -} -//---------------------------------------------------------------------------// -TEST(MeshManager, tet4_test) -{ - testInlineMesh("Tet4"); -} -//---------------------------------------------------------------------------// -TEST(MeshManager, hex8_test) -{ - testInlineMesh("Hex8"); -} -//---------------------------------------------------------------------------// -TEST(MeshManager, bad_elem_type_test) -{ - // Get the MPI communicator. - auto comm = Teuchos::rcp_dynamic_cast>( - Teuchos::DefaultComm::getComm()); - - // Make an empty parameter database and build mesh parmaeters. - Parameter::ParameterDatabase parameter_db(comm); - auto mesh_params = parameter_db.meshParameters(); - mesh_params->set("Mesh Input Type", "Inline"); - auto& inline_params = mesh_params->sublist("Inline"); - inline_params.set("Element Type", "BadElem"); - - // Create the mesh. - std::string msg - = "Invalid inline element type. Valid options are 'Tri3', " - "'Quad4', 'Tet4' and 'Hex8'"; - EXPECT_THROW( - try { - MeshManager mesh_manager(parameter_db, comm); - } catch (const std::runtime_error& e) { - EXPECT_EQ(msg, e.what()); - throw; - }, - std::runtime_error); -} - -//---------------------------------------------------------------------------// -TEST(MeshManager, bad_mesh_type_test) -{ - // Get the MPI communicator. - auto comm = Teuchos::rcp_dynamic_cast>( - Teuchos::DefaultComm::getComm()); - - // Make an empty parameter database and build mesh parmaeters. - Parameter::ParameterDatabase parameter_db(comm); - auto mesh_params = parameter_db.meshParameters(); - mesh_params->set("Mesh Input Type", "Throw"); - - // Create the mesh. - std::string msg - = "Invalid mesh input type. Valid options are 'File' and 'Inline'"; - EXPECT_THROW( - try { - MeshManager mesh_manager(parameter_db, comm); - } catch (const std::runtime_error& e) { - EXPECT_EQ(msg, e.what()); - throw; - }, - std::runtime_error); -} - -//---------------------------------------------------------------------------// - -} // end namespace Test -} // end namespace VertexCFD diff --git a/src/drivers/unit_test/tstPhysicsManager.cpp b/src/drivers/unit_test/tstPhysicsManager.cpp deleted file mode 100644 index 63d91b5..0000000 --- a/src/drivers/unit_test/tstPhysicsManager.cpp +++ /dev/null @@ -1,136 +0,0 @@ -#include -#include - -#include -#include -#include -#include - -#include - -#include -#include -#include - -#include - -#include - -//---------------------------------------------------------------------------// -// TESTS -//---------------------------------------------------------------------------// -namespace VertexCFD -{ -namespace Test -{ -//---------------------------------------------------------------------------// -template -auto createPhysicsManager(const std::string& location, - const std::string& filename) -{ - // Initialize mesh dimension - constexpr int num_space_dim = NumSpaceDim; - - // Get the MPI communicator. - auto comm = Teuchos::rcp_dynamic_cast>( - Teuchos::DefaultComm::getComm()); - - // Parse input. - int argc = 2; - const std::string option = "--i="; - std::string argv_str = option + location + filename; - char* argv[2]; - argv[1] = &argv_str[0]; - - // Setup database. - auto parameter_db - = Teuchos::rcp(new Parameter::ParameterDatabase(comm, argc, argv)); - - // Create the mesh. - auto mesh_manager = Teuchos::rcp(new MeshManager(*parameter_db, comm)); - - // Create physics. - double t_init = 1.3; - auto physics_manager = Teuchos::rcp( - new PhysicsManager(std::integral_constant{}, - parameter_db, - mesh_manager, - t_init)); - - // Finish physics. - physics_manager->setupModel(); - - return physics_manager; -} - -//---------------------------------------------------------------------------// -TEST(PhysicsManager, manager_test) -{ - auto physics_manager = createPhysicsManager<2>( - VERTEXCFD_DRIVER_TEST_INPUT_DIR, "simple_box_2d.xml"); - - // Check data. - EXPECT_TRUE(Teuchos::nonnull(physics_manager->globalData())); - EXPECT_TRUE(Teuchos::nonnull(physics_manager->equationSetFactory())); - EXPECT_EQ(1, physics_manager->physicsBlocks().size()); - EXPECT_EQ(2, physics_manager->integrationOrder()); - EXPECT_TRUE(Teuchos::nonnull(physics_manager->dofManager())); - EXPECT_TRUE(Teuchos::nonnull(physics_manager->linearObjectFactory())); - EXPECT_TRUE(Teuchos::nonnull(physics_manager->worksetContainer())); - EXPECT_EQ(4, physics_manager->boundaryConditions().size()); - EXPECT_TRUE(Teuchos::nonnull(physics_manager->boundaryConditionFactory())); - EXPECT_TRUE(Teuchos::nonnull(physics_manager->closureModelFactory())); - EXPECT_TRUE(Teuchos::nonnull(physics_manager->modelEvaluator())); -} - -//---------------------------------------------------------------------------// -// Test boundary factory model of incompressible NS equations with full -// induction MHD model enabled using a dummy input file for a 3D geometry. -TEST(PhysicsManagerFIM, manager_test) -{ - auto physics_manager = createPhysicsManager<3>( - VERTEXCFD_DRIVER_TEST_DATA_DIR, "simple_box_fim_3d.xml"); - // Check bouondary logic. - EXPECT_EQ(6, physics_manager->boundaryConditions().size()); - EXPECT_TRUE(Teuchos::nonnull(physics_manager->boundaryConditionFactory())); -} - -//---------------------------------------------------------------------------// -template -void testScalarParameter() -{ - // Create physics manager. - auto physics_manager = createPhysicsManager<2>( - VERTEXCFD_DRIVER_TEST_INPUT_DIR, "simple_box_2d.xml"); - - // Add a scalar parameter. - const std::string scalar_name = "scalar_param"; - const double param_value = 2.03; - auto param_id - = physics_manager->addScalarParameter(scalar_name, param_value); - EXPECT_EQ(0, param_id); - EXPECT_EQ(0, physics_manager->getParameterIndex(scalar_name)); - - // Finish physics. - physics_manager->setupModel(); - - // Check scalar parameter. - auto param_lib = physics_manager->globalData()->pl; - EXPECT_EQ(param_value, param_lib->getValue(scalar_name)); -} -//---------------------------------------------------------------------------// -TEST(PhysicsManager, scalar_parameter_test_residual) -{ - testScalarParameter(); -} - -//---------------------------------------------------------------------------// -TEST(PhysicsManager, scalar_parameter_test_jacobian) -{ - testScalarParameter(); -} - -//---------------------------------------------------------------------------// - -} // end namespace Test -} // end namespace VertexCFD diff --git a/src/equation_sets/VertexCFD_EquationSet_Factory.hpp b/src/equation_sets/VertexCFD_EquationSet_Factory.hpp deleted file mode 100644 index 48731c2..0000000 --- a/src/equation_sets/VertexCFD_EquationSet_Factory.hpp +++ /dev/null @@ -1,59 +0,0 @@ -#ifndef VERTEXCFD_EQUATIONSET_FACTORY_HPP -#define VERTEXCFD_EQUATIONSET_FACTORY_HPP - -#include "VertexCFD_EquationSet_Heat.hpp" -#include "VertexCFD_EquationSet_IncompressibleNavierStokes.hpp" - -#include -#include -#include - -namespace VertexCFD -{ -namespace EquationSet -{ -//---------------------------------------------------------------------------// - -PANZER_DECLARE_EQSET_TEMPLATE_BUILDER(Heat, Heat) -PANZER_DECLARE_EQSET_TEMPLATE_BUILDER(IncompressibleNavierStokes, - IncompressibleNavierStokes) - -//---------------------------------------------------------------------------// -class Factory : public panzer::EquationSetFactory -{ - public: - Teuchos::RCP> - buildEquationSet(const Teuchos::RCP& params, - const int& default_integration_order, - const panzer::CellData& cell_data, - const Teuchos::RCP& global_data, - const bool build_transient_support) const override - { - // This variable needs to have this exact name to work with the macro - // called below. - auto eq_set = Teuchos::rcp( - new panzer::EquationSet_TemplateManager); - - // The "found" variable is used in-place in the macro called below. - bool found = false; - - // Call the macro for each equation set and check that we found it. - PANZER_BUILD_EQSET_OBJECTS("Heat", Heat); - PANZER_BUILD_EQSET_OBJECTS("IncompressibleNavierStokes", - IncompressibleNavierStokes); - if (!found) - { - throw std::runtime_error("Equation set not valid"); - } - - // Return the equation set - return eq_set; - } -}; - -//---------------------------------------------------------------------------// - -} // end namespace EquationSet -} // end namespace VertexCFD - -#endif // end VERTEXCFD_EQUATIONSET_FACTORY_HPP diff --git a/src/equation_sets/VertexCFD_EquationSet_Heat.cpp b/src/equation_sets/VertexCFD_EquationSet_Heat.cpp deleted file mode 100644 index b88f903..0000000 --- a/src/equation_sets/VertexCFD_EquationSet_Heat.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_EquationSet_Heat.hpp" -#include "VertexCFD_EquationSet_Heat_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL(VertexCFD::EquationSet::Heat) diff --git a/src/equation_sets/VertexCFD_EquationSet_Heat.hpp b/src/equation_sets/VertexCFD_EquationSet_Heat.hpp deleted file mode 100644 index 37e0e13..0000000 --- a/src/equation_sets/VertexCFD_EquationSet_Heat.hpp +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef VERTEXCFD_EQUATIONSET_HEAT_HPP -#define VERTEXCFD_EQUATIONSET_HEAT_HPP - -#include -#include -#include -#include -#include - -#include - -#include -#include - -#include - -namespace VertexCFD -{ -namespace EquationSet -{ -//---------------------------------------------------------------------------// -// Conductive heat equation -//---------------------------------------------------------------------------// -template -class Heat : public panzer::EquationSet_DefaultImpl -{ - public: - Heat(const Teuchos::RCP& params, - const int& default_integration_order, - const panzer::CellData& cell_data, - const Teuchos::RCP& gd, - const bool build_transient_support); - - void buildAndRegisterEquationSetEvaluators( - PHX::FieldManager& fm, - const panzer::FieldLibrary& field_library, - const Teuchos::ParameterList& user_data) const override; - - std::string fieldName(const int dof) const; - - private: - const std::string _dof_name; -}; - -//---------------------------------------------------------------------------// - -} // end namespace EquationSet -} // end namespace VertexCFD - -#endif // end VERTEXCFD_EQUATIONSET_HEAT_HPP diff --git a/src/equation_sets/VertexCFD_EquationSet_Heat_impl.hpp b/src/equation_sets/VertexCFD_EquationSet_Heat_impl.hpp deleted file mode 100644 index 3d6b277..0000000 --- a/src/equation_sets/VertexCFD_EquationSet_Heat_impl.hpp +++ /dev/null @@ -1,147 +0,0 @@ -#ifndef VERTEXCFD_EQUATIONSET_HEAT_IMPL_HPP -#define VERTEXCFD_EQUATIONSET_HEAT_IMPL_HPP - -#include -#include -#include -#include -#include - -#include -#include - -namespace VertexCFD -{ -namespace EquationSet -{ -//---------------------------------------------------------------------------// -template -Heat::Heat(const Teuchos::RCP& params, - const int& default_integration_order, - const panzer::CellData& cell_data, - const Teuchos::RCP& global_data, - const bool build_transient_support) - : panzer::EquationSet_DefaultImpl(params, - default_integration_order, - cell_data, - global_data, - build_transient_support) - , _dof_name("temperature") -{ - // This equation set need not always be transient. Could solve Poisson - if (!this->buildTransientSupport()) - { - throw std::logic_error("Heat equation requires transient support"); - } - - // Set default parameter values and validate the inputs. - Teuchos::ParameterList valid_parameters; - this->setDefaultValidParameters(valid_parameters); - valid_parameters.set( - "Model ID", "", "Closure model id associated with this equation set"); - valid_parameters.set("Basis Order", 1, "Order of the basis"); - valid_parameters.set("Integration Order", 2, "Order of the integration"); - params->validateParametersAndSetDefaults(valid_parameters); - - // Extract parameters. - const int basis_order = params->get("Basis Order", 1); - const int integration_order - = params->get("Integration Order", basis_order + 1); - const auto model_id = params->get("Model ID"); - - // Get the number of space dimensions. - const auto num_space_dim = cell_data.baseCellDimension(); - if (!(num_space_dim == 2 || num_space_dim == 3)) - { - throw std::runtime_error("Number of space dimensions not supported"); - } - - this->addDOF(_dof_name, "HGrad", basis_order, integration_order); - this->addDOFGrad(_dof_name); - if (this->buildTransientSupport()) - { - this->addDOFTimeDerivative(_dof_name); - } - this->addClosureModel(model_id); - this->setupDOFs(); -} - -//---------------------------------------------------------------------------// -template -void Heat::buildAndRegisterEquationSetEvaluators( - PHX::FieldManager& fm, - const panzer::FieldLibrary&, - const Teuchos::ParameterList&) const -{ - const auto ir = this->getIntRuleForDOF(_dof_name); - const auto basis = this->getBasisIRLayoutForDOF(_dof_name); - - std::vector term_names; - - if (this->buildTransientSupport()) - { - const std::string term_name{"RESIDUAL_" + _dof_name + "_TRANSIENT_OP"}; - term_names.push_back(term_name); - const auto op{Teuchos::rcp( - new panzer::Integrator_BasisTimesScalar( - panzer::EvaluatorStyle::EVALUATES, - term_name, - "DXDT_" + _dof_name, - *basis, - *ir, - 1.0))}; - this->template registerEvaluator(fm, op); - } - - { - const std::string term_name{"RESIDUAL_" + _dof_name - + "_CONDUCTIVE_TERM"}; - term_names.push_back(term_name); - const std::vector field_multipliers{ - "thermal_conductivity"}; - const auto op{Teuchos::rcp( - new panzer::Integrator_GradBasisDotVector( - panzer::EvaluatorStyle::EVALUATES, - term_name, - "GRAD_" + _dof_name, - *basis, - *ir, - 1.0, - field_multipliers))}; - this->template registerEvaluator(fm, op); - } - - { - const auto term_name{"RESIDUAL_" + _dof_name + "_SOURCE_OP"}; - const auto op{Teuchos::rcp( - new panzer::Integrator_BasisTimesScalar( - panzer::EvaluatorStyle::EVALUATES, - term_name, - "SOURCE_" + _dof_name, - *basis, - *ir, - -1.0))}; - this->template registerEvaluator(fm, op); - } - - this->buildAndRegisterResidualSummationEvaluator(fm, _dof_name, term_names); -} - -//---------------------------------------------------------------------------/ -template -std::string Heat::fieldName(const int dof) const -{ - if (dof > 0) - { - throw std::logic_error("Heat equation contributes a single DOF"); - } - - return _dof_name; -} - -//---------------------------------------------------------------------------// - -} // end namespace EquationSet -} // end namespace VertexCFD - -#endif // end VERTEXCFD_EQUATIONSET_HEAT_IMPL_HPP diff --git a/src/equation_sets/VertexCFD_EquationSet_IncompressibleNavierStokes.cpp b/src/equation_sets/VertexCFD_EquationSet_IncompressibleNavierStokes.cpp deleted file mode 100644 index a3d3994..0000000 --- a/src/equation_sets/VertexCFD_EquationSet_IncompressibleNavierStokes.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_EquationSet_IncompressibleNavierStokes.hpp" -#include "VertexCFD_EquationSet_IncompressibleNavierStokes_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL( - VertexCFD::EquationSet::IncompressibleNavierStokes) diff --git a/src/equation_sets/VertexCFD_EquationSet_IncompressibleNavierStokes.hpp b/src/equation_sets/VertexCFD_EquationSet_IncompressibleNavierStokes.hpp deleted file mode 100644 index c8b92d0..0000000 --- a/src/equation_sets/VertexCFD_EquationSet_IncompressibleNavierStokes.hpp +++ /dev/null @@ -1,68 +0,0 @@ -#ifndef VERTEXCFD_EQUATIONSET_INCOMPRESSIBLE_NAVIERSTOKES_HPP -#define VERTEXCFD_EQUATIONSET_INCOMPRESSIBLE_NAVIERSTOKES_HPP - -#include -#include -#include -#include - -#include - -#include -#include - -#include -#include -#include - -namespace VertexCFD -{ -namespace EquationSet -{ -//---------------------------------------------------------------------------// -// Isothermal Navier Stokes equations for incompressible flow. -// Navier Stokes equations for incompressible flow. -//---------------------------------------------------------------------------// -template -class IncompressibleNavierStokes - : public panzer::EquationSet_DefaultImpl -{ - public: - IncompressibleNavierStokes(const Teuchos::RCP& params, - const int& default_integration_order, - const panzer::CellData& cell_data, - const Teuchos::RCP& gd, - const bool build_transient_support); - - void buildAndRegisterEquationSetEvaluators( - PHX::FieldManager& fm, - const panzer::FieldLibrary& field_library, - const Teuchos::ParameterList& user_data) const override; - - private: - int _num_space_dim; - std::unordered_map _equ_dof_ns_pair; - std::unordered_map _equ_dof_ep_pair; - std::unordered_map _equ_dof_tm_pair; - std::unordered_map _equ_dof_fim_pair; - std::unordered_map> - _equ_source_term; - bool _build_viscous_flux; - bool _build_temp_equ; - bool _build_ind_less_equ; - bool _build_constant_source; - bool _build_buoyancy_source; - bool _build_viscous_heat; - std::string _turbulence_model; - bool _build_full_induction_model; - bool _build_resistive_flux; - bool _build_magn_corr; - bool _build_godunov_powell_source; -}; - -//---------------------------------------------------------------------------// - -} // end namespace EquationSet -} // end namespace VertexCFD - -#endif // end VERTEXCFD_EQUATIONSET_INCOMPRESSIBLE_NAVIERSTOKES_HPP diff --git a/src/full_induction_mhd_solver/boundary_conditions/VertexCFD_BoundaryState_FullInductionConducting.cpp b/src/full_induction_mhd_solver/boundary_conditions/VertexCFD_BoundaryState_FullInductionConducting.cpp deleted file mode 100644 index 5a83502..0000000 --- a/src/full_induction_mhd_solver/boundary_conditions/VertexCFD_BoundaryState_FullInductionConducting.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "full_induction_mhd_solver/boundary_conditions/VertexCFD_BoundaryState_FullInductionConducting.hpp" -#include "full_induction_mhd_solver/boundary_conditions/VertexCFD_BoundaryState_FullInductionConducting_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS_NUMSPACEDIM( - VertexCFD::BoundaryCondition::FullInductionConducting) diff --git a/src/full_induction_mhd_solver/boundary_conditions/VertexCFD_BoundaryState_FullInductionConducting.hpp b/src/full_induction_mhd_solver/boundary_conditions/VertexCFD_BoundaryState_FullInductionConducting.hpp deleted file mode 100644 index e5c8062..0000000 --- a/src/full_induction_mhd_solver/boundary_conditions/VertexCFD_BoundaryState_FullInductionConducting.hpp +++ /dev/null @@ -1,87 +0,0 @@ -#ifndef VERTEXCFD_BOUNDARYSTATE_FULLINDUCTIONCONDUCTING_HPP -#define VERTEXCFD_BOUNDARYSTATE_FULLINDUCTIONCONDUCTING_HPP - -#include "full_induction_mhd_solver/mhd_properties/VertexCFD_FullInductionMHDProperties.hpp" - -#include -#include - -#include -#include -#include -#include - -namespace VertexCFD -{ -namespace BoundaryCondition -{ -//---------------------------------------------------------------------------// -template -class FullInductionConducting : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - static constexpr int num_space_dim = NumSpaceDim; - - FullInductionConducting( - const panzer::IntegrationRule& ir, - const Teuchos::ParameterList& bc_params, - const MHDProperties::FullInductionMHDProperties& mhd_props); - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - public: - Kokkos::Array, - num_space_dim> - _boundary_induced_magnetic_field; - PHX::MDField - _boundary_scalar_magnetic_potential; - - Kokkos::Array< - PHX::MDField, - num_space_dim> - _boundary_grad_induced_magnetic_field; - - private: - Kokkos::Array _bnd_magn_field; - bool _build_magn_corr; - bool _build_resistive_flux; - bool _dirichlet_scalar_magn_pot; - double _bnd_scalar_magn_pot; - double _magnetic_permeability; - - PHX::MDField - _normals; - PHX::MDField - _scalar_magnetic_potential; - - Kokkos::Array, - num_space_dim> - _boundary_velocity; - - Kokkos::Array, - num_space_dim> - _induced_magnetic_field; - - Kokkos::Array< - PHX::MDField, - num_space_dim> - _grad_induced_magnetic_field; - - Kokkos::Array, 3> - _external_magnetic_field; - - PHX::MDField _resistivity; -}; - -//---------------------------------------------------------------------------// - -} // end namespace BoundaryCondition -} // end namespace VertexCFD - -#endif // VERTEXCFD_BOUNDARYSTATE_FULLINDUCTIONCONDUCTING_HPP diff --git a/src/full_induction_mhd_solver/boundary_conditions/VertexCFD_BoundaryState_FullInductionFixed.cpp b/src/full_induction_mhd_solver/boundary_conditions/VertexCFD_BoundaryState_FullInductionFixed.cpp deleted file mode 100644 index 1604bff..0000000 --- a/src/full_induction_mhd_solver/boundary_conditions/VertexCFD_BoundaryState_FullInductionFixed.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "full_induction_mhd_solver/boundary_conditions/VertexCFD_BoundaryState_FullInductionFixed.hpp" -#include "full_induction_mhd_solver/boundary_conditions/VertexCFD_BoundaryState_FullInductionFixed_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS_NUMSPACEDIM( - VertexCFD::BoundaryCondition::FullInductionFixed) diff --git a/src/full_induction_mhd_solver/boundary_conditions/VertexCFD_BoundaryState_FullInductionFixed.hpp b/src/full_induction_mhd_solver/boundary_conditions/VertexCFD_BoundaryState_FullInductionFixed.hpp deleted file mode 100644 index 2fe3e5d..0000000 --- a/src/full_induction_mhd_solver/boundary_conditions/VertexCFD_BoundaryState_FullInductionFixed.hpp +++ /dev/null @@ -1,69 +0,0 @@ -#ifndef VERTEXCFD_BOUNDARYSTATE_FULLINDUCTIONFIXED_HPP -#define VERTEXCFD_BOUNDARYSTATE_FULLINDUCTIONFIXED_HPP - -#include "full_induction_mhd_solver/mhd_properties/VertexCFD_FullInductionMHDProperties.hpp" - -#include -#include - -#include -#include -#include -#include - -namespace VertexCFD -{ -namespace BoundaryCondition -{ -//---------------------------------------------------------------------------// -template -class FullInductionFixed : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - static constexpr int num_space_dim = NumSpaceDim; - - FullInductionFixed( - const panzer::IntegrationRule& ir, - const Teuchos::ParameterList& bc_params, - const MHDProperties::FullInductionMHDProperties& mhd_props); - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - public: - Kokkos::Array, - num_space_dim> - _boundary_induced_magnetic_field; - PHX::MDField - _boundary_scalar_magnetic_potential; - - Kokkos::Array< - PHX::MDField, - num_space_dim> - _boundary_grad_induced_magnetic_field; - - private: - Kokkos::Array _bnd_magn_field; - bool _build_magn_corr; - bool _dirichlet_scalar_magn_pot; - double _bnd_scalar_magn_pot; - - PHX::MDField - _scalar_magnetic_potential; - Kokkos::Array< - PHX::MDField, - num_space_dim> - _grad_induced_magnetic_field; -}; - -//---------------------------------------------------------------------------// - -} // end namespace BoundaryCondition -} // end namespace VertexCFD - -#endif // VERTEXCFD_BOUNDARYSTATE_FULLINDUCTIONFIXED_HPP diff --git a/src/full_induction_mhd_solver/boundary_conditions/VertexCFD_FullInductionBoundaryState_Factory.cpp b/src/full_induction_mhd_solver/boundary_conditions/VertexCFD_FullInductionBoundaryState_Factory.cpp deleted file mode 100644 index 264d7dd..0000000 --- a/src/full_induction_mhd_solver/boundary_conditions/VertexCFD_FullInductionBoundaryState_Factory.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "full_induction_mhd_solver/boundary_conditions/VertexCFD_FullInductionBoundaryState_Factory.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS_NUMSPACEDIM( - VertexCFD::BoundaryCondition::FullInductionBoundaryStateFactory) diff --git a/src/full_induction_mhd_solver/boundary_conditions/VertexCFD_FullInductionBoundaryState_Factory.hpp b/src/full_induction_mhd_solver/boundary_conditions/VertexCFD_FullInductionBoundaryState_Factory.hpp deleted file mode 100644 index c9372bf..0000000 --- a/src/full_induction_mhd_solver/boundary_conditions/VertexCFD_FullInductionBoundaryState_Factory.hpp +++ /dev/null @@ -1,111 +0,0 @@ -#ifndef VERTEXCFD_FULLINDUCTIONBOUNDARYSTATE_FACTORY_HPP -#define VERTEXCFD_FULLINDUCTIONBOUNDARYSTATE_FACTORY_HPP - -#include "closure_models/VertexCFD_Closure_ConstantScalarField.hpp" -#include "closure_models/VertexCFD_Closure_ExternalMagneticField.hpp" - -#include "full_induction_mhd_solver/boundary_conditions/VertexCFD_BoundaryState_FullInductionConducting.hpp" -#include "full_induction_mhd_solver/boundary_conditions/VertexCFD_BoundaryState_FullInductionFixed.hpp" -#include "full_induction_mhd_solver/closure_models/VertexCFD_Closure_MagneticPressure.hpp" -#include "full_induction_mhd_solver/closure_models/VertexCFD_Closure_TotalMagneticField.hpp" - -#include "full_induction_mhd_solver/mhd_properties/VertexCFD_FullInductionMHDProperties.hpp" - -#include - -#include -#include - -namespace VertexCFD -{ -namespace BoundaryCondition -{ -//---------------------------------------------------------------------------// -template -class FullInductionBoundaryStateFactory -{ - public: - static constexpr int num_space_dim = NumSpaceDim; - - static std::vector>> - create(const panzer::IntegrationRule& ir, - const Teuchos::ParameterList& bc_params, - const Teuchos::ParameterList& user_params, - const MHDProperties::FullInductionMHDProperties& mhd_props) - { - // Evaluator vector to return - std::vector>> evaluators; - - // Add total magnetic field, magnetic pressure, and resistivity - // closures - const auto ext_magn_field_op = Teuchos::rcp( - new ClosureModel::ExternalMagneticField( - ir, user_params)); - evaluators.push_back(ext_magn_field_op); - - const auto tot_magn_field_op = Teuchos::rcp( - new ClosureModel:: - TotalMagneticField( - ir, "BOUNDARY_")); - evaluators.push_back(tot_magn_field_op); - - const auto magn_press_op = Teuchos::rcp( - new ClosureModel::MagneticPressure( - ir, mhd_props)); - evaluators.push_back(magn_press_op); - - const auto resistivity_op = Teuchos::rcp( - new ClosureModel::ConstantScalarField( - ir, "resistivity", mhd_props.resistivity())); - evaluators.push_back(resistivity_op); - - // Loop over boundary conditions found in input file for the - // induced magnetic field and scalar magnetic potential - bool found_model = false; - if (bc_params.isType("Type")) - { - const auto bc_type = bc_params.get("Type"); - - if (bc_type == "Conducting") - { - const auto state = Teuchos::rcp( - new FullInductionConducting( - ir, bc_params, mhd_props)); - evaluators.push_back(state); - found_model = true; - } - - if (bc_type == "Fixed") - { - const auto state = Teuchos::rcp( - new FullInductionFixed( - ir, bc_params, mhd_props)); - evaluators.push_back(state); - found_model = true; - } - - // Error message if model not found - if (!found_model) - { - std::string msg = "\n\nBoundary state " + bc_type - + " failed to build.\n"; - msg += "The boundary conditions implemented in VERTEX-CFD\n"; - msg += "for the full induction equations are:\n"; - msg += "Conducting,\n"; - msg += "Fixed,\n"; - msg += "\n"; - throw std::runtime_error(msg); - } - } - - // Return vector of evaluators - return evaluators; - } -}; - -//---------------------------------------------------------------------------// - -} // end namespace BoundaryCondition -} // end namespace VertexCFD - -#endif // end VERTEXCFD_FULLINDUCTIONBOUNDARYSTATE_FACTORY_HPP diff --git a/src/full_induction_mhd_solver/boundary_conditions/unit_test/CMakeLists.txt b/src/full_induction_mhd_solver/boundary_conditions/unit_test/CMakeLists.txt deleted file mode 100644 index f89da12..0000000 --- a/src/full_induction_mhd_solver/boundary_conditions/unit_test/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -set(TEST_HARNESS_DIR ${CMAKE_SOURCE_DIR}/src/test_harness) -include(${TEST_HARNESS_DIR}/TestHarness.cmake) - -VertexCFD_add_tests( - LIBS VertexCFD - NAMES - FullInductionConducting - FullInductionFixed - ) diff --git a/src/full_induction_mhd_solver/boundary_conditions/unit_test/doc/fullInductionConducting_reference.py b/src/full_induction_mhd_solver/boundary_conditions/unit_test/doc/fullInductionConducting_reference.py deleted file mode 100644 index 0b68f6e..0000000 --- a/src/full_induction_mhd_solver/boundary_conditions/unit_test/doc/fullInductionConducting_reference.py +++ /dev/null @@ -1,88 +0,0 @@ -import numpy as np - - -def np_array_to_cpp_str(my_arr): - my_str = np.array2string(my_arr, separator=', ') - my_str = my_str.replace("[", "{") - my_str = my_str.replace("]", "}") - return my_str - - -def get_conducting_bc_exp_val(norm, u_bnd, b, b_bnd, b_ext, grad_b, psi, - psi_bnd, mu, eta, build_magn_corr, dir_magn_pot, - build_resistive): - b_dot_n = np.dot(b - b_bnd, norm) - grad_b_dot_n = [] - for i in range(len(grad_b)): - grad_b_dot_n.append(np.dot(grad_b[i], norm)) - - exp_b = b - for i in range(len(b)): - if (i < len(norm)): - exp_b[i] -= b_dot_n * norm[i] - - if build_resistive: - # i-loop over the magnetic field dimensions - for i in range(len(grad_b)): - # j-loop over the gradient/spatial dimensions - for j in range(len(grad_b[i])): - if i != j: - grad_b_dot_n[i] += mu / eta * norm[j] * ( - u_bnd[i] * (b_ext[j] + b_bnd[j]) - u_bnd[j] * - (b_ext[i] + b_bnd[i])) - - exp_grad_b = grad_b - for i in range(len(grad_b)): - for j in range(len(grad_b[i])): - if (j < len(norm)): - exp_grad_b[i][j] -= grad_b_dot_n[i] * norm[j] - - print("exp_b =\n", np_array_to_cpp_str(exp_b), ";\n") - print("exp_grad_b =\n", np_array_to_cpp_str(exp_grad_b), ";\n") - if build_magn_corr: - exp_psi = psi - if dir_magn_pot: - exp_psi = psi_bnd - print("exp_psi =", exp_psi, ";\n") - - -def get_case_exp_vals(n_grad, n_space, build_magn_corr, dir_magn_pot, - build_resistive): - u_bnd = np.array([3.0, -4.0, 5.0]) - b = np.array([1.25, 2.5, 3.75]) - b_bnd = np.array([1.1, 2.2, 3.3]) - b_ext = np.array([-0.05, 0.025, -0.0125]) - norm = np.array([.45, -.65, .35]) - grad_b = np.array([[11.0, -5.5, 2.75], [-6.0, 3.0, -1.5], - [3.25, -1.625, 0.8125]]) - psi = 4.4 - psi_bnd = 5.5 - mu = 0.12 - eta = 3.6 - - print("\nFull Induction Conducting Wall Case:\n") - print("\tnum_grad_dim = ", n_grad) - print("\tnum_space_dim = ", n_space) - print("\tbuild_magn_corr = ", build_magn_corr) - print("\tdirichlet_scalar_magn_pot = ", dir_magn_pot) - print("\tbuild_resistive_flux = ", build_resistive, "\n") - - get_conducting_bc_exp_val(norm[:n_grad], u_bnd[:n_space], b[:n_space], - b_bnd[:n_space], b_ext[:n_space], - grad_b[:n_space, :n_grad], psi, psi_bnd, mu, eta, - build_magn_corr, dir_magn_pot, build_resistive) - - -get_case_exp_vals(2, 2, False, False, False) -get_case_exp_vals(2, 2, False, False, True) -get_case_exp_vals(2, 2, True, False, False) -get_case_exp_vals(2, 2, True, False, True) -get_case_exp_vals(2, 2, True, True, False) -get_case_exp_vals(2, 2, True, True, True) - -get_case_exp_vals(3, 3, False, False, False) -get_case_exp_vals(3, 3, False, False, True) -get_case_exp_vals(3, 3, True, False, False) -get_case_exp_vals(3, 3, True, False, True) -get_case_exp_vals(3, 3, True, True, False) -get_case_exp_vals(3, 3, True, True, True) diff --git a/src/full_induction_mhd_solver/boundary_conditions/unit_test/tstFullInductionConducting.cpp b/src/full_induction_mhd_solver/boundary_conditions/unit_test/tstFullInductionConducting.cpp deleted file mode 100644 index a2e79cc..0000000 --- a/src/full_induction_mhd_solver/boundary_conditions/unit_test/tstFullInductionConducting.cpp +++ /dev/null @@ -1,383 +0,0 @@ -#include "VertexCFD_EvaluatorTestHarness.hpp" -#include "full_induction_mhd_solver/boundary_conditions/VertexCFD_BoundaryState_FullInductionConducting.hpp" - -#include "full_induction_mhd_solver/mhd_properties/VertexCFD_FullInductionMHDProperties.hpp" -#include "utils/VertexCFD_Utils_VectorField.hpp" - -#include - -//---------------------------------------------------------------------------// -// TESTS -//---------------------------------------------------------------------------// -namespace VertexCFD -{ -namespace Test -{ -//---------------------------------------------------------------------------// -// Test data dependencies. -template -struct Dependencies : public PHX::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - using scalar_type = typename EvalType::ScalarT; - - static constexpr int num_field_dim = 3; - int num_space_dim; - - double _scalar_magn_pot; - double _eta; - - PHX::MDField _boundary_velocity_0; - PHX::MDField _boundary_velocity_1; - PHX::MDField _boundary_velocity_2; - - Kokkos::Array, - num_field_dim> - _induced_magnetic_field; - - Kokkos::Array< - PHX::MDField, - num_field_dim> - _grad_induced_magnetic_field; - - PHX::MDField - _scalar_magnetic_potential; - - PHX::MDField _resistivity; - - Kokkos::Array, - num_field_dim> - _external_magnetic_field; - - PHX::MDField _normals; - - Dependencies(const panzer::IntegrationRule& ir, - const double scalar_magn_pot, - const double eta) - : num_space_dim(ir.spatial_dimension) - , _scalar_magn_pot(scalar_magn_pot) - , _eta(eta) - , _boundary_velocity_0("BOUNDARY_velocity_0", ir.dl_scalar) - , _boundary_velocity_1("BOUNDARY_velocity_1", ir.dl_scalar) - , _boundary_velocity_2("BOUNDARY_velocity_2", ir.dl_scalar) - , _scalar_magnetic_potential("scalar_magnetic_potential", ir.dl_scalar) - , _resistivity("resistivity", ir.dl_scalar) - , _normals("Side Normal", ir.dl_vector) - { - this->addEvaluatedField(_boundary_velocity_0); - this->addEvaluatedField(_boundary_velocity_1); - if (num_space_dim == 3) - this->addEvaluatedField(_boundary_velocity_2); - - Utils::addEvaluatedVectorField(*this, - ir.dl_scalar, - _induced_magnetic_field, - "induced_magnetic_field_"); - - Utils::addEvaluatedVectorField(*this, - ir.dl_vector, - _grad_induced_magnetic_field, - "GRAD_induced_magnetic_field_"); - - this->addEvaluatedField(_scalar_magnetic_potential); - this->addEvaluatedField(_resistivity); - - Utils::addEvaluatedVectorField(*this, - ir.dl_scalar, - _external_magnetic_field, - "external_magnetic_field_"); - - this->addEvaluatedField(_normals); - - this->setName( - "Full Induction Model Conducting Unit Test Dependencies"); - } - - void evaluateFields(typename panzer::Traits::EvalData d) override - { - _boundary_velocity_0.deep_copy(3.0); - _boundary_velocity_1.deep_copy(-4.0); - if (num_space_dim == 3) - _boundary_velocity_2.deep_copy(5.0); - - for (int dim = 0; dim < num_field_dim; ++dim) - { - _induced_magnetic_field[dim].deep_copy(1.25 * (dim + 1)); - _external_magnetic_field[dim].deep_copy(pow(-0.5, dim + 1) * 0.1); - } - - _scalar_magnetic_potential.deep_copy(_scalar_magn_pot); - _resistivity.deep_copy(_eta); - - Kokkos::parallel_for( - "full induction model conducting unit test dependencies", - Kokkos::RangePolicy(0, d.num_cells), - *this); - } - - KOKKOS_INLINE_FUNCTION void operator()(const int c) const - { - const int num_point = _grad_induced_magnetic_field[0].extent(1); - const int num_grad_dim = _grad_induced_magnetic_field[0].extent(2); - for (int qp = 0; qp < num_point; ++qp) - { - _normals(c, qp, 0) = 0.45; - _normals(c, qp, 1) = -0.65; - if (num_grad_dim == 3) - _normals(c, qp, 2) = 0.35; - for (int fdim = 0; fdim < num_field_dim; ++fdim) - { - for (int gdim = 0; gdim < num_grad_dim; ++gdim) - { - _grad_induced_magnetic_field[fdim](c, qp, gdim) - = (fdim + 11) * pow(-0.5, fdim + gdim); - } - } - } - } -}; - -//---------------------------------------------------------------------------// -template -void testEval(bool build_magn_corr, - bool dirichlet_scalar_magn_pot, - bool build_resistive_flux) -{ - // Test fixture - static constexpr int num_space_dim = NumSpaceDim; - const int integration_order = 2; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - - const double nanval = std::numeric_limits::signaling_NaN(); - const double scalar_magn_pot - = (build_magn_corr && !dirichlet_scalar_magn_pot) ? 4.4 : nanval; - const Kokkos::Array bnd_b = {1.1, 2.2, 3.3}; - const double eta = 3.6; - - // Create dependencies - const auto dep_eval = Teuchos::rcp( - new Dependencies(*test_fixture.ir, scalar_magn_pot, eta)); - test_fixture.registerEvaluator(dep_eval); - - // Create conducting wall evaluator. - const double bnd_scalar_magn_pot - = (build_magn_corr && dirichlet_scalar_magn_pot) ? 5.5 : nanval; - - Teuchos::ParameterList bc_params; - bc_params.set("induced_magnetic_field_0", bnd_b[0]); - bc_params.set("induced_magnetic_field_1", bnd_b[1]); - if (num_space_dim == 3) - bc_params.set("induced_magnetic_field_2", bnd_b[2]); - if (build_magn_corr && dirichlet_scalar_magn_pot) - bc_params.set("scalar_magnetic_potential", bnd_scalar_magn_pot); - - Teuchos::ParameterList full_indu_params; - full_indu_params.set("Vacuum Magnetic Permeability", 0.12); - full_indu_params.set("Build Magnetic Correction Potential Equation", - build_magn_corr); - full_indu_params.set("Hyperbolic Divergence Cleaning Speed", 1.1); - full_indu_params.set("Build Resistive Flux", build_resistive_flux); - full_indu_params.set("Resistivity", eta); - MHDProperties::FullInductionMHDProperties mhd_props(full_indu_params); - - const auto cond_eval = Teuchos::rcp( - new BoundaryCondition:: - FullInductionConducting( - *test_fixture.ir, bc_params, mhd_props)); - - test_fixture.registerEvaluator(cond_eval); - - // Add required test fields. - for (int dim = 0; dim < num_space_dim; ++dim) - { - test_fixture.registerTestField( - cond_eval->_boundary_induced_magnetic_field[dim]); - test_fixture.registerTestField( - cond_eval->_boundary_grad_induced_magnetic_field[dim]); - } - if (build_magn_corr) - { - test_fixture.registerTestField( - cond_eval->_boundary_scalar_magnetic_potential); - } - - // Evaluate values - test_fixture.evaluate(); - - // Check values - const auto bnd_magn_field_0_result - = test_fixture.getTestFieldData( - cond_eval->_boundary_induced_magnetic_field[0]); - const auto bnd_grad_magn_field_0_result - = test_fixture.getTestFieldData( - cond_eval->_boundary_grad_induced_magnetic_field[0]); - const auto bnd_magn_field_1_result - = test_fixture.getTestFieldData( - cond_eval->_boundary_induced_magnetic_field[1]); - const auto bnd_grad_magn_field_1_result - = test_fixture.getTestFieldData( - cond_eval->_boundary_grad_induced_magnetic_field[1]); - - // Set up expected values based on case - // For now VERTEX only supports num_grad_dim = num_space_dim, - // but the reference script can produce values for the case - // where num_grad_dim = 2 and num_space_dim = 3 - const Kokkos::Array exp_b_2d = {1.307375, 2.417125, nanval}; - const Kokkos::Array exp_b_3d = {1.2365, 2.5195, 3.7395}; - - const auto exp_b = num_space_dim == 2 ? exp_b_2d : exp_b_3d; - - const Kokkos::Array, 3> exp_grad_b_2d - = {{{7.16375, 0.04125, nanval}, - {-3.9075, -0.0225, nanval}, - {nanval, nanval, nanval}}}; - const Kokkos::Array, 3> exp_grad_b_2d_res - = {{{7.26978125, -0.11190625, nanval}, - {-3.83409375, -0.12853125, nanval}, - {nanval, nanval, nanval}}}; - const Kokkos::Array, 3> exp_grad_b_3d - = {{{6.730625, 0.666875, -0.570625}, - {-3.67125, -0.36375, 0.31125}, - {1.98859375, 0.19703125, -0.16859375}}}; - const Kokkos::Array, 3> exp_grad_b_3d_res - = {{{6.81244062, 0.54869688, -0.50699062}, - {-3.4704, -0.65386667, 0.46746667}, - {2.25640937, -0.18981354, 0.03970729}}}; - - const auto exp_grad_b = num_space_dim == 2 ? build_resistive_flux - ? exp_grad_b_2d_res - : exp_grad_b_2d - : build_resistive_flux ? exp_grad_b_3d_res - : exp_grad_b_3d; - - const double exp_scalar_magn_pot - = dirichlet_scalar_magn_pot ? bnd_scalar_magn_pot : scalar_magn_pot; - - const auto& ir = *test_fixture.ir; - const int num_point = ir.num_points; - const double tol = build_resistive_flux ? 6.0e-9 : 1.0e-12; - for (int qp = 0; qp < num_point; ++qp) - { - EXPECT_DOUBLE_EQ(exp_b[0], fieldValue(bnd_magn_field_0_result, 0, qp)); - EXPECT_DOUBLE_EQ(exp_b[1], fieldValue(bnd_magn_field_1_result, 0, qp)); - if (num_space_dim == 3) - { - const auto bnd_magn_field_2_result - = test_fixture.getTestFieldData( - cond_eval->_boundary_induced_magnetic_field[2]); - EXPECT_DOUBLE_EQ(exp_b[2], - fieldValue(bnd_magn_field_2_result, 0, qp)); - } - if (build_magn_corr) - { - const auto bnd_scalar_magn_pot_result - = test_fixture.getTestFieldData( - cond_eval->_boundary_scalar_magnetic_potential); - EXPECT_DOUBLE_EQ(exp_scalar_magn_pot, - fieldValue(bnd_scalar_magn_pot_result, 0, qp)); - } - - for (int d = 0; d < num_space_dim; ++d) - { - EXPECT_NEAR(exp_grad_b[0][d], - fieldValue(bnd_grad_magn_field_0_result, 0, qp, d), - tol); - EXPECT_NEAR(exp_grad_b[1][d], - fieldValue(bnd_grad_magn_field_1_result, 0, qp, d), - tol); - if (num_space_dim == 3) - { - const auto bnd_grad_magn_field_2_result - = test_fixture.getTestFieldData( - cond_eval->_boundary_grad_induced_magnetic_field[2]); - EXPECT_NEAR(exp_grad_b[2][d], - fieldValue(bnd_grad_magn_field_2_result, 0, qp, d), - tol); - } - } - } -} - -//---------------------------------------------------------------------------// -struct FullInductionConductingTestParams -{ - bool build_magn_corr; - bool dirichlet_scalar_magn_pot; - bool build_resistive_flux; -}; - -class FullInductionConducting - : public testing::TestWithParam -{ - public: - struct PrintNameString - { - template - std::string operator()(const testing::TestParamInfo& info) const - { - auto p = static_cast(info.param); - - const std::string base_name = p.build_resistive_flux ? "Resistive" - : ""; - const std::string pot_name = !p.build_magn_corr ? "NoCleaning" - : p.dirichlet_scalar_magn_pot - ? "FixedScalarMagneticPotential" - : "FreeScalarMagneticPotential"; - return base_name + pot_name; - } - }; -}; - -//---------------------------------------------------------------------------// -TEST_P(FullInductionConducting, Residual2d) -{ - auto params = GetParam(); - testEval(params.build_magn_corr, - params.dirichlet_scalar_magn_pot, - params.build_resistive_flux); -} - -//---------------------------------------------------------------------------// -TEST_P(FullInductionConducting, Jacobian2d) -{ - auto params = GetParam(); - testEval(params.build_magn_corr, - params.dirichlet_scalar_magn_pot, - params.build_resistive_flux); -} - -//---------------------------------------------------------------------------// -TEST_P(FullInductionConducting, Residual3d) -{ - auto params = GetParam(); - testEval(params.build_magn_corr, - params.dirichlet_scalar_magn_pot, - params.build_resistive_flux); -} - -//---------------------------------------------------------------------------// -TEST_P(FullInductionConducting, Jacobian3d) -{ - auto params = GetParam(); - testEval(params.build_magn_corr, - params.dirichlet_scalar_magn_pot, - params.build_resistive_flux); -} - -//---------------------------------------------------------------------------// -INSTANTIATE_TEST_SUITE_P( - Test, - FullInductionConducting, - testing::Values(FullInductionConductingTestParams{false, false, false}, - FullInductionConductingTestParams{false, false, true}, - FullInductionConductingTestParams{true, false, false}, - FullInductionConductingTestParams{true, false, true}, - FullInductionConductingTestParams{true, true, false}, - FullInductionConductingTestParams{true, true, true}), - FullInductionConducting::PrintNameString()); - -//---------------------------------------------------------------------------// -} // end namespace Test -} // end namespace VertexCFD diff --git a/src/full_induction_mhd_solver/boundary_conditions/unit_test/tstFullInductionFixed.cpp b/src/full_induction_mhd_solver/boundary_conditions/unit_test/tstFullInductionFixed.cpp deleted file mode 100644 index f42eb4c..0000000 --- a/src/full_induction_mhd_solver/boundary_conditions/unit_test/tstFullInductionFixed.cpp +++ /dev/null @@ -1,256 +0,0 @@ -#include "VertexCFD_EvaluatorTestHarness.hpp" -#include "full_induction_mhd_solver/boundary_conditions/VertexCFD_BoundaryState_FullInductionFixed.hpp" - -#include "full_induction_mhd_solver/mhd_properties/VertexCFD_FullInductionMHDProperties.hpp" -#include "utils/VertexCFD_Utils_VectorField.hpp" - -#include - -//---------------------------------------------------------------------------// -// TESTS -//---------------------------------------------------------------------------// -namespace VertexCFD -{ -namespace Test -{ -//---------------------------------------------------------------------------// -// Test data dependencies. -template -struct Dependencies : public PHX::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - using scalar_type = typename EvalType::ScalarT; - - static constexpr int num_field_dim = 3; - - Kokkos::Array _grad_b; - double _scalar_magn_pot; - - Kokkos::Array< - PHX::MDField, - 3> - _grad_induced_magnetic_field; - PHX::MDField - _scalar_magnetic_potential; - - Dependencies(const panzer::IntegrationRule& ir, - const Kokkos::Array grad_b, - const double scalar_magn_pot) - : _grad_b(grad_b) - , _scalar_magn_pot(scalar_magn_pot) - , _scalar_magnetic_potential("scalar_magnetic_potential", ir.dl_scalar) - { - Utils::addEvaluatedVectorField(*this, - ir.dl_vector, - _grad_induced_magnetic_field, - "GRAD_induced_magnetic_field_"); - - this->addEvaluatedField(_scalar_magnetic_potential); - - this->setName("Full Induction Model Fixed Unit Test Dependencies"); - } - - void evaluateFields(typename panzer::Traits::EvalData /**d**/) override - { - for (int dim = 0; dim < num_field_dim; ++dim) - { - _grad_induced_magnetic_field[dim].deep_copy(_grad_b[dim]); - } - _scalar_magnetic_potential.deep_copy(_scalar_magn_pot); - } -}; - -//---------------------------------------------------------------------------// -template -void testEval(bool build_magn_corr, bool dirichlet_scalar_magn_pot) -{ - // Test fixture - static constexpr int num_space_dim = NumSpaceDim; - const int integration_order = 2; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - - const double nanval = std::numeric_limits::signaling_NaN(); - const Kokkos::Array grad_b - = {1.1, 2.2, num_space_dim == 2 ? nanval : 3.3}; - const double scalar_magn_pot - = (build_magn_corr && !dirichlet_scalar_magn_pot) ? 4.4 : nanval; - - // Create dependencies - const auto dep_eval = Teuchos::rcp( - new Dependencies(*test_fixture.ir, grad_b, scalar_magn_pot)); - test_fixture.registerEvaluator(dep_eval); - - // Create fixed evaluator. - const Kokkos::Array bnd_b - = {0.3, 0.4, num_space_dim == 2 ? nanval : 0.5}; - const double bnd_scalar_magn_pot - = (build_magn_corr && dirichlet_scalar_magn_pot) ? 5.5 : nanval; - const double exp_scalar_magn_pot - = dirichlet_scalar_magn_pot ? bnd_scalar_magn_pot : scalar_magn_pot; - - Teuchos::ParameterList bc_params; - bc_params.set("induced_magnetic_field_0", bnd_b[0]); - bc_params.set("induced_magnetic_field_1", bnd_b[1]); - if (num_space_dim == 3) - bc_params.set("induced_magnetic_field_2", bnd_b[2]); - if (build_magn_corr && dirichlet_scalar_magn_pot) - bc_params.set("scalar_magnetic_potential", bnd_scalar_magn_pot); - - Teuchos::ParameterList full_indu_params; - full_indu_params.set("Vacuum Magnetic Permeability", 0.1); - full_indu_params.set("Build Magnetic Correction Potential Equation", - build_magn_corr); - full_indu_params.set("Hyperbolic Divergence Cleaning Speed", 1.1); - MHDProperties::FullInductionMHDProperties mhd_props(full_indu_params); - - const auto fixed_eval = Teuchos::rcp( - new BoundaryCondition:: - FullInductionFixed( - *test_fixture.ir, bc_params, mhd_props)); - - test_fixture.registerEvaluator(fixed_eval); - - // Add required test fields. - for (int dim = 0; dim < num_space_dim; ++dim) - { - test_fixture.registerTestField( - fixed_eval->_boundary_induced_magnetic_field[dim]); - test_fixture.registerTestField( - fixed_eval->_boundary_grad_induced_magnetic_field[dim]); - } - if (build_magn_corr) - { - test_fixture.registerTestField( - fixed_eval->_boundary_scalar_magnetic_potential); - } - - // Evaluate values - test_fixture.evaluate(); - - // Check values - const auto bnd_magn_field_0_result - = test_fixture.getTestFieldData( - fixed_eval->_boundary_induced_magnetic_field[0]); - const auto bnd_grad_magn_field_0_result - = test_fixture.getTestFieldData( - fixed_eval->_boundary_grad_induced_magnetic_field[0]); - const auto bnd_magn_field_1_result - = test_fixture.getTestFieldData( - fixed_eval->_boundary_induced_magnetic_field[1]); - const auto bnd_grad_magn_field_1_result - = test_fixture.getTestFieldData( - fixed_eval->_boundary_grad_induced_magnetic_field[1]); - - const int num_point = bnd_magn_field_0_result.extent(1); - for (int qp = 0; qp < num_point; ++qp) - { - EXPECT_DOUBLE_EQ(bnd_b[0], fieldValue(bnd_magn_field_0_result, 0, qp)); - EXPECT_DOUBLE_EQ(bnd_b[1], fieldValue(bnd_magn_field_1_result, 0, qp)); - if (num_space_dim == 3) - { - const auto bnd_magn_field_2_result - = test_fixture.getTestFieldData( - fixed_eval->_boundary_induced_magnetic_field[2]); - EXPECT_DOUBLE_EQ(bnd_b[2], - fieldValue(bnd_magn_field_2_result, 0, qp)); - } - if (build_magn_corr) - { - const auto bnd_scalar_magn_pot_result - = test_fixture.getTestFieldData( - fixed_eval->_boundary_scalar_magnetic_potential); - EXPECT_DOUBLE_EQ(exp_scalar_magn_pot, - fieldValue(bnd_scalar_magn_pot_result, 0, qp)); - } - - for (int d = 0; d < num_space_dim; ++d) - { - EXPECT_DOUBLE_EQ( - grad_b[0], fieldValue(bnd_grad_magn_field_0_result, 0, qp, d)); - EXPECT_DOUBLE_EQ( - grad_b[1], fieldValue(bnd_grad_magn_field_1_result, 0, qp, d)); - if (num_space_dim == 3) - { - const auto bnd_grad_magn_field_2_result - = test_fixture.getTestFieldData( - fixed_eval->_boundary_grad_induced_magnetic_field[2]); - EXPECT_DOUBLE_EQ( - grad_b[2], - fieldValue(bnd_grad_magn_field_2_result, 0, qp, d)); - } - } - } -} - -//---------------------------------------------------------------------------// -struct FullInductionFixedTestParams -{ - bool build_magn_corr; - bool dirichlet_scalar_magn_pot; -}; - -class FullInductionFixed - : public testing::TestWithParam -{ - public: - struct PrintNameString - { - template - std::string operator()(const testing::TestParamInfo& info) const - { - auto p = static_cast(info.param); - const std::string test_name = !p.build_magn_corr ? "NoCleaning" - : p.dirichlet_scalar_magn_pot - ? "FixedScalarMagneticPotential" - : "FreeScalarMagneticPotential"; - return test_name; - } - }; -}; - -//---------------------------------------------------------------------------// -TEST_P(FullInductionFixed, residual_2d) -{ - auto params = GetParam(); - testEval(params.build_magn_corr, - params.dirichlet_scalar_magn_pot); -} - -//---------------------------------------------------------------------------// -TEST_P(FullInductionFixed, jacobian_2d) -{ - auto params = GetParam(); - testEval(params.build_magn_corr, - params.dirichlet_scalar_magn_pot); -} - -//---------------------------------------------------------------------------// -TEST_P(FullInductionFixed, residual_3d) -{ - auto params = GetParam(); - testEval(params.build_magn_corr, - params.dirichlet_scalar_magn_pot); -} - -//---------------------------------------------------------------------------// -TEST_P(FullInductionFixed, jacobian_3d) -{ - auto params = GetParam(); - testEval(params.build_magn_corr, - params.dirichlet_scalar_magn_pot); -} - -//---------------------------------------------------------------------------// -INSTANTIATE_TEST_SUITE_P( - Test, - FullInductionFixed, - testing::Values(FullInductionFixedTestParams{false, false}, - FullInductionFixedTestParams{true, false}, - FullInductionFixedTestParams{true, true}), - FullInductionFixed::PrintNameString()); - -//---------------------------------------------------------------------------// -} // end namespace Test -} // end namespace VertexCFD diff --git a/src/full_induction_mhd_solver/closure_models/VertexCFD_Closure_DivergenceCleaningSource.cpp b/src/full_induction_mhd_solver/closure_models/VertexCFD_Closure_DivergenceCleaningSource.cpp deleted file mode 100644 index e18647c..0000000 --- a/src/full_induction_mhd_solver/closure_models/VertexCFD_Closure_DivergenceCleaningSource.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_Closure_DivergenceCleaningSource.hpp" -#include "VertexCFD_Closure_DivergenceCleaningSource_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS_NUMSPACEDIM( - VertexCFD::ClosureModel::DivergenceCleaningSource) diff --git a/src/full_induction_mhd_solver/closure_models/VertexCFD_Closure_DivergenceCleaningSource.hpp b/src/full_induction_mhd_solver/closure_models/VertexCFD_Closure_DivergenceCleaningSource.hpp deleted file mode 100644 index 39dde03..0000000 --- a/src/full_induction_mhd_solver/closure_models/VertexCFD_Closure_DivergenceCleaningSource.hpp +++ /dev/null @@ -1,54 +0,0 @@ -#ifndef VERTEXCFD_CLOSURE_DIVERGENCECLEANINGSOURCE_HPP -#define VERTEXCFD_CLOSURE_DIVERGENCECLEANINGSOURCE_HPP - -#include -#include - -#include -#include -#include -#include - -#include - -namespace VertexCFD -{ -namespace ClosureModel -{ -//---------------------------------------------------------------------------// -// Hyperbolic divergence cleaning source term for the magnetic correction -// potential equation -//---------------------------------------------------------------------------// -template -class DivergenceCleaningSource : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - static constexpr int num_space_dim = NumSpaceDim; - - DivergenceCleaningSource(const panzer::IntegrationRule& ir); - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - PHX::MDField - _div_cleaning_potential_source; - - private: - Kokkos::Array, - num_space_dim> - _velocity; - PHX::MDField - _grad_scalar_magnetic_potential; -}; - -//---------------------------------------------------------------------------// - -} // end namespace ClosureModel -} // end namespace VertexCFD - -#endif // end VERTEXCFD_CLOSURE_DIVERGENCECLEANINGSOURCE_HPP diff --git a/src/full_induction_mhd_solver/closure_models/VertexCFD_Closure_FullInductionLocalTimeStepSize.cpp b/src/full_induction_mhd_solver/closure_models/VertexCFD_Closure_FullInductionLocalTimeStepSize.cpp deleted file mode 100644 index 6cdcbdc..0000000 --- a/src/full_induction_mhd_solver/closure_models/VertexCFD_Closure_FullInductionLocalTimeStepSize.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_Closure_FullInductionLocalTimeStepSize.hpp" -#include "VertexCFD_Closure_FullInductionLocalTimeStepSize_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS_NUMSPACEDIM( - VertexCFD::ClosureModel::FullInductionLocalTimeStepSize) diff --git a/src/full_induction_mhd_solver/closure_models/VertexCFD_Closure_FullInductionLocalTimeStepSize.hpp b/src/full_induction_mhd_solver/closure_models/VertexCFD_Closure_FullInductionLocalTimeStepSize.hpp deleted file mode 100644 index 2dca978..0000000 --- a/src/full_induction_mhd_solver/closure_models/VertexCFD_Closure_FullInductionLocalTimeStepSize.hpp +++ /dev/null @@ -1,71 +0,0 @@ -#ifndef VERTEXCFD_CLOSURE_FULLINDUCTIONLOCALTIMESTEPSIZE_HPP -#define VERTEXCFD_CLOSURE_FULLINDUCTIONLOCALTIMESTEPSIZE_HPP - -#include "incompressible_solver/fluid_properties/VertexCFD_ConstantFluidProperties.hpp" - -#include "full_induction_mhd_solver/mhd_properties/VertexCFD_FullInductionMHDProperties.hpp" - -#include -#include - -#include -#include -#include -#include - -#include - -namespace VertexCFD -{ -namespace ClosureModel -{ -//---------------------------------------------------------------------------// -// Compute local time step size based on the mesh size and maximum eigenvalue -// for the full induction MHD equation set (under incompressible assumption). -// The time step size used by the solver and based on the CFL condition is -// computed in the observer -// 'VertexCFD_TempusTimeStepControl_GlobalCFL_impl.hpp' -//---------------------------------------------------------------------------// -template -class FullInductionLocalTimeStepSize - : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - static constexpr int num_space_dim = NumSpaceDim; - - FullInductionLocalTimeStepSize( - const panzer::IntegrationRule& ir, - const FluidProperties::ConstantFluidProperties& fluid_prop, - const MHDProperties::FullInductionMHDProperties& mhd_props); - - void evaluateFields(typename Traits::EvalData d) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - public: - PHX::MDField _local_dt; - - private: - double _rho; - double _magnetic_permeability; - double _c_h; - - PHX::MDField - _element_length; - Kokkos::Array, - num_space_dim> - _velocity; - Kokkos::Array, 3> - _total_magnetic_field; -}; - -//---------------------------------------------------------------------------// - -} // end namespace ClosureModel -} // end namespace VertexCFD - -#endif // end VERTEXCFD_CLOSURE_FULLINDUCTIONLOCALTIMESTEPSIZE_HPP diff --git a/src/full_induction_mhd_solver/closure_models/VertexCFD_Closure_FullInductionModelErrorNorms.hpp b/src/full_induction_mhd_solver/closure_models/VertexCFD_Closure_FullInductionModelErrorNorms.hpp deleted file mode 100644 index 4340066..0000000 --- a/src/full_induction_mhd_solver/closure_models/VertexCFD_Closure_FullInductionModelErrorNorms.hpp +++ /dev/null @@ -1,67 +0,0 @@ -#ifndef VERTEXCFD_CLOSURE_FULLINDUCTIONMODELERRORNORMS_HPP -#define VERTEXCFD_CLOSURE_FULLINDUCTIONMODELERRORNORMS_HPP - -#include -#include - -#include -#include -#include -#include - -#include - -#include - -namespace VertexCFD -{ -namespace ClosureModel -{ -//---------------------------------------------------------------------------// -// Compute error norms between exact solution and numerical solutions -//---------------------------------------------------------------------------// -template -class FullInductionModelErrorNorms - : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - static constexpr int num_space_dim = NumSpaceDim; - - FullInductionModelErrorNorms(const panzer::IntegrationRule& ir); - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - Kokkos::Array, - num_space_dim> - _L1_error_induced; - - Kokkos::Array, - num_space_dim> - _L2_error_induced; - - PHX::MDField _volume; - - private: - Kokkos::Array, - num_space_dim> - _exact_induced_magnetic_field; - - Kokkos::Array, - num_space_dim> - _induced_magnetic_field; -}; - -//---------------------------------------------------------------------------// - -} // namespace ClosureModel -} // end namespace VertexCFD - -#include "VertexCFD_Closure_FullInductionModelErrorNorms_impl.hpp" - -#endif // VERTEXCFD_CLOSURE_FULLINDUCTIONMODELERRORNORMS_HPP diff --git a/src/full_induction_mhd_solver/closure_models/VertexCFD_Closure_GodunovPowellSource.cpp b/src/full_induction_mhd_solver/closure_models/VertexCFD_Closure_GodunovPowellSource.cpp deleted file mode 100644 index 50f0faa..0000000 --- a/src/full_induction_mhd_solver/closure_models/VertexCFD_Closure_GodunovPowellSource.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_Closure_GodunovPowellSource.hpp" -#include "VertexCFD_Closure_GodunovPowellSource_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS_NUMSPACEDIM( - VertexCFD::ClosureModel::GodunovPowellSource) diff --git a/src/full_induction_mhd_solver/closure_models/VertexCFD_Closure_GodunovPowellSource.hpp b/src/full_induction_mhd_solver/closure_models/VertexCFD_Closure_GodunovPowellSource.hpp deleted file mode 100644 index c1285cd..0000000 --- a/src/full_induction_mhd_solver/closure_models/VertexCFD_Closure_GodunovPowellSource.hpp +++ /dev/null @@ -1,67 +0,0 @@ -#ifndef VERTEXCFD_CLOSURE_GODUNOVPOWELLSOURCE_HPP -#define VERTEXCFD_CLOSURE_GODUNOVPOWELLSOURCE_HPP - -#include "full_induction_mhd_solver/mhd_properties/VertexCFD_FullInductionMHDProperties.hpp" - -#include -#include - -#include -#include -#include -#include - -#include - -namespace VertexCFD -{ -namespace ClosureModel -{ -//---------------------------------------------------------------------------// -// Godunov-Powell source evaluation for full induction MHD -//---------------------------------------------------------------------------// -template -class GodunovPowellSource : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - static constexpr int num_space_dim = NumSpaceDim; - - GodunovPowellSource( - const panzer::IntegrationRule& ir, - const MHDProperties::FullInductionMHDProperties& mhd_props); - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - Kokkos::Array, - num_space_dim> - _godunov_powell_momentum_source; - - Kokkos::Array, - num_space_dim> - _godunov_powell_induction_source; - - private: - double _magnetic_permeability; - - PHX::MDField - _divergence_total_magnetic_field; - - Kokkos::Array, - num_space_dim> - _velocity; - Kokkos::Array, 3> - _total_magnetic_field; -}; - -//---------------------------------------------------------------------------// - -} // end namespace ClosureModel -} // end namespace VertexCFD - -#endif // end VERTEXCFD_CLOSURE_GODUNOVPOWELLSOURCE_HPP diff --git a/src/full_induction_mhd_solver/closure_models/VertexCFD_Closure_InductionConstantSource.cpp b/src/full_induction_mhd_solver/closure_models/VertexCFD_Closure_InductionConstantSource.cpp deleted file mode 100644 index 85d3fee..0000000 --- a/src/full_induction_mhd_solver/closure_models/VertexCFD_Closure_InductionConstantSource.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_Closure_InductionConstantSource.hpp" -#include "VertexCFD_Closure_InductionConstantSource_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS_NUMSPACEDIM( - VertexCFD::ClosureModel::InductionConstantSource) diff --git a/src/full_induction_mhd_solver/closure_models/VertexCFD_Closure_InductionConstantSource.hpp b/src/full_induction_mhd_solver/closure_models/VertexCFD_Closure_InductionConstantSource.hpp deleted file mode 100644 index 69a7464..0000000 --- a/src/full_induction_mhd_solver/closure_models/VertexCFD_Closure_InductionConstantSource.hpp +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef VERTEXCFD_CLOSURE_INDUCTIONCONSTANTSOURCE_HPP -#define VERTEXCFD_CLOSURE_INDUCTIONCONSTANTSOURCE_HPP - -#include "full_induction_mhd_solver/mhd_properties/VertexCFD_FullInductionMHDProperties.hpp" - -#include -#include - -#include -#include -#include -#include - -#include - -namespace VertexCFD -{ -namespace ClosureModel -{ -//---------------------------------------------------------------------------// -// Linear-in-time external magnetic field source for induction equations -//---------------------------------------------------------------------------// -template -class InductionConstantSource : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - static constexpr int num_space_dim = NumSpaceDim; - - InductionConstantSource(const panzer::IntegrationRule& ir, - const Teuchos::ParameterList& model_params); - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - Kokkos::Array, - num_space_dim> - _induction_source; - - private: - Kokkos::Array _ind_input_source; -}; - -//---------------------------------------------------------------------------// - -} // end namespace ClosureModel -} // end namespace VertexCFD - -#endif // end VERTEXCFD_CLOSURE_INDUCTIONCONSTANTSOURCE_HPP diff --git a/src/full_induction_mhd_solver/closure_models/VertexCFD_Closure_InductionConvectiveFlux.cpp b/src/full_induction_mhd_solver/closure_models/VertexCFD_Closure_InductionConvectiveFlux.cpp deleted file mode 100644 index 424f7a2..0000000 --- a/src/full_induction_mhd_solver/closure_models/VertexCFD_Closure_InductionConvectiveFlux.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_Closure_InductionConvectiveFlux.hpp" -#include "VertexCFD_Closure_InductionConvectiveFlux_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS_NUMSPACEDIM( - VertexCFD::ClosureModel::InductionConvectiveFlux) diff --git a/src/full_induction_mhd_solver/closure_models/VertexCFD_Closure_InductionConvectiveFlux.hpp b/src/full_induction_mhd_solver/closure_models/VertexCFD_Closure_InductionConvectiveFlux.hpp deleted file mode 100644 index 5f0c79a..0000000 --- a/src/full_induction_mhd_solver/closure_models/VertexCFD_Closure_InductionConvectiveFlux.hpp +++ /dev/null @@ -1,76 +0,0 @@ -#ifndef VERTEXCFD_CLOSURE_INDUCTIONCONVECTIVEFLUX_HPP -#define VERTEXCFD_CLOSURE_INDUCTIONCONVECTIVEFLUX_HPP - -#include "full_induction_mhd_solver/mhd_properties/VertexCFD_FullInductionMHDProperties.hpp" - -#include -#include - -#include -#include -#include -#include - -#include - -#include - -namespace VertexCFD -{ -namespace ClosureModel -{ -//---------------------------------------------------------------------------// -// Multi-dimension induction convective flux evaluation. -//---------------------------------------------------------------------------// -template -class InductionConvectiveFlux : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - static constexpr int num_space_dim = NumSpaceDim; - - InductionConvectiveFlux( - const panzer::IntegrationRule& ir, - const MHDProperties::FullInductionMHDProperties& mhd_props, - const std::string& flux_prefix = "", - const std::string& field_prefix = ""); - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - Kokkos::Array< - PHX::MDField, - num_space_dim> - _momentum_flux; - Kokkos::Array< - PHX::MDField, - num_space_dim> - _induction_flux; - PHX::MDField - _magnetic_correction_potential_flux; - - private: - Kokkos::Array, - num_space_dim> - _velocity; - Kokkos::Array, 3> - _total_magnetic_field; - PHX::MDField - _scalar_magnetic_potential; - PHX::MDField _magnetic_pressure; - - bool _solve_magn_corr; - double _magnetic_permeability; - double _c_h; -}; - -//---------------------------------------------------------------------------// - -} // end namespace ClosureModel -} // end namespace VertexCFD - -#endif // end VERTEXCFD_CLOSURE_INDUCTIONCONVECTIVEFLUX_HPP diff --git a/src/full_induction_mhd_solver/closure_models/VertexCFD_Closure_InductionResistiveFlux.cpp b/src/full_induction_mhd_solver/closure_models/VertexCFD_Closure_InductionResistiveFlux.cpp deleted file mode 100644 index 02a51d0..0000000 --- a/src/full_induction_mhd_solver/closure_models/VertexCFD_Closure_InductionResistiveFlux.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_Closure_InductionResistiveFlux.hpp" -#include "VertexCFD_Closure_InductionResistiveFlux_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS_NUMSPACEDIM( - VertexCFD::ClosureModel::InductionResistiveFlux) diff --git a/src/full_induction_mhd_solver/closure_models/VertexCFD_Closure_InductionResistiveFlux.hpp b/src/full_induction_mhd_solver/closure_models/VertexCFD_Closure_InductionResistiveFlux.hpp deleted file mode 100644 index ddcdc6a..0000000 --- a/src/full_induction_mhd_solver/closure_models/VertexCFD_Closure_InductionResistiveFlux.hpp +++ /dev/null @@ -1,74 +0,0 @@ -#ifndef VERTEXCFD_CLOSURE_INDUCTIONRESISTIVEFLUX_HPP -#define VERTEXCFD_CLOSURE_INDUCTIONRESISTIVEFLUX_HPP - -#include "full_induction_mhd_solver/mhd_properties/VertexCFD_FullInductionMHDProperties.hpp" - -#include -#include - -#include -#include -#include -#include - -#include - -#include - -namespace VertexCFD -{ -namespace ClosureModel -{ -//---------------------------------------------------------------------------// -// Multi-dimension induction resistive flux evaluation. -//---------------------------------------------------------------------------// -template -class InductionResistiveFlux : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - static constexpr int num_space_dim = NumSpaceDim; - - InductionResistiveFlux( - const panzer::IntegrationRule& ir, - const MHDProperties::FullInductionMHDProperties& mhd_props, - const std::string& flux_prefix = "", - const std::string& gradient_prefix = ""); - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - Kokkos::Array< - PHX::MDField, - num_space_dim> - _induction_flux; - PHX::MDField - _magnetic_correction_potential_flux; - - private: - Kokkos::Array, 3> - _total_magnetic_field; - PHX::MDField _resistivity; - - Kokkos::Array< - PHX::MDField, - 3> - _grad_total_magnetic_field; - PHX::MDField - _grad_resistivity; - - bool _variable_resistivity; - bool _solve_magn_corr; - double _magnetic_permeability; -}; - -//---------------------------------------------------------------------------// - -} // end namespace ClosureModel -} // end namespace VertexCFD - -#endif // end VERTEXCFD_CLOSURE_INDUCTIONRESISTIVEFLUX_HPP diff --git a/src/full_induction_mhd_solver/closure_models/VertexCFD_Closure_MHDVortexProblemExact.cpp b/src/full_induction_mhd_solver/closure_models/VertexCFD_Closure_MHDVortexProblemExact.cpp deleted file mode 100644 index 6d7ad80..0000000 --- a/src/full_induction_mhd_solver/closure_models/VertexCFD_Closure_MHDVortexProblemExact.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_Closure_MHDVortexProblemExact.hpp" -#include "VertexCFD_Closure_MHDVortexProblemExact_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS_NUMSPACEDIM( - VertexCFD::ClosureModel::MHDVortexProblemExact) diff --git a/src/full_induction_mhd_solver/closure_models/VertexCFD_Closure_MHDVortexProblemExact.hpp b/src/full_induction_mhd_solver/closure_models/VertexCFD_Closure_MHDVortexProblemExact.hpp deleted file mode 100644 index 7b858a4..0000000 --- a/src/full_induction_mhd_solver/closure_models/VertexCFD_Closure_MHDVortexProblemExact.hpp +++ /dev/null @@ -1,66 +0,0 @@ -#ifndef VERTEXCFD_CLOSURE_MHDVORTEXPROBLEMEXACT_HPP -#define VERTEXCFD_CLOSURE_MHDVORTEXPROBLEMEXACT_HPP - -#include -#include - -#include -#include -#include -#include - -#include - -#include - -namespace VertexCFD -{ -namespace ClosureModel -{ -//---------------------------------------------------------------------------// -// Exact solution for MHD vortex problem -//---------------------------------------------------------------------------// -template -class MHDVortexProblemExact : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - static constexpr int num_space_dim = NumSpaceDim; - - MHDVortexProblemExact(const panzer::IntegrationRule& ir, - const Teuchos::ParameterList& full_induction_params); - - void postRegistrationSetup(typename Traits::SetupData sd, - PHX::FieldManager& fm) override; - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - private: - int _ir_degree; - int _ir_index; - int _basis_index; - Kokkos::Array _vel_0; - Kokkos::Array _xy_0; - double _time; - PHX::MDField _ip_coords; - - public: - PHX::MDField _lagrange_pressure; - Kokkos::Array, num_space_dim> - _velocity; - Kokkos::Array, num_space_dim> - _induced_magnetic_field; -}; - -//---------------------------------------------------------------------------// - -} // end namespace ClosureModel -} // end namespace VertexCFD - -#endif // end - // VERTEXCFD_CLOSURE_MHDVORTEXPROBLEMEXACT_HPP diff --git a/src/full_induction_mhd_solver/closure_models/VertexCFD_Closure_MagneticCorrectionDampingSource.cpp b/src/full_induction_mhd_solver/closure_models/VertexCFD_Closure_MagneticCorrectionDampingSource.cpp deleted file mode 100644 index e6cdfc5..0000000 --- a/src/full_induction_mhd_solver/closure_models/VertexCFD_Closure_MagneticCorrectionDampingSource.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_Closure_MagneticCorrectionDampingSource.hpp" -#include "VertexCFD_Closure_MagneticCorrectionDampingSource_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS( - VertexCFD::ClosureModel::MagneticCorrectionDampingSource) diff --git a/src/full_induction_mhd_solver/closure_models/VertexCFD_Closure_MagneticCorrectionDampingSource.hpp b/src/full_induction_mhd_solver/closure_models/VertexCFD_Closure_MagneticCorrectionDampingSource.hpp deleted file mode 100644 index 1638c50..0000000 --- a/src/full_induction_mhd_solver/closure_models/VertexCFD_Closure_MagneticCorrectionDampingSource.hpp +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef VERTEXCFD_CLOSURE_MAGNETICCORRECTIONDAMPINGSOURCE_HPP -#define VERTEXCFD_CLOSURE_MAGNETICCORRECTIONDAMPINGSOURCE_HPP - -#include "full_induction_mhd_solver/mhd_properties/VertexCFD_FullInductionMHDProperties.hpp" - -#include -#include - -#include -#include -#include -#include - -#include - -namespace VertexCFD -{ -namespace ClosureModel -{ -//---------------------------------------------------------------------------// -// Damping term for the magnetic correction potential field -//---------------------------------------------------------------------------// -template -class MagneticCorrectionDampingSource - : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - - MagneticCorrectionDampingSource( - const panzer::IntegrationRule& ir, - const MHDProperties::FullInductionMHDProperties& mhd_props); - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - PHX::MDField - _damping_potential_source; - - private: - double _alpha; - - PHX::MDField - _scalar_magnetic_potential; -}; - -//---------------------------------------------------------------------------// - -} // end namespace ClosureModel -} // end namespace VertexCFD - -#endif // end VERTEXCFD_CLOSURE_MAGNETICCORRECTIONDAMPINGSOURCE_HPP diff --git a/src/full_induction_mhd_solver/closure_models/VertexCFD_Closure_MagneticPressure.cpp b/src/full_induction_mhd_solver/closure_models/VertexCFD_Closure_MagneticPressure.cpp deleted file mode 100644 index c0ff1d5..0000000 --- a/src/full_induction_mhd_solver/closure_models/VertexCFD_Closure_MagneticPressure.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_Closure_MagneticPressure.hpp" -#include "VertexCFD_Closure_MagneticPressure_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS( - VertexCFD::ClosureModel::MagneticPressure) diff --git a/src/full_induction_mhd_solver/closure_models/VertexCFD_Closure_MagneticPressure.hpp b/src/full_induction_mhd_solver/closure_models/VertexCFD_Closure_MagneticPressure.hpp deleted file mode 100644 index e483376..0000000 --- a/src/full_induction_mhd_solver/closure_models/VertexCFD_Closure_MagneticPressure.hpp +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef VERTEXCFD_CLOSURE_MAGNETICPRESSURE_HPP -#define VERTEXCFD_CLOSURE_MAGNETICPRESSURE_HPP - -#include "full_induction_mhd_solver/mhd_properties/VertexCFD_FullInductionMHDProperties.hpp" - -#include -#include - -#include -#include -#include -#include - -#include - -#include - -namespace VertexCFD -{ -namespace ClosureModel -{ -//---------------------------------------------------------------------------// -// Magnetic pressure for full induction MHD -//---------------------------------------------------------------------------// -template -class MagneticPressure : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - - MagneticPressure(const panzer::IntegrationRule& ir, - const MHDProperties::FullInductionMHDProperties& mhd_props); - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - private: - double _magnetic_permeability; - Kokkos::Array, 3> - _total_magnetic_field; - - public: - PHX::MDField _magnetic_pressure; -}; - -//---------------------------------------------------------------------------// - -} // end namespace ClosureModel -} // end namespace VertexCFD - -#endif // end - // VERTEXCFD_CLOSURE_MAGNETICPRESSURE_HPP diff --git a/src/full_induction_mhd_solver/closure_models/VertexCFD_Closure_TotalMagneticField.cpp b/src/full_induction_mhd_solver/closure_models/VertexCFD_Closure_TotalMagneticField.cpp deleted file mode 100644 index 4ec12fb..0000000 --- a/src/full_induction_mhd_solver/closure_models/VertexCFD_Closure_TotalMagneticField.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_Closure_TotalMagneticField.hpp" -#include "VertexCFD_Closure_TotalMagneticField_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS_NUMSPACEDIM( - VertexCFD::ClosureModel::TotalMagneticField) diff --git a/src/full_induction_mhd_solver/closure_models/VertexCFD_Closure_TotalMagneticField.hpp b/src/full_induction_mhd_solver/closure_models/VertexCFD_Closure_TotalMagneticField.hpp deleted file mode 100644 index 32ded79..0000000 --- a/src/full_induction_mhd_solver/closure_models/VertexCFD_Closure_TotalMagneticField.hpp +++ /dev/null @@ -1,59 +0,0 @@ -#ifndef VERTEXCFD_CLOSURE_TOTALMAGNETICFIELD_HPP -#define VERTEXCFD_CLOSURE_TOTALMAGNETICFIELD_HPP - -#include -#include - -#include -#include -#include -#include - -#include - -#include - -namespace VertexCFD -{ -namespace ClosureModel -{ -//---------------------------------------------------------------------------// -// Compute total magnetic field for full induction MHD -//---------------------------------------------------------------------------// -template -class TotalMagneticField : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - static constexpr int num_space_dim = NumSpaceDim; - - TotalMagneticField(const panzer::IntegrationRule& ir, - const std::string& field_prefix = ""); - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - private: - bool _uniform_external_field; - Kokkos::Array, - num_space_dim> - _induced_magnetic_field; - Kokkos::Array, 3> - _external_magnetic_field; - - public: - Kokkos::Array, 3> - _total_magnetic_field; -}; - -//---------------------------------------------------------------------------// - -} // end namespace ClosureModel -} // end namespace VertexCFD - -#endif // end - // VERTEXCFD_CLOSURE_TOTALMAGNETICFIELD_HPP diff --git a/src/full_induction_mhd_solver/closure_models/VertexCFD_Closure_TotalMagneticFieldGradient.cpp b/src/full_induction_mhd_solver/closure_models/VertexCFD_Closure_TotalMagneticFieldGradient.cpp deleted file mode 100644 index c7aa481..0000000 --- a/src/full_induction_mhd_solver/closure_models/VertexCFD_Closure_TotalMagneticFieldGradient.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_Closure_TotalMagneticFieldGradient.hpp" -#include "VertexCFD_Closure_TotalMagneticFieldGradient_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS_NUMSPACEDIM( - VertexCFD::ClosureModel::TotalMagneticFieldGradient) diff --git a/src/full_induction_mhd_solver/closure_models/VertexCFD_Closure_TotalMagneticFieldGradient.hpp b/src/full_induction_mhd_solver/closure_models/VertexCFD_Closure_TotalMagneticFieldGradient.hpp deleted file mode 100644 index fae751a..0000000 --- a/src/full_induction_mhd_solver/closure_models/VertexCFD_Closure_TotalMagneticFieldGradient.hpp +++ /dev/null @@ -1,65 +0,0 @@ -#ifndef VERTEXCFD_CLOSURE_TOTALMAGNETICFIELDGRADIENT_HPP -#define VERTEXCFD_CLOSURE_TOTALMAGNETICFIELDGRADIENT_HPP - -#include -#include - -#include -#include -#include -#include - -#include - -#include - -namespace VertexCFD -{ -namespace ClosureModel -{ -//---------------------------------------------------------------------------// -// Compute total magnetic field gradient for full induction MHD -//---------------------------------------------------------------------------// -template -class TotalMagneticFieldGradient - : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - static constexpr int num_space_dim = NumSpaceDim; - - TotalMagneticFieldGradient(const panzer::IntegrationRule& ir, - const std::string& gradient_prefix = ""); - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - private: - bool _uniform_external_field; - Kokkos::Array< - PHX::MDField, - num_space_dim> - _grad_induced_magnetic_field; - Kokkos::Array< - PHX::MDField, - 3> - _grad_external_magnetic_field; - - public: - Kokkos::Array< - PHX::MDField, - 3> - _grad_total_magnetic_field; -}; - -//---------------------------------------------------------------------------// - -} // end namespace ClosureModel -} // end namespace VertexCFD - -#endif // end - // VERTEXCFD_CLOSURE_TOTALMAGNETICFIELDGRADIENT_HPP diff --git a/src/full_induction_mhd_solver/closure_models/VertexCFD_FullInductionClosureModelFactory.hpp b/src/full_induction_mhd_solver/closure_models/VertexCFD_FullInductionClosureModelFactory.hpp deleted file mode 100644 index 3c3a4da..0000000 --- a/src/full_induction_mhd_solver/closure_models/VertexCFD_FullInductionClosureModelFactory.hpp +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef VERTEXCFD_FULLINDUCTIONCLOSUREMODELFACTORY_HPP -#define VERTEXCFD_FULLINDUCTIONCLOSUREMODELFACTORY_HPP - -#include - -#include - -#include -#include - -namespace VertexCFD -{ -namespace ClosureModel -{ -//---------------------------------------------------------------------------// -template -class FullInductionFactory -{ - public: - static constexpr int num_space_dim = NumSpaceDim; - - void buildClosureModel( - const std::string& closure_type, - const Teuchos::RCP& ir, - const Teuchos::ParameterList& user_params, - const Teuchos::ParameterList& closure_params, - bool& found_model, - std::string& error_msg, - Teuchos::RCP>>> - evaluators); -}; - -//---------------------------------------------------------------------------// - -} // end namespace ClosureModel -} // end namespace VertexCFD - -#endif // end VERTEXCFD_FULLINDUCTIONCLOSUREMODELFACTORY_HPP diff --git a/src/full_induction_mhd_solver/closure_models/VertexCFD_FullInductionClosureModelFactory_Hessian2d.cpp b/src/full_induction_mhd_solver/closure_models/VertexCFD_FullInductionClosureModelFactory_Hessian2d.cpp deleted file mode 100644 index 2d345da..0000000 --- a/src/full_induction_mhd_solver/closure_models/VertexCFD_FullInductionClosureModelFactory_Hessian2d.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include "VertexCFD_FullInductionClosureModelFactory.hpp" -#include "VertexCFD_FullInductionClosureModelFactory_impl.hpp" - -template class VertexCFD::ClosureModel:: - FullInductionFactory; diff --git a/src/full_induction_mhd_solver/closure_models/VertexCFD_FullInductionClosureModelFactory_Hessian3d.cpp b/src/full_induction_mhd_solver/closure_models/VertexCFD_FullInductionClosureModelFactory_Hessian3d.cpp deleted file mode 100644 index 777f2ff..0000000 --- a/src/full_induction_mhd_solver/closure_models/VertexCFD_FullInductionClosureModelFactory_Hessian3d.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include "VertexCFD_FullInductionClosureModelFactory.hpp" -#include "VertexCFD_FullInductionClosureModelFactory_impl.hpp" - -template class VertexCFD::ClosureModel:: - FullInductionFactory; diff --git a/src/full_induction_mhd_solver/closure_models/VertexCFD_FullInductionClosureModelFactory_Jacobian2d.cpp b/src/full_induction_mhd_solver/closure_models/VertexCFD_FullInductionClosureModelFactory_Jacobian2d.cpp deleted file mode 100644 index 36a3339..0000000 --- a/src/full_induction_mhd_solver/closure_models/VertexCFD_FullInductionClosureModelFactory_Jacobian2d.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include "VertexCFD_FullInductionClosureModelFactory.hpp" -#include "VertexCFD_FullInductionClosureModelFactory_impl.hpp" - -template class VertexCFD::ClosureModel:: - FullInductionFactory; diff --git a/src/full_induction_mhd_solver/closure_models/VertexCFD_FullInductionClosureModelFactory_Jacobian3d.cpp b/src/full_induction_mhd_solver/closure_models/VertexCFD_FullInductionClosureModelFactory_Jacobian3d.cpp deleted file mode 100644 index f16a9a0..0000000 --- a/src/full_induction_mhd_solver/closure_models/VertexCFD_FullInductionClosureModelFactory_Jacobian3d.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include "VertexCFD_FullInductionClosureModelFactory.hpp" -#include "VertexCFD_FullInductionClosureModelFactory_impl.hpp" - -template class VertexCFD::ClosureModel:: - FullInductionFactory; diff --git a/src/full_induction_mhd_solver/closure_models/VertexCFD_FullInductionClosureModelFactory_Residual2d.cpp b/src/full_induction_mhd_solver/closure_models/VertexCFD_FullInductionClosureModelFactory_Residual2d.cpp deleted file mode 100644 index c3245bb..0000000 --- a/src/full_induction_mhd_solver/closure_models/VertexCFD_FullInductionClosureModelFactory_Residual2d.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include "VertexCFD_FullInductionClosureModelFactory.hpp" -#include "VertexCFD_FullInductionClosureModelFactory_impl.hpp" - -template class VertexCFD::ClosureModel:: - FullInductionFactory; diff --git a/src/full_induction_mhd_solver/closure_models/VertexCFD_FullInductionClosureModelFactory_Residual3d.cpp b/src/full_induction_mhd_solver/closure_models/VertexCFD_FullInductionClosureModelFactory_Residual3d.cpp deleted file mode 100644 index 75fce2c..0000000 --- a/src/full_induction_mhd_solver/closure_models/VertexCFD_FullInductionClosureModelFactory_Residual3d.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include "VertexCFD_FullInductionClosureModelFactory.hpp" -#include "VertexCFD_FullInductionClosureModelFactory_impl.hpp" - -template class VertexCFD::ClosureModel:: - FullInductionFactory; diff --git a/src/full_induction_mhd_solver/closure_models/VertexCFD_FullInductionClosureModelFactory_Tangent2d.cpp b/src/full_induction_mhd_solver/closure_models/VertexCFD_FullInductionClosureModelFactory_Tangent2d.cpp deleted file mode 100644 index 9a34c79..0000000 --- a/src/full_induction_mhd_solver/closure_models/VertexCFD_FullInductionClosureModelFactory_Tangent2d.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include "VertexCFD_FullInductionClosureModelFactory.hpp" -#include "VertexCFD_FullInductionClosureModelFactory_impl.hpp" - -template class VertexCFD::ClosureModel:: - FullInductionFactory; diff --git a/src/full_induction_mhd_solver/closure_models/VertexCFD_FullInductionClosureModelFactory_Tangent3d.cpp b/src/full_induction_mhd_solver/closure_models/VertexCFD_FullInductionClosureModelFactory_Tangent3d.cpp deleted file mode 100644 index 05fc7fc..0000000 --- a/src/full_induction_mhd_solver/closure_models/VertexCFD_FullInductionClosureModelFactory_Tangent3d.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include "VertexCFD_FullInductionClosureModelFactory.hpp" -#include "VertexCFD_FullInductionClosureModelFactory_impl.hpp" - -template class VertexCFD::ClosureModel:: - FullInductionFactory; diff --git a/src/full_induction_mhd_solver/closure_models/VertexCFD_FullInductionClosureModelFactory_impl.hpp b/src/full_induction_mhd_solver/closure_models/VertexCFD_FullInductionClosureModelFactory_impl.hpp deleted file mode 100644 index 9e925e7..0000000 --- a/src/full_induction_mhd_solver/closure_models/VertexCFD_FullInductionClosureModelFactory_impl.hpp +++ /dev/null @@ -1,231 +0,0 @@ -#ifndef VERTEXCFD_FULLINDUCTIONCLOSUREMODELFACTORY_IMPL_HPP -#define VERTEXCFD_FULLINDUCTIONCLOSUREMODELFACTORY_IMPL_HPP - -#include "incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleVariableTimeDerivative.hpp" -#include "incompressible_solver/fluid_properties/VertexCFD_ConstantFluidProperties.hpp" - -#include "closure_models/VertexCFD_Closure_ConstantScalarField.hpp" - -#include "full_induction_mhd_solver/closure_models/VertexCFD_Closure_DivergenceCleaningSource.hpp" -#include "full_induction_mhd_solver/closure_models/VertexCFD_Closure_FullInductionLocalTimeStepSize.hpp" -#include "full_induction_mhd_solver/closure_models/VertexCFD_Closure_FullInductionModelErrorNorms.hpp" -#include "full_induction_mhd_solver/closure_models/VertexCFD_Closure_GodunovPowellSource.hpp" -#include "full_induction_mhd_solver/closure_models/VertexCFD_Closure_InductionConstantSource.hpp" -#include "full_induction_mhd_solver/closure_models/VertexCFD_Closure_InductionConvectiveFlux.hpp" -#include "full_induction_mhd_solver/closure_models/VertexCFD_Closure_InductionResistiveFlux.hpp" -#include "full_induction_mhd_solver/closure_models/VertexCFD_Closure_MHDVortexProblemExact.hpp" -#include "full_induction_mhd_solver/closure_models/VertexCFD_Closure_MagneticCorrectionDampingSource.hpp" -#include "full_induction_mhd_solver/closure_models/VertexCFD_Closure_MagneticPressure.hpp" -#include "full_induction_mhd_solver/closure_models/VertexCFD_Closure_TotalMagneticField.hpp" -#include "full_induction_mhd_solver/closure_models/VertexCFD_Closure_TotalMagneticFieldGradient.hpp" - -#include "full_induction_mhd_solver/mhd_properties/VertexCFD_FullInductionMHDProperties.hpp" - -namespace VertexCFD -{ -namespace ClosureModel -{ -//---------------------------------------------------------------------------// -template -void FullInductionFactory::buildClosureModel( - const std::string& closure_type, - const Teuchos::RCP& ir, - const Teuchos::ParameterList& user_params, - const Teuchos::ParameterList& closure_params, - bool& found_model, - std::string& error_msg, - Teuchos::RCP>>> - evaluators) -{ - // Fluid properties - Teuchos::ParameterList fluid_prop_list - = user_params.sublist("Fluid Properties"); - const bool build_temp_equ - = user_params.isType("Build Temperature Equation") - ? user_params.get("Build Temperature Equation") - : false; - fluid_prop_list.set("Build Temperature Equation", build_temp_equ); - FluidProperties::ConstantFluidProperties incompressible_fluidprop_params - = FluidProperties::ConstantFluidProperties(fluid_prop_list); - - // Properties used by full induction MHD closure models - const auto full_induction_params - = user_params.sublist("Full Induction MHD Properties"); - MHDProperties::FullInductionMHDProperties mhd_props - = MHDProperties::FullInductionMHDProperties(full_induction_params); - const bool build_magn_corr = mhd_props.buildMagnCorr(); - - // Closure models - if (closure_type == "InductionConvectiveFlux") - { - auto eval = Teuchos::rcp( - new InductionConvectiveFlux( - *ir, mhd_props)); - evaluators->push_back(eval); - found_model = true; - } - - if (closure_type == "InductionResistiveFlux") - { - auto eval = Teuchos::rcp( - new InductionResistiveFlux( - *ir, mhd_props)); - evaluators->push_back(eval); - found_model = true; - } - - if (closure_type == "MagneticPressure") - { - auto eval = Teuchos::rcp( - new MagneticPressure(*ir, mhd_props)); - evaluators->push_back(eval); - found_model = true; - } - - if (closure_type == "FullInductionTimeDerivative") - { - std::vector mhd_names_list_vct; - for (int dim = 0; dim < num_space_dim; ++dim) - { - Teuchos::ParameterList ind_names_list; - ind_names_list.set( - "Field Name", "induced_magnetic_field_" + std::to_string(dim)); - ind_names_list.set("Equation Name", - "induction_" + std::to_string(dim)); - mhd_names_list_vct.push_back(ind_names_list); - } - if (build_magn_corr) - { - Teuchos::ParameterList magn_corr_names_list; - magn_corr_names_list.set("Field Name", "scalar_magnetic_potential"); - magn_corr_names_list.set("Equation Name", - "magnetic_correction_potential"); - mhd_names_list_vct.push_back(magn_corr_names_list); - } - for (auto& mhd_names_list : mhd_names_list_vct) - { - auto eval_time = Teuchos::rcp( - new IncompressibleVariableTimeDerivative( - *ir, mhd_names_list)); - evaluators->push_back(eval_time); - } - found_model = true; - } - - if (closure_type == "TotalMagneticField") - { - auto eval = Teuchos::rcp( - new TotalMagneticField( - *ir)); - evaluators->push_back(eval); - auto eval_grad = Teuchos::rcp( - new TotalMagneticFieldGradient( - *ir)); - evaluators->push_back(eval_grad); - found_model = true; - } - - if (closure_type == "MHDVortexProblemExact") - { - auto eval = Teuchos::rcp( - new MHDVortexProblemExact( - *ir, full_induction_params)); - evaluators->push_back(eval); - found_model = true; - } - - if (closure_type == "FullInductionModelErrorNorm") - { - auto eval = Teuchos::rcp( - new FullInductionModelErrorNorms( - *ir)); - evaluators->push_back(eval); - found_model = true; - } - - if (closure_type == "DivergenceCleaningSource") - { - auto eval = Teuchos::rcp( - new DivergenceCleaningSource( - *ir)); - evaluators->push_back(eval); - found_model = true; - } - - if (closure_type == "GodunovPowellSource") - { - auto eval = Teuchos::rcp( - new GodunovPowellSource( - *ir, mhd_props)); - evaluators->push_back(eval); - found_model = true; - } - - if (closure_type == "MagneticCorrectionDampingSource") - { - auto eval = Teuchos::rcp( - new MagneticCorrectionDampingSource( - *ir, mhd_props)); - evaluators->push_back(eval); - found_model = true; - } - - if (closure_type == "FullInductionLocalTimeStepSize") - { - auto eval = Teuchos::rcp( - new FullInductionLocalTimeStepSize( - *ir, incompressible_fluidprop_params, mhd_props)); - evaluators->push_back(eval); - found_model = true; - } - - if (closure_type == "Resistivity") - { - if (mhd_props.variableResistivity()) - { - throw std::runtime_error( - "No closure models currently exist to evaluate variable " - "resistivity. Use a constant resistivity only."); - } - else - { - auto eval = Teuchos::rcp( - new ConstantScalarField( - *ir, "resistivity", mhd_props.resistivity())); - evaluators->push_back(eval); - found_model = true; - } - } - - if (closure_type == "InductionConstantSource") - { - auto eval = Teuchos::rcp( - new InductionConstantSource( - *ir, closure_params)); - evaluators->push_back(eval); - found_model = true; - } - - // Initialize 'error_msg' with list of closure models for induction MHD - // equations - error_msg = "DivergenceCleaningSource\n"; - error_msg += "FullInductionLocalTimeStepSize\n"; - error_msg += "FullInductionModelErrorNorm\n"; - error_msg += "FullInductionTimeDerivative\n"; - error_msg += "GodunovPowellSource\n"; - error_msg += "InductionConstantSource\n"; - error_msg += "InductionConvectiveFlux\n"; - error_msg += "InductionResistiveFlux\n"; - error_msg += "MagneticCorrectionDampingSource\n"; - error_msg += "MagneticPressure\n"; - error_msg += "MHDVortexProblemExact\n"; - error_msg += "Resistivity\n"; - error_msg += "TotalMagneticField\n"; -} - -//---------------------------------------------------------------------------// - -} // end namespace ClosureModel -} // end namespace VertexCFD - -#endif // end VERTEXCFD_FULLINDUCTIONCLOSUREMODELFACTORY_IMPL_HPP diff --git a/src/full_induction_mhd_solver/closure_models/unit_test/CMakeLists.txt b/src/full_induction_mhd_solver/closure_models/unit_test/CMakeLists.txt deleted file mode 100644 index b938849..0000000 --- a/src/full_induction_mhd_solver/closure_models/unit_test/CMakeLists.txt +++ /dev/null @@ -1,21 +0,0 @@ -set(TEST_HARNESS_DIR ${CMAKE_SOURCE_DIR}/src/test_harness) -include(${TEST_HARNESS_DIR}/TestHarness.cmake) - -VertexCFD_add_tests( - LIBS VertexCFD - NAMES - MagneticPressure - FullInductionTimeDerivative - InductionConvectiveFlux - InductionResistiveFlux - TotalMagneticField - TotalMagneticFieldGradient - MHDVortexProblemExact - FullInductionErrorNorms - DivergenceCleaningSource - GodunovPowellSource - MagneticCorrectionDampingSource - FullInductionLocalTimeStepSize - ResistivityFactory - InductionConstantSource - ) diff --git a/src/full_induction_mhd_solver/closure_models/unit_test/doc/divergenceCleaningSource_reference.py b/src/full_induction_mhd_solver/closure_models/unit_test/doc/divergenceCleaningSource_reference.py deleted file mode 100644 index f150e0c..0000000 --- a/src/full_induction_mhd_solver/closure_models/unit_test/doc/divergenceCleaningSource_reference.py +++ /dev/null @@ -1,36 +0,0 @@ -import numpy as np -import math - - -def get_exp_val_at_point(qp, num_grad_dim, num_space_dim): - # set the dependencies - max_dim = max(num_grad_dim, num_space_dim) - grad_psi = np.zeros(max_dim) - vel = np.zeros(max_dim) - - for d in range(num_grad_dim): - grad_psi[d] = pow(-0.9, d + 1) * (qp + d + 1) - for d in range(num_space_dim): - vel[d] = pow(-0.6, d) * (qp + d + 1) - - exp_pot_src_val = -np.dot(vel, grad_psi) - - return exp_pot_src_val - - -def get_exp_values(num_grad_dim, num_space_dim): - # get expected values at maximum of 8 quadrature points - max_num_qp = 8 - exp_pot_src_vals = np.zeros(max_num_qp) - for qp in range(max_num_qp): - exp_pot_src_vals[qp] = get_exp_val_at_point(qp, num_grad_dim, - num_space_dim) - - print("Divergence Cleaning Source (num_grad_dim = ", num_grad_dim, - ", num_space_dim = ", num_space_dim, ")") - print(" exp_src_magn_pot[", max_num_qp, "] = ", exp_pot_src_vals, "\n") - - -get_exp_values(2, 2) -get_exp_values(2, 3) -get_exp_values(3, 3) diff --git a/src/full_induction_mhd_solver/closure_models/unit_test/doc/error_norms_reference.py b/src/full_induction_mhd_solver/closure_models/unit_test/doc/error_norms_reference.py deleted file mode 100644 index ae2cb2f..0000000 --- a/src/full_induction_mhd_solver/closure_models/unit_test/doc/error_norms_reference.py +++ /dev/null @@ -1,17 +0,0 @@ -import math - -# computational/exact solution -comp = [0.3, 0.4, 0.5] -exact = [0.7, 0.9, 1.1] - -var_id = range(len(comp)) - -# L1 error norm -print("L1 norm of vec{B}):") -for i in var_id: - print(abs(comp[i] - exact[i])) - -# L2 error norm -print("L2 norm vec{B}:") -for i in var_id: - print((comp[i] - exact[i])**2.0) diff --git a/src/full_induction_mhd_solver/closure_models/unit_test/doc/fullInductionLocalTimeStepSize_reference.py b/src/full_induction_mhd_solver/closure_models/unit_test/doc/fullInductionLocalTimeStepSize_reference.py deleted file mode 100644 index 9d8d3a0..0000000 --- a/src/full_induction_mhd_solver/closure_models/unit_test/doc/fullInductionLocalTimeStepSize_reference.py +++ /dev/null @@ -1,39 +0,0 @@ -import math - -# Dependent values -u = -1.5 -v = 2.0 -w = -0.5 - -b_0 = 1.1 -b_1 = -1.2 -b_2 = 1.3 - -rho = 0.9 -mu_0 = 0.1 - -# Alfven speeds -c_a_0 = abs(b_0) / math.sqrt(mu_0 * rho) -c_a_1 = abs(b_1) / math.sqrt(mu_0 * rho) -c_a_2 = abs(b_2) / math.sqrt(mu_0 * rho) - -h0 = 0.25 -h1 = 0.5 -h2 = 0.75 - -# 2-D case, c_h = 0.1 -c_h = 0.1 -dt = 1.0 / ((abs(u) + max(c_a_0, c_h)) / h0 + (abs(v) + max(c_a_1, c_h)) / h1) -print("2-D dt, c_h = 0.1: ", dt) - -# 3-D case, large c_h -c_h = 5.0 -dt = 1.0 / ((abs(u) + max(c_a_0, c_h)) / h0 + (abs(v) + max(c_a_1, c_h)) / h1 + - (abs(w) + max(c_a_2, c_h)) / h2) -print("3-D dt, c_h = 5.0: ", dt) - -# 3-D case, no c_h contribution -c_h = 5.0 -dt = 1.0 / ((abs(u) + c_a_0) / h0 + (abs(v) + c_a_1) / h1 + - (abs(w) + c_a_2) / h2) -print("3-D dt, no c_h: ", dt) diff --git a/src/full_induction_mhd_solver/closure_models/unit_test/doc/godunovPowellSource_reference.py b/src/full_induction_mhd_solver/closure_models/unit_test/doc/godunovPowellSource_reference.py deleted file mode 100644 index eb94f9b..0000000 --- a/src/full_induction_mhd_solver/closure_models/unit_test/doc/godunovPowellSource_reference.py +++ /dev/null @@ -1,42 +0,0 @@ -import numpy as np -import math - - -def get_exp_val_at_point(qp, num_space_dim): - # set the dependencies - mu_0 = 0.05 - div_mag = pow(-1.0, qp) * (qp + 1.1) - vel = np.zeros(3) - mag = np.zeros(3) - for d in range(num_space_dim): - vel[d] = pow(-0.6, d) * (qp + d + 1.2) - for d in range(3): - mag[d] = pow(-0.9, d + 1) * (qp + d + 1.3) - - exp_mtm_src_val = np.zeros(num_space_dim) - exp_ind_src_val = np.zeros(num_space_dim) - for d in range(num_space_dim): - exp_mtm_src_val[d] = -div_mag * mag[d] / mu_0 - exp_ind_src_val[d] = -div_mag * vel[d] - - return (exp_mtm_src_val, exp_ind_src_val) - - -def get_exp_values(num_space_dim): - # get expected values at maximum of 8 quadrature points - max_num_qp = 8 - exp_mtm_src_vals = np.zeros((max_num_qp, num_space_dim)) - exp_ind_src_vals = np.zeros((max_num_qp, num_space_dim)) - for qp in range(max_num_qp): - (exp_mtm_src_vals[qp], - exp_ind_src_vals[qp]) = get_exp_val_at_point(qp, num_space_dim) - - print("Divergence Cleaning Source (num_space_dim = ", num_space_dim, ")") - print(" exp_src_mtm[", max_num_qp, "][", num_space_dim, "] =\n", - exp_mtm_src_vals, "\n") - print(" exp_src_ind[", max_num_qp, "][", num_space_dim, "] =\n", - exp_ind_src_vals, "\n") - - -get_exp_values(2) -get_exp_values(3) diff --git a/src/full_induction_mhd_solver/closure_models/unit_test/doc/inductionConvectiveFlux_reference.py b/src/full_induction_mhd_solver/closure_models/unit_test/doc/inductionConvectiveFlux_reference.py deleted file mode 100644 index cba5287..0000000 --- a/src/full_induction_mhd_solver/closure_models/unit_test/doc/inductionConvectiveFlux_reference.py +++ /dev/null @@ -1,80 +0,0 @@ -import numpy as np - -# set the dependencies -v = np.array((1.25, 1.5, 1.125)) -b = np.array((1.1, 2.1, 3.1)) - -psi = 0.4 -pmag = 0.8 -mu_0 = .05 -c_h = 5.0 - -mtm_0_flux = np.array((0.125, -0.26, 0.377)) -mtm_1_flux = np.array((0.250, -0.52, 0.754)) -mtm_2_flux = np.array((0.375, -0.78, 1.131)) - -# compute the induction contribution to momentum flux -# rho_u fluxes in x, y, z directions -mtm_0_flux[0] += -b[0] * b[0] / mu_0 + pmag -mtm_0_flux[1] += -b[1] * b[0] / mu_0 -mtm_0_flux[2] += -b[2] * b[0] / mu_0 -# rho_v fluxes in x, y, z directions -mtm_1_flux[0] += -b[0] * b[1] / mu_0 -mtm_1_flux[1] += -b[1] * b[1] / mu_0 + pmag -mtm_1_flux[2] += -b[2] * b[1] / mu_0 -# r_ho_w fluxes in x, y, z directions -mtm_2_flux[0] += -b[0] * b[2] / mu_0 -mtm_2_flux[1] += -b[1] * b[2] / mu_0 -mtm_2_flux[2] += -b[2] * b[2] / mu_0 + pmag - -# compute induction equation flux (without divergence cleaning) -# x direction flux for the induction equations [F_x(B_0), F_x(B_1), F_x(B_2)] -ind_flux_x = [ - v[0] * b[0] - b[0] * v[0], v[0] * b[1] - b[0] * v[1], - v[0] * b[2] - b[0] * v[2] -] -# y direction flux for the induction equations [F_y(B_0), F_y(B_1), F_y(B_2)] -ind_flux_y = [ - v[1] * b[0] - b[1] * v[0], v[1] * b[1] - b[1] * v[1], - v[1] * b[2] - b[1] * v[2] -] -# z direction flux for the induction equations [F_z(B_0), F_z(B_1), F_z(B_2)] -ind_flux_z = [ - v[2] * b[0] - b[2] * v[0], v[2] * b[1] - b[2] * v[1], - v[2] * b[2] - b[2] * v[2] -] - -# print expected momentum fluxes -print("\nExpected fluxes (no divergence cleaning)\n") -print("\tmtm_0_flux = ", mtm_0_flux) -print("\tmtm_1_flux = ", mtm_1_flux) -print("\tmtm_2_flux = ", mtm_2_flux) - -# B_0 fluxes -print("\n\tind_0_flux = ", ind_flux_x[0], ind_flux_y[0], ind_flux_z[0]) -# B_1 fluxes -print("\tind_1_flux = ", ind_flux_x[1], ind_flux_y[1], ind_flux_z[1]) -# B_2 fluxes -print("\tind_2_flux = ", ind_flux_x[2], ind_flux_y[2], ind_flux_z[2]) - -# add divergence cleaning contributions -ind_flux_x[0] += c_h * psi -ind_flux_y[1] += c_h * psi -ind_flux_z[2] += c_h * psi -psi_flux = b * c_h - -# print expected momentum fluxes -print("\nExpected fluxes (with divergence cleaning)\n") -print("\tmtm_0_flux = ", mtm_0_flux) -print("\tmtm_1_flux = ", mtm_1_flux) -print("\tmtm_2_flux = ", mtm_2_flux) - -# B_0 fluxes -print("\n\tind_0_flux = ", ind_flux_x[0], ind_flux_y[0], ind_flux_z[0]) -# B_1 fluxes -print("\tind_1_flux = ", ind_flux_x[1], ind_flux_y[1], ind_flux_z[1]) -# B_2 fluxes -print("\tind_2_flux = ", ind_flux_x[2], ind_flux_y[2], ind_flux_z[2]) - -print("\n\tpsi_flux = ", psi_flux) -print() diff --git a/src/full_induction_mhd_solver/closure_models/unit_test/doc/inductionResitiveFlux_reference.py b/src/full_induction_mhd_solver/closure_models/unit_test/doc/inductionResitiveFlux_reference.py deleted file mode 100644 index 3cd10f6..0000000 --- a/src/full_induction_mhd_solver/closure_models/unit_test/doc/inductionResitiveFlux_reference.py +++ /dev/null @@ -1,71 +0,0 @@ -import numpy as np -import math - - -def vector_divergence(grad_vec, dim): - div = 0 - for d in range(dim): - div += grad_vec[d][d] - return div - - -def resistive_flux(eta, b, num_grad_dim, const_eta): - # set up gradient test values - grad_eta = np.empty(num_grad_dim) - grad_b = np.empty((3, num_grad_dim)) - for dim in range(num_grad_dim): - if (const_eta): - grad_eta[dim] = 0.0 - else: - grad_eta[dim] = eta * math.pow(-1, dim + 1) * (dim + 2) - for i in range(3): - grad_b[i][dim] = b[i] * math.pow(-1, dim) * (dim + 1) - - # first term: eta * grad_b - eta_times_grad_b = eta * grad_b - - # second_term - # div(eta B) = eta div(B) + grad(eta).B - div_b = 0.0 - grad_eta_dot_b = 0.0 - for dim in range(num_grad_dim): - div_b += grad_b[dim][dim] - grad_eta_dot_b += grad_eta[dim] * b[dim] - div_eta_b = np.zeros((3, num_grad_dim)) - for dim in range(num_grad_dim): - div_eta_b[dim][dim] = eta * div_b + grad_eta_dot_b - - ind_flux = eta_times_grad_b - div_eta_b - - # third term B otimes grad(eta) - # G_x = B_x d_eta/dx G_y = B_y d_eta/dx G_z = B_z d_eta/dx - # B_x d_eta/dy B_y d_eta/dy B_z d_eta/dy - # B_x d_eta/dz B_y d_eta/dz B_z d_eta/dz - for i in range(num_grad_dim): - for j in range(num_grad_dim): - ind_flux[i][j] += b[j] * grad_eta[i] - - print("\ninduction eqn resistive flux ", num_grad_dim, "D:\n") - print("\tind_0_flux = ", ind_flux[0]) - print("\tind_1_flux = ", ind_flux[1]) - print("\tind_2_flux = ", ind_flux[2]) - - -# set the dependencies -eta = 0.16 -b = np.array((1.1, 2.1, 3.1)) -mu_0 = 0.05 - -hat_eta = eta / mu_0 - -# 2D test, variable resistivity -resistive_flux(hat_eta, b, 2, False) - -# 3D test, variable resistivity -resistive_flux(hat_eta, b, 3, False) - -# 2D test, constant resistivity -resistive_flux(hat_eta, b, 2, True) - -# 3D test, constant resistivity -resistive_flux(hat_eta, b, 3, True) diff --git a/src/full_induction_mhd_solver/closure_models/unit_test/doc/mhd_vortex_problem_exact_reference.py b/src/full_induction_mhd_solver/closure_models/unit_test/doc/mhd_vortex_problem_exact_reference.py deleted file mode 100644 index e0e3924..0000000 --- a/src/full_induction_mhd_solver/closure_models/unit_test/doc/mhd_vortex_problem_exact_reference.py +++ /dev/null @@ -1,36 +0,0 @@ -import math - -# -x = 0.2 -y = 0.4 -x0 = 0.1 -y0 = -0.2 -dx = x - x0 -dy = y - y0 - -# -u0 = 2.0 -v0 = -0.5 - -# -time = 0.6 - -# -r = (dx - time * u0) * (dx - time * u0) -r += (dy - time * u0) * (dy - time * u0) -r = math.sqrt(r) -r2 = r * r - -# -lp = 1.0 + 0.5 * math.exp(1.0) * (1.0 - r2 * math.exp(-r2)) -print("Exact lagrange pressure:", lp) - -mg0 = -math.exp(0.5 * (1.0 - r2)) * dy -mg1 = math.exp(0.5 * (1.0 - r2)) * dx -print("Exact x-magnetic field:", mg0) -print("Exact y-magnetic field:", mg1) - -v0 = mg0 + u0 -v1 = mg1 -print("Exact x-velocity:", v0) -print("Exact y-velocity:", v1) diff --git a/src/full_induction_mhd_solver/closure_models/unit_test/tstDivergenceCleaningSource.cpp b/src/full_induction_mhd_solver/closure_models/unit_test/tstDivergenceCleaningSource.cpp deleted file mode 100644 index 84ce66f..0000000 --- a/src/full_induction_mhd_solver/closure_models/unit_test/tstDivergenceCleaningSource.cpp +++ /dev/null @@ -1,188 +0,0 @@ -#include -#include - -#include "full_induction_mhd_solver/closure_models/VertexCFD_Closure_DivergenceCleaningSource.hpp" - -#include "utils/VertexCFD_Utils_VectorField.hpp" - -#include - -namespace VertexCFD -{ -namespace Test -{ - -template -struct Dependencies : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - static constexpr int num_space_dim = NumSpaceDim; - using scalar_type = typename EvalType::ScalarT; - - Kokkos::Array, - num_space_dim> - velocity; - PHX::MDField - grad_scalar_magnetic_potential; - - Dependencies(const panzer::IntegrationRule& ir) - : grad_scalar_magnetic_potential("GRAD_scalar_magnetic_potential", - ir.dl_vector) - { - this->addEvaluatedField(grad_scalar_magnetic_potential); - Utils::addEvaluatedVectorField( - *this, ir.dl_scalar, velocity, "velocity_"); - - this->setName("Divergence Cleaning Source Unit Test Dependencies"); - } - - void evaluateFields(typename panzer::Traits::EvalData d) override - { - Kokkos::parallel_for( - "divergence cleaning source test dependencies", - Kokkos::RangePolicy(0, d.num_cells), - *this); - } - - KOKKOS_INLINE_FUNCTION void operator()(const int c) const - { - const int num_point = grad_scalar_magnetic_potential.extent(1); - const int num_grad_dim = grad_scalar_magnetic_potential.extent(2); - using std::pow; - - for (int qp = 0; qp < num_point; ++qp) - { - for (int dim = 0; dim < num_grad_dim; ++dim) - { - grad_scalar_magnetic_potential(c, qp, dim) = pow(-0.9, dim + 1) - * (qp + dim + 1); - } - for (int dim = 0; dim < num_space_dim; ++dim) - { - velocity[dim](c, qp) = pow(-0.6, dim) * (qp + dim + 1); - } - } - } -}; - -template -void testEval(const int num_grad_dim) -{ - constexpr int num_space_dim = NumSpaceDim; - const int integration_order = 2; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_grad_dim, integration_order, basis_order); - - const auto& ir = *test_fixture.ir; - - // Initialize class object to test - auto deps = Teuchos::rcp(new Dependencies(ir)); - test_fixture.registerEvaluator(deps); - - auto eval = Teuchos::rcp( - new ClosureModel::DivergenceCleaningSource(ir)); - test_fixture.registerEvaluator(eval); - test_fixture.registerTestField( - eval->_div_cleaning_potential_source); - - test_fixture.evaluate(); - - const auto src_magn_pot = test_fixture.getTestFieldData( - eval->_div_cleaning_potential_source); - - const int num_point = ir.num_points; - - const double exp_src_magn_pot_2d[8] - = {2.844, 7.974, 15.876, 26.55, 39.996, 56.214, 75.204, 96.966}; - const double exp_src_magn_pot_3d[8] = { - 5.20596, 12.17304, 22.437, 35.99784, 52.85556, 73.01016, 96.46164, 123.21}; - const auto exp_src_magn_pot = num_grad_dim == 2 ? exp_src_magn_pot_2d - : exp_src_magn_pot_3d; - - // Assert values - for (int qp = 0; qp < num_point; ++qp) - { - EXPECT_DOUBLE_EQ(exp_src_magn_pot[qp], fieldValue(src_magn_pot, 0, qp)); - } -} - -//-----------------------------------------------------------------// -TEST(DivergenceCleaningSource2Vel2D, residual_test) -{ - testEval(2); -} - -//-----------------------------------------------------------------// -TEST(DivergenceCleaningSource2Vel2D, jacobian_test) -{ - testEval(2); -} - -//-----------------------------------------------------------------// -TEST(DivergenceCleaningSource3Vel2D, residual_test) -{ - testEval(2); -} - -//-----------------------------------------------------------------// -TEST(DivergenceCleaningSource3Vel2D, jacobian_test) -{ - testEval(2); -} -//-----------------------------------------------------------------// -TEST(DivergenceCleaningSource3D, residual_test) -{ - testEval(3); -} - -//-----------------------------------------------------------------// -TEST(DivergenceCleaningSource3D, jacobian_test) -{ - testEval(3); -} - -//-----------------------------------------------------------------// -template -void testFactory() -{ - constexpr int num_space_dim = NumSpaceDim; - ClosureModelFactoryTestFixture test_fixture; - test_fixture.user_params.sublist("Full Induction MHD Properties") - .set("Vacuum Magnetic Permeability", 0.1) - .set("Build Magnetic Correction Potential Equation", false); - test_fixture.user_params.sublist("Fluid Properties") - .set("Kinematic viscosity", 1.5) - .set("Artificial compressibility", 0.1); - test_fixture.type_name = "DivergenceCleaningSource"; - test_fixture.eval_name = "Divergence Cleaning Source " - + std::to_string(num_space_dim) + "D"; - test_fixture.template buildAndTest< - ClosureModel::DivergenceCleaningSource, - num_space_dim>(); -} - -TEST(DivergenceCleaningSource_Factory2D, residual_test) -{ - testFactory(); -} - -TEST(DivergenceCleaningSource_Factory2D, jacobian_test) -{ - testFactory(); -} - -TEST(DivergenceCleaningSource_Factory3D, residual_test) -{ - testFactory(); -} - -TEST(DivergenceCleaningSource_Factory3D, jacobian_test) -{ - testFactory(); -} - -} // namespace Test -} // namespace VertexCFD diff --git a/src/full_induction_mhd_solver/closure_models/unit_test/tstFullInductionErrorNorms.cpp b/src/full_induction_mhd_solver/closure_models/unit_test/tstFullInductionErrorNorms.cpp deleted file mode 100644 index e1c3e64..0000000 --- a/src/full_induction_mhd_solver/closure_models/unit_test/tstFullInductionErrorNorms.cpp +++ /dev/null @@ -1,196 +0,0 @@ -#include -#include - -#include - -#include - -//---------------------------------------------------------------------------// -// TESTS -//---------------------------------------------------------------------------// -namespace VertexCFD -{ -namespace Test -{ -//---------------------------------------------------------------------------// -template -struct Dependencies : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - using scalar_type = typename EvalType::ScalarT; - static constexpr int num_space_dim = NumSpaceDim; - - // exact solution - Kokkos::Array, num_space_dim> - exact_induced_magn_field; - - // numerical solution - Kokkos::Array, - num_space_dim> - induced_magn_field; - - Dependencies(const panzer::IntegrationRule& ir) - { - // exact solution - Utils::addEvaluatedVectorField(*this, - ir.dl_scalar, - exact_induced_magn_field, - "Exact_induced_magnetic_field_"); - - // numerical solution - Utils::addEvaluatedVectorField( - *this, ir.dl_scalar, induced_magn_field, "induced_magnetic_field_"); - - this->setName("FullInduction Error Norms Unit Test Dependencies"); - } - - void evaluateFields(typename panzer::Traits::EvalData) override - { - // assign prescribed values to exact and numerical solution - for (int i = 0; i < num_space_dim; ++i) - { - exact_induced_magn_field[i].deep_copy(0.3 + 0.1 * i); - induced_magn_field[i].deep_copy(0.7 + 0.2 * i); - } - } -}; - -template -void testEval() -{ - // Setup test fixture. - constexpr int num_space_dim = NumSpaceDim; - const int integration_order = 0; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - - const auto& ir = *test_fixture.ir; - - const auto deps - = Teuchos::rcp(new Dependencies(ir)); - test_fixture.registerEvaluator(deps); - - // Create evaluator. - const auto eval = Teuchos::rcp( - new ClosureModel::FullInductionModelErrorNorms(ir)); - test_fixture.registerEvaluator(eval); - - // Add required test fields. - for (int dim = 0; dim < num_space_dim; ++dim) - { - test_fixture.registerTestField(eval->_L1_error_induced[dim]); - test_fixture.registerTestField(eval->_L2_error_induced[dim]); - } - - // Evaluate - test_fixture.evaluate(); - - // Check the values - const auto L1_error_induced_0 - = test_fixture.getTestFieldData(eval->_L1_error_induced[0]); - const auto L1_error_induced_1 - = test_fixture.getTestFieldData(eval->_L1_error_induced[1]); - const auto L2_error_induced_0 - = test_fixture.getTestFieldData(eval->_L2_error_induced[0]); - const auto L2_error_induced_1 - = test_fixture.getTestFieldData(eval->_L2_error_induced[1]); - - // Reference values - const double L1_ref[3] = {0.39999999999999997, 0.5, 0.6000000000000001}; - const double L2_ref[3] = {0.15999999999999998, 0.25, 0.3600000000000001}; - - // Check the L1/L2 error solutions - const int num_point = ir.num_points; - for (int qp = 0; qp < num_point; ++qp) - { - EXPECT_DOUBLE_EQ(L1_ref[0], fieldValue(L1_error_induced_0, 0, qp)); - EXPECT_DOUBLE_EQ(L1_ref[1], fieldValue(L1_error_induced_1, 0, qp)); - - EXPECT_DOUBLE_EQ(L2_ref[0], fieldValue(L2_error_induced_0, 0, qp)); - EXPECT_DOUBLE_EQ(L2_ref[1], fieldValue(L2_error_induced_1, 0, qp)); - - if (num_space_dim == 3) - { - const auto L1_error_induced_2 - = test_fixture.getTestFieldData( - eval->_L1_error_induced[2]); - const auto L2_error_induced_2 - = test_fixture.getTestFieldData( - eval->_L2_error_induced[2]); - - EXPECT_DOUBLE_EQ(L1_ref[2], fieldValue(L1_error_induced_2, 0, qp)); - EXPECT_DOUBLE_EQ(L2_ref[2], fieldValue(L2_error_induced_2, 0, qp)); - } - } -} - -//---------------------------------------------------------------------------// -TEST(FullInductionL1L2Isothermal_Error2D, residual_test) -{ - testEval(); -} - -//---------------------------------------------------------------------------// -TEST(FullInductionL1L2Isothermal_Error2D, jacobian_test) -{ - testEval(); -} - -//---------------------------------------------------------------------------// -TEST(FullInductionL1L2Isothermal_Error3D, residual_test) -{ - testEval(); -} - -//---------------------------------------------------------------------------// -TEST(FullInductionL1L2Isothermal_Error3D, jacobian_test) -{ - testEval(); -} - -//---------------------------------------------------------------------------// - -template -void testFactory() -{ - constexpr int num_space_dim = NumSpaceDim; - ClosureModelFactoryTestFixture test_fixture; - test_fixture.type_name = "FullInductionModelErrorNorm"; - test_fixture.user_params.sublist("Fluid Properties") - .set("Kinematic viscosity", 0.1) - .set("Artificial compressibility", 2.0); - test_fixture.user_params.sublist("Full Induction MHD Properties"); - if (num_space_dim == 2) - test_fixture.eval_name = "Full Induction Model Error Norms 2D"; - else if (num_space_dim == 3) - test_fixture.eval_name = "Full Induction Model Error Norms 3D"; - test_fixture.template buildAndTest< - ClosureModel::FullInductionModelErrorNorms, - num_space_dim>(); -} - -TEST(FullInductionErrorNorms_Factory2D, residual_test) -{ - testFactory(); -} - -TEST(FullInductionErrorNorms_Factory2D, jacobian_test) -{ - testFactory(); -} - -TEST(FullInductionErrorNorms_Factory3D, residual_test) -{ - testFactory(); -} - -TEST(FullInductionErrorNorms_Factory3D, jacobian_test) -{ - testFactory(); -} - -} // end namespace Test -} // end namespace VertexCFD diff --git a/src/full_induction_mhd_solver/closure_models/unit_test/tstFullInductionLocalTimeStepSize.cpp b/src/full_induction_mhd_solver/closure_models/unit_test/tstFullInductionLocalTimeStepSize.cpp deleted file mode 100644 index 5ac38b5..0000000 --- a/src/full_induction_mhd_solver/closure_models/unit_test/tstFullInductionLocalTimeStepSize.cpp +++ /dev/null @@ -1,221 +0,0 @@ -#include -#include - -#include "incompressible_solver/fluid_properties/VertexCFD_ConstantFluidProperties.hpp" - -#include "full_induction_mhd_solver/closure_models/VertexCFD_Closure_FullInductionLocalTimeStepSize.hpp" - -#include "full_induction_mhd_solver/mhd_properties/VertexCFD_FullInductionMHDProperties.hpp" - -#include - -#include - -//---------------------------------------------------------------------------// -// TESTS -//---------------------------------------------------------------------------// -namespace VertexCFD -{ -namespace Test -{ -//---------------------------------------------------------------------------// -// Test data dependencies. -template -struct Dependencies : public PHX::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - using scalar_type = typename EvalType::ScalarT; - - double _u; - double _v; - double _w; - Kokkos::Array _h; - - PHX::MDField _element_length; - Kokkos::Array, 3> - _velocity; - Kokkos::Array, 3> - _tot_magn_field; - - Dependencies(const panzer::IntegrationRule& ir, - const double u, - const double v, - const double w, - const Kokkos::Array h) - : _u(u) - , _v(v) - , _w(w) - , _h(h) - , _element_length("element_length", ir.dl_vector) - { - this->addEvaluatedField(_element_length); - Utils::addEvaluatedVectorField( - *this, ir.dl_scalar, _velocity, "velocity_"); - Utils::addEvaluatedVectorField( - *this, ir.dl_scalar, _tot_magn_field, "total_magnetic_field_"); - this->setName( - "Full Induction Local Time Step Size Unit Test Dependencies"); - } - - void evaluateFields(typename panzer::Traits::EvalData d) override - { - _velocity[0].deep_copy(_u); - _velocity[1].deep_copy(_v); - _velocity[2].deep_copy(_w); - _tot_magn_field[0].deep_copy(1.1); - _tot_magn_field[1].deep_copy(-1.2); - _tot_magn_field[2].deep_copy(1.3); - Kokkos::parallel_for( - "test dependencies", - Kokkos::RangePolicy(0, d.num_cells), - *this); - } - - KOKKOS_INLINE_FUNCTION void operator()(const int c) const - { - int num_point = _element_length.extent(1); - for (int qp = 0; qp < num_point; ++qp) - { - _element_length(c, qp, 0) = _h[0]; - _element_length(c, qp, 1) = _h[1]; - _element_length(c, qp, 2) = _h[2]; - } - } -}; - -//---------------------------------------------------------------------------// -template -void testEval(const bool build_magn_corr) -{ - // Setup test fixture. - constexpr int num_space_dim = NumSpaceDim; - const int integration_order = 2; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - - // Eval dependencies. - const double nan_val = std::numeric_limits::quiet_NaN(); - const double u = -1.5; - const double v = 2.0; - const double w = num_space_dim == 3 ? -0.5 : nan_val; - const Kokkos::Array h - = {0.25, 0.5, num_space_dim == 3 ? 0.75 : nan_val}; - - auto dep_eval = Teuchos::rcp( - new Dependencies(*test_fixture.ir, u, v, w, h)); - test_fixture.registerEvaluator(dep_eval); - - Teuchos::ParameterList fluid_params; - fluid_params.set("Density", 0.9); - fluid_params.set("Kinematic viscosity", nan_val); - fluid_params.set("Artificial compressibility", nan_val); - fluid_params.set("Build Temperature Equation", false); - FluidProperties::ConstantFluidProperties incompressible_fluidprop_params - = FluidProperties::ConstantFluidProperties(fluid_params); - - const double c_h = num_space_dim == 2 ? 0.1 : 5.0; - Teuchos::ParameterList full_induction_params; - full_induction_params.set("Vacuum Magnetic Permeability", 0.1); - full_induction_params.set("Build Magnetic Correction Potential Equation", - build_magn_corr); - full_induction_params.set("Hyperbolic Divergence Cleaning Speed", c_h); - MHDProperties::FullInductionMHDProperties mhd_props - = MHDProperties::FullInductionMHDProperties(full_induction_params); - - // Create test evaluator. - auto dt_eval = Teuchos::rcp( - new ClosureModel::FullInductionLocalTimeStepSize( - *test_fixture.ir, incompressible_fluidprop_params, mhd_props)); - test_fixture.registerEvaluator(dt_eval); - - // Add required test fields. - test_fixture.registerTestField(dt_eval->_local_dt); - - // Evaluate test fields. - test_fixture.evaluate(); - - // Check the test fields. - auto local_dt_result - = test_fixture.getTestFieldData(dt_eval->_local_dt); - - const int num_qp = num_space_dim == 2 ? 4 : 8; - const double result = num_space_dim == 2 ? 0.030612244897959186 - : build_magn_corr ? 0.02112676056338028 - : 0.02556818181818182; - for (int qp = 0; qp < num_qp; ++qp) - EXPECT_DOUBLE_EQ(result, fieldValue(local_dt_result, 0, qp)); -} - -//---------------------------------------------------------------------------// -TEST(FullInductionLocalTimeStepSize2D, residual_test) -{ - testEval(true); -} - -//---------------------------------------------------------------------------// -TEST(FullInductionLocalTimeStepSize2D, jacobian_test) -{ - testEval(true); -} - -//---------------------------------------------------------------------------// -TEST(FullInductionLocalTimeStepSize3D, residual_test) -{ - testEval(true); -} - -//---------------------------------------------------------------------------// -TEST(FullInductionLocalTimeStepSize3D, jacobian_test) -{ - testEval(true); -} - -//---------------------------------------------------------------------------// -TEST(FullInductionLocalTimeStepSizeNoDivCleaning3D, residual_test) -{ - testEval(false); -} - -//---------------------------------------------------------------------------// -TEST(FullInductionLocalTimeStepSizeNoDivCleaning3D, jacobian_test) -{ - testEval(false); -} - -//---------------------------------------------------------------------------// - -template -void testFactory() -{ - constexpr int num_space_dim = NumSpaceDim; - ClosureModelFactoryTestFixture test_fixture; - test_fixture.type_name = "FullInductionLocalTimeStepSize"; - test_fixture.eval_name = "Full Induction Local Time Step Size"; - test_fixture.user_params.sublist("Fluid Properties") - .set("Kinematic viscosity", 0.1) - .set("Artificial compressibility", 2.0); - test_fixture.user_params.sublist("Full Induction MHD Properties") - .set("Vacuum Magnetic Permeability", 0.1) - .set("Build Magnetic Correction Potential Equation", false); - test_fixture.template buildAndTest< - ClosureModel::FullInductionLocalTimeStepSize, - num_space_dim>(); -} - -TEST(FullInductionLocalTimeStepSize_Factory2D, residual_test) -{ - testFactory(); -} - -TEST(FullInductionLocalTimeStepSize_Factory2D, jacobian_test) -{ - testFactory(); -} - -} // end namespace Test -} // end namespace VertexCFD diff --git a/src/full_induction_mhd_solver/closure_models/unit_test/tstFullInductionTimeDerivative.cpp b/src/full_induction_mhd_solver/closure_models/unit_test/tstFullInductionTimeDerivative.cpp deleted file mode 100644 index d2a06ec..0000000 --- a/src/full_induction_mhd_solver/closure_models/unit_test/tstFullInductionTimeDerivative.cpp +++ /dev/null @@ -1,91 +0,0 @@ -#include -#include - -#include "incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleVariableTimeDerivative.hpp" - -#include - -namespace VertexCFD -{ -namespace Test -{ - -//-----------------------------------------------------------------// -template -void testFactory(const bool build_magn_corr) -{ - static constexpr int num_space_dim = NumSpaceDim; - ClosureModelFactoryTestFixture test_fixture; - test_fixture.type_name = "FullInductionTimeDerivative"; - std::vector eval_names; - for (int dim = 0; dim < num_space_dim; ++dim) - { - eval_names.push_back("induction_" + std::to_string(dim) - + " Incompressible Time Derivative 2D"); - } - if (build_magn_corr) - { - eval_names.push_back( - "magnetic_correction_potential Incompressible Time Derivative 2D"); - } - test_fixture.user_params.sublist("Full Induction MHD Properties") - .set("Build Magnetic Correction Potential Equation", build_magn_corr) - .set("Hyperbolic Divergence Cleaning Speed", 1.1); - test_fixture.user_params.sublist("Fluid Properties") - .set("Kinematic viscosity", 1.5) - .set("Artificial compressibility", 0.1); - - test_fixture.num_evaluators = eval_names.size(); - for (int ind = 0; ind < test_fixture.num_evaluators; ++ind) - { - test_fixture.eval_index = ind; - test_fixture.eval_name = eval_names[ind]; - test_fixture.template buildAndTest< - ClosureModel::IncompressibleVariableTimeDerivative, - num_space_dim>(); - } -} - -TEST(FullInductionTimeDerivative_Factory2D, residual_test) -{ - testFactory(false); -} - -TEST(FullInductionTimeDerivative_Factory2D, jacobian_test) -{ - testFactory(false); -} - -TEST(FullInductionTimeDerivative_Factory3D, residual_test) -{ - testFactory(false); -} - -TEST(FullInductionTimeDerivative_Factory3D, jacobian_test) -{ - testFactory(false); -} - -TEST(FullInductionDivCleaningTimeDerivative_Factory2D, residual_test) -{ - testFactory(true); -} - -TEST(FullInductionDivCleaningTimeDerivative_Factory2D, jacobian_test) -{ - testFactory(true); -} - -TEST(FullInductionDivCleaningTimeDerivative_Factory3D, residual_test) -{ - testFactory(true); -} - -TEST(FullInductionDivCleaningTimeDerivative_Factory3D, jacobian_test) -{ - testFactory(true); -} -//-----------------------------------------------------------------// -} // namespace Test -} // namespace VertexCFD diff --git a/src/full_induction_mhd_solver/closure_models/unit_test/tstGodunovPowellSource.cpp b/src/full_induction_mhd_solver/closure_models/unit_test/tstGodunovPowellSource.cpp deleted file mode 100644 index 1402add..0000000 --- a/src/full_induction_mhd_solver/closure_models/unit_test/tstGodunovPowellSource.cpp +++ /dev/null @@ -1,223 +0,0 @@ -#include -#include - -#include "full_induction_mhd_solver/closure_models/VertexCFD_Closure_GodunovPowellSource.hpp" - -#include "full_induction_mhd_solver/mhd_properties/VertexCFD_FullInductionMHDProperties.hpp" - -#include "utils/VertexCFD_Utils_VectorField.hpp" - -#include - -namespace VertexCFD -{ -namespace Test -{ - -template -struct Dependencies : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - static constexpr int num_space_dim = NumSpaceDim; - using scalar_type = typename EvalType::ScalarT; - - PHX::MDField div_magn_field; - - Kokkos::Array, - num_space_dim> - velocity; - Kokkos::Array, 3> - tot_magn_field; - - Dependencies(const panzer::IntegrationRule& ir) - : div_magn_field("divergence_total_magnetic_field", ir.dl_scalar) - { - this->addEvaluatedField(div_magn_field); - Utils::addEvaluatedVectorField( - *this, ir.dl_scalar, velocity, "velocity_"); - Utils::addEvaluatedVectorField( - *this, ir.dl_scalar, tot_magn_field, "total_magnetic_field_"); - - this->setName("Godunov-Powell Source Unit Test Dependencies"); - } - - void evaluateFields(typename panzer::Traits::EvalData d) override - { - Kokkos::parallel_for( - "godunov-powell source test dependencies", - Kokkos::RangePolicy(0, d.num_cells), - *this); - } - - KOKKOS_INLINE_FUNCTION void operator()(const int c) const - { - const int num_point = div_magn_field.extent(1); - const int num_field_dim = tot_magn_field.size(); - using std::pow; - - for (int qp = 0; qp < num_point; ++qp) - { - div_magn_field(c, qp) = pow(-1.0, qp) * (qp + 1.1); - for (int dim = 0; dim < num_space_dim; ++dim) - { - velocity[dim](c, qp) = pow(-0.6, dim) * (qp + dim + 1.2); - } - for (int dim = 0; dim < num_field_dim; ++dim) - { - tot_magn_field[dim](c, qp) = pow(-0.9, dim + 1) - * (qp + dim + 1.3); - } - } - } -}; - -template -void testEval() -{ - constexpr int num_space_dim = NumSpaceDim; - const int integration_order = 2; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - - auto& ir = *test_fixture.ir; - - // Initialize class object to test - auto deps = Teuchos::rcp(new Dependencies(ir)); - test_fixture.registerEvaluator(deps); - - Teuchos::ParameterList full_induction_params; - full_induction_params.set("Vacuum Magnetic Permeability", 0.05); - MHDProperties::FullInductionMHDProperties mhd_props - = MHDProperties::FullInductionMHDProperties(full_induction_params); - - auto eval = Teuchos::rcp( - new ClosureModel::GodunovPowellSource(ir, mhd_props)); - test_fixture.registerEvaluator(eval); - for (int dim = 0; dim < num_space_dim; ++dim) - { - test_fixture.registerTestField( - eval->_godunov_powell_momentum_source[dim]); - test_fixture.registerTestField( - eval->_godunov_powell_induction_source[dim]); - } - - test_fixture.evaluate(); - - const auto src_mom_0 = test_fixture.getTestFieldData( - eval->_godunov_powell_momentum_source[0]); - const auto src_mom_1 = test_fixture.getTestFieldData( - eval->_godunov_powell_momentum_source[1]); - - const auto src_ind_0 = test_fixture.getTestFieldData( - eval->_godunov_powell_induction_source[0]); - const auto src_ind_1 = test_fixture.getTestFieldData( - eval->_godunov_powell_induction_source[1]); - - const int num_point = ir.num_points; - - const double exp_src_mom[8][3] = {{25.74, -40.986, 52.9254}, - {-86.94, 112.266, -131.6574}, - {184.14, -215.946, 239.5494}, - {-317.34, 352.026, -376.6014}, - {486.54, -520.506, 542.8134}, - {-691.74, 721.386, -738.1854}, - {932.94, -954.666, 962.7174}, - {-1210.14, 1220.346, -1216.4094}}; - - const double exp_src_ind[8][3] = {{-1.32, 1.452, -1.2672}, - {4.62, -4.032, 3.1752}, - {-9.92, 7.812, -5.8032}, - {17.22, -12.792, 9.1512}, - {-26.52, 18.972, -13.2192}, - {37.82, -26.352, 18.0072}, - {-51.12, 34.932, -23.5152}, - {66.42, -44.712, 29.7432}}; - - // Assert values - for (int qp = 0; qp < num_point; ++qp) - { - EXPECT_DOUBLE_EQ(exp_src_mom[qp][0], fieldValue(src_mom_0, 0, qp)); - EXPECT_DOUBLE_EQ(exp_src_mom[qp][1], fieldValue(src_mom_1, 0, qp)); - EXPECT_DOUBLE_EQ(exp_src_ind[qp][0], fieldValue(src_ind_0, 0, qp)); - EXPECT_DOUBLE_EQ(exp_src_ind[qp][1], fieldValue(src_ind_1, 0, qp)); - if (num_space_dim > 2) - { - const auto src_mom_2 = test_fixture.getTestFieldData( - eval->_godunov_powell_momentum_source[2]); - EXPECT_DOUBLE_EQ(exp_src_mom[qp][2], fieldValue(src_mom_2, 0, qp)); - const auto src_ind_2 = test_fixture.getTestFieldData( - eval->_godunov_powell_induction_source[2]); - EXPECT_DOUBLE_EQ(exp_src_ind[qp][2], fieldValue(src_ind_2, 0, qp)); - } - } -}; - -//-----------------------------------------------------------------// -TEST(GodunovPowellSource2D, residual_test) -{ - testEval(); -} - -//-----------------------------------------------------------------// -TEST(GodunovPowellSource2D, jacobian_test) -{ - testEval(); -} - -//-----------------------------------------------------------------// -TEST(GodunovPowellSource3D, residual_test) -{ - testEval(); -} - -//-----------------------------------------------------------------// -TEST(GodunovPowellSource3D, jacobian_test) -{ - testEval(); -} - -//-----------------------------------------------------------------// -template -void testFactory() -{ - constexpr int num_space_dim = NumSpaceDim; - ClosureModelFactoryTestFixture test_fixture; - test_fixture.user_params.sublist("Full Induction MHD Properties") - .set("Vacuum Magnetic Permeability", 0.1) - .set("Build Magnetic Correction Potential Equation", false); - test_fixture.user_params.sublist("Fluid Properties") - .set("Kinematic viscosity", 1.5) - .set("Artificial compressibility", 0.1); - test_fixture.type_name = "GodunovPowellSource"; - test_fixture.eval_name = "Godunov-Powell Source " - + std::to_string(num_space_dim) + "D"; - test_fixture.template buildAndTest< - ClosureModel::GodunovPowellSource, - num_space_dim>(); -} - -TEST(GodunovPowellSource_Factory2D, residual_test) -{ - testFactory(); -} - -TEST(GodunovPowellSource_Factory2D, jacobian_test) -{ - testFactory(); -} - -TEST(GodunovPowellSource_Factory3D, residual_test) -{ - testFactory(); -} - -TEST(GodunovPowellSource_Factory3D, jacobian_test) -{ - testFactory(); -} - -} // namespace Test -} // namespace VertexCFD diff --git a/src/full_induction_mhd_solver/closure_models/unit_test/tstInductionConstantSource.cpp b/src/full_induction_mhd_solver/closure_models/unit_test/tstInductionConstantSource.cpp deleted file mode 100644 index d046af9..0000000 --- a/src/full_induction_mhd_solver/closure_models/unit_test/tstInductionConstantSource.cpp +++ /dev/null @@ -1,127 +0,0 @@ -#include -#include - -#include "full_induction_mhd_solver/closure_models/VertexCFD_Closure_InductionConstantSource.hpp" - -#include - -namespace VertexCFD -{ -namespace Test -{ - -template -void testEval() -{ - constexpr int num_space_dim = NumSpaceDim; - const int integration_order = 2; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - - const auto& ir = *test_fixture.ir; - - // Initialize class object to test - Teuchos::Array ind_input_source(num_space_dim); - ind_input_source[0] = 0.1; - ind_input_source[1] = 0.2; - if (num_space_dim == 3) - ind_input_source[2] = 0.3; - Teuchos::ParameterList closure_params; - closure_params.set("Induction Source", ind_input_source); - auto eval = Teuchos::rcp( - new ClosureModel:: - InductionConstantSource( - ir, closure_params)); - test_fixture.registerEvaluator(eval); - for (int dim = 0; dim < num_space_dim; ++dim) - test_fixture.registerTestField(eval->_induction_source[dim]); - - test_fixture.evaluate(); - - const auto fc_ind_0 - = test_fixture.getTestFieldData(eval->_induction_source[0]); - const auto fc_ind_1 - = test_fixture.getTestFieldData(eval->_induction_source[1]); - - const int num_point = ir.num_points; - - // Assert values - for (int qp = 0; qp < num_point; ++qp) - { - EXPECT_EQ(ind_input_source[0], fieldValue(fc_ind_0, 0, qp)); - EXPECT_EQ(ind_input_source[1], fieldValue(fc_ind_1, 0, qp)); - if (num_space_dim > 2) // 3D mesh - { - const auto fc_ind_2 = test_fixture.getTestFieldData( - eval->_induction_source[2]); - EXPECT_EQ(ind_input_source[2], fieldValue(fc_ind_2, 0, qp)); - } - } -} - -//-----------------------------------------------------------------// -TEST(InductionConstantSource2D, Residual) -{ - testEval(); -} - -//-----------------------------------------------------------------// -TEST(InductionConstantSource2D, Jacobian) -{ - testEval(); -} - -//-----------------------------------------------------------------// -TEST(InductionConstantSource3D, Residual) -{ - testEval(); -} - -//-----------------------------------------------------------------// -TEST(InductionConstantSource3D, Jacobian) -{ - testEval(); -} - -//-----------------------------------------------------------------// -template -void testFactory() -{ - constexpr int num_space_dim = NumSpaceDim; - ClosureModelFactoryTestFixture test_fixture; - const Teuchos::Array ind_input_source(num_space_dim); - test_fixture.model_params.set("Induction Source", ind_input_source); - test_fixture.user_params.sublist("Full Induction MHD Properties") - .set("Vacuum Magnetic Permeability", 0.1) - .set("Build Magnetic Correction Potential Equation", false); - test_fixture.type_name = "InductionConstantSource"; - test_fixture.eval_name = "Induction Constant Source " - + std::to_string(num_space_dim) + "D"; - test_fixture.template buildAndTest< - ClosureModel::InductionConstantSource, - num_space_dim>(); -} - -TEST(InductionConstantSourceFactory2D, Residual) -{ - testFactory(); -} - -TEST(InductionConstantSourceFactory2D, Jacobian) -{ - testFactory(); -} - -TEST(InductionConstantSourceFactory3D, Residual) -{ - testFactory(); -} - -TEST(InductionConstantSourceFactory3D, Jacobian) -{ - testFactory(); -} - -} // namespace Test -} // namespace VertexCFD diff --git a/src/full_induction_mhd_solver/closure_models/unit_test/tstInductionConvectiveFlux.cpp b/src/full_induction_mhd_solver/closure_models/unit_test/tstInductionConvectiveFlux.cpp deleted file mode 100644 index bd085f5..0000000 --- a/src/full_induction_mhd_solver/closure_models/unit_test/tstInductionConvectiveFlux.cpp +++ /dev/null @@ -1,313 +0,0 @@ -#include -#include - -#include "full_induction_mhd_solver/closure_models/VertexCFD_Closure_InductionConvectiveFlux.hpp" - -#include "full_induction_mhd_solver/mhd_properties/VertexCFD_FullInductionMHDProperties.hpp" - -#include "utils/VertexCFD_Utils_VectorField.hpp" - -#include - -namespace VertexCFD -{ -namespace Test -{ -template -struct Dependencies : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - using scalar_type = typename EvalType::ScalarT; - static constexpr int num_space_dim = NumSpaceDim; - - const Kokkos::Array _f_rhov; - const Kokkos::Array _v; - const Kokkos::Array _b; - const double _psi; - const double _p_mag; - const bool _build_magn_corr; - - Kokkos::Array< - PHX::MDField, - num_space_dim> - mtm_flux; - Kokkos::Array, - num_space_dim> - vel; - Kokkos::Array, 3> mag; - PHX::MDField magn_pot; - PHX::MDField magn_pres; - - Dependencies(const panzer::IntegrationRule& ir, - const Kokkos::Array& f_rhov, - const Kokkos::Array& v, - const Kokkos::Array& b, - const double psi, - const double p_mag, - const bool build_magn_corr, - const std::string& flux_pre, - const std::string& field_pre) - : _f_rhov(f_rhov) - , _v(v) - , _b(b) - , _psi(psi) - , _p_mag(p_mag) - , _build_magn_corr(build_magn_corr) - , magn_pot(field_pre + "scalar_magnetic_potential", ir.dl_scalar) - , magn_pres("magnetic_pressure", ir.dl_scalar) - { - Utils::addEvaluatedVectorField(*this, - ir.dl_vector, - mtm_flux, - flux_pre + "CONVECTIVE_FLUX_momentum_"); - Utils::addEvaluatedVectorField( - *this, ir.dl_scalar, vel, field_pre + "velocity_"); - Utils::addEvaluatedVectorField( - *this, ir.dl_scalar, mag, "total_magnetic_field_"); - this->addEvaluatedField(magn_pres); - if (_build_magn_corr) - { - this->addEvaluatedField(magn_pot); - } - - this->setName("Induction Convective Flux Unit Test Dependencies"); - } - - void evaluateFields(typename panzer::Traits::EvalData d) override - { - Kokkos::parallel_for( - "induction convective flux test dependencies", - Kokkos::RangePolicy(0, d.num_cells), - *this); - } - - KOKKOS_INLINE_FUNCTION void operator()(const int c) const - { - const int num_point = mag[0].extent(1); - for (int qp = 0; qp < num_point; ++qp) - { - for (int field_dim = 0; field_dim < 3; ++field_dim) - { - mag[field_dim](c, qp) = _b[field_dim]; - } - for (int vel_dim = 0; vel_dim < num_space_dim; ++vel_dim) - { - vel[vel_dim](c, qp) = _v[vel_dim]; - for (int flux_dim = 0; flux_dim < num_space_dim; ++flux_dim) - { - mtm_flux[vel_dim](c, qp, flux_dim) = _f_rhov[flux_dim] - * (vel_dim + 1); - } - } - magn_pres(c, qp) = _p_mag; - if (_build_magn_corr) - magn_pot(c, qp) = _psi; - } - } -}; - -template -void testEval(const bool build_magn_corr, - const std::string& flux_pre, - const std::string& field_pre) -{ - constexpr int num_space_dim = NumSpaceDim; - const int integration_order = 2; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - - const auto& ir = *test_fixture.ir; - - // Initialize velocity components and dependents - const Kokkos::Array f_rhov = {0.125, -0.26, 0.377}; - const Kokkos::Array v = {1.25, 1.5, 1.125}; - const Kokkos::Array b = {1.1, 2.1, 3.1}; - const double psi = 0.4; - const double p_mag = 0.8; - - auto deps = Teuchos::rcp(new Dependencies( - ir, f_rhov, v, b, psi, p_mag, build_magn_corr, flux_pre, field_pre)); - test_fixture.registerEvaluator(deps); - - // Initialize class object to test - Teuchos::ParameterList full_induction_params; - full_induction_params.set("Vacuum Magnetic Permeability", 0.05); - full_induction_params.set("Build Magnetic Correction Potential Equation", - build_magn_corr); - if (build_magn_corr) - { - full_induction_params.set("Hyperbolic Divergence Cleaning Speed", 5.0); - } - - MHDProperties::FullInductionMHDProperties mhd_props - = MHDProperties::FullInductionMHDProperties(full_induction_params); - - auto eval = Teuchos::rcp( - new ClosureModel:: - InductionConvectiveFlux( - ir, mhd_props, flux_pre, field_pre)); - - test_fixture.registerEvaluator(eval); - for (int dim = 0; dim < num_space_dim; ++dim) - { - test_fixture.registerTestField(eval->_momentum_flux[dim]); - test_fixture.registerTestField(eval->_induction_flux[dim]); - } - if (build_magn_corr) - { - test_fixture.registerTestField( - eval->_magnetic_correction_potential_flux); - } - - test_fixture.evaluate(); - - // Expected values - const double exp_mom_0_flux[3] = {-23.275, -46.46, -67.823}; - const double exp_mom_1_flux[3] = {-45.95, -87.92, -129.446}; - const double exp_mom_2_flux[3] = {-67.825, -130.98, -190.269}; - - const double psi_cont = build_magn_corr ? 2. : 0.; - - const double exp_ind_0_flux[3] = {psi_cont, -0.9749999999999999, -2.6375}; - const double exp_ind_1_flux[3] = {0.9749999999999999, psi_cont, -2.2875}; - const double exp_ind_2_flux[3] = {2.6375, 2.2875, psi_cont}; - - const double exp_psi_flux[3] = {5.5, 10.5, 15.5}; - - const auto fc_mom_0 - = test_fixture.getTestFieldData(eval->_momentum_flux[0]); - const auto fc_mom_1 - = test_fixture.getTestFieldData(eval->_momentum_flux[1]); - - const auto fc_ind_0 - = test_fixture.getTestFieldData(eval->_induction_flux[0]); - const auto fc_ind_1 - = test_fixture.getTestFieldData(eval->_induction_flux[1]); - - const int num_point = ir.num_points; - // Assert values - for (int qp = 0; qp < num_point; ++qp) - { - for (int dim = 0; dim < num_space_dim; dim++) - { - EXPECT_DOUBLE_EQ(exp_mom_0_flux[dim], - fieldValue(fc_mom_0, 0, qp, dim)); - EXPECT_DOUBLE_EQ(exp_mom_1_flux[dim], - fieldValue(fc_mom_1, 0, qp, dim)); - EXPECT_DOUBLE_EQ(exp_ind_0_flux[dim], - fieldValue(fc_ind_0, 0, qp, dim)); - EXPECT_DOUBLE_EQ(exp_ind_1_flux[dim], - fieldValue(fc_ind_1, 0, qp, dim)); - if (num_space_dim > 2) - { - const auto fc_mom_2 = test_fixture.getTestFieldData( - eval->_momentum_flux[2]); - EXPECT_DOUBLE_EQ(exp_mom_2_flux[dim], - fieldValue(fc_mom_2, 0, qp, dim)); - const auto fc_ind_2 = test_fixture.getTestFieldData( - eval->_induction_flux[2]); - EXPECT_DOUBLE_EQ(exp_ind_2_flux[dim], - fieldValue(fc_ind_2, 0, qp, dim)); - } - - if (build_magn_corr) - { - const auto fc_psi = test_fixture.getTestFieldData( - eval->_magnetic_correction_potential_flux); - EXPECT_DOUBLE_EQ(exp_psi_flux[dim], - fieldValue(fc_psi, 0, qp, dim)); - } - } - } -} - -//-----------------------------------------------------------------// -TEST(InductionConvectiveFluxNoCleaning2D, residual_test) -{ - testEval(false, "", ""); -} - -//-----------------------------------------------------------------// -TEST(InductionConvectiveFluxNoCleaning2D, jacobian_test) -{ - testEval(false, "", ""); -} - -//-----------------------------------------------------------------// -TEST(InductionConvectiveFluxNoCleaning3D, residual_test) -{ - testEval(false, "Foo_", "Bar_"); -} - -//-----------------------------------------------------------------// -TEST(InductionConvectiveFluxNoCleaning3D, jacobian_test) -{ - testEval(false, "Foo_", "Bar_"); -} - -//-----------------------------------------------------------------// -TEST(InductionConvectiveFluxDivCleaning2D, residual_test) -{ - testEval(true, "Foo_", "Bar_"); -} - -//-----------------------------------------------------------------// -TEST(InductionConvectiveFluxNoDivCleaning2D, jacobian_test) -{ - testEval(true, "Foo_", "Bar_"); -} - -//-----------------------------------------------------------------// -TEST(InductionConvectiveFluxDivCleaning3D, residual_test) -{ - testEval(true, "", ""); -} - -//-----------------------------------------------------------------// -TEST(InductionConvectiveFluxDivCleaning3D, jacobian_test) -{ - testEval(true, "", ""); -} -//-----------------------------------------------------------------// -template -void testFactory() -{ - constexpr int num_space_dim = NumSpaceDim; - ClosureModelFactoryTestFixture test_fixture; - test_fixture.user_params.sublist("Full Induction MHD Properties") - .set("Vacuum Magnetic Permeability", 0.1) - .set("Build Magnetic Correction Potential Equation", false); - test_fixture.user_params.sublist("Fluid Properties") - .set("Kinematic viscosity", 1.5) - .set("Artificial compressibility", 0.1); - test_fixture.type_name = "InductionConvectiveFlux"; - test_fixture.eval_name = "Induction Convective Flux " - + std::to_string(num_space_dim) + "D"; - test_fixture.template buildAndTest< - ClosureModel::InductionConvectiveFlux, - num_space_dim>(); -} - -TEST(InductionConvectiveFlux_Factory2D, residual_test) -{ - testFactory(); -} - -TEST(InductionConvectiveFlux_Factory2D, jacobian_test) -{ - testFactory(); -} - -TEST(InductionConvectiveFlux_Factory3D, residual_test) -{ - testFactory(); -} - -TEST(InductionConvectiveFlux_Factory3D, jacobian_test) -{ - testFactory(); -} - -} // namespace Test -} // namespace VertexCFD diff --git a/src/full_induction_mhd_solver/closure_models/unit_test/tstInductionResistiveFlux.cpp b/src/full_induction_mhd_solver/closure_models/unit_test/tstInductionResistiveFlux.cpp deleted file mode 100644 index 89ffa7e..0000000 --- a/src/full_induction_mhd_solver/closure_models/unit_test/tstInductionResistiveFlux.cpp +++ /dev/null @@ -1,488 +0,0 @@ -#include -#include - -#include "full_induction_mhd_solver/closure_models/VertexCFD_Closure_InductionResistiveFlux.hpp" - -#include "full_induction_mhd_solver/mhd_properties/VertexCFD_FullInductionMHDProperties.hpp" - -#include "utils/VertexCFD_Utils_VectorField.hpp" - -#include - -namespace VertexCFD -{ -namespace Test -{ -template -struct Dependencies : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - using scalar_type = typename EvalType::ScalarT; - - const Kokkos::Array _b; - const double _res; - - Kokkos::Array, 3> mag; - Kokkos::Array< - PHX::MDField, - 3> - grad_mag; - PHX::MDField eta; - PHX::MDField grad_eta; - - Dependencies(const panzer::IntegrationRule& ir, - const Kokkos::Array& b, - const double res, - const std::string& grad_pre) - : _b(b) - , _res(res) - , eta("resistivity", ir.dl_scalar) - , grad_eta("GRAD_resistivity", ir.dl_vector) - { - Utils::addEvaluatedVectorField( - *this, ir.dl_scalar, mag, "total_magnetic_field_"); - Utils::addEvaluatedVectorField(*this, - ir.dl_vector, - grad_mag, - grad_pre + "GRAD_total_magnetic_field_"); - this->addEvaluatedField(eta); - this->addEvaluatedField(grad_eta); - - this->setName("Induction Resistive Flux Unit Test Dependencies"); - } - - void evaluateFields(typename panzer::Traits::EvalData d) override - { - Kokkos::parallel_for( - "induction resistive flux test dependencies", - Kokkos::RangePolicy(0, d.num_cells), - *this); - } - - KOKKOS_INLINE_FUNCTION void operator()(const int c) const - { - const int num_point = grad_eta.extent(1); - const int num_space_dim = grad_eta.extent(2); - - for (int qp = 0; qp < num_point; ++qp) - { - for (int field_dim = 0; field_dim < 3; ++field_dim) - { - mag[field_dim](c, qp) = _b[field_dim]; - } - eta(c, qp) = _res; - for (int grad_dim = 0; grad_dim < num_space_dim; ++grad_dim) - { - const int b_mult = pow(-1, grad_dim) * (grad_dim + 1); - for (int field_dim = 0; field_dim < 3; ++field_dim) - { - grad_mag[field_dim](c, qp, grad_dim) = _b[field_dim] - * b_mult; - } - const int eta_mult = pow(-1, grad_dim + 1) * (grad_dim + 2); - grad_eta(c, qp, grad_dim) = _res * eta_mult; - } - } - } -}; - -//-----------------------------------------------------------------// -template -void testEval(const Teuchos::ParameterList& test_params, - const std::string& flux_pre, - const std::string& grad_pre) -{ - constexpr int num_space_dim = NumSpaceDim; - const int integration_order = 2; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - - const auto& ir = *test_fixture.ir; - - // Initialize velocity components and dependents - const Kokkos::Array b = {1.1, 2.1, 3.1}; - const double eta = 0.16; - - auto deps = Teuchos::rcp(new Dependencies(ir, b, eta, grad_pre)); - test_fixture.registerEvaluator(deps); - - // Initialize class object to test - Teuchos::ParameterList full_induction_params - = test_params.sublist("Full Induction MHD Properties"); - full_induction_params.set("Vacuum Magnetic Permeability", 0.05); - full_induction_params.set("Build Resistive Flux", true); - MHDProperties::FullInductionMHDProperties mhd_props - = MHDProperties::FullInductionMHDProperties(full_induction_params); - const auto build_magn_corr = mhd_props.buildMagnCorr(); - - auto eval = Teuchos::rcp( - new ClosureModel:: - InductionResistiveFlux( - ir, mhd_props, flux_pre, grad_pre)); - - test_fixture.registerEvaluator(eval); - for (int dim = 0; dim < num_space_dim; ++dim) - { - test_fixture.registerTestField(eval->_induction_flux[dim]); - } - if (build_magn_corr) - { - test_fixture.registerTestField( - eval->_magnetic_correction_potential_flux); - } - - test_fixture.evaluate(); - - const auto exp_ind_0_flux - = test_params.get>("Exp Ind 0 Flux"); - const auto exp_ind_1_flux - = test_params.get>("Exp Ind 1 Flux"); - const auto exp_ind_2_flux - = test_params.get>("Exp Ind 2 Flux"); - - const auto fc_ind_0 - = test_fixture.getTestFieldData(eval->_induction_flux[0]); - const auto fc_ind_1 - = test_fixture.getTestFieldData(eval->_induction_flux[1]); - - const int num_point = ir.num_points; - // Assert values - for (int qp = 0; qp < num_point; ++qp) - { - for (int dim = 0; dim < num_space_dim; dim++) - { - EXPECT_DOUBLE_EQ(exp_ind_0_flux[dim], - fieldValue(fc_ind_0, 0, qp, dim)); - EXPECT_DOUBLE_EQ(exp_ind_1_flux[dim], - fieldValue(fc_ind_1, 0, qp, dim)); - if (num_space_dim > 2) - { - const auto fc_ind_2 = test_fixture.getTestFieldData( - eval->_induction_flux[2]); - EXPECT_DOUBLE_EQ(exp_ind_2_flux[dim], - fieldValue(fc_ind_2, 0, qp, dim)); - } - - if (build_magn_corr) - { - const auto fc_psi = test_fixture.getTestFieldData( - eval->_magnetic_correction_potential_flux); - EXPECT_DOUBLE_EQ(0.0, fieldValue(fc_psi, 0, qp, dim)); - } - } - } -} - -//-----------------------------------------------------------------// -template -void testEval2D(const bool build_magn_corr, const bool var_resistivity) -{ - // Expected values 2D - // Variable resistivity - const double nanval = std::numeric_limits::signaling_NaN(); - const Teuchos::Array exp_ind_0_flux_var_eta( - {-6.72, -20.48, nanval}); - const Teuchos::Array exp_ind_1_flux_var_eta({17.28, 3.52, nanval}); - // Constant resistivity - const Teuchos::Array exp_ind_0_flux_const_eta( - {13.44, -7.04, nanval}); - const Teuchos::Array exp_ind_1_flux_const_eta( - {6.72, -3.52, nanval}); - - const auto exp_ind_0_flux = var_resistivity ? exp_ind_0_flux_var_eta - : exp_ind_0_flux_const_eta; - const auto exp_ind_1_flux = var_resistivity ? exp_ind_1_flux_var_eta - : exp_ind_1_flux_const_eta; - // NOTE: currently we will not have a flux vector for B_z - // (exp_ind_2_flux) as we are limiting the induced magnetic field to the - // mesh dimension. The fact that the reference script does compute non-zero - // expected values for the B_z flux suggests that perhaps we do need to - // always include the B_z component. - const Teuchos::Array exp_ind_2_flux({nanval, nanval, nanval}); - - Teuchos::ParameterList full_ind_params; - full_ind_params.set("Build Magnetic Correction Potential Equation", - build_magn_corr); - if (build_magn_corr) - { - full_ind_params.set("Hyperbolic Divergence Cleaning Speed", 1.1); - } - full_ind_params.set("Variable Resistivity", var_resistivity); - if (!var_resistivity) - { - full_ind_params.set("Resistivity", 1.5); - } - Teuchos::ParameterList test_params; - test_params.set("Full Induction MHD Properties", full_ind_params); - test_params.set("Exp Ind 0 Flux", exp_ind_0_flux); - test_params.set("Exp Ind 1 Flux", exp_ind_1_flux); - test_params.set("Exp Ind 2 Flux", exp_ind_2_flux); - - testEval(test_params, "Foo_", "Bar_"); -} - -//-----------------------------------------------------------------// -TEST(InductionResistiveFluxNoCleaning2D, residual_test) -{ - // For now, tests with variable resistivity will throw an error. - // Test for the appropriate error here, but retain the old test - // for use once a resistivity closure has been added. - const std::string exp_msg - = "No closure models currently exist to evaluate variable " - "resistivity. Use a constant resistivity only."; - EXPECT_THROW( - try { - testEval2D(false, true); - } catch (const std::runtime_error& e) { - EXPECT_EQ(exp_msg, e.what()); - throw; - }, - std::runtime_error); - // testEval2D(false, true); -} - -TEST(InductionResistiveFluxNoCleaning2D, jacobian_test) -{ - // For now, tests with variable resistivity will throw an error. - // Test for the appropriate error here, but retain the old test - // for use once a resistivity closure has been added. - const std::string exp_msg - = "No closure models currently exist to evaluate variable " - "resistivity. Use a constant resistivity only."; - EXPECT_THROW( - try { - testEval2D(false, true); - } catch (const std::runtime_error& e) { - EXPECT_EQ(exp_msg, e.what()); - throw; - }, - std::runtime_error); - // testEval2D(false, true); -} - -//-----------------------------------------------------------------// -TEST(InductionResistiveFluxDivCleaning2D, residual_test) -{ - // For now, tests with variable resistivity will throw an error. - // Test for the appropriate error here, but retain the old test - // for use once a resistivity closure has been added. - const std::string exp_msg - = "No closure models currently exist to evaluate variable " - "resistivity. Use a constant resistivity only."; - EXPECT_THROW( - try { - testEval2D(true, true); - } catch (const std::runtime_error& e) { - EXPECT_EQ(exp_msg, e.what()); - throw; - }, - std::runtime_error); - // testEval2D(true, true); -} - -TEST(InductionResistiveFluxDivCleaning2D, jacobian_test) -{ - // For now, tests with variable resistivity will throw an error. - // Test for the appropriate error here, but retain the old test - // for use once a resistivity closure has been added. - const std::string exp_msg - = "No closure models currently exist to evaluate variable " - "resistivity. Use a constant resistivity only."; - EXPECT_THROW( - try { - testEval2D(true, true); - } catch (const std::runtime_error& e) { - EXPECT_EQ(exp_msg, e.what()); - throw; - }, - std::runtime_error); - // testEval2D(true, true); -} - -//-----------------------------------------------------------------// -TEST(InductionResistiveFluxConstantResistivity2D, residual_test) -{ - testEval2D(false, false); -} - -TEST(InductionResistiveFluxConstantResistivity2D, jacobian_test) -{ - testEval2D(false, false); -} - -//-----------------------------------------------------------------// -template -void testEval3D(const bool build_magn_corr, const bool var_resistivity) -{ - // Expected values 3D - // Variable resistivity - const Teuchos::Array exp_ind_0_flux_var_eta({3.2, -20.48, -9.28}); - const Teuchos::Array exp_ind_1_flux_var_eta({17.28, 13.44, 49.92}); - const Teuchos::Array exp_ind_2_flux_var_eta({-4.16, -46.72, -3.2}); - // Constant resistivity - const Teuchos::Array exp_ind_0_flux_const_eta( - {-16.32, -7.04, 10.56}); - const Teuchos::Array exp_ind_1_flux_const_eta( - {6.72, -33.28, 20.16}); - const Teuchos::Array exp_ind_2_flux_const_eta({9.92, -19.84, 9.92}); - - const auto exp_ind_0_flux = var_resistivity ? exp_ind_0_flux_var_eta - : exp_ind_0_flux_const_eta; - const auto exp_ind_1_flux = var_resistivity ? exp_ind_1_flux_var_eta - : exp_ind_1_flux_const_eta; - const auto exp_ind_2_flux = var_resistivity ? exp_ind_2_flux_var_eta - : exp_ind_2_flux_const_eta; - - Teuchos::ParameterList full_ind_params; - full_ind_params.set("Build Magnetic Correction Potential Equation", - build_magn_corr); - if (build_magn_corr) - { - full_ind_params.set("Hyperbolic Divergence Cleaning Speed", 1.1); - } - full_ind_params.set("Variable Resistivity", var_resistivity); - if (!var_resistivity) - { - full_ind_params.set("Resistivity", 1.5); - } - Teuchos::ParameterList test_params; - test_params.set("Full Induction MHD Properties", full_ind_params); - test_params.set("Exp Ind 0 Flux", exp_ind_0_flux); - test_params.set("Exp Ind 1 Flux", exp_ind_1_flux); - test_params.set("Exp Ind 2 Flux", exp_ind_2_flux); - - testEval(test_params, "", ""); -} - -//-----------------------------------------------------------------// -TEST(InductionResistiveFluxNoCleaning3D, residual_test) -{ - // For now, tests with variable resistivity will throw an error. - // Test for the appropriate error here, but retain the old test - // for use once a resistivity closure has been added. - const std::string exp_msg - = "No closure models currently exist to evaluate variable " - "resistivity. Use a constant resistivity only."; - EXPECT_THROW( - try { - testEval3D(false, true); - } catch (const std::runtime_error& e) { - EXPECT_EQ(exp_msg, e.what()); - throw; - }, - std::runtime_error); - // testEval3D(false, true); -} - -TEST(InductionResistiveFluxNoCleaning3D, jacobian_test) -{ - // For now, tests with variable resistivity will throw an error. - // Test for the appropriate error here, but retain the old test - // for use once a resistivity closure has been added. - const std::string exp_msg - = "No closure models currently exist to evaluate variable " - "resistivity. Use a constant resistivity only."; - EXPECT_THROW( - try { - testEval3D(false, true); - } catch (const std::runtime_error& e) { - EXPECT_EQ(exp_msg, e.what()); - throw; - }, - std::runtime_error); - // testEval3D(false, true); -} - -//-----------------------------------------------------------------// -TEST(InductionResistiveFluxDivCleaning3D, residual_test) -{ - // For now, tests with variable resistivity will throw an error. - // Test for the appropriate error here, but retain the old test - // for use once a resistivity closure has been added. - const std::string exp_msg - = "No closure models currently exist to evaluate variable " - "resistivity. Use a constant resistivity only."; - EXPECT_THROW( - try { - testEval3D(true, true); - } catch (const std::runtime_error& e) { - EXPECT_EQ(exp_msg, e.what()); - throw; - }, - std::runtime_error); - // testEval3D(true, true); -} - -TEST(InductionResistiveFluxDivCleaning3D, jacobian_test) -{ - // For now, tests with variable resistivity will throw an error. - // Test for the appropriate error here, but retain the old test - // for use once a resistivity closure has been added. - const std::string exp_msg - = "No closure models currently exist to evaluate variable " - "resistivity. Use a constant resistivity only."; - EXPECT_THROW( - try { - testEval3D(true, true); - } catch (const std::runtime_error& e) { - EXPECT_EQ(exp_msg, e.what()); - throw; - }, - std::runtime_error); - // testEval3D(true, true); -} - -//-----------------------------------------------------------------// -TEST(InductionResistiveFluxConstantResistivity3D, residual_test) -{ - testEval3D(false, false); -} - -TEST(InductionResistiveFluxConstantResistivity3D, jacobian_test) -{ - testEval3D(false, false); -} - -//-----------------------------------------------------------------// -template -void testFactory() -{ - constexpr int num_space_dim = NumSpaceDim; - ClosureModelFactoryTestFixture test_fixture; - test_fixture.user_params.sublist("Full Induction MHD Properties") - .set("Vacuum Magnetic Permeability", 0.1) - .set("Build Magnetic Correction Potential Equation", false); - test_fixture.user_params.sublist("Fluid Properties") - .set("Kinematic viscosity", 1.5) - .set("Artificial compressibility", 0.1); - test_fixture.type_name = "InductionResistiveFlux"; - test_fixture.eval_name = "Induction Resistive Flux " - + std::to_string(num_space_dim) + "D"; - test_fixture.template buildAndTest< - ClosureModel::InductionResistiveFlux, - num_space_dim>(); -} - -TEST(InductionResistiveFlux_Factory2D, residual_test) -{ - testFactory(); -} - -TEST(InductionResistiveFlux_Factory2D, jacobian_test) -{ - testFactory(); -} - -TEST(InductionResistiveFlux_Factory3D, residual_test) -{ - testFactory(); -} - -TEST(InductionResistiveFlux_Factory3D, jacobian_test) -{ - testFactory(); -} - -} // namespace Test -} // namespace VertexCFD diff --git a/src/full_induction_mhd_solver/closure_models/unit_test/tstMHDVortexProblemExact.cpp b/src/full_induction_mhd_solver/closure_models/unit_test/tstMHDVortexProblemExact.cpp deleted file mode 100644 index 10c7aca..0000000 --- a/src/full_induction_mhd_solver/closure_models/unit_test/tstMHDVortexProblemExact.cpp +++ /dev/null @@ -1,162 +0,0 @@ -#include -#include - -#include "full_induction_mhd_solver/closure_models/VertexCFD_Closure_MHDVortexProblemExact.hpp" - -#include - -namespace VertexCFD -{ -namespace Test -{ -template -void testEval() -{ - const int integration_order = 1; - const int basis_order = 1; - static constexpr int num_space_dim = NumSpaceDim; - - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - - const auto& ir = *test_fixture.ir; - const double time = 0.6; - test_fixture.setTime(time); - - // Set non-trivial coordinates for the degree of freedom - const int num_point = ir.num_points; - auto ip_coord_view - = test_fixture.int_values->ip_coordinates.get_static_view(); - auto ip_coord_mirror = Kokkos::create_mirror(ip_coord_view); - ip_coord_mirror(0, 0, 0) = 0.2; - ip_coord_mirror(0, 0, 1) = 0.4; - Kokkos::deep_copy(ip_coord_view, ip_coord_mirror); - - // Closure parameters - Teuchos::Array xy_0(2); - xy_0[0] = 0.1; - xy_0[1] = -0.2; - Teuchos::Array vel_0(2); - vel_0[0] = 2.0; - vel_0[1] = -0.5; - Teuchos::ParameterList mhd_params; - mhd_params.set>("velocity_0", vel_0); - mhd_params.set>("center_0", xy_0); - - // Initialize and register - auto eval = Teuchos::rcp( - new ClosureModel::MHDVortexProblemExact(ir, mhd_params)); - test_fixture.registerEvaluator(eval); - test_fixture.registerTestField(eval->_lagrange_pressure); - test_fixture.registerTestField(eval->_induced_magnetic_field[0]); - test_fixture.registerTestField(eval->_induced_magnetic_field[1]); - test_fixture.registerTestField(eval->_velocity[0]); - test_fixture.registerTestField(eval->_velocity[1]); - test_fixture.evaluate(); - - // Evaluate test fields - const auto fv_lag_pres - = test_fixture.getTestFieldData(eval->_lagrange_pressure); - const auto fv_mgn_field_0 = test_fixture.getTestFieldData( - eval->_induced_magnetic_field[0]); - const auto fv_mgn_field_1 = test_fixture.getTestFieldData( - eval->_induced_magnetic_field[1]); - const auto fv_vel_0 - = test_fixture.getTestFieldData(eval->_velocity[0]); - const auto fv_vel_1 - = test_fixture.getTestFieldData(eval->_velocity[1]); - - // Assert values - const double tol = 1.0e-15; - for (int qp = 0; qp < num_point; ++qp) - { - EXPECT_NEAR(1.9152034448503858, fieldValue(fv_lag_pres, 0, qp), tol); - EXPECT_NEAR( - -0.45120855259162973, fieldValue(fv_mgn_field_0, 0, qp), tol); - EXPECT_NEAR( - 0.07520142543193828, fieldValue(fv_mgn_field_1, 0, qp), tol); - EXPECT_NEAR(1.5487914474083704, fieldValue(fv_vel_0, 0, qp), tol); - EXPECT_NEAR(0.07520142543193828, fieldValue(fv_vel_1, 0, qp), tol); - - if (num_space_dim == 3) - { - const auto fv_mgn_field_2 = test_fixture.getTestFieldData( - eval->_induced_magnetic_field[2]); - const auto fv_vel_2 - = test_fixture.getTestFieldData(eval->_velocity[2]); - EXPECT_EQ(0.0, fieldValue(fv_mgn_field_2, 0, qp)); - EXPECT_EQ(0.0, fieldValue(fv_vel_2, 0, qp)); - } - } -} - -//-----------------------------------------------------------------// -TEST(MHDVortexProblemExact2D, residual_test) -{ - testEval(); -} - -//-----------------------------------------------------------------// -TEST(MHDVortexProblemExact2D, jacobian_test) -{ - testEval(); -} - -//-----------------------------------------------------------------// -TEST(MHDVortexProblemExact3D, residual_test) -{ - testEval(); -} - -//-----------------------------------------------------------------// -TEST(MHDVortexProblemExact3D, jacobian_test) -{ - testEval(); -} - -//-----------------------------------------------------------------// -template -void testFactory() -{ - static constexpr int num_space_dim = NumSpaceDim; - ClosureModelFactoryTestFixture test_fixture; - test_fixture.type_name = "MHDVortexProblemExact"; - test_fixture.eval_name = "MHD Vortex Problem Exact Solution " - + std::to_string(num_space_dim) + "D."; - const Teuchos::Array dummy(2); - test_fixture.user_params.sublist("Full Induction MHD Properties") - .set("velocity_0", dummy) - .set("center_0", dummy); - test_fixture.user_params.sublist("Fluid Properties") - .set("Kinematic viscosity", 1.5) - .set("Artificial compressibility", 0.1); - test_fixture.template buildAndTest< - ClosureModel::MHDVortexProblemExact, - num_space_dim>(); -} - -TEST(MHDVortexProblemExact_Factory2D, residual_test) -{ - testFactory(); -} - -TEST(MHDVortexProblemExact_Factory2D, jacobian_test) -{ - testFactory(); -} - -TEST(MHDVortexProblemExact_Factory3D, residual_test) -{ - testFactory(); -} - -TEST(MHDVortexProblemExact_Factory3D, jacobian_test) -{ - testFactory(); -} - -//-----------------------------------------------------------------// -} // namespace Test -} // namespace VertexCFD diff --git a/src/full_induction_mhd_solver/closure_models/unit_test/tstMagneticCorrectionDampingSource.cpp b/src/full_induction_mhd_solver/closure_models/unit_test/tstMagneticCorrectionDampingSource.cpp deleted file mode 100644 index f9b3ae8..0000000 --- a/src/full_induction_mhd_solver/closure_models/unit_test/tstMagneticCorrectionDampingSource.cpp +++ /dev/null @@ -1,157 +0,0 @@ -#include -#include - -#include "full_induction_mhd_solver/closure_models/VertexCFD_Closure_MagneticCorrectionDampingSource.hpp" - -#include "full_induction_mhd_solver/mhd_properties/VertexCFD_FullInductionMHDProperties.hpp" - -#include - -namespace VertexCFD -{ -namespace Test -{ - -template -struct Dependencies : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - using scalar_type = typename EvalType::ScalarT; - - PHX::MDField - scalar_magnetic_potential; - - Dependencies(const panzer::IntegrationRule& ir) - : scalar_magnetic_potential("scalar_magnetic_potential", ir.dl_scalar) - { - this->addEvaluatedField(scalar_magnetic_potential); - - this->setName( - "Magnetic Correction Damping Source Unit Test Dependencies"); - } - - void evaluateFields(typename panzer::Traits::EvalData) override - { - scalar_magnetic_potential.deep_copy(0.3); - } -}; - -template -void testEval(const bool use_default_alpha) -{ - static constexpr int num_space_dim = 2; - const int integration_order = 2; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - - auto& ir = *test_fixture.ir; - - const double alpha = 2.0; - Teuchos::ParameterList full_induction_params; - full_induction_params.set("Build Magnetic Correction Potential Equation", - true); - if (use_default_alpha) - { - full_induction_params.set("Hyperbolic Divergence Cleaning Speed", - alpha * 0.18); - } - else - { - full_induction_params.set("Hyperbolic Divergence Cleaning Speed", 1.1); - full_induction_params.set("Magnetic Correction Damping Factor", alpha); - } - MHDProperties::FullInductionMHDProperties mhd_props - = MHDProperties::FullInductionMHDProperties(full_induction_params); - - // Initialize class object to test - auto deps = Teuchos::rcp(new Dependencies(ir)); - test_fixture.registerEvaluator(deps); - - auto eval = Teuchos::rcp( - new ClosureModel::MagneticCorrectionDampingSource( - ir, mhd_props)); - test_fixture.registerEvaluator(eval); - test_fixture.registerTestField(eval->_damping_potential_source); - - test_fixture.evaluate(); - - const auto src_magn_pot = test_fixture.getTestFieldData( - eval->_damping_potential_source); - - const int num_point = ir.num_points; - - // Assert values - for (int qp = 0; qp < num_point; ++qp) - { - EXPECT_DOUBLE_EQ(-0.6, fieldValue(src_magn_pot, 0, qp)); - } -} - -//-----------------------------------------------------------------// -TEST(MagneticCorrectionDampingSource, residual_test) -{ - testEval(false); -} - -//-----------------------------------------------------------------// -TEST(MagneticCorrectionDampingSource, jacobian_test) -{ - testEval(false); -} - -//-----------------------------------------------------------------// -TEST(MagneticCorrectionDampingSourceDefaultAlpha, residual_test) -{ - testEval(true); -} - -//-----------------------------------------------------------------// -TEST(MagneticCorrectionDampingSourceDefaultAlpha, jacobian_test) -{ - testEval(true); -} - -//-----------------------------------------------------------------// -template -void testFactory() -{ - constexpr int num_space_dim = NumSpaceDim; - ClosureModelFactoryTestFixture test_fixture; - test_fixture.user_params.sublist("Full Induction MHD Properties") - .set("Vacuum Magnetic Permeability", 0.1) - .set("Build Magnetic Correction Potential Equation", false) - .set("Hyperbolic Divergence Cleaning Speed", 1.0); - test_fixture.user_params.sublist("Fluid Properties") - .set("Kinematic viscosity", 1.5) - .set("Artificial compressibility", 0.1); - test_fixture.type_name = "MagneticCorrectionDampingSource"; - test_fixture.eval_name = "Magnetic Correction Damping Source"; - test_fixture.template buildAndTest< - ClosureModel::MagneticCorrectionDampingSource, - num_space_dim>(); -} - -TEST(MagneticCorrectionDampingSource_Factory2D, residual_test) -{ - testFactory(); -} - -TEST(MagneticCorrectionDampingSource_Factory2D, jacobian_test) -{ - testFactory(); -} - -TEST(MagneticCorrectionDampingSource_Factory3D, residual_test) -{ - testFactory(); -} - -TEST(MagneticCorrectionDampingSource_Factory3D, jacobian_test) -{ - testFactory(); -} - -} // namespace Test -} // namespace VertexCFD diff --git a/src/full_induction_mhd_solver/closure_models/unit_test/tstMagneticPressure.cpp b/src/full_induction_mhd_solver/closure_models/unit_test/tstMagneticPressure.cpp deleted file mode 100644 index 0621bad..0000000 --- a/src/full_induction_mhd_solver/closure_models/unit_test/tstMagneticPressure.cpp +++ /dev/null @@ -1,156 +0,0 @@ -#include -#include - -#include "full_induction_mhd_solver/closure_models/VertexCFD_Closure_MagneticPressure.hpp" - -#include "utils/VertexCFD_Utils_VectorField.hpp" - -#include - -namespace VertexCFD -{ -namespace Test -{ -template -struct Dependencies : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - using scalar_type = typename EvalType::ScalarT; - - Kokkos::Array, 3> - tot_magn_field; - - const Kokkos::Array _b; - - Dependencies(const panzer::IntegrationRule& ir, - const Kokkos::Array b) - : _b(b) - { - Utils::addEvaluatedVectorField( - *this, ir.dl_scalar, tot_magn_field, "total_magnetic_field_"); - this->setName("Magnetic Pressure"); - } - - void evaluateFields(typename panzer::Traits::EvalData /**d**/) override - { - const int num_field_dim = tot_magn_field.size(); - for (int dim = 0; dim < num_field_dim; ++dim) - tot_magn_field[dim].deep_copy(_b[dim]); - } -}; - -template -void testEval(const int num_space_dim) -{ - const int integration_order = 1; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - - const auto& ir = *test_fixture.ir; - - // Initialize magnetic field components and dependencies - const double b0 = 0.25; - const double b1 = 0.5; - const double b2 = num_space_dim == 3 ? 0.75 : 0.125; - - // Eval dependencies - const auto deps - = Teuchos::rcp(new Dependencies(ir, {b0, b1, b2})); - test_fixture.registerEvaluator(deps); - - // Closure parameters - const double mu_0 = 2.0e-3; - Teuchos::ParameterList full_induction_params; - full_induction_params.set("Vacuum Magnetic Permeability", mu_0); - MHDProperties::FullInductionMHDProperties mhd_props - = MHDProperties::FullInductionMHDProperties(full_induction_params); - - // Initialize and register - auto eval = Teuchos::rcp( - new ClosureModel::MagneticPressure( - ir, mhd_props)); - test_fixture.registerEvaluator(eval); - test_fixture.registerTestField(eval->_magnetic_pressure); - test_fixture.evaluate(); - - // Evaluate test fields - const auto fv_magn_pres - = test_fixture.getTestFieldData(eval->_magnetic_pressure); - - // Expected values - const int num_point = ir.num_points; - const double exp_magn_pres = (b0 * b0 + b1 * b1 + b2 * b2) / (2.0 * mu_0); - - // Assert values - for (int qp = 0; qp < num_point; ++qp) - { - EXPECT_EQ(exp_magn_pres, fieldValue(fv_magn_pres, 0, qp)); - } -} - -//-----------------------------------------------------------------// -TEST(MagneticPressure2D, residual_test) -{ - testEval(2); -} - -//-----------------------------------------------------------------// -TEST(MagneticPressure2D, jacobian_test) -{ - testEval(2); -} - -//-----------------------------------------------------------------// -TEST(MagneticPressure3D, residual_test) -{ - testEval(3); -} - -//-----------------------------------------------------------------// -TEST(MagneticPressure3D, jacobian_test) -{ - testEval(3); -} - -//-----------------------------------------------------------------// -template -void testFactory() -{ - static constexpr int num_space_dim = NumSpaceDim; - ClosureModelFactoryTestFixture test_fixture; - test_fixture.type_name = "MagneticPressure"; - test_fixture.eval_name = "Magnetic Pressure"; - test_fixture.user_params.sublist("Full Induction MHD Properties") - .set("Vacuum Magnetic Permeability", 0.125); - test_fixture.user_params.sublist("Fluid Properties") - .set("Kinematic viscosity", 1.5) - .set("Artificial compressibility", 0.1); - test_fixture.template buildAndTest< - ClosureModel::MagneticPressure, - num_space_dim>(); -} - -TEST(MagneticPressure_Factory2D, residual_test) -{ - testFactory(); -} - -TEST(MagneticPressure_Factory2D, jacobian_test) -{ - testFactory(); -} - -TEST(MagneticPressure_Factory3D, residual_test) -{ - testFactory(); -} - -TEST(MagneticPressure_Factory3D, jacobian_test) -{ - testFactory(); -} - -//-----------------------------------------------------------------// -} // namespace Test -} // namespace VertexCFD diff --git a/src/full_induction_mhd_solver/closure_models/unit_test/tstResistivityFactory.cpp b/src/full_induction_mhd_solver/closure_models/unit_test/tstResistivityFactory.cpp deleted file mode 100644 index 8633bba..0000000 --- a/src/full_induction_mhd_solver/closure_models/unit_test/tstResistivityFactory.cpp +++ /dev/null @@ -1,95 +0,0 @@ -#include "VertexCFD_EvaluatorTestHarness.hpp" -#include "closure_models/unit_test/VertexCFD_ClosureModelFactoryTestHarness.hpp" - -#include "closure_models/VertexCFD_Closure_ConstantScalarField.hpp" - -#include "full_induction_mhd_solver/mhd_properties/VertexCFD_FullInductionMHDProperties.hpp" - -#include - -#include - -namespace VertexCFD -{ -namespace Test -{ - -//-----------------------------------------------------------------// -// Full Induction MHD closure model factory test for "Resistivity" -// using the constant scalar field closure model -//-----------------------------------------------------------------// -template -void testFactory(const bool variable_resistivity) -{ - static constexpr int num_space_dim = NumSpaceDim; - ClosureModelFactoryTestFixture test_fixture; - test_fixture.type_name = "Resistivity"; - test_fixture.eval_name = "Constant Scalar Field \"resistivity\""; - test_fixture.user_params.sublist("Full Induction MHD Properties") - .set("Vacuum Magnetic Permeability", 0.125) - .set("Build Resistive Flux", true) - .set("Resistivity", 1.25) - .set("Variable Resistivity", variable_resistivity); - test_fixture.user_params.sublist("Fluid Properties") - .set("Kinematic viscosity", 1.5) - .set("Artificial compressibility", 0.1); - test_fixture.template buildAndTest< - ClosureModel::ConstantScalarField, - num_space_dim>(); -} - -TEST(ResistivityFactory2D, residual_test) -{ - testFactory(false); -} - -TEST(ResistivityFactory2D, jacobian_test) -{ - testFactory(false); -} - -TEST(ResistivityFactory3D, residual_test) -{ - testFactory(false); -} - -TEST(ResistivityFactory3D, jacobian_test) -{ - testFactory(false); -} - -//-----------------------------------------------------------------// -// Full Induction MHD closure model factory exception test for -// "Resistivity" when "Variable Resistivity" is true. -//-----------------------------------------------------------------// -template -void testFactoryException() -{ - const std::string msg - = "No closure models currently exist to evaluate variable " - "resistivity. Use a constant resistivity only."; - EXPECT_THROW( - try { - (testFactory(true)); - } catch (const std::runtime_error& e) { - EXPECT_EQ(msg, e.what()); - throw; - }, - std::runtime_error); -} - -TEST(ResistivityFactoryException, residual_test) -{ - testFactoryException(); -} - -TEST(ResistivityFactoryException, jacobian_test) -{ - testFactoryException(); -} - -//-----------------------------------------------------------------// - -//-----------------------------------------------------------------// -} // namespace Test -} // namespace VertexCFD diff --git a/src/full_induction_mhd_solver/closure_models/unit_test/tstTotalMagneticField.cpp b/src/full_induction_mhd_solver/closure_models/unit_test/tstTotalMagneticField.cpp deleted file mode 100644 index 7ae9372..0000000 --- a/src/full_induction_mhd_solver/closure_models/unit_test/tstTotalMagneticField.cpp +++ /dev/null @@ -1,214 +0,0 @@ -#include -#include - -#include "full_induction_mhd_solver/closure_models/VertexCFD_Closure_TotalMagneticField.hpp" - -#include "utils/VertexCFD_Utils_VectorField.hpp" - -#include - -#include - -namespace VertexCFD -{ -namespace Test -{ -template -struct Dependencies : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - using scalar_type = typename EvalType::ScalarT; - - Kokkos::Array, 3> - ind_magn_field; - Kokkos::Array, 3> - ext_magn_field; - - const Kokkos::Array _bi; - const Kokkos::Array _b0; - - Dependencies(const panzer::IntegrationRule& ir, - const Kokkos::Array bi, - const Kokkos::Array b0, - const std::string& field_prefix) - : _bi(bi) - , _b0(b0) - { - Utils::addEvaluatedVectorField( - *this, - ir.dl_scalar, - ind_magn_field, - field_prefix + "induced_magnetic_field_"); - Utils::addEvaluatedVectorField( - *this, ir.dl_scalar, ext_magn_field, "external_magnetic_field_"); - this->setName("Total Magnetic Field Test Dependencies"); - } - - void evaluateFields(typename panzer::Traits::EvalData /**d**/) override - { - for (int dim = 0; dim < 3; ++dim) - { - ind_magn_field[dim].deep_copy(_bi[dim]); - ext_magn_field[dim].deep_copy(_b0[dim]); - } - } -}; - -template -void testEval(const std::string& field_prefix) -{ - static constexpr int num_space_dim = NumSpaceDim; - const int integration_order = 1; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - - const auto& ir = *test_fixture.ir; - - // Initialize induced / external magnetic field components and - // dependencies - const Kokkos::Array bi - = {0.25, - 0.5, - num_space_dim > 2 ? 0.9 : std::numeric_limits::quiet_NaN()}; - const Kokkos::Array b0 = {0.325, -0.65, 0.7}; - const Kokkos::Array b_exp - = {bi[0] + b0[0], - bi[1] + b0[1], - num_space_dim == 2 ? b0[2] : b0[2] + bi[2]}; - - // Eval dependencies - const auto deps - = Teuchos::rcp(new Dependencies(ir, bi, b0, field_prefix)); - test_fixture.registerEvaluator(deps); - - // Initialize and register - const auto eval = [&]() { - if (field_prefix == "") - { - // check evaluator with defaulted field name - return Teuchos::rcp( - new ClosureModel::TotalMagneticField(ir)); - } - else - { - // check evaluator with specified field name prefix - return Teuchos::rcp( - new ClosureModel:: - TotalMagneticField( - ir, field_prefix)); - } - }(); - - test_fixture.registerEvaluator(eval); - - for (int dim = 0; dim < num_space_dim; ++dim) - { - test_fixture.registerTestField( - eval->_total_magnetic_field[dim]); - } - test_fixture.evaluate(); - - // Evaluate test fields - const auto bt_0 = test_fixture.getTestFieldData( - eval->_total_magnetic_field[0]); - const auto bt_1 = test_fixture.getTestFieldData( - eval->_total_magnetic_field[1]); - const auto bt_2 = test_fixture.getTestFieldData( - eval->_total_magnetic_field[2]); - - // Expected values - const int num_point = ir.num_points; - - // Assert values - for (int qp = 0; qp < num_point; ++qp) - { - EXPECT_EQ(b_exp[0], fieldValue(bt_0, 0, qp)); - EXPECT_EQ(b_exp[1], fieldValue(bt_1, 0, qp)); - EXPECT_EQ(b_exp[2], fieldValue(bt_2, 0, qp)); - } -} - -//-----------------------------------------------------------------// -TEST(TotalMagneticField2D, residual_test) -{ - testEval(""); -} - -//-----------------------------------------------------------------// -TEST(TotalMagneticField2D, jacobian_test) -{ - testEval(""); -} - -//-----------------------------------------------------------------// -TEST(TotalMagneticField3D, residual_test) -{ - testEval(""); -} - -//-----------------------------------------------------------------// -TEST(TotalMagneticField3D, jacobian_test) -{ - testEval(""); -} -//-----------------------------------------------------------------// -TEST(TotalMagneticFieldWithFieldPrefix3D, residual_test) -{ - testEval("FOO_"); -} - -//-----------------------------------------------------------------// -TEST(TotalMagneticFieldWithFieldPrefix3D, jacobian_test) -{ - testEval("FOO_"); -} - -//-----------------------------------------------------------------// -template -void testFactory() -{ - static constexpr int num_space_dim = NumSpaceDim; - ClosureModelFactoryTestFixture test_fixture; - // The factory registers this closure and TotalMagneticFieldGradient for - // type_name = "TotalMagneticField". This closure model will be the first - // of the two registered evals - test_fixture.num_evaluators = 2; - test_fixture.eval_index = 0; - test_fixture.type_name = "TotalMagneticField"; - test_fixture.eval_name = "Total Magnetic Field " - + std::to_string(num_space_dim) + "D"; - test_fixture.user_params.sublist("Full Induction MHD Properties"); - test_fixture.user_params.sublist("Fluid Properties") - .set("Kinematic viscosity", 1.5) - .set("Artificial compressibility", 0.1); - test_fixture.template buildAndTest< - ClosureModel::TotalMagneticField, - num_space_dim>(); -} - -TEST(TotalMagneticField_Factory2D, residual_test) -{ - testFactory(); -} - -TEST(TotalMagneticField_Factory2D, jacobian_test) -{ - testFactory(); -} - -TEST(TotalMagneticField_Factory3D, residual_test) -{ - testFactory(); -} - -TEST(TotalMagneticField_Factory3D, jacobian_test) -{ - testFactory(); -} - -//-----------------------------------------------------------------// -} // namespace Test -} // namespace VertexCFD diff --git a/src/full_induction_mhd_solver/closure_models/unit_test/tstTotalMagneticFieldGradient.cpp b/src/full_induction_mhd_solver/closure_models/unit_test/tstTotalMagneticFieldGradient.cpp deleted file mode 100644 index 67e4f9e..0000000 --- a/src/full_induction_mhd_solver/closure_models/unit_test/tstTotalMagneticFieldGradient.cpp +++ /dev/null @@ -1,243 +0,0 @@ -#include -#include - -#include "full_induction_mhd_solver/closure_models/VertexCFD_Closure_TotalMagneticFieldGradient.hpp" - -#include "utils/VertexCFD_Utils_VectorField.hpp" - -#include - -#include - -namespace VertexCFD -{ -namespace Test -{ -template -struct Dependencies : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - using scalar_type = typename EvalType::ScalarT; - - Kokkos::Array< - PHX::MDField, - 3> - grad_ind_magn_field; - Kokkos::Array< - PHX::MDField, - 3> - grad_ext_magn_field; - - const Kokkos::Array _bi; - const Kokkos::Array _b0; - - Dependencies(const panzer::IntegrationRule& ir, - const Kokkos::Array bi, - const Kokkos::Array b0, - const std::string& gradient_prefix) - : _bi(bi) - , _b0(b0) - { - Utils::addEvaluatedVectorField( - *this, - ir.dl_vector, - grad_ind_magn_field, - gradient_prefix + "GRAD_induced_magnetic_field_"); - Utils::addEvaluatedVectorField(*this, - ir.dl_vector, - grad_ext_magn_field, - "GRAD_external_magnetic_field_"); - this->setName("Total Magnetic Field Gradient Test Dependencies"); - } - - void evaluateFields(typename panzer::Traits::EvalData d) override - { - Kokkos::parallel_for( - "total magnetic field gradient test dependencies", - Kokkos::RangePolicy(0, d.num_cells), - *this); - } - - KOKKOS_INLINE_FUNCTION void operator()(const int c) const - { - const int num_point = grad_ind_magn_field[0].extent(1); - const int num_grad_dim = grad_ind_magn_field[0].extent(2); - for (int qp = 0; qp < num_point; ++qp) - { - for (int dim = 0; dim < 3; ++dim) - { - const double qpd = (qp + dim + 1); - for (int grad_dim = 0; grad_dim < num_grad_dim; ++grad_dim) - { - const double mult = qpd / (grad_dim + 1); - grad_ind_magn_field[dim](c, qp, grad_dim) = _bi[dim] * mult; - grad_ext_magn_field[dim](c, qp, grad_dim) = _b0[dim] * mult; - } - } - } - } -}; - -template -void testEval(const std::string& gradient_prefix) -{ - static constexpr int num_space_dim = NumSpaceDim; - const int integration_order = 1; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - - const auto& ir = *test_fixture.ir; - - // Initialize induced / external magnetic field gradient base values - const Kokkos::Array bi - = {0.25, - 0.5, - num_space_dim > 2 ? 0.9 : std::numeric_limits::quiet_NaN()}; - const Kokkos::Array b0 = {0.325, -0.65, 0.7}; - - // Eval dependencies - const auto deps = Teuchos::rcp( - new Dependencies(ir, bi, b0, gradient_prefix)); - test_fixture.registerEvaluator(deps); - - // Initialize and register - const auto eval = [&]() { - if (gradient_prefix == "") - { - // check evaluator with defaulted field name - return Teuchos::rcp( - new ClosureModel::TotalMagneticFieldGradient(ir)); - } - else - { - // check evaluator with specified field name prefix - return Teuchos::rcp( - new ClosureModel::TotalMagneticFieldGradient( - ir, gradient_prefix)); - } - }(); - - test_fixture.registerEvaluator(eval); - - for (int dim = 0; dim < num_space_dim; ++dim) - { - test_fixture.registerTestField( - eval->_grad_total_magnetic_field[dim]); - } - test_fixture.evaluate(); - - // Evaluate test fields - const auto grad_bt_0 = test_fixture.getTestFieldData( - eval->_grad_total_magnetic_field[0]); - const auto grad_bt_1 = test_fixture.getTestFieldData( - eval->_grad_total_magnetic_field[1]); - const auto grad_bt_2 = test_fixture.getTestFieldData( - eval->_grad_total_magnetic_field[2]); - - // Expected values - const int num_point = ir.num_points; - const int num_grad_dim = ir.spatial_dimension; - - // Assert values - for (int qp = 0; qp < num_point; ++qp) - { - for (int dim = 0; dim < num_grad_dim; ++dim) - { - // Currently force assumption of uniform external field, so the - // expected total field gradient is just the induced field gradient - const double exp_0 = bi[0] * (qp + 1) / (dim + 1); - EXPECT_DOUBLE_EQ(exp_0, fieldValue(grad_bt_0, 0, qp, dim)); - const double exp_1 = bi[1] * (qp + 2) / (dim + 1); - EXPECT_DOUBLE_EQ(exp_1, fieldValue(grad_bt_1, 0, qp, dim)); - const double exp_2 - = num_space_dim < 3 ? 0.0 : bi[2] * (qp + 3) / (dim + 1); - EXPECT_DOUBLE_EQ(exp_2, fieldValue(grad_bt_2, 0, qp, dim)); - } - } -} - -//-----------------------------------------------------------------// -TEST(TotalMagneticFieldGradient2D, residual_test) -{ - testEval(""); -} - -//-----------------------------------------------------------------// -TEST(TotalMagneticFieldGradient2D, jacobian_test) -{ - testEval(""); -} - -//-----------------------------------------------------------------// -TEST(TotalMagneticFieldGradient3D, residual_test) -{ - testEval(""); -} - -//-----------------------------------------------------------------// -TEST(TotalMagneticFieldGradient3D, jacobian_test) -{ - testEval(""); -} -//-----------------------------------------------------------------// -TEST(TotalMagneticFieldGradientWithFieldPrefix3D, residual_test) -{ - testEval("FOO_"); -} - -//-----------------------------------------------------------------// -TEST(TotalMagneticFieldGradientWithFieldPrefix3D, jacobian_test) -{ - testEval("FOO_"); -} - -//-----------------------------------------------------------------// -template -void testFactory() -{ - static constexpr int num_space_dim = NumSpaceDim; - ClosureModelFactoryTestFixture test_fixture; - // Gradient closure is built with "TotalMagneticField" in the factory, and - // will be the second of the two evaluators - test_fixture.num_evaluators = 2; - test_fixture.eval_index = 1; - test_fixture.type_name = "TotalMagneticField"; - test_fixture.eval_name = "Total Magnetic Field Gradient" - + std::to_string(num_space_dim) + "D"; - test_fixture.user_params.sublist("Full Induction MHD Properties"); - test_fixture.user_params.sublist("Fluid Properties") - .set("Kinematic viscosity", 1.5) - .set("Artificial compressibility", 0.1); - test_fixture.template buildAndTest< - ClosureModel::TotalMagneticFieldGradient, - num_space_dim>(); -} - -TEST(TotalMagneticFieldGradient_Factory2D, residual_test) -{ - testFactory(); -} - -TEST(TotalMagneticFieldGradient_Factory2D, jacobian_test) -{ - testFactory(); -} - -TEST(TotalMagneticFieldGradient_Factory3D, residual_test) -{ - testFactory(); -} - -TEST(TotalMagneticFieldGradient_Factory3D, jacobian_test) -{ - testFactory(); -} - -//-----------------------------------------------------------------// -} // namespace Test -} // namespace VertexCFD diff --git a/src/full_induction_mhd_solver/initial_conditions/VertexCFD_FullInductionInitialConditionFactory.cpp b/src/full_induction_mhd_solver/initial_conditions/VertexCFD_FullInductionInitialConditionFactory.cpp deleted file mode 100644 index 26ed5a2..0000000 --- a/src/full_induction_mhd_solver/initial_conditions/VertexCFD_FullInductionInitialConditionFactory.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_FullInductionInitialConditionFactory.hpp" -#include "VertexCFD_FullInductionInitialConditionFactory_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_NUMSPACEDIM( - VertexCFD::InitialCondition::FullInductionICFactory) diff --git a/src/full_induction_mhd_solver/initial_conditions/VertexCFD_FullInductionInitialConditionFactory.hpp b/src/full_induction_mhd_solver/initial_conditions/VertexCFD_FullInductionInitialConditionFactory.hpp deleted file mode 100644 index 70dbe48..0000000 --- a/src/full_induction_mhd_solver/initial_conditions/VertexCFD_FullInductionInitialConditionFactory.hpp +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef VERTEXCFD_FULLINDUCTIONINITIALCONDITIONFACTORY_HPP -#define VERTEXCFD_FULLINDUCTIONINITIALCONDITIONFACTORY_HPP - -#include - -#include - -#include - -#include -#include - -namespace VertexCFD -{ -namespace InitialCondition -{ -//---------------------------------------------------------------------------// -template -class FullInductionICFactory -{ - public: - static constexpr int num_space_dim = NumSpaceDim; - - void buildClosureModel( - const std::string& closure_type, - const std::vector>& bases, - const Teuchos::ParameterList& user_params, - const Teuchos::ParameterList& ic_params, - bool& found_model, - std::string& error_msg, - Teuchos::RCP>>> - evaluators); -}; - -//---------------------------------------------------------------------------// - -} // end namespace InitialCondition -} // end namespace VertexCFD - -#endif // end VERTEXCFD_FULLINDUCTIONINITIALCONDITIONFACTORY_HPP diff --git a/src/full_induction_mhd_solver/initial_conditions/VertexCFD_FullInductionInitialConditionFactory_impl.hpp b/src/full_induction_mhd_solver/initial_conditions/VertexCFD_FullInductionInitialConditionFactory_impl.hpp deleted file mode 100644 index 78f99e7..0000000 --- a/src/full_induction_mhd_solver/initial_conditions/VertexCFD_FullInductionInitialConditionFactory_impl.hpp +++ /dev/null @@ -1,59 +0,0 @@ -#ifndef VERTEXCFD_FULLINDUCTIONINITIALCONDITIONFACTORY_IMPL_HPP -#define VERTEXCFD_FULLINDUCTIONINITIALCONDITIONFACTORY_IMPL_HPP - -#include "VertexCFD_InitialCondition_DivergenceAdvectionTest.hpp" -#include "VertexCFD_InitialCondition_MHDVortexProblem.hpp" - -namespace VertexCFD -{ -namespace InitialCondition -{ -//---------------------------------------------------------------------------// -template -void FullInductionICFactory::buildClosureModel( - const std::string& ic_type, - const std::vector>& bases, - const Teuchos::ParameterList& user_params, - const Teuchos::ParameterList& /*ic_params*/, - bool& found_model, - std::string& error_msg, - Teuchos::RCP>>> - evaluators) -{ - const auto mhd_prop_list - = user_params.sublist("Full Induction MHD Properties"); - - if (ic_type == "MHDVortexProblem") - { - for (const auto& b : bases) - { - auto eval = Teuchos::rcp( - new MHDVortexProblem( - mhd_prop_list, *b)); - evaluators->push_back(eval); - found_model = true; - } - } - - if (ic_type == "DivergenceAdvectionTest") - { - for (const auto& b : bases) - { - auto eval = Teuchos::rcp( - new DivergenceAdvectionTest( - mhd_prop_list, *b)); - evaluators->push_back(eval); - found_model = true; - } - } - - error_msg = "DivergenceAdvectionTest\n"; - error_msg += "MHDVortexProblem\n"; -} - -//---------------------------------------------------------------------------// - -} // end namespace InitialCondition -} // end namespace VertexCFD - -#endif // end VERTEXCFD_FULLINDUCTIONINITIALCONDITIONFACTORY_IMPL_HPP diff --git a/src/full_induction_mhd_solver/initial_conditions/VertexCFD_InitialCondition_DivergenceAdvectionTest.cpp b/src/full_induction_mhd_solver/initial_conditions/VertexCFD_InitialCondition_DivergenceAdvectionTest.cpp deleted file mode 100644 index 1303e45..0000000 --- a/src/full_induction_mhd_solver/initial_conditions/VertexCFD_InitialCondition_DivergenceAdvectionTest.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_InitialCondition_DivergenceAdvectionTest.hpp" -#include "VertexCFD_InitialCondition_DivergenceAdvectionTest_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS_NUMSPACEDIM( - VertexCFD::InitialCondition::DivergenceAdvectionTest) diff --git a/src/full_induction_mhd_solver/initial_conditions/VertexCFD_InitialCondition_DivergenceAdvectionTest.hpp b/src/full_induction_mhd_solver/initial_conditions/VertexCFD_InitialCondition_DivergenceAdvectionTest.hpp deleted file mode 100644 index 16bdd3f..0000000 --- a/src/full_induction_mhd_solver/initial_conditions/VertexCFD_InitialCondition_DivergenceAdvectionTest.hpp +++ /dev/null @@ -1,65 +0,0 @@ -#ifndef VERTEXCFD_INITIALCONDITION_DIVERGENCEADVECTIONTEST_HPP -#define VERTEXCFD_INITIALCONDITION_DIVERGENCEADVECTIONTEST_HPP - -#include -#include -#include - -#include -#include -#include -#include - -#include - -namespace VertexCFD -{ -namespace InitialCondition -{ -template -class DivergenceAdvectionTest : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - static constexpr int num_space_dim = NumSpaceDim; - - DivergenceAdvectionTest(const Teuchos::ParameterList& params, - const panzer::PureBasis& basis); - - void postRegistrationSetup(typename Traits::SetupData sd, - PHX::FieldManager& fm) override; - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - PHX::MDField _lagrange_pressure; - Kokkos::Array, - num_space_dim> - _velocity; - Kokkos::Array, - num_space_dim> - _induced_magnetic_field; - - private: - std::string _basis_name; - int _basis_index; - PHX::MDField _basis_coords; - - double _phi; - double _r0; - Kokkos::Array _xy_0; - Kokkos::Array _vel; -}; - -//---------------------------------------------------------------------------// - -} // end namespace InitialCondition -} // end namespace VertexCFD - -#include "VertexCFD_InitialCondition_DivergenceAdvectionTest_impl.hpp" - -#endif // end VERTEXCFD_INITIALCONDITION_DIVERGENCEADVECTIONTEST_HPP diff --git a/src/full_induction_mhd_solver/initial_conditions/VertexCFD_InitialCondition_MHDVortexProblem.cpp b/src/full_induction_mhd_solver/initial_conditions/VertexCFD_InitialCondition_MHDVortexProblem.cpp deleted file mode 100644 index 84759ee..0000000 --- a/src/full_induction_mhd_solver/initial_conditions/VertexCFD_InitialCondition_MHDVortexProblem.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_InitialCondition_MHDVortexProblem.hpp" -#include "VertexCFD_InitialCondition_MHDVortexProblem_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS_NUMSPACEDIM( - VertexCFD::InitialCondition::MHDVortexProblem) diff --git a/src/full_induction_mhd_solver/initial_conditions/VertexCFD_InitialCondition_MHDVortexProblem.hpp b/src/full_induction_mhd_solver/initial_conditions/VertexCFD_InitialCondition_MHDVortexProblem.hpp deleted file mode 100644 index 656b900..0000000 --- a/src/full_induction_mhd_solver/initial_conditions/VertexCFD_InitialCondition_MHDVortexProblem.hpp +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef VERTEXCFD_INITIALCONDITION_MHDVORTEXPROBLEM_HPP -#define VERTEXCFD_INITIALCONDITION_MHDVORTEXPROBLEM_HPP - -#include -#include -#include - -#include -#include -#include -#include - -#include - -namespace VertexCFD -{ -namespace InitialCondition -{ -template -class MHDVortexProblem : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - static constexpr int num_space_dim = NumSpaceDim; - - MHDVortexProblem(const Teuchos::ParameterList& params, - const panzer::PureBasis& basis); - - void postRegistrationSetup(typename Traits::SetupData sd, - PHX::FieldManager& fm) override; - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - PHX::MDField _lagrange_pressure; - Kokkos::Array, - num_space_dim> - _velocity; - Kokkos::Array, - num_space_dim> - _induced_magnetic_field; - - private: - std::string _basis_name; - int _basis_index; - PHX::MDField _basis_coords; - - Kokkos::Array _vel_0; - Kokkos::Array _xy_0; -}; - -//---------------------------------------------------------------------------// - -} // end namespace InitialCondition -} // end namespace VertexCFD - -#include "VertexCFD_InitialCondition_MHDVortexProblem_impl.hpp" - -#endif // end VERTEXCFD_INITIALCONDITION_MHDVORTEXPROBLEM_HPP diff --git a/src/full_induction_mhd_solver/initial_conditions/unit_test/CMakeLists.txt b/src/full_induction_mhd_solver/initial_conditions/unit_test/CMakeLists.txt deleted file mode 100644 index 621ea7e..0000000 --- a/src/full_induction_mhd_solver/initial_conditions/unit_test/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -set(TEST_HARNESS_DIR ${CMAKE_SOURCE_DIR}/src/test_harness) -include(${TEST_HARNESS_DIR}/TestHarness.cmake) - -VertexCFD_add_tests( - LIBS VertexCFD - NAMES - MHDVortexProblem - DivergenceAdvectionTest - ) diff --git a/src/full_induction_mhd_solver/initial_conditions/unit_test/tstDivergenceAdvectionTest.cpp b/src/full_induction_mhd_solver/initial_conditions/unit_test/tstDivergenceAdvectionTest.cpp deleted file mode 100644 index a8be139..0000000 --- a/src/full_induction_mhd_solver/initial_conditions/unit_test/tstDivergenceAdvectionTest.cpp +++ /dev/null @@ -1,251 +0,0 @@ -#include - -#include "full_induction_mhd_solver/initial_conditions/VertexCFD_InitialCondition_DivergenceAdvectionTest.hpp" - -#include "utils/VertexCFD_Utils_Constants.hpp" - -#include - -//---------------------------------------------------------------------------// -// TESTS -//---------------------------------------------------------------------------//¬ -namespace VertexCFD -{ -namespace Test -{ -//---------------------------------------------------------------------------// -template -auto compute_ref_sol(const Teuchos::ParameterList& params, const SubviewType& x) -{ - using Constants::pi; - using std::pow; - using std::sqrt; - - constexpr int num_conserve = 6; - Kokkos::Array ref_solution; - - const auto psi = params.isType("Lagrange Pressure") - ? params.get("Lagrange Pressure") - : 6.0; - - const auto r0 = params.isType("Divergence Bubble Radius") - ? params.get("Divergence Bubble Radius") - : 1.0 / sqrt(8.0); - - const auto x_c - = params.isType>("Divergence Bubble Center") - ? params.get>("Divergence Bubble Center") - : Teuchos::Array(3, 0); - - const auto vel = params.isType>("Velocity") - ? params.get>("Velocity") - : Teuchos::Array({1.0, 1.0, 0.0}); - - const double dx = x[0] - x_c[0]; - const double dy = x[1] - x_c[1]; - const double r = sqrt(dx * dx + dy * dy); - - // Lagrange pressure - ref_solution[0] = psi; - // Magnetic field - if (r < r0) - { - ref_solution[1] = (pow(r / r0, 8) - 2.0 * pow(r / r0, 4) + 1) - / sqrt(4.0 * pi); - } - else - { - ref_solution[1] = 0.0; - } - ref_solution[2] = 0.0; - // Velocity - ref_solution[3] = vel[0]; - ref_solution[4] = vel[1]; - ref_solution[5] = vel[2]; - - return ref_solution; -} - -//---------------------------------------------------------------------------// -template -void testEval(const bool set_input_params = false) -{ - // Test fixture - constexpr int num_space_dim = NumSpaceDim; - const int integration_order = 1; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - - const double r0 = 1.5; - const double nanval = std::numeric_limits::signaling_NaN(); - const double x_z = num_space_dim == 2 ? nanval : 0.5; - const Teuchos::Array x0({0.3, 0.4, x_z}); - Teuchos::ParameterList model_params; - if (set_input_params) - { - model_params.set("Lagrange Pressure", 2.3); - model_params.set("Divergence Bubble Radius", r0); - model_params.set("Divergence Bubble Center", x0); - const double v_z = num_space_dim == 2 ? nanval : 0.325; - model_params.set("Velocity", - Teuchos::Array({0.2, -0.125, v_z})); - } - Teuchos::ParameterList mhd_params; - mhd_params.set("Divergence Advection Test", model_params); - - const int num_coord = test_fixture.cell_topo->getNodeCount(); - - // Set non-trivial coordinates for the degree of freedom - Kokkos::View x( - "coordinate", num_space_dim, num_coord); - auto basis_coord_view - = test_fixture.workset->bases[0]->basis_coordinates.get_static_view(); - auto basis_coord_mirror = Kokkos::create_mirror(basis_coord_view); - for (int basis = 0; basis < num_coord; basis++) - { - // set coordinates inside and outside of bubble radius - x(0, basis) = r0 / (num_coord - 2) * basis * std::cos(basis) + x0[0]; - x(1, basis) = r0 / (num_coord - 2) * basis * std::sin(basis) + x0[1]; - if (num_space_dim > 2) - x(2, basis) = r0 * (basis); - for (int dim = 0; dim < num_space_dim; ++dim) - { - basis_coord_mirror(0, basis, dim) = x(dim, basis); - } - } - Kokkos::deep_copy(basis_coord_view, basis_coord_mirror); - - // Create evaluator. - auto mhd_val = Teuchos::rcp( - new InitialCondition:: - DivergenceAdvectionTest( - mhd_params, *test_fixture.basis_ir_layout->getBasis())); - test_fixture.registerEvaluator(mhd_val); - - // Add required test fields. - test_fixture.registerTestField(mhd_val->_lagrange_pressure); - for (int dim = 0; dim < num_space_dim; ++dim) - { - test_fixture.registerTestField(mhd_val->_velocity[dim]); - test_fixture.registerTestField( - mhd_val->_induced_magnetic_field[dim]); - } - - // Evaluate IC. - test_fixture.evaluate(); - - // Check the IC value for all scalars. - const auto lg_pressure_result - = test_fixture.getTestFieldData(mhd_val->_lagrange_pressure); - const auto velocity_0_result - = test_fixture.getTestFieldData(mhd_val->_velocity[0]); - const auto velocity_1_result - = test_fixture.getTestFieldData(mhd_val->_velocity[1]); - const auto magn_field_0_result = test_fixture.getTestFieldData( - mhd_val->_induced_magnetic_field[0]); - const auto magn_field_1_result = test_fixture.getTestFieldData( - mhd_val->_induced_magnetic_field[1]); - - // Assert number of points - EXPECT_EQ(num_coord, lg_pressure_result.extent(1)); - EXPECT_EQ(num_coord, velocity_0_result.extent(1)); - EXPECT_EQ(num_coord, velocity_1_result.extent(1)); - EXPECT_EQ(num_coord, magn_field_0_result.extent(1)); - EXPECT_EQ(num_coord, magn_field_1_result.extent(1)); - - // Loop over number of points and compare against reference values - const int num_point = lg_pressure_result.extent(1); - const double tol = 1.0e-15; - for (int qp = 0; qp < num_point; ++qp) - { - const auto x_subview = Kokkos::subview(x, Kokkos::ALL(), qp); - - // Compute reference values - const auto ref_solution = compute_ref_sol(model_params, x_subview); - - // Assert - EXPECT_NEAR( - ref_solution[0], fieldValue(lg_pressure_result, 0, qp), tol); - EXPECT_NEAR( - ref_solution[1], fieldValue(magn_field_0_result, 0, qp), tol); - EXPECT_NEAR( - ref_solution[2], fieldValue(magn_field_1_result, 0, qp), tol); - EXPECT_DOUBLE_EQ(ref_solution[3], fieldValue(velocity_0_result, 0, qp)); - EXPECT_DOUBLE_EQ(ref_solution[4], fieldValue(velocity_1_result, 0, qp)); - - if (num_space_dim == 3) - { - const auto velocity_2_result - = test_fixture.getTestFieldData( - mhd_val->_velocity[2]); - EXPECT_EQ(num_coord, velocity_2_result.extent(1)); - EXPECT_DOUBLE_EQ(ref_solution[5], - fieldValue(velocity_2_result, 0, qp)); - - const auto magn_field_2_result - = test_fixture.getTestFieldData( - mhd_val->_induced_magnetic_field[2]); - EXPECT_EQ(num_coord, magn_field_2_result.extent(1)); - EXPECT_DOUBLE_EQ(0.0, fieldValue(magn_field_2_result, 0, qp)); - } - } -} - -//---------------------------------------------------------------------------// -// Divergence Advection Test 2D, default values -// Residual -TEST(DivergenceAdvectionTestDefaultIC2D, residual) -{ - testEval(); -} - -// Jacobian -TEST(DivergenceAdvectionTestDefaultIC2D, jacobian) -{ - testEval(); -} - -// Divergence Advection Test 2D, input values -// Residual -TEST(DivergenceAdvectionTestInputsIC2D, residual) -{ - testEval(true); -} - -// Jacobian -TEST(DivergenceAdvectionTestInputsIC2D, jacobian) -{ - testEval(true); -} - -// Divergence Advection Test 3D, default values -// Residual -TEST(DivergenceAdvectionTestDefaultIC3D, residual) -{ - testEval(); -} - -// Jacobian -TEST(DivergenceAdvectionTestDefaultIC3D, jacobian) -{ - testEval(); -} - -// Divergence Advection Test 3D, input values -// Residual -TEST(DivergenceAdvectionTestInputsIC3D, residual) -{ - testEval(true); -} - -// Jacobian -TEST(DivergenceAdvectionTestInputsIC3D, jacobian) -{ - testEval(true); -} -//---------------------------------------------------------------------------// - -//---------------------------------------------------------------------------// -} // end namespace Test -} // end namespace VertexCFD diff --git a/src/full_induction_mhd_solver/initial_conditions/unit_test/tstMHDVortexProblem.cpp b/src/full_induction_mhd_solver/initial_conditions/unit_test/tstMHDVortexProblem.cpp deleted file mode 100644 index a201805..0000000 --- a/src/full_induction_mhd_solver/initial_conditions/unit_test/tstMHDVortexProblem.cpp +++ /dev/null @@ -1,192 +0,0 @@ -#include - -#include "full_induction_mhd_solver/initial_conditions/VertexCFD_InitialCondition_MHDVortexProblem.hpp" - -#include - -//---------------------------------------------------------------------------// -// TESTS -//---------------------------------------------------------------------------//¬ -namespace VertexCFD -{ -namespace Test -{ -//---------------------------------------------------------------------------// -template -auto compute_ref_sol(const Teuchos::ParameterList& params, const SubviewType& x) -{ - using std::exp; - using std::sqrt; - - constexpr int num_conserve = 5; - Kokkos::Array ref_solution; - - // Get MHD vortex problem properties - const auto vel_0 = params.get>("velocity_0"); - const auto xy_0 = params.get>("center_0"); - - const double dx = x[0] - xy_0[0]; - const double dy = x[1] - xy_0[1]; - const double r2 = dx * dx + dy * dy; - - // Lagrange pressure - ref_solution[0] = 1.0 + 0.5 * exp(1.) * (1. - r2 * exp(-r2)); - // Magnetic field - ref_solution[1] = -exp(0.5 * (1.0 - r2)) * dy; - ref_solution[2] = exp(0.5 * (1.0 - r2)) * dx; - // Velocity - ref_solution[3] = ref_solution[1] + vel_0[0]; - ref_solution[4] = ref_solution[2] + vel_0[1]; - - return ref_solution; -} - -//---------------------------------------------------------------------------// -template -void testEval() -{ - // Test fixture - constexpr int num_space_dim = NumSpaceDim; - const int integration_order = 1; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - - const int num_coord = test_fixture.cell_topo->getNodeCount(); - - // Set non-trivial coordinates for the degree of freedom - Kokkos::View x( - "coordinate", num_space_dim, num_coord); - auto basis_coord_view - = test_fixture.workset->bases[0]->basis_coordinates.get_static_view(); - auto basis_coord_mirror = Kokkos::create_mirror(basis_coord_view); - Kokkos::Array _xy_0{}; - for (int dim = 0; dim < num_space_dim; dim++) - { - for (int basis = 0; basis < num_coord; basis++) - { - // random coordinate assigned - x(dim, basis) = (0.5 + dim * 4.5) * (basis + 1); - basis_coord_mirror(0, basis, dim) = x(dim, basis); - _xy_0[dim] += x(dim, basis); - } - } - Kokkos::deep_copy(basis_coord_view, basis_coord_mirror); - - // Create the param list to initialize the evaluator - Teuchos::ParameterList model_params; - Teuchos::Array xy_0(2); - Teuchos::Array vel_0(2); - vel_0[0] = 1.2; - vel_0[1] = 2.4; - - // center of vortex is center of the cell - for (int dim = 0; dim < 2; ++dim) - xy_0[dim] = _xy_0[dim] / std::pow(num_space_dim, 2); - - model_params.set>("velocity_0", vel_0); - model_params.set>("center_0", xy_0); - - // Create evaluator. - auto mhd_val = Teuchos::rcp( - new InitialCondition:: - MHDVortexProblem( - model_params, *test_fixture.basis_ir_layout->getBasis())); - test_fixture.registerEvaluator(mhd_val); - - // Add required test fields. - test_fixture.registerTestField(mhd_val->_lagrange_pressure); - for (int dim = 0; dim < num_space_dim; ++dim) - { - test_fixture.registerTestField(mhd_val->_velocity[dim]); - test_fixture.registerTestField( - mhd_val->_induced_magnetic_field[dim]); - } - - // Evaluate IC. - test_fixture.evaluate(); - - // Check the IC value for all scalars. - const auto lg_pressure_result - = test_fixture.getTestFieldData(mhd_val->_lagrange_pressure); - const auto velocity_0_result - = test_fixture.getTestFieldData(mhd_val->_velocity[0]); - const auto velocity_1_result - = test_fixture.getTestFieldData(mhd_val->_velocity[1]); - const auto magn_field_0_result = test_fixture.getTestFieldData( - mhd_val->_induced_magnetic_field[0]); - const auto magn_field_1_result = test_fixture.getTestFieldData( - mhd_val->_induced_magnetic_field[1]); - - // Assert number of points - EXPECT_EQ(num_coord, lg_pressure_result.extent(1)); - EXPECT_EQ(num_coord, velocity_0_result.extent(1)); - EXPECT_EQ(num_coord, velocity_1_result.extent(1)); - EXPECT_EQ(num_coord, magn_field_0_result.extent(1)); - EXPECT_EQ(num_coord, magn_field_1_result.extent(1)); - - // Loop over number of points and compare against reference values - const int num_point = lg_pressure_result.extent(1); - const double tol = 1.0e-15; - for (int d = 0; d < num_point; ++d) - { - const auto x_subview = Kokkos::subview(x, Kokkos::ALL(), d); - - // Compute reference values - const auto ref_solution = compute_ref_sol(model_params, x_subview); - - // Assert - EXPECT_NEAR(ref_solution[0], fieldValue(lg_pressure_result, 0, d), tol); - EXPECT_NEAR( - ref_solution[1], fieldValue(magn_field_0_result, 0, d), tol); - EXPECT_NEAR( - ref_solution[2], fieldValue(magn_field_1_result, 0, d), tol); - EXPECT_DOUBLE_EQ(ref_solution[3], fieldValue(velocity_0_result, 0, d)); - EXPECT_DOUBLE_EQ(ref_solution[4], fieldValue(velocity_1_result, 0, d)); - - if (num_space_dim == 3) - { - const auto velocity_2_result - = test_fixture.getTestFieldData( - mhd_val->_velocity[2]); - EXPECT_EQ(num_coord, velocity_2_result.extent(1)); - EXPECT_DOUBLE_EQ(0.0, fieldValue(velocity_2_result, 0, d)); - - const auto magn_field_2_result - = test_fixture.getTestFieldData( - mhd_val->_induced_magnetic_field[2]); - EXPECT_EQ(num_coord, magn_field_2_result.extent(1)); - EXPECT_DOUBLE_EQ(0.0, fieldValue(magn_field_2_result, 0, d)); - } - } -} - -//---------------------------------------------------------------------------// -// MHD vortex probem 2D -// Residual -TEST(MHDVortexProblemIC2D, residual) -{ - testEval(); -} - -// Jacobian -TEST(MHDVortexProblemIC2D, jacobian) -{ - testEval(); -} - -// MHD vortex probem 3D -// Residual -TEST(MHDVortexProblemIC3D, residual) -{ - testEval(); -} - -// Jacobian -TEST(MHDVortexProblemIC3D, jacobian) -{ - testEval(); -} -//---------------------------------------------------------------------------// -} // end namespace Test -} // end namespace VertexCFD diff --git a/src/full_induction_mhd_solver/mhd_properties/VertexCFD_FullInductionMHDProperties.hpp b/src/full_induction_mhd_solver/mhd_properties/VertexCFD_FullInductionMHDProperties.hpp deleted file mode 100644 index 402ddab..0000000 --- a/src/full_induction_mhd_solver/mhd_properties/VertexCFD_FullInductionMHDProperties.hpp +++ /dev/null @@ -1,140 +0,0 @@ -#ifndef VERTEXCFD_FULLINDUCTIONMHDPROPERTIES_HPP -#define VERTEXCFD_FULLINDUCTIONMHDPROPERTIES_HPP - -#include - -#include - -namespace VertexCFD -{ -namespace MHDProperties -{ -//---------------------------------------------------------------------------// -// Full induction MHD properties -//---------------------------------------------------------------------------// - -class FullInductionMHDProperties -{ - public: - FullInductionMHDProperties() = default; - explicit FullInductionMHDProperties(const Teuchos::ParameterList& mhd_params) - : _build_magn_corr(false) - , _build_resistive_flux(false) - , _variable_resistivity(false) - , _mu_0(1.0) - , _eta(std::numeric_limits::quiet_NaN()) - , _c_h(0.0) - { - if (mhd_params.isType("Build Magnetic Correction " - "Potential Equation")) - { - _build_magn_corr = mhd_params.get( - "Build Magnetic " - "Correction Potential " - "Equation"); - } - - // Vacuum magnetic permeability - if (mhd_params.isType("Vacuum Magnetic Permeability")) - { - _mu_0 = mhd_params.get("Vacuum Magnetic Permeability"); - } - - // Resistivity - if (mhd_params.isType("Build Resistive Flux")) - { - _build_resistive_flux - = mhd_params.get("Build Resistive Flux"); - } - - if (_build_resistive_flux) - { - if (mhd_params.isType("Variable Resistivity")) - { - _variable_resistivity - = mhd_params.get("Variable Resistivity"); - } - if (_variable_resistivity) - { - throw std::runtime_error( - "No closure models currently exist to evaluate variable " - "resistivity. Use a constant resistivity only."); - } - else - { - _eta = mhd_params.get("Resistivity"); - } - } - - // Divergence cleaning parameters - // Hyperbolic divergence cleaning speed - if (_build_magn_corr) - { - _c_h = mhd_params.get( - "Hyperbolic Divergence Cleaning Speed"); - } - // Magnetic correction potential equaiton damping factor - if (mhd_params.isType("Magnetic Correction Damping Factor")) - { - _alpha - = mhd_params.get("Magnetic Correction Damping Factor"); - } - else - { - _alpha = _c_h / 0.18; - } - } - - // Build magnetic correction boolean - KOKKOS_INLINE_FUNCTION bool buildMagnCorr() const - { - return _build_magn_corr; - } - - // Build magnetic correction boolean - KOKKOS_INLINE_FUNCTION bool buildResistiveFlux() const - { - return _build_resistive_flux; - } - - // Variable resistivity boolean - KOKKOS_INLINE_FUNCTION bool variableResistivity() const - { - return _variable_resistivity; - } - - // Vacuum magnetic permeability - KOKKOS_INLINE_FUNCTION double vacuumMagneticPermeability() const - { - return _mu_0; - } - - // Constant resistivity - KOKKOS_INLINE_FUNCTION double resistivity() const { return _eta; } - - // Divergence cleaning speed - KOKKOS_INLINE_FUNCTION double hyperbolicDivergenceCleaningSpeed() const - { - return _c_h; - } - - // Magnetic correction damping factor - KOKKOS_INLINE_FUNCTION double magneticCorrectionDampingFactor() const - { - return _alpha; - } - - private: - bool _build_magn_corr; - bool _build_resistive_flux; - bool _variable_resistivity; - double _mu_0; - double _eta; - double _c_h; - double _alpha; -}; - -} // namespace MHDProperties -} // namespace VertexCFD - -#endif // VERTEXCFD_FULLINDUCTIONMHDPROPERTIES_HPP diff --git a/src/full_induction_mhd_solver/mhd_properties/unit_test/CMakeLists.txt b/src/full_induction_mhd_solver/mhd_properties/unit_test/CMakeLists.txt deleted file mode 100644 index 282142a..0000000 --- a/src/full_induction_mhd_solver/mhd_properties/unit_test/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -set(TEST_HARNESS_DIR ${CMAKE_SOURCE_DIR}/src/test_harness) -include(${TEST_HARNESS_DIR}/TestHarness.cmake) - -VertexCFD_add_tests( - LIBS VertexCFD - NAMES - FullInductionMHDProperties - ) diff --git a/src/full_induction_mhd_solver/mhd_properties/unit_test/tstFullInductionMHDProperties.cpp b/src/full_induction_mhd_solver/mhd_properties/unit_test/tstFullInductionMHDProperties.cpp deleted file mode 100644 index 047393d..0000000 --- a/src/full_induction_mhd_solver/mhd_properties/unit_test/tstFullInductionMHDProperties.cpp +++ /dev/null @@ -1,151 +0,0 @@ -#include "full_induction_mhd_solver/mhd_properties/VertexCFD_FullInductionMHDProperties.hpp" - -#include - -#include - -#include - -using namespace VertexCFD::MHDProperties; - -//---------------------------------------------------------------------------// -// TESTS -//---------------------------------------------------------------------------// -namespace Test -{ -class FullInductionMHDPropertiesTest : public ::testing::Test -{ - protected: - std::unique_ptr mhd_props; - - virtual void SetUp() override; - virtual void SetUpConstantProps(const bool set_alpha); - virtual void SetUpVariableResistivity(); -}; - -// Set up default (minimal inputs) -void FullInductionMHDPropertiesTest::SetUp() -{ - Teuchos::ParameterList mhd_params; - mhd_props = std::make_unique(mhd_params); -} - -// Set all properties with constant resistivity -void FullInductionMHDPropertiesTest::SetUpConstantProps(const bool set_alpha) -{ - Teuchos::ParameterList mhd_params; - mhd_params.set("Build Magnetic Correction Potential Equation", true); - mhd_params.set("Build Resistive Flux", true); - mhd_params.set("Vacuum Magnetic Permeability", 0.5); - mhd_params.set("Variable Resistivity", false); - mhd_params.set("Resistivity", 1.5); - mhd_params.set("Hyperbolic Divergence Cleaning Speed", 1.8); - if (set_alpha) - { - mhd_params.set("Magnetic Correction Damping Factor", 2.0); - } - mhd_props = std::make_unique(mhd_params); -} - -// Set variable resistivity -void FullInductionMHDPropertiesTest::SetUpVariableResistivity() -{ - Teuchos::ParameterList mhd_params; - mhd_params.set("Build Magnetic Correction Potential Equation", false); - mhd_params.set("Build Resistive Flux", true); - mhd_params.set("Variable Resistivity", true); - mhd_props = std::make_unique(mhd_params); -} -//---------------------------------------------------------------------------// - -// Test default properties -TEST_F(FullInductionMHDPropertiesTest, defaults) -{ - FullInductionMHDPropertiesTest::SetUp(); - - EXPECT_FALSE(mhd_props->variableResistivity()); - - EXPECT_FALSE(mhd_props->buildMagnCorr()); - - EXPECT_FALSE(mhd_props->buildResistiveFlux()); - - const double mu_0 = mhd_props->vacuumMagneticPermeability(); - EXPECT_DOUBLE_EQ(1.0, mu_0); - - const double eta = mhd_props->resistivity(); - EXPECT_TRUE(std::isnan(eta)); - - const double c_h = mhd_props->hyperbolicDivergenceCleaningSpeed(); - EXPECT_DOUBLE_EQ(0.0, c_h); - - const double alpha = mhd_props->magneticCorrectionDampingFactor(); - EXPECT_DOUBLE_EQ(0.0, alpha); -} - -// Test constant properties with derived alpha -TEST_F(FullInductionMHDPropertiesTest, derived_alpha) -{ - FullInductionMHDPropertiesTest::SetUpConstantProps(false); - - EXPECT_FALSE(mhd_props->variableResistivity()); - - EXPECT_TRUE(mhd_props->buildMagnCorr()); - - EXPECT_TRUE(mhd_props->buildResistiveFlux()); - - const double mu_0 = mhd_props->vacuumMagneticPermeability(); - EXPECT_DOUBLE_EQ(0.5, mu_0); - - const double eta = mhd_props->resistivity(); - EXPECT_EQ(1.5, eta); - - const double c_h = mhd_props->hyperbolicDivergenceCleaningSpeed(); - EXPECT_DOUBLE_EQ(1.8, c_h); - - const double alpha = mhd_props->magneticCorrectionDampingFactor(); - EXPECT_DOUBLE_EQ(10.0, alpha); -} - -// Test constant properties with input alpha -TEST_F(FullInductionMHDPropertiesTest, set_alpha) -{ - FullInductionMHDPropertiesTest::SetUpConstantProps(true); - - EXPECT_FALSE(mhd_props->variableResistivity()); - - EXPECT_TRUE(mhd_props->buildMagnCorr()); - - EXPECT_TRUE(mhd_props->buildResistiveFlux()); - - const double mu_0 = mhd_props->vacuumMagneticPermeability(); - EXPECT_DOUBLE_EQ(0.5, mu_0); - - const double eta = mhd_props->resistivity(); - EXPECT_EQ(1.5, eta); - - const double c_h = mhd_props->hyperbolicDivergenceCleaningSpeed(); - EXPECT_DOUBLE_EQ(1.8, c_h); - - const double alpha = mhd_props->magneticCorrectionDampingFactor(); - EXPECT_DOUBLE_EQ(2.0, alpha); -} - -// Test variable resistivity -TEST_F(FullInductionMHDPropertiesTest, variable_resistivity) -{ - const std::string exp_msg - = "No closure models currently exist to evaluate variable " - "resistivity. Use a constant resistivity only."; - EXPECT_THROW( - try { - FullInductionMHDPropertiesTest::SetUpVariableResistivity(); - } catch (const std::runtime_error& e) { - EXPECT_EQ(exp_msg, e.what()); - throw; - }, - std::runtime_error); -} - -//---------------------------------------------------------------------------// - -} // end namespace Test diff --git a/src/incompressible_lsvof_solver/closure_models/VertexCFD_Closure_IncompressibleLSVOFConvectiveFlux.cpp b/src/incompressible_lsvof_solver/closure_models/VertexCFD_Closure_IncompressibleLSVOFConvectiveFlux.cpp deleted file mode 100644 index 417916d..0000000 --- a/src/incompressible_lsvof_solver/closure_models/VertexCFD_Closure_IncompressibleLSVOFConvectiveFlux.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_Closure_IncompressibleLSVOFConvectiveFlux.hpp" -#include "VertexCFD_Closure_IncompressibleLSVOFConvectiveFlux_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS_NUMSPACEDIM( - VertexCFD::ClosureModel::IncompressibleLSVOFConvectiveFlux) diff --git a/src/incompressible_lsvof_solver/closure_models/VertexCFD_Closure_IncompressibleLSVOFConvectiveFlux.hpp b/src/incompressible_lsvof_solver/closure_models/VertexCFD_Closure_IncompressibleLSVOFConvectiveFlux.hpp deleted file mode 100644 index 8755369..0000000 --- a/src/incompressible_lsvof_solver/closure_models/VertexCFD_Closure_IncompressibleLSVOFConvectiveFlux.hpp +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef VERTEXCFD_CLOSURE_INCOMPRESSIBLELSVOFCONVECTIVEFLUX_HPP -#define VERTEXCFD_CLOSURE_INCOMPRESSIBLELSVOFCONVECTIVEFLUX_HPP - -#include -#include - -#include -#include -#include -#include - -#include - -#include - -namespace VertexCFD -{ -namespace ClosureModel -{ -//---------------------------------------------------------------------------// -// Multi-dimension convective flux evaluation for LSVOF Navier-Stokes equations -//---------------------------------------------------------------------------// -template -class IncompressibleLSVOFConvectiveFlux - : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - static constexpr int num_space_dim = NumSpaceDim; - - IncompressibleLSVOFConvectiveFlux(const panzer::IntegrationRule& ir, - const std::string& flux_prefix = "", - const std::string& field_prefix = ""); - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - PHX::MDField - _continuity_flux; - Kokkos::Array< - PHX::MDField, - num_space_dim> - _momentum_flux; - - private: - PHX::MDField _rho; - PHX::MDField _pressure; - Kokkos::Array, - num_space_dim> - _velocity; -}; - -//---------------------------------------------------------------------------// - -} // end namespace ClosureModel -} // end namespace VertexCFD - -#endif // end VERTEXCFD_CLOSURE_INCOMPRESSIBLELSVOFCONVECTIVEFLUX_HPP diff --git a/src/incompressible_lsvof_solver/closure_models/unit_test/tstIncompressibleLSVOFConvectiveFlux.cpp b/src/incompressible_lsvof_solver/closure_models/unit_test/tstIncompressibleLSVOFConvectiveFlux.cpp deleted file mode 100644 index e435d9b..0000000 --- a/src/incompressible_lsvof_solver/closure_models/unit_test/tstIncompressibleLSVOFConvectiveFlux.cpp +++ /dev/null @@ -1,165 +0,0 @@ -#include "VertexCFD_EvaluatorTestHarness.hpp" -#include "closure_models/unit_test/VertexCFD_ClosureModelFactoryTestHarness.hpp" - -#include "incompressible_lsvof_solver/closure_models/VertexCFD_Closure_IncompressibleLSVOFConvectiveFlux.hpp" - -#include - -namespace VertexCFD -{ -namespace Test -{ -template -struct Dependencies : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - using scalar_type = typename EvalType::ScalarT; - - double _u; - double _v; - double _w; - - PHX::MDField pressure; - PHX::MDField vel_0; - PHX::MDField vel_1; - PHX::MDField vel_2; - PHX::MDField rho; - - Dependencies(const panzer::IntegrationRule& ir, - const double u, - const double v, - const double w) - : _u(u) - , _v(v) - , _w(w) - , pressure("lagrange_pressure", ir.dl_scalar) - , vel_0("velocity_0", ir.dl_scalar) - , vel_1("velocity_1", ir.dl_scalar) - , vel_2("velocity_2", ir.dl_scalar) - , rho("density", ir.dl_scalar) - - { - this->addEvaluatedField(pressure); - this->addEvaluatedField(vel_0); - this->addEvaluatedField(vel_1); - this->addEvaluatedField(vel_2); - this->addEvaluatedField(rho); - - this->setName( - "Incompressible LSVOF Convective Flux Unit Test Dependencies"); - } - - void evaluateFields(typename panzer::Traits::EvalData) override - { - pressure.deep_copy(0.75); - vel_0.deep_copy(_u); - vel_1.deep_copy(_v); - vel_2.deep_copy(_w); - rho.deep_copy(1.375); - } -}; - -template -void testEval() -{ - constexpr int num_space_dim = NumSpaceDim; - const int integration_order = 2; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - - const auto& ir = *test_fixture.ir; - - // Initialize velocity components and dependents - const double _nanval = std::numeric_limits::quiet_NaN(); - const double u = 0.25; - const double v = 0.5; - const double w = num_space_dim > 2 ? 0.125 : _nanval; - const double p = 0.75; - const double rho = 1.375; - - auto deps = Teuchos::rcp(new Dependencies(ir, u, v, w)); - test_fixture.registerEvaluator(deps); - - // Initialize class object to test - const auto eval = Teuchos::rcp( - new ClosureModel::IncompressibleLSVOFConvectiveFlux(ir)); - test_fixture.registerEvaluator(eval); - test_fixture.registerTestField(eval->_continuity_flux); - for (int dim = 0; dim < num_space_dim; ++dim) - test_fixture.registerTestField(eval->_momentum_flux[dim]); - - test_fixture.evaluate(); - - const auto fc_cont - = test_fixture.getTestFieldData(eval->_continuity_flux); - const auto fc_mom_0 - = test_fixture.getTestFieldData(eval->_momentum_flux[0]); - const auto fc_mom_1 - = test_fixture.getTestFieldData(eval->_momentum_flux[1]); - - const int num_point = ir.num_points; - - // Expected values - const double exp_cont_flux[3] = {rho * u, rho * v, rho * w}; - const double exp_mom_0_flux[3] - = {rho * u * u + p, - rho * u * v, - num_space_dim == 3 ? rho * u * w : _nanval}; - const double exp_mom_1_flux[3] - = {rho * v * u, - rho * v * v + p, - num_space_dim == 3 ? rho * v * w : _nanval}; - const double exp_mom_2_flux[3] - = {rho * w * u, - rho * w * v, - num_space_dim == 3 ? rho * w * w + p : _nanval}; - - // Assert values - for (int qp = 0; qp < num_point; ++qp) - { - for (int dim = 0; dim < num_space_dim; dim++) - { - EXPECT_EQ(exp_cont_flux[dim], fieldValue(fc_cont, 0, qp, dim)); - EXPECT_EQ(exp_mom_0_flux[dim], fieldValue(fc_mom_0, 0, qp, dim)); - EXPECT_EQ(exp_mom_1_flux[dim], fieldValue(fc_mom_1, 0, qp, dim)); - - if (num_space_dim > 2) // 3D mesh - { - const auto fc_mom_2 = test_fixture.getTestFieldData( - eval->_momentum_flux[2]); - EXPECT_EQ(exp_mom_2_flux[dim], - fieldValue(fc_mom_2, 0, qp, dim)); - } - } - } -} - -//-----------------------------------------------------------------// -TEST(IncompressibleLSVOFConvectiveFlux2D, Residual) -{ - testEval(); -} - -//-----------------------------------------------------------------// -TEST(IncompressibleLSVOFConvectiveFlux2D, Jacobian) -{ - testEval(); -} - -//-----------------------------------------------------------------// -TEST(IncompressibleLSVOFConvectiveFlux3D, Residual) -{ - testEval(); -} - -//-----------------------------------------------------------------// -TEST(IncompressibleLSVOFConvectiveFlux3D, Jacobian) -{ - testEval(); -} - -} // namespace Test -} // namespace VertexCFD diff --git a/src/incompressible_solver/boundary_conditions/VertexCFD_BoundaryState_IncompressibleCavityLid.cpp b/src/incompressible_solver/boundary_conditions/VertexCFD_BoundaryState_IncompressibleCavityLid.cpp deleted file mode 100644 index 42d6396..0000000 --- a/src/incompressible_solver/boundary_conditions/VertexCFD_BoundaryState_IncompressibleCavityLid.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_BoundaryState_IncompressibleCavityLid.hpp" -#include "VertexCFD_BoundaryState_IncompressibleCavityLid_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS_NUMSPACEDIM( - VertexCFD::BoundaryCondition::IncompressibleCavityLid) diff --git a/src/incompressible_solver/boundary_conditions/VertexCFD_BoundaryState_IncompressibleCavityLid.hpp b/src/incompressible_solver/boundary_conditions/VertexCFD_BoundaryState_IncompressibleCavityLid.hpp deleted file mode 100644 index c87aea2..0000000 --- a/src/incompressible_solver/boundary_conditions/VertexCFD_BoundaryState_IncompressibleCavityLid.hpp +++ /dev/null @@ -1,97 +0,0 @@ -#ifndef VERTEXCFD_BOUNDARYSTATE_INCOMPRESSIBLECAVITYLID_HPP -#define VERTEXCFD_BOUNDARYSTATE_INCOMPRESSIBLECAVITYLID_HPP - -#include "incompressible_solver/fluid_properties/VertexCFD_ConstantFluidProperties.hpp" - -#include -#include - -#include -#include -#include -#include - -#include - -#include - -namespace VertexCFD -{ -namespace BoundaryCondition -{ -//---------------------------------------------------------------------------// -// Lid condition for 2D or 3D lid-driven cavity problem -//---------------------------------------------------------------------------// -template -class IncompressibleCavityLid : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - static constexpr int num_space_dim = NumSpaceDim; - - IncompressibleCavityLid( - const panzer::IntegrationRule& ir, - const FluidProperties::ConstantFluidProperties& fluid_prop, - const Teuchos::ParameterList& bc_params, - const std::string& continuity_model_name); - - void postRegistrationSetup(typename Traits::SetupData sd, - PHX::FieldManager& fm) override; - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - public: - PHX::MDField - _boundary_lagrange_pressure; - PHX::MDField - _boundary_grad_lagrange_pressure; - PHX::MDField _boundary_temperature; - PHX::MDField - _boundary_grad_temperature; - Kokkos::Array, - num_space_dim> - _boundary_velocity; - - Kokkos::Array< - PHX::MDField, - num_space_dim> - _boundary_grad_velocity; - - private: - int _ir_degree; - int _ir_index; - - PHX::MDField _lagrange_pressure; - PHX::MDField - _grad_lagrange_pressure; - PHX::MDField - _grad_temperature; - - Kokkos::Array< - PHX::MDField, - num_space_dim> - _grad_velocity; - - PHX::MDField _ip_coords; - - bool _solve_temp; - std::string _continuity_model_name; - bool _is_edac; - int _wall_dir; - int _vel_dir; - double _h; - double _u_wall; - double _T_bc; -}; - -//---------------------------------------------------------------------------// - -} // end namespace BoundaryCondition -} // end namespace VertexCFD - -#endif // VERTEXCFD_BOUNDARYSTATE_INCOMPRESSIBLECAVITYLID_HPP diff --git a/src/incompressible_solver/boundary_conditions/VertexCFD_BoundaryState_IncompressibleDirichlet.cpp b/src/incompressible_solver/boundary_conditions/VertexCFD_BoundaryState_IncompressibleDirichlet.cpp deleted file mode 100644 index 3d226b3..0000000 --- a/src/incompressible_solver/boundary_conditions/VertexCFD_BoundaryState_IncompressibleDirichlet.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "incompressible_solver/boundary_conditions/VertexCFD_BoundaryState_IncompressibleDirichlet.hpp" -#include "incompressible_solver/boundary_conditions/VertexCFD_BoundaryState_IncompressibleDirichlet_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS_NUMSPACEDIM( - VertexCFD::BoundaryCondition::IncompressibleDirichlet) diff --git a/src/incompressible_solver/boundary_conditions/VertexCFD_BoundaryState_IncompressibleDirichlet.hpp b/src/incompressible_solver/boundary_conditions/VertexCFD_BoundaryState_IncompressibleDirichlet.hpp deleted file mode 100644 index af968f3..0000000 --- a/src/incompressible_solver/boundary_conditions/VertexCFD_BoundaryState_IncompressibleDirichlet.hpp +++ /dev/null @@ -1,85 +0,0 @@ -#ifndef VERTEXCFD_BOUNDARYSTATE_INCOMPRESSIBLEDIRICHLET_HPP -#define VERTEXCFD_BOUNDARYSTATE_INCOMPRESSIBLEDIRICHLET_HPP - -#include "incompressible_solver/fluid_properties/VertexCFD_ConstantFluidProperties.hpp" - -#include -#include - -#include -#include -#include -#include - -namespace VertexCFD -{ -namespace BoundaryCondition -{ -//---------------------------------------------------------------------------// -template -class IncompressibleDirichlet : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - static constexpr int num_space_dim = NumSpaceDim; - - IncompressibleDirichlet( - const panzer::IntegrationRule& ir, - const FluidProperties::ConstantFluidProperties& fluid_prop, - const Teuchos::ParameterList& bc_params, - const std::string& continuity_model_name); - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - public: - PHX::MDField - _boundary_lagrange_pressure; - PHX::MDField - _boundary_grad_lagrange_pressure; - Kokkos::Array, - num_space_dim> - _boundary_velocity; - PHX::MDField _boundary_temperature; - - Kokkos::Array< - PHX::MDField, - num_space_dim> - _boundary_grad_velocity; - - PHX::MDField - _boundary_grad_temperature; - - private: - double _time; - double _time_init; - double _time_final; - Kokkos::Array _a_vel; - Kokkos::Array _b_vel; - double _T_dirichlet; - - PHX::MDField _lagrange_pressure; - PHX::MDField - _grad_lagrange_pressure; - Kokkos::Array< - PHX::MDField, - num_space_dim> - _grad_velocity; - PHX::MDField - _grad_temperature; - - bool _solve_temp; - std::string _continuity_model_name; - bool _is_edac; -}; - -//---------------------------------------------------------------------------// - -} // end namespace BoundaryCondition -} // end namespace VertexCFD - -#endif // VERTEXCFD_BOUNDARYSTATE_INCOMPRESSIBLEDIRICHLET_HPP diff --git a/src/incompressible_solver/boundary_conditions/VertexCFD_BoundaryState_IncompressibleFreeSlip.cpp b/src/incompressible_solver/boundary_conditions/VertexCFD_BoundaryState_IncompressibleFreeSlip.cpp deleted file mode 100644 index 10a6e93..0000000 --- a/src/incompressible_solver/boundary_conditions/VertexCFD_BoundaryState_IncompressibleFreeSlip.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_BoundaryState_IncompressibleFreeSlip.hpp" -#include "VertexCFD_BoundaryState_IncompressibleFreeSlip_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS_NUMSPACEDIM( - VertexCFD::BoundaryCondition::IncompressibleFreeSlip) diff --git a/src/incompressible_solver/boundary_conditions/VertexCFD_BoundaryState_IncompressibleFreeSlip.hpp b/src/incompressible_solver/boundary_conditions/VertexCFD_BoundaryState_IncompressibleFreeSlip.hpp deleted file mode 100644 index 232c493..0000000 --- a/src/incompressible_solver/boundary_conditions/VertexCFD_BoundaryState_IncompressibleFreeSlip.hpp +++ /dev/null @@ -1,86 +0,0 @@ -#ifndef VERTEXCFD_BOUNDARYSTATE_INCOMPRESSIBLEFREESLIP_HPP -#define VERTEXCFD_BOUNDARYSTATE_INCOMPRESSIBLEFREESLIP_HPP - -#include "incompressible_solver/fluid_properties/VertexCFD_ConstantFluidProperties.hpp" - -#include -#include - -#include -#include -#include -#include - -#include - -namespace VertexCFD -{ -namespace BoundaryCondition -{ -//---------------------------------------------------------------------------// -template -class IncompressibleFreeSlip : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - static constexpr int num_space_dim = NumSpaceDim; - - IncompressibleFreeSlip( - const panzer::IntegrationRule& ir, - const FluidProperties::ConstantFluidProperties& fluid_prop, - const std::string& continuity_model_name); - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - public: - PHX::MDField - _boundary_lagrange_pressure; - PHX::MDField - _boundary_grad_lagrange_pressure; - PHX::MDField _boundary_temperature; - Kokkos::Array, - num_space_dim> - _boundary_velocity; - - Kokkos::Array< - PHX::MDField, - num_space_dim> - _boundary_grad_velocity; - PHX::MDField - _boundary_grad_temperature; - - private: - PHX::MDField _lagrange_pressure; - PHX::MDField - _grad_lagrange_pressure; - PHX::MDField _temperature; - Kokkos::Array, - num_space_dim> - _velocity; - PHX::MDField - _grad_temperature; - - PHX::MDField - _normals; - - Kokkos::Array< - PHX::MDField, - num_space_dim> - _grad_velocity; - - bool _solve_temp; - std::string _continuity_model_name; - bool _is_edac; -}; - -//---------------------------------------------------------------------------// - -} // end namespace BoundaryCondition -} // end namespace VertexCFD - -#endif // VERTEXCFD_BOUNDARYSTATE_INCOMPRESSIBLEFREESLIP_HPP diff --git a/src/incompressible_solver/boundary_conditions/VertexCFD_BoundaryState_IncompressibleLaminarFlow.cpp b/src/incompressible_solver/boundary_conditions/VertexCFD_BoundaryState_IncompressibleLaminarFlow.cpp deleted file mode 100644 index 80232de..0000000 --- a/src/incompressible_solver/boundary_conditions/VertexCFD_BoundaryState_IncompressibleLaminarFlow.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_BoundaryState_IncompressibleLaminarFlow.hpp" -#include "VertexCFD_BoundaryState_IncompressibleLaminarFlow_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS_NUMSPACEDIM( - VertexCFD::BoundaryCondition::IncompressibleLaminarFlow) diff --git a/src/incompressible_solver/boundary_conditions/VertexCFD_BoundaryState_IncompressibleNoSlip.cpp b/src/incompressible_solver/boundary_conditions/VertexCFD_BoundaryState_IncompressibleNoSlip.cpp deleted file mode 100644 index ba59f16..0000000 --- a/src/incompressible_solver/boundary_conditions/VertexCFD_BoundaryState_IncompressibleNoSlip.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "incompressible_solver/boundary_conditions/VertexCFD_BoundaryState_IncompressibleNoSlip.hpp" -#include "incompressible_solver/boundary_conditions/VertexCFD_BoundaryState_IncompressibleNoSlip_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS_NUMSPACEDIM( - VertexCFD::BoundaryCondition::IncompressibleNoSlip) diff --git a/src/incompressible_solver/boundary_conditions/VertexCFD_BoundaryState_IncompressibleNoSlip.hpp b/src/incompressible_solver/boundary_conditions/VertexCFD_BoundaryState_IncompressibleNoSlip.hpp deleted file mode 100644 index 3d17077..0000000 --- a/src/incompressible_solver/boundary_conditions/VertexCFD_BoundaryState_IncompressibleNoSlip.hpp +++ /dev/null @@ -1,82 +0,0 @@ -#ifndef VERTEXCFD_BOUNDARYSTATE_INCOMPRESSIBLENOSLIP_HPP -#define VERTEXCFD_BOUNDARYSTATE_INCOMPRESSIBLENOSLIP_HPP - -#include "incompressible_solver/fluid_properties/VertexCFD_ConstantFluidProperties.hpp" - -#include -#include - -#include -#include -#include -#include - -#include - -#include - -namespace VertexCFD -{ -namespace BoundaryCondition -{ -//---------------------------------------------------------------------------// -template -class IncompressibleNoSlip : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - static constexpr int num_space_dim = NumSpaceDim; - - IncompressibleNoSlip( - const panzer::IntegrationRule& ir, - const FluidProperties::ConstantFluidProperties& fluid_prop, - const Teuchos::ParameterList& bc_params, - const std::string& continuity_model_name); - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - public: - PHX::MDField - _boundary_lagrange_pressure; - PHX::MDField - _boundary_grad_lagrange_pressure; - PHX::MDField _boundary_temperature; - Kokkos::Array, - num_space_dim> - _boundary_velocity; - - Kokkos::Array< - PHX::MDField, - num_space_dim> - _boundary_grad_velocity; - PHX::MDField - _boundary_grad_temperature; - - private: - PHX::MDField _lagrange_pressure; - PHX::MDField - _grad_lagrange_pressure; - Kokkos::Array< - PHX::MDField, - num_space_dim> - _grad_velocity; - PHX::MDField - _grad_temperature; - - bool _solve_temp; - std::string _continuity_model_name; - bool _is_edac; - double _T_wall; -}; - -//---------------------------------------------------------------------------// - -} // end namespace BoundaryCondition -} // end namespace VertexCFD - -#endif // VERTEXCFD_BOUNDARYSTATE_INCOMPRESSIBLENOSLIP_HPP diff --git a/src/incompressible_solver/boundary_conditions/VertexCFD_BoundaryState_IncompressiblePressureOutflow.cpp b/src/incompressible_solver/boundary_conditions/VertexCFD_BoundaryState_IncompressiblePressureOutflow.cpp deleted file mode 100644 index 0b12d7a..0000000 --- a/src/incompressible_solver/boundary_conditions/VertexCFD_BoundaryState_IncompressiblePressureOutflow.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_BoundaryState_IncompressiblePressureOutflow.hpp" -#include "VertexCFD_BoundaryState_IncompressiblePressureOutflow_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS_NUMSPACEDIM( - VertexCFD::BoundaryCondition::IncompressiblePressureOutflow) diff --git a/src/incompressible_solver/boundary_conditions/VertexCFD_BoundaryState_IncompressiblePressureOutflow.hpp b/src/incompressible_solver/boundary_conditions/VertexCFD_BoundaryState_IncompressiblePressureOutflow.hpp deleted file mode 100644 index 2acde23..0000000 --- a/src/incompressible_solver/boundary_conditions/VertexCFD_BoundaryState_IncompressiblePressureOutflow.hpp +++ /dev/null @@ -1,95 +0,0 @@ -#ifndef VERTEXCFD_BOUNDARYSTATE_INCOMPRESSIBLEPRESSUREOUTFLOW_HPP -#define VERTEXCFD_BOUNDARYSTATE_INCOMPRESSIBLEPRESSUREOUTFLOW_HPP - -#include "incompressible_solver/fluid_properties/VertexCFD_ConstantFluidProperties.hpp" - -#include -#include - -#include -#include -#include -#include - -#include - -#include - -namespace VertexCFD -{ -namespace BoundaryCondition -{ -//---------------------------------------------------------------------------// -// Isothermal and isotropic pressure outflow boundary condition. -//---------------------------------------------------------------------------// -template -class IncompressiblePressureOutflow - : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - static constexpr int num_space_dim = NumSpaceDim; - - IncompressiblePressureOutflow( - const panzer::IntegrationRule& ir, - const FluidProperties::ConstantFluidProperties& fluid_prop, - const Teuchos::ParameterList& bc_params, - const std::string& continuity_model_name); - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - public: - PHX::MDField - _boundary_lagrange_pressure; - PHX::MDField - _boundary_grad_lagrange_pressure; - - PHX::MDField _boundary_temperature; - - PHX::MDField - _boundary_grad_temperature; - - Kokkos::Array, - num_space_dim> - _boundary_velocity; - - Kokkos::Array< - PHX::MDField, - num_space_dim> - _boundary_grad_velocity; - - private: - PHX::MDField - _grad_lagrange_pressure; - - PHX::MDField _temperature; - - PHX::MDField - _grad_temperature; - - Kokkos::Array, - num_space_dim> - _velocity; - - Kokkos::Array< - PHX::MDField, - num_space_dim> - _grad_velocity; - - bool _solve_temp; - std::string _continuity_model_name; - bool _is_edac; - double _p_back; -}; - -//---------------------------------------------------------------------------// - -} // end namespace BoundaryCondition -} // end namespace VertexCFD - -#endif // VERTEXCFD_BOUNDARYSTATE_INCOMPRESSIBLEPRESSUREOUTFLOW_HPP diff --git a/src/incompressible_solver/boundary_conditions/VertexCFD_BoundaryState_IncompressibleRotatingWall.cpp b/src/incompressible_solver/boundary_conditions/VertexCFD_BoundaryState_IncompressibleRotatingWall.cpp deleted file mode 100644 index 8279d7d..0000000 --- a/src/incompressible_solver/boundary_conditions/VertexCFD_BoundaryState_IncompressibleRotatingWall.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_BoundaryState_IncompressibleRotatingWall.hpp" -#include "VertexCFD_BoundaryState_IncompressibleRotatingWall_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS_NUMSPACEDIM( - VertexCFD::BoundaryCondition::IncompressibleRotatingWall) diff --git a/src/incompressible_solver/boundary_conditions/VertexCFD_BoundaryState_IncompressibleRotatingWall.hpp b/src/incompressible_solver/boundary_conditions/VertexCFD_BoundaryState_IncompressibleRotatingWall.hpp deleted file mode 100644 index d207d4c..0000000 --- a/src/incompressible_solver/boundary_conditions/VertexCFD_BoundaryState_IncompressibleRotatingWall.hpp +++ /dev/null @@ -1,99 +0,0 @@ -#ifndef VERTEXCFD_BOUNDARYSTATE_INCOMPRESSIBLEROTATINGWALL_HPP -#define VERTEXCFD_BOUNDARYSTATE_INCOMPRESSIBLEROTATINGWALL_HPP - -#include "incompressible_solver/fluid_properties/VertexCFD_ConstantFluidProperties.hpp" - -#include -#include - -#include -#include -#include -#include - -#include - -#include - -namespace VertexCFD -{ -namespace BoundaryCondition -{ -//---------------------------------------------------------------------------// -// Isothermal no-slip rotating wall. -//---------------------------------------------------------------------------// -template -class IncompressibleRotatingWall - : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - static constexpr int num_space_dim = NumSpaceDim; - - IncompressibleRotatingWall( - const panzer::IntegrationRule& ir, - const FluidProperties::ConstantFluidProperties& fluid_prop, - const Teuchos::ParameterList& bc_params, - const std::string& continuity_model_name); - - void postRegistrationSetup(typename Traits::SetupData sd, - PHX::FieldManager& fm) override; - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - public: - PHX::MDField - _boundary_lagrange_pressure; - PHX::MDField - _boundary_grad_lagrange_pressure; - PHX::MDField _boundary_temperature; - Kokkos::Array, - num_space_dim> - _boundary_velocity; - - Kokkos::Array< - PHX::MDField, - num_space_dim> - _boundary_grad_velocity; - PHX::MDField - _boundary_grad_temperature; - - private: - int _ir_degree; - bool _set_lagrange_pressure; - double _lp_wall; - int _ir_index; - double _a_vel, _b_vel; - double _time_init, _time_final; - double _angular_velocity; - bool _solve_temp; - std::string _continuity_model_name; - bool _is_edac; - double _T_wall; - - PHX::MDField _lagrange_pressure; - PHX::MDField - _grad_lagrange_pressure; - - Kokkos::Array< - PHX::MDField, - num_space_dim> - _grad_velocity; - - PHX::MDField - _grad_temperature; - - PHX::MDField _ip_coords; -}; - -//---------------------------------------------------------------------------// - -} // end namespace BoundaryCondition -} // end namespace VertexCFD - -#endif // VERTEXCFD_BOUNDARYSTATE_INCOMPRESSIBLEROTATINGWALL_HPP diff --git a/src/incompressible_solver/boundary_conditions/VertexCFD_BoundaryState_IncompressibleSymmetry.cpp b/src/incompressible_solver/boundary_conditions/VertexCFD_BoundaryState_IncompressibleSymmetry.cpp deleted file mode 100644 index da6dbf7..0000000 --- a/src/incompressible_solver/boundary_conditions/VertexCFD_BoundaryState_IncompressibleSymmetry.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_BoundaryState_IncompressibleSymmetry.hpp" -#include "VertexCFD_BoundaryState_IncompressibleSymmetry_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS_NUMSPACEDIM( - VertexCFD::BoundaryCondition::IncompressibleSymmetry) diff --git a/src/incompressible_solver/boundary_conditions/VertexCFD_BoundaryState_IncompressibleSymmetry.hpp b/src/incompressible_solver/boundary_conditions/VertexCFD_BoundaryState_IncompressibleSymmetry.hpp deleted file mode 100644 index 8ed42b9..0000000 --- a/src/incompressible_solver/boundary_conditions/VertexCFD_BoundaryState_IncompressibleSymmetry.hpp +++ /dev/null @@ -1,86 +0,0 @@ -#ifndef VERTEXCFD_BOUNDARYSTATE_INCOMPRESSIBLESYMMETRY_HPP -#define VERTEXCFD_BOUNDARYSTATE_INCOMPRESSIBLESYMMETRY_HPP - -#include "incompressible_solver/fluid_properties/VertexCFD_ConstantFluidProperties.hpp" - -#include -#include - -#include -#include -#include -#include - -#include - -namespace VertexCFD -{ -namespace BoundaryCondition -{ -//---------------------------------------------------------------------------// -template -class IncompressibleSymmetry : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - static constexpr int num_space_dim = NumSpaceDim; - - IncompressibleSymmetry( - const panzer::IntegrationRule& ir, - const FluidProperties::ConstantFluidProperties& fluid_prop, - const std::string& continuity_model_name); - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - public: - PHX::MDField - _boundary_lagrange_pressure; - PHX::MDField - _boundary_grad_lagrange_pressure; - PHX::MDField _boundary_temperature; - Kokkos::Array, - num_space_dim> - _boundary_velocity; - - Kokkos::Array< - PHX::MDField, - num_space_dim> - _boundary_grad_velocity; - PHX::MDField - _boundary_grad_temperature; - - private: - PHX::MDField _lagrange_pressure; - PHX::MDField - _grad_lagrange_pressure; - PHX::MDField _temperature; - Kokkos::Array, - num_space_dim> - _velocity; - PHX::MDField - _grad_temperature; - - PHX::MDField - _normals; - - Kokkos::Array< - PHX::MDField, - num_space_dim> - _grad_velocity; - - bool _solve_temp; - std::string _continuity_model_name; - bool _is_edac; -}; - -//---------------------------------------------------------------------------// - -} // end namespace BoundaryCondition -} // end namespace VertexCFD - -#endif // VERTEXCFD_BOUNDARYSTATE_INCOMPRESSIBLESYMMETRY_HPP diff --git a/src/incompressible_solver/boundary_conditions/VertexCFD_BoundaryState_IncompressibleWallFunction.cpp b/src/incompressible_solver/boundary_conditions/VertexCFD_BoundaryState_IncompressibleWallFunction.cpp deleted file mode 100644 index a27ecd8..0000000 --- a/src/incompressible_solver/boundary_conditions/VertexCFD_BoundaryState_IncompressibleWallFunction.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_BoundaryState_IncompressibleWallFunction.hpp" -#include "VertexCFD_BoundaryState_IncompressibleWallFunction_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS_NUMSPACEDIM( - VertexCFD::BoundaryCondition::IncompressibleWallFunction) diff --git a/src/incompressible_solver/boundary_conditions/VertexCFD_BoundaryState_IncompressibleWallFunction.hpp b/src/incompressible_solver/boundary_conditions/VertexCFD_BoundaryState_IncompressibleWallFunction.hpp deleted file mode 100644 index 540bc79..0000000 --- a/src/incompressible_solver/boundary_conditions/VertexCFD_BoundaryState_IncompressibleWallFunction.hpp +++ /dev/null @@ -1,92 +0,0 @@ -#ifndef VERTEXCFD_BOUNDARYSTATE_INCOMPRESSIBLEWALLFUNCTION_HPP -#define VERTEXCFD_BOUNDARYSTATE_INCOMPRESSIBLEWALLFUNCTION_HPP - -#include "incompressible_solver/fluid_properties/VertexCFD_ConstantFluidProperties.hpp" - -#include -#include - -#include -#include -#include -#include - -#include - -namespace VertexCFD -{ -namespace BoundaryCondition -{ -//---------------------------------------------------------------------------// -template -class IncompressibleWallFunction - : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - static constexpr int num_space_dim = NumSpaceDim; - - IncompressibleWallFunction( - const panzer::IntegrationRule& ir, - const FluidProperties::ConstantFluidProperties& fluid_prop, - const std::string& continuity_model_name); - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - public: - PHX::MDField - _boundary_lagrange_pressure; - PHX::MDField - _boundary_grad_lagrange_pressure; - PHX::MDField _boundary_temperature; - Kokkos::Array, - num_space_dim> - _boundary_velocity; - - Kokkos::Array< - PHX::MDField, - num_space_dim> - _boundary_grad_velocity; - PHX::MDField - _boundary_grad_temperature; - - private: - PHX::MDField _boundary_u_tau; - PHX::MDField _boundary_y_plus; - PHX::MDField _boundary_nu_t; - PHX::MDField _lagrange_pressure; - PHX::MDField - _grad_lagrange_pressure; - PHX::MDField _temperature; - Kokkos::Array, - num_space_dim> - _velocity; - PHX::MDField - _grad_temperature; - - PHX::MDField - _normals; - - Kokkos::Array< - PHX::MDField, - num_space_dim> - _grad_velocity; - - double _rho; - double _nu; - bool _solve_temp; - std::string _continuity_model_name; - bool _is_edac; -}; - -//---------------------------------------------------------------------------// - -} // end namespace BoundaryCondition -} // end namespace VertexCFD - -#endif // VERTEXCFD_BOUNDARYSTATE_INCOMPRESSIBLEWALLFUNCTION_HPP diff --git a/src/incompressible_solver/boundary_conditions/VertexCFD_IncompressibleBoundaryState_Factory.cpp b/src/incompressible_solver/boundary_conditions/VertexCFD_IncompressibleBoundaryState_Factory.cpp deleted file mode 100644 index a187379..0000000 --- a/src/incompressible_solver/boundary_conditions/VertexCFD_IncompressibleBoundaryState_Factory.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "incompressible_solver/boundary_conditions/VertexCFD_IncompressibleBoundaryState_Factory.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS_NUMSPACEDIM( - VertexCFD::BoundaryCondition::IncompressibleBoundaryStateFactory) diff --git a/src/incompressible_solver/boundary_conditions/VertexCFD_IncompressibleBoundaryState_Factory.hpp b/src/incompressible_solver/boundary_conditions/VertexCFD_IncompressibleBoundaryState_Factory.hpp deleted file mode 100644 index 4fbf65e..0000000 --- a/src/incompressible_solver/boundary_conditions/VertexCFD_IncompressibleBoundaryState_Factory.hpp +++ /dev/null @@ -1,171 +0,0 @@ -#ifndef VERTEXCFD_INCOMPRESSIBLEBOUNDARYSTATE_FACTORY_HPP -#define VERTEXCFD_INCOMPRESSIBLEBOUNDARYSTATE_FACTORY_HPP - -#include "incompressible_solver/boundary_conditions/VertexCFD_BoundaryState_IncompressibleCavityLid.hpp" -#include "incompressible_solver/boundary_conditions/VertexCFD_BoundaryState_IncompressibleDirichlet.hpp" -#include "incompressible_solver/boundary_conditions/VertexCFD_BoundaryState_IncompressibleFreeSlip.hpp" -#include "incompressible_solver/boundary_conditions/VertexCFD_BoundaryState_IncompressibleLaminarFlow.hpp" -#include "incompressible_solver/boundary_conditions/VertexCFD_BoundaryState_IncompressibleNoSlip.hpp" -#include "incompressible_solver/boundary_conditions/VertexCFD_BoundaryState_IncompressiblePressureOutflow.hpp" -#include "incompressible_solver/boundary_conditions/VertexCFD_BoundaryState_IncompressibleRotatingWall.hpp" -#include "incompressible_solver/boundary_conditions/VertexCFD_BoundaryState_IncompressibleSymmetry.hpp" -#include "incompressible_solver/boundary_conditions/VertexCFD_BoundaryState_IncompressibleWallFunction.hpp" - -#include "incompressible_solver/fluid_properties/VertexCFD_ConstantFluidProperties.hpp" - -#include - -#include -#include - -namespace VertexCFD -{ -namespace BoundaryCondition -{ -//---------------------------------------------------------------------------// -template -class IncompressibleBoundaryStateFactory -{ - public: - static Teuchos::RCP> - create(const panzer::IntegrationRule& ir, - const Teuchos::ParameterList& bc_params, - const Teuchos::ParameterList& user_params) - { - // Space dimension - constexpr int num_space_dim = NumSpaceDim; - - // Equation of state - Teuchos::ParameterList fluid_prop_list - = user_params.sublist("Fluid Properties"); - std::string continuity_model_name - = user_params.isType("Continuity Model") - ? user_params.get("Continuity Model") - : "AC"; - const bool build_temp_equ - = user_params.isType("Build Temperature Equation") - ? user_params.get("Build Temperature Equation") - : false; - const bool build_buoyancy - = user_params.isType("Build Buoyancy Source") - ? user_params.get("Build Buoyancy Source") - : false; - const bool build_ind_less_equ - = user_params.isType("Build Inductionless MHD Equation") - ? user_params.get("Build Inductionless MHD Equation") - : false; - - fluid_prop_list.set("Build Temperature Equation", build_temp_equ); - fluid_prop_list.set("Build Buoyancy Source", build_buoyancy); - fluid_prop_list.set("Build Inductionless MHD Equation", - build_ind_less_equ); - FluidProperties::ConstantFluidProperties fluid_prop(fluid_prop_list); - - // Loop over boundary conditions - Teuchos::RCP> state; - bool found_model = false; - - if (bc_params.isType("Type")) - { - if (bc_params.get("Type") == "No-Slip") - { - state = Teuchos::rcp( - new IncompressibleNoSlip( - ir, fluid_prop, bc_params, continuity_model_name)); - found_model = true; - } - - if (bc_params.get("Type") == "Dirichlet") - { - state = Teuchos::rcp( - new IncompressibleDirichlet( - ir, fluid_prop, bc_params, continuity_model_name)); - found_model = true; - } - - if (bc_params.get("Type") == "Pressure Outflow") - { - state = Teuchos::rcp( - new IncompressiblePressureOutflow( - ir, fluid_prop, bc_params, continuity_model_name)); - found_model = true; - } - - if (bc_params.get("Type") == "Free Slip") - { - state = Teuchos::rcp( - new IncompressibleFreeSlip( - ir, fluid_prop, continuity_model_name)); - found_model = true; - } - - if (bc_params.get("Type") == "Symmetry") - { - state = Teuchos::rcp( - new IncompressibleSymmetry( - ir, fluid_prop, continuity_model_name)); - found_model = true; - } - - if (bc_params.get("Type") == "Rotating Wall") - { - state = Teuchos::rcp( - new IncompressibleRotatingWall( - ir, fluid_prop, bc_params, continuity_model_name)); - found_model = true; - } - - if (bc_params.get("Type") == "Laminar Flow") - { - state = Teuchos::rcp( - new IncompressibleLaminarFlow( - ir, fluid_prop, bc_params, continuity_model_name)); - found_model = true; - } - - if (bc_params.get("Type") == "Cavity Lid") - { - state = Teuchos::rcp( - new IncompressibleCavityLid( - ir, fluid_prop, bc_params, continuity_model_name)); - found_model = true; - } - - if (bc_params.get("Type") == "Velocity Wall Function") - { - state = Teuchos::rcp( - new IncompressibleWallFunction( - ir, fluid_prop, continuity_model_name)); - found_model = true; - } - } - - if (!found_model) - { - std::string msg = "\n\nBoundary state " - + bc_params.get("Type") - + " failed to build.\n"; - msg += "The boundary conditions implemented in VertexCFD are:\n"; - msg += "No-Slip,\n"; - msg += "Dirichlet,\n"; - msg += "Free Slip,\n"; - msg += "Pressure Outflow,\n"; - msg += "Rotating Wall,\n"; - msg += "Laminar Flow,\n"; - msg += "Symmetry,\n"; - msg += "Cavity Lid\n"; - msg += "Velocity Wall Function\n"; - msg += "\n"; - throw std::runtime_error(msg); - } - - return state; - } -}; - -//---------------------------------------------------------------------------// - -} // end namespace BoundaryCondition -} // end namespace VertexCFD - -#endif // end VERTEXCFD_INCOMPRESSIBLEBOUNDARYSTATE_FACTORY_HPP diff --git a/src/incompressible_solver/boundary_conditions/unit_test/CMakeLists.txt b/src/incompressible_solver/boundary_conditions/unit_test/CMakeLists.txt deleted file mode 100644 index 1d1e334..0000000 --- a/src/incompressible_solver/boundary_conditions/unit_test/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -set(TEST_HARNESS_DIR ${CMAKE_SOURCE_DIR}/src/test_harness) -include(${TEST_HARNESS_DIR}/TestHarness.cmake) - -VertexCFD_add_tests( - LIBS VertexCFD - NAMES - TimeTransientIncompressibleDirichlet - IncompressibleFreeSlip - IncompressibleNoSlip - IncompressibleSymmetry - TimeTransientIncompressibleRotatingWall - IncompressiblePressureOutflow - IncompressibleBoundaryLaminarFlow - IncompressibleCavityLid - IncompressibleWallFunction - ) diff --git a/src/incompressible_solver/boundary_conditions/unit_test/doc/incompressible_cavity_flow_reference.py b/src/incompressible_solver/boundary_conditions/unit_test/doc/incompressible_cavity_flow_reference.py deleted file mode 100644 index b6d1c5e..0000000 --- a/src/incompressible_solver/boundary_conditions/unit_test/doc/incompressible_cavity_flow_reference.py +++ /dev/null @@ -1,34 +0,0 @@ -# Functions -def bc2d(y, h, U_0): - u = U_0 * pow(1.0 - pow(y / h, 18.0), 2.0) - return u, 0.0 - - -def bc3d(y, z, h, U_0): - u = U_0 * pow(1.0 - pow(y / h, 18.0), 2.0) * pow(1.0 - pow(z / h, 18.0), - 2.0) - return u, 0.0, 0.0 - - -# IC parameters -h = 1.0 -U_0 = 2.0 - -# Compute ic values in 2D -y = 0.7375 -u, v = bc2d(y, h, U_0) - -# Print ic values -print("\n2D laminar flow:") -print("u: ", u) -print("v: ", v) - -# Compute ic values in 3D -z = 0.9775 -u, v, w = bc3d(y, z, h, U_0) - -# Print ic values -print("\n3D laminar flow:") -print("u: ", u) -print("v: ", v) -print("w: ", w) diff --git a/src/incompressible_solver/boundary_conditions/unit_test/doc/incompressible_symmetry_reference.py b/src/incompressible_solver/boundary_conditions/unit_test/doc/incompressible_symmetry_reference.py deleted file mode 100644 index 4ce0ab4..0000000 --- a/src/incompressible_solver/boundary_conditions/unit_test/doc/incompressible_symmetry_reference.py +++ /dev/null @@ -1,27 +0,0 @@ -import numpy as np - -# 2D and 3D velocity gradients -grad_vel_2D = np.array([[-0.25, -0.5], [0.5, 1.0]]) -grad_vel_3D = np.array([[-0.25, -0.5, -0.125], [0.5, 1.0, 0.25], - [-0.75, -1.5, -0.375]]) - -normals = [-0.02, 0.04, -0.06] - -dim_list = [2, 3] - -for dim in dim_list: - print("Computing boundary velocity gradient in ", dim, "D\n") - - grad_vel = grad_vel_2D - if (dim == 3): - grad_vel = grad_vel_3D - - normals_dim = normals[:dim] - - for d in range(dim): - boundary_grad_u = grad_vel[d] - np.array( - np.dot(grad_vel[d], normals_dim)) * normals_dim - print("Boundary gradient of component ", d, " is: ", boundary_grad_u, - "\n") - - print("\n") diff --git a/src/incompressible_solver/boundary_conditions/unit_test/doc/incompressible_wall_function_reference.py b/src/incompressible_solver/boundary_conditions/unit_test/doc/incompressible_wall_function_reference.py deleted file mode 100644 index d2550cd..0000000 --- a/src/incompressible_solver/boundary_conditions/unit_test/doc/incompressible_wall_function_reference.py +++ /dev/null @@ -1,51 +0,0 @@ -import numpy as np - -# Wall function quantities -u_tau = 2.0 -y_plus = 13.0 -nu_t = 5.0 - -# Flow quantities -rho = 1.0 -nu = 2.5 -vel = np.array([1.0, -2.0, 3.0]) - -# 2D and 3D velocity gradients -grad_vel_2D = np.array([[-0.25, -0.5], [0.5, 1.0]]) -grad_vel_3D = np.array([[-0.25, -0.5, -0.125], [0.5, 1.0, 0.25], - [-0.75, -1.5, -0.375]]) - -grad_temp = np.array([1.0, -2.0, 3.0]) - -normals = [-0.02, 0.04, -0.06] - -dim_list = [2, 3] - -for dim in dim_list: - print("Computing boundary velocity gradient in ", dim, "D\n") - - grad_vel = grad_vel_2D - if (dim == 3): - grad_vel = grad_vel_3D - - vel_dim = vel[:dim] - grad_temp_dim = grad_temp[:dim] - normals_dim = normals[:dim] - - boundary_vel = vel_dim - np.array(np.dot(vel_dim, - normals_dim)) * normals_dim - print("Boundary velocity: ", boundary_vel) - - boundary_grad_temp = grad_temp_dim - np.array( - np.dot(grad_temp_dim, normals_dim)) * normals_dim - - print("Boundary temperature gradient: ", boundary_grad_temp) - - for d in range(dim): - boundary_grad_u = grad_vel[d] - if d == 0: - boundary_grad_u[1] = u_tau / y_plus * vel_dim[d] / rho / (nu + - nu_t) - print("Boundary gradient of component ", d, " is: ", boundary_grad_u, - "\n") - print("\n") diff --git a/src/incompressible_solver/boundary_conditions/unit_test/doc/time_dependent_incompressible_rotating_wall_reference.py b/src/incompressible_solver/boundary_conditions/unit_test/doc/time_dependent_incompressible_rotating_wall_reference.py deleted file mode 100644 index 669c6ea..0000000 --- a/src/incompressible_solver/boundary_conditions/unit_test/doc/time_dependent_incompressible_rotating_wall_reference.py +++ /dev/null @@ -1,99 +0,0 @@ -from decimal import * - -getcontext().prec = 60 -places = Decimal(10)**-16 - - -# Print value -def show(name, d): - print(name + " = ", str(d.quantize(places)).rstrip('0')) - - -# Function to calculate boundary values -def calculate_boundary_values(omega, - omega_init, - x, - y, - dim, - time, - time_init=Decimal(0.0), - time_final=Decimal(10)**-6): - # Compute time transient coefficients - if (time < time_init): time = time_init - if (time > time_final): time = time_final - - dt = time_final - time_init - a = (omega - omega_init) / dt - b = omega_init - a * time_init - - # Compute velocity components - u = -(a * time + b) * y - v = (a * time + b) * x - w = Decimal(0.0) # the z-component of the velocity is always 0.0 - - # Show values - show("u", u) - show("v", v) - if (dim == 3): show("w", w) - - -# Constant input arguments for all tests -omega = Decimal(2.0) -x = Decimal('0.7375') -y = Decimal('0.9775') - -# 2-D cases -# Steady case (no transient) -dim = 2 -print("\n2-D test case 'steady") -omega_init = omega - -time = Decimal(3.0) - -calculate_boundary_values(omega, omega_init, x, y, dim, time) - -# time > time_final (same result as steady-state case) -print("\n2-D test case 'time > time_final'") -omega_init = Decimal(1.0) - -time_init = Decimal(0.5) -time_final = Decimal(3.0) -time = Decimal(3.5) - -calculate_boundary_values(omega, omega_init, x, y, dim, time, time_init, - time_final) - -# time < time_init -print("\n2-D test case 'time < time_init'") -omega_init = Decimal(1.0) - -time_init = Decimal(0.5) -time_final = Decimal(3.0) -time = Decimal('0.2') - -calculate_boundary_values(omega, omega_init, x, y, dim, time, time_init, - time_final) - -# time_init < time < time_final -print("\n2-D test case 'time_init < time < time_final'") -omega_init = Decimal(1.0) - -time_init = Decimal(0.5) -time_final = Decimal(3.0) -time = Decimal(1.5) - -calculate_boundary_values(omega, omega_init, x, y, dim, time, time_init, - time_final) - -# 3-D case -dim = 3 -# time_init < time < time_final -print("\n3-D test case 'time_init < time < time_final'") -omega_init = Decimal(1.0) - -time_init = Decimal(0.5) -time_final = Decimal(3.0) -time = Decimal(1.5) - -calculate_boundary_values(omega, omega_init, x, y, dim, time, time_init, - time_final) diff --git a/src/incompressible_solver/boundary_conditions/unit_test/tstIncompressibleFreeSlip.cpp b/src/incompressible_solver/boundary_conditions/unit_test/tstIncompressibleFreeSlip.cpp deleted file mode 100644 index f650b33..0000000 --- a/src/incompressible_solver/boundary_conditions/unit_test/tstIncompressibleFreeSlip.cpp +++ /dev/null @@ -1,409 +0,0 @@ -#include - -#include "incompressible_solver/boundary_conditions/VertexCFD_BoundaryState_IncompressibleFreeSlip.hpp" -#include "incompressible_solver/fluid_properties/VertexCFD_ConstantFluidProperties.hpp" - -#include -#include - -//---------------------------------------------------------------------------// -// TESTS -//---------------------------------------------------------------------------// -namespace VertexCFD -{ -namespace Test -{ -//---------------------------------------------------------------------------// -// Continuity Equation cases -enum class ContinuityModel -{ - AC, - EDAC -}; -//---------------------------------------------------------------------------// -// Test data dependencies. -template -struct Dependencies : public PHX::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - using scalar_type = typename EvalType::ScalarT; - - double _phi, _u_0, _u_1, _u_2; - bool _build_temp_equ; - ContinuityModel _continuity_model; - - PHX::MDField _lagrange_pressure; - PHX::MDField _temperature; - PHX::MDField _velocity_0; - PHX::MDField _velocity_1; - PHX::MDField _velocity_2; - - PHX::MDField _normals; - - PHX::MDField - _grad_velocity_0; - PHX::MDField - _grad_velocity_1; - PHX::MDField - _grad_velocity_2; - PHX::MDField - _grad_temperature; - PHX::MDField - _grad_lagrange_pressure; - - Dependencies(const panzer::IntegrationRule& ir, - const double phi, - const double u_0, - const double u_1, - const double u_2, - const bool build_temp_equ, - const ContinuityModel continuity_model) - : _phi(phi) - , _u_0(u_0) - , _u_1(u_1) - , _u_2(u_2) - , _build_temp_equ(build_temp_equ) - , _continuity_model(continuity_model) - , _lagrange_pressure("lagrange_pressure", ir.dl_scalar) - , _temperature("temperature", ir.dl_scalar) - , _velocity_0("velocity_0", ir.dl_scalar) - , _velocity_1("velocity_1", ir.dl_scalar) - , _velocity_2("velocity_2", ir.dl_scalar) - , _normals("Side Normal", ir.dl_vector) - , _grad_velocity_0("GRAD_velocity_0", ir.dl_vector) - , _grad_velocity_1("GRAD_velocity_1", ir.dl_vector) - , _grad_velocity_2("GRAD_velocity_2", ir.dl_vector) - , _grad_temperature("GRAD_temperature", ir.dl_vector) - , _grad_lagrange_pressure("GRAD_lagrange_pressure", ir.dl_vector) - { - this->addEvaluatedField(_lagrange_pressure); - if (_build_temp_equ) - this->addEvaluatedField(_temperature); - this->addEvaluatedField(_velocity_0); - this->addEvaluatedField(_velocity_1); - this->addEvaluatedField(_velocity_2); - - this->addEvaluatedField(_normals); - - this->addEvaluatedField(_grad_velocity_0); - this->addEvaluatedField(_grad_velocity_1); - this->addEvaluatedField(_grad_velocity_2); - if (_build_temp_equ) - this->addEvaluatedField(_grad_temperature); - if (_continuity_model == ContinuityModel::EDAC) - this->addEvaluatedField(_grad_lagrange_pressure); - - this->setName("Incompressible FreeSlip Unit Test Dependencies"); - } - - void evaluateFields(typename panzer::Traits::EvalData d) override - { - // Set scalar variables - _lagrange_pressure.deep_copy(_phi); - _velocity_0.deep_copy(_u_0); - _velocity_1.deep_copy(_u_1); - _velocity_2.deep_copy(_u_2); - if (_build_temp_equ) - _temperature.deep_copy(_u_0 + _u_1); - - Kokkos::parallel_for( - "incompressible free slip test dependencies", - Kokkos::RangePolicy(0, d.num_cells), - *this); - } - - KOKKOS_INLINE_FUNCTION - void operator()(const int c) const - { - const int num_point = _lagrange_pressure.extent(1); - const int num_space_dim = _grad_velocity_0.extent(2); - for (int qp = 0; qp < num_point; ++qp) - { - // Set gradient and normal vectors - for (int d = 0; d < num_space_dim; ++d) - { - _normals(c, qp, d) = 0.01 * (d + 1) * (d * num_point + 1) - * (qp + 1); - int dqp = (qp + 1) * (d + num_point + 1); - _grad_velocity_0(c, qp, d) = _u_0 * dqp; - _grad_velocity_1(c, qp, d) = _u_1 * dqp; - _grad_velocity_2(c, qp, d) = _u_2 * dqp; - if (_build_temp_equ) - _grad_temperature(c, qp, d) = (_u_0 + _u_1) * dqp; - if (_continuity_model == ContinuityModel::EDAC) - _grad_lagrange_pressure(c, qp, d) = (_u_0 - _u_1); - } - } - } -}; - -//---------------------------------------------------------------------------// -template -void testEval(const bool build_temp_equ, const ContinuityModel continuity_model) -{ - // Test fixture - constexpr int num_space_dim = NumSpaceDim; - const int integration_order = 2; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - - std::string continuity_model_name = ""; - switch (continuity_model) - { - case (ContinuityModel::AC): - continuity_model_name = "AC"; - break; - case (ContinuityModel::EDAC): - continuity_model_name = "EDAC"; - break; - } - - // Initialize values and create dependencies - const double phi = 1.5; - const double u_0 = 2.0; - const double u_1 = 2.5; - const double u_2 - = num_space_dim == 3 ? 2.75 : std::numeric_limits::quiet_NaN(); - double vel[3] = {u_0, u_1, u_2}; - const auto dep_eval = Teuchos::rcp(new Dependencies( - *test_fixture.ir, phi, u_0, u_1, u_2, build_temp_equ, continuity_model)); - test_fixture.registerEvaluator(dep_eval); - - // Equation of state - Teuchos::ParameterList fluid_prop_list; - fluid_prop_list.set("Kinematic viscosity", 0.375); - fluid_prop_list.set("Artificial compressibility", 2.0); - fluid_prop_list.set("Build Temperature Equation", build_temp_equ); - if (build_temp_equ) - { - fluid_prop_list.set("Thermal conductivity", 0.5); - fluid_prop_list.set("Specific heat capacity", 0.6); - } - const FluidProperties::ConstantFluidProperties fluid_prop(fluid_prop_list); - - // Create free slip evaluator. - auto free_slip_eval = Teuchos::rcp( - new BoundaryCondition:: - IncompressibleFreeSlip( - *test_fixture.ir, fluid_prop, continuity_model_name)); - test_fixture.registerEvaluator(free_slip_eval); - - // Add required test fields. - test_fixture.registerTestField( - free_slip_eval->_boundary_lagrange_pressure); - for (int dim = 0; dim < num_space_dim; ++dim) - { - test_fixture.registerTestField( - free_slip_eval->_boundary_velocity[dim]); - test_fixture.registerTestField( - free_slip_eval->_boundary_grad_velocity[dim]); - } - if (continuity_model == ContinuityModel::EDAC) - { - test_fixture.registerTestField( - free_slip_eval->_boundary_grad_lagrange_pressure); - } - - // Evaluate incompressible free slip - test_fixture.evaluate(); - - // Get free slip field - auto boundary_lagrange_pressure_result - = test_fixture.getTestFieldData( - free_slip_eval->_boundary_lagrange_pressure); - - // Loop over quadrature points and mesh dimension - const int num_point = boundary_lagrange_pressure_result.extent(1); - for (int qp = 0; qp < num_point; ++qp) - { - // Lagrange pressure - EXPECT_DOUBLE_EQ(phi, - fieldValue(boundary_lagrange_pressure_result, 0, qp)); - - // Calculate velocity boundary using normal vector - const auto normals - = test_fixture.getTestFieldData(dep_eval->_normals); - const double n0 = fieldValue(normals, 0, qp, 0); - const double n1 = fieldValue(normals, 0, qp, 1); - const double n2 = num_space_dim == 3 - ? fieldValue(normals, 0, qp, 2) - : std::numeric_limits::quiet_NaN(); - - double u_dot_n = u_0 * n0 + u_1 * n1; - if (num_space_dim == 3) - u_dot_n += u_2 * n2; - const double u_bnd = u_0 - u_dot_n * n0; - const double v_bnd = u_1 - u_dot_n * n1; - const double w_bnd = num_space_dim == 3 ? u_2 - u_dot_n * n2 : 0.0; - double vel_bnd[3] = {u_bnd, v_bnd, w_bnd}; - - double grad_T_dot_n = 0.0; - if (build_temp_equ) - { - for (int d = 0; d < num_space_dim; ++d) - { - const int dqp = (qp + 1) * (d + num_point + 1); - grad_T_dot_n += (u_0 + u_1) * dqp - * fieldValue(normals, 0, qp, d); - } - } - - // Temperature - if (build_temp_equ) - { - const auto boundary_temperature_result - = test_fixture.getTestFieldData( - free_slip_eval->_boundary_temperature); - EXPECT_DOUBLE_EQ(u_0 + u_1, - fieldValue(boundary_temperature_result, 0, qp)); - } - - // Loop over mesh dimension to assert gradient vectors - for (int d = 0; d < num_space_dim; ++d) - { - const auto boundary_velocity_d_result - = test_fixture.getTestFieldData( - free_slip_eval->_boundary_velocity[d]); - EXPECT_DOUBLE_EQ(vel_bnd[d], - fieldValue(boundary_velocity_d_result, 0, qp)); - - const int dqp = (qp + 1) * (d + num_point + 1); - - for (int vel_dim = 0; vel_dim < num_space_dim; ++vel_dim) - { - const auto boundary_grad_velocity_d_result - = test_fixture.getTestFieldData( - free_slip_eval->_boundary_grad_velocity[vel_dim]); - EXPECT_DOUBLE_EQ( - vel[vel_dim] * dqp, - fieldValue(boundary_grad_velocity_d_result, 0, qp, d)); - } - if (build_temp_equ) - { - const auto grad_temp_result - = test_fixture.getTestFieldData( - dep_eval->_grad_temperature); - const double grad_temp_ref - = fieldValue(grad_temp_result, 0, qp, d) - - grad_T_dot_n * fieldValue(normals, 0, qp, d); - const auto boundary_grad_temperature_result - = test_fixture.getTestFieldData( - free_slip_eval->_boundary_grad_temperature); - EXPECT_DOUBLE_EQ( - grad_temp_ref, - fieldValue(boundary_grad_temperature_result, 0, qp, d)); - } - if (continuity_model == ContinuityModel::EDAC) - { - const double exp_val = vel[0] - vel[1]; - const auto boundary_grad_lagrange_pressure_result - = test_fixture.getTestFieldData( - free_slip_eval->_boundary_grad_lagrange_pressure); - EXPECT_DOUBLE_EQ( - exp_val, - fieldValue( - boundary_grad_lagrange_pressure_result, 0, qp, d)); - } - } - } -} - -//---------------------------------------------------------------------------// -// Value parameterized test fixture -struct EvaluationTest : public testing::TestWithParam -{ - // Case generator for parameterized test - struct ParamNameGenerator - { - std::string - operator()(const testing::TestParamInfo& info) const - { - const auto continuity_model = info.param; - switch (continuity_model) - { - case (ContinuityModel::AC): - return "AC"; - case (ContinuityModel::EDAC): - return "EDAC"; - default: - return "INVALID_NAME"; - } - } - }; -}; - -//---------------------------------------------------------------------------// -// 2-D incompressible isothermal freeSlip -TEST_P(EvaluationTest, isothermalresidual2D) -{ - ContinuityModel continuity_model; - continuity_model = GetParam(); - testEval(false, continuity_model); -} - -TEST_P(EvaluationTest, isothermaljacobian2D) -{ - ContinuityModel continuity_model; - continuity_model = GetParam(); - testEval(false, continuity_model); -} - -//---------------------------------------------------------------------------// -// 3-D incompressible isothermal freeSlip -TEST_P(EvaluationTest, isothermalresidual3D) -{ - ContinuityModel continuity_model; - continuity_model = GetParam(); - testEval(false, continuity_model); -} - -TEST_P(EvaluationTest, isothermaljacobian3D) -{ - ContinuityModel continuity_model; - continuity_model = GetParam(); - testEval(false, continuity_model); -} - -//---------------------------------------------------------------------------// -// 2-D incompressible freeSlip -TEST_P(EvaluationTest, residual2D) -{ - ContinuityModel continuity_model; - continuity_model = GetParam(); - testEval(true, continuity_model); -} - -TEST_P(EvaluationTest, jacobian2D) -{ - ContinuityModel continuity_model; - continuity_model = GetParam(); - testEval(true, continuity_model); -} - -//---------------------------------------------------------------------------// -// 3-D incompressible freeSlip -TEST_P(EvaluationTest, residual3D) -{ - ContinuityModel continuity_model; - continuity_model = GetParam(); - testEval(true, continuity_model); -} - -TEST_P(EvaluationTest, jacobian3D) -{ - ContinuityModel continuity_model; - continuity_model = GetParam(); - testEval(true, continuity_model); -} - -//---------------------------------------------------------------------------// -// Generate test suite with continuity models -INSTANTIATE_TEST_SUITE_P(ContinuityModelType, - EvaluationTest, - testing::Values(ContinuityModel::AC, - ContinuityModel::EDAC), - EvaluationTest::ParamNameGenerator{}); - -} // end namespace Test -} // end namespace VertexCFD diff --git a/src/incompressible_solver/boundary_conditions/unit_test/tstIncompressibleNoSlip.cpp b/src/incompressible_solver/boundary_conditions/unit_test/tstIncompressibleNoSlip.cpp deleted file mode 100644 index 3e27eed..0000000 --- a/src/incompressible_solver/boundary_conditions/unit_test/tstIncompressibleNoSlip.cpp +++ /dev/null @@ -1,370 +0,0 @@ -#include - -#include "incompressible_solver/boundary_conditions/VertexCFD_BoundaryState_IncompressibleNoSlip.hpp" -#include "incompressible_solver/fluid_properties/VertexCFD_ConstantFluidProperties.hpp" - -#include -#include - -//---------------------------------------------------------------------------// -// TESTS -//---------------------------------------------------------------------------// -namespace VertexCFD -{ -namespace Test -{ -//---------------------------------------------------------------------------// -// Continuity Equation cases -enum class ContinuityModel -{ - AC, - EDAC -}; -//---------------------------------------------------------------------------// -// Test data dependencies. -template -struct Dependencies : public PHX::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - using scalar_type = typename EvalType::ScalarT; - - double _phi, _u_0, _u_1, _u_2; - bool _build_tmp_equ; - ContinuityModel _continuity_model; - - PHX::MDField _lagrange_pressure; - PHX::MDField _velocity_0; - PHX::MDField _velocity_1; - PHX::MDField _velocity_2; - - PHX::MDField - _grad_velocity_0; - PHX::MDField - _grad_velocity_1; - PHX::MDField - _grad_velocity_2; - - PHX::MDField - _grad_temperature; - PHX::MDField - _grad_lagrange_pressure; - - Dependencies(const panzer::IntegrationRule& ir, - double phi, - double u_0, - double u_1, - double u_2, - const bool build_tmp_equ, - const ContinuityModel continuity_model) - : _phi(phi) - , _u_0(u_0) - , _u_1(u_1) - , _u_2(u_2) - , _build_tmp_equ(build_tmp_equ) - , _continuity_model(continuity_model) - , _lagrange_pressure("lagrange_pressure", ir.dl_scalar) - , _velocity_0("velocity_0", ir.dl_scalar) - , _velocity_1("velocity_1", ir.dl_scalar) - , _velocity_2("velocity_2", ir.dl_scalar) - , _grad_velocity_0("GRAD_velocity_0", ir.dl_vector) - , _grad_velocity_1("GRAD_velocity_1", ir.dl_vector) - , _grad_velocity_2("GRAD_velocity_2", ir.dl_vector) - , _grad_temperature("GRAD_temperature", ir.dl_vector) - , _grad_lagrange_pressure("GRAD_lagrange_pressure", ir.dl_vector) - { - this->addEvaluatedField(_lagrange_pressure); - this->addEvaluatedField(_velocity_0); - this->addEvaluatedField(_velocity_1); - this->addEvaluatedField(_velocity_2); - - this->addEvaluatedField(_grad_velocity_0); - this->addEvaluatedField(_grad_velocity_1); - this->addEvaluatedField(_grad_velocity_2); - if (build_tmp_equ) - this->addEvaluatedField(_grad_temperature); - if (_continuity_model == ContinuityModel::EDAC) - this->addEvaluatedField(_grad_lagrange_pressure); - - this->setName("Incompressible NoSlip Unit Test Dependencies"); - } - - void evaluateFields(typename panzer::Traits::EvalData d) override - { - // Set scalar variables - _lagrange_pressure.deep_copy(_phi); - _velocity_0.deep_copy(_u_0); - _velocity_1.deep_copy(_u_1); - _velocity_2.deep_copy(_u_2); - - Kokkos::parallel_for( - "incompressible no slip test dependencies", - Kokkos::RangePolicy(0, d.num_cells), - *this); - } - - KOKKOS_INLINE_FUNCTION - void operator()(const int c) const - { - const int num_point = _lagrange_pressure.extent(1); - const int num_space_dim = _grad_velocity_0.extent(2); - for (int qp = 0; qp < num_point; ++qp) - { - // Set gradient and normal vectors - for (int d = 0; d < num_space_dim; ++d) - { - const int dqp = (qp + 1) * (d + num_point + 1); - _grad_velocity_0(c, qp, d) = _u_0 * dqp; - _grad_velocity_1(c, qp, d) = _u_1 * dqp; - _grad_velocity_2(c, qp, d) = _u_2 * dqp; - if (_build_tmp_equ) - _grad_temperature(c, qp, d) = (_u_0 + _u_1) * dqp; - if (_continuity_model == ContinuityModel::EDAC) - _grad_lagrange_pressure(c, qp, d) = (_u_0 - _u_1); - } - } - } -}; - -//---------------------------------------------------------------------------// -template -void testEval(const bool build_temp_equ, const ContinuityModel continuity_model) -{ - // Test fixture - constexpr int num_space_dim = NumSpaceDim; - const int integration_order = 2; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - - std::string continuity_model_name = ""; - switch (continuity_model) - { - case (ContinuityModel::AC): - continuity_model_name = "AC"; - break; - case (ContinuityModel::EDAC): - continuity_model_name = "EDAC"; - break; - } - - // Initialize values and create dependencies - const double phi = 1.5; - const double u = 2.0; - const double v = 2.5; - const double w - = num_space_dim == 3 ? 2.75 : std::numeric_limits::quiet_NaN(); - const double vel[3] = {u, v, w}; - const double T_wall = u * v; - const auto dep_eval = Teuchos::rcp(new Dependencies( - *test_fixture.ir, phi, u, v, w, build_temp_equ, continuity_model)); - test_fixture.registerEvaluator(dep_eval); - - // Equation of state - Teuchos::ParameterList fluid_prop_list; - fluid_prop_list.set("Kinematic viscosity", 0.375); - fluid_prop_list.set("Artificial compressibility", 2.0); - fluid_prop_list.set("Build Temperature Equation", build_temp_equ); - if (build_temp_equ) - { - fluid_prop_list.set("Thermal conductivity", 0.5); - fluid_prop_list.set("Specific heat capacity", 0.6); - } - const FluidProperties::ConstantFluidProperties fluid_prop(fluid_prop_list); - - // Boundary condition - Teuchos::ParameterList bc_params; - if (build_temp_equ) - bc_params.set("Wall Temperature", T_wall); - - // Create no slip evaluator. - auto no_slip_eval = Teuchos::rcp( - new BoundaryCondition::IncompressibleNoSlip( - *test_fixture.ir, fluid_prop, bc_params, continuity_model_name)); - test_fixture.registerEvaluator(no_slip_eval); - - // Add required test fields. - test_fixture.registerTestField( - no_slip_eval->_boundary_lagrange_pressure); - for (int dim = 0; dim < num_space_dim; ++dim) - { - test_fixture.registerTestField( - no_slip_eval->_boundary_velocity[dim]); - test_fixture.registerTestField( - no_slip_eval->_boundary_grad_velocity[dim]); - } - - if (build_temp_equ) - { - test_fixture.registerTestField( - no_slip_eval->_boundary_grad_temperature); - } - - if (continuity_model == ContinuityModel::EDAC) - { - test_fixture.registerTestField( - no_slip_eval->_boundary_grad_lagrange_pressure); - } - - // Evaluate incompressible free slip - test_fixture.evaluate(); - - // Get no slip field - auto boundary_lagrange_pressure_result - = test_fixture.getTestFieldData( - no_slip_eval->_boundary_lagrange_pressure); - - // Loop over quadrature points and mesh dimension - const int num_point = boundary_lagrange_pressure_result.extent(1); - for (int qp = 0; qp < num_point; ++qp) - { - // Lagrange pressure - EXPECT_DOUBLE_EQ(phi, - fieldValue(boundary_lagrange_pressure_result, 0, qp)); - - // Loop over mesh dimension to assert velocity and gradient vectors - for (int vel_dim = 0; vel_dim < num_space_dim; ++vel_dim) - { - const auto boundary_velocity_d_result - = test_fixture.getTestFieldData( - no_slip_eval->_boundary_velocity[vel_dim]); - EXPECT_DOUBLE_EQ(0.0, - fieldValue(boundary_velocity_d_result, 0, qp)); - } - - for (int d = 0; d < num_space_dim; ++d) - { - const int dqp = (qp + 1) * (d + num_point + 1); - for (int vel_dim = 0; vel_dim < num_space_dim; ++vel_dim) - { - const auto boundary_grad_velocity_d_result - = test_fixture.getTestFieldData( - no_slip_eval->_boundary_grad_velocity[vel_dim]); - EXPECT_DOUBLE_EQ( - vel[vel_dim] * dqp, - fieldValue(boundary_grad_velocity_d_result, 0, qp, d)); - - if (build_temp_equ) - { - const auto boundary_grad_temperature_result - = test_fixture.getTestFieldData( - no_slip_eval->_boundary_grad_temperature); - EXPECT_DOUBLE_EQ( - (vel[0] + vel[1]) * dqp, - fieldValue(boundary_grad_temperature_result, 0, qp, d)); - } - - if (continuity_model == ContinuityModel::EDAC) - { - const double exp_val = vel[0] - vel[1]; - const auto boundary_grad_lagrange_pressure_result - = test_fixture.getTestFieldData( - no_slip_eval->_boundary_grad_lagrange_pressure); - EXPECT_DOUBLE_EQ( - exp_val, - fieldValue( - boundary_grad_lagrange_pressure_result, 0, qp, d)); - } - } - } - } -} - -//---------------------------------------------------------------------------// -// Value parameterized test fixture -struct EvaluationTest : public testing::TestWithParam -{ - // Case generator for parameterized test - struct ParamNameGenerator - { - std::string - operator()(const testing::TestParamInfo& info) const - { - const auto continuity_model = info.param; - switch (continuity_model) - { - case (ContinuityModel::AC): - return "AC"; - case (ContinuityModel::EDAC): - return "EDAC"; - default: - return "INVALID_NAME"; - } - } - }; -}; - -// 2-D incompressible isothermal no slip -TEST_P(EvaluationTest, isothermalresidual2D) -{ - ContinuityModel continuity_model; - continuity_model = GetParam(); - testEval(false, continuity_model); -} - -TEST_P(EvaluationTest, isothermaljacobian2D) -{ - ContinuityModel continuity_model; - continuity_model = GetParam(); - testEval(false, continuity_model); -} - -//---------------------------------------------------------------------------// -// 3-D incompressible isothermal no slip -TEST_P(EvaluationTest, isothermalresidual3D) -{ - ContinuityModel continuity_model; - continuity_model = GetParam(); - testEval(false, continuity_model); -} - -TEST_P(EvaluationTest, isothermaljacobian3D) -{ - ContinuityModel continuity_model; - continuity_model = GetParam(); - testEval(false, continuity_model); -} - -//---------------------------------------------------------------------------// -// 2-D incompressible no slip -TEST_P(EvaluationTest, residual2D) -{ - ContinuityModel continuity_model; - continuity_model = GetParam(); - testEval(true, continuity_model); -} - -TEST_P(EvaluationTest, jacobian2D) -{ - ContinuityModel continuity_model; - continuity_model = GetParam(); - testEval(true, continuity_model); -} - -//---------------------------------------------------------------------------// -// 3-D incompressible no slip -TEST_P(EvaluationTest, residual3D) -{ - ContinuityModel continuity_model; - continuity_model = GetParam(); - testEval(true, continuity_model); -} - -TEST_P(EvaluationTest, jacobian3D) -{ - ContinuityModel continuity_model; - continuity_model = GetParam(); - testEval(true, continuity_model); -} - -//---------------------------------------------------------------------------// -// Generate test suite with continuity models -INSTANTIATE_TEST_SUITE_P(ContinuityModelType, - EvaluationTest, - testing::Values(ContinuityModel::AC, - ContinuityModel::EDAC), - EvaluationTest::ParamNameGenerator{}); - -} // end namespace Test -} // end namespace VertexCFD diff --git a/src/incompressible_solver/boundary_conditions/unit_test/tstIncompressiblePressureOutflow.cpp b/src/incompressible_solver/boundary_conditions/unit_test/tstIncompressiblePressureOutflow.cpp deleted file mode 100644 index 3bf3dc5..0000000 --- a/src/incompressible_solver/boundary_conditions/unit_test/tstIncompressiblePressureOutflow.cpp +++ /dev/null @@ -1,359 +0,0 @@ -#include "incompressible_solver/boundary_conditions/VertexCFD_BoundaryState_IncompressiblePressureOutflow.hpp" -#include "incompressible_solver/fluid_properties/VertexCFD_ConstantFluidProperties.hpp" -#include - -#include -#include - -#include -#include -#include - -#include - -#include - -//---------------------------------------------------------------------------// -// TESTS -//---------------------------------------------------------------------------// -namespace VertexCFD -{ -namespace Test -{ -//---------------------------------------------------------------------------// -// Continuity Equation cases -enum class ContinuityModel -{ - AC, - EDAC -}; -//---------------------------------------------------------------------------// -// Test data dependencies. -template -struct Dependencies : public PHX::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - using scalar_type = typename EvalType::ScalarT; - - double _u0, _u1, _u2; - bool _build_tmp_equ; - ContinuityModel _continuity_model; - - PHX::MDField _velocity_0; - PHX::MDField _velocity_1; - PHX::MDField _velocity_2; - PHX::MDField _temperature; - PHX::MDField - _grad_velocity_0; - PHX::MDField - _grad_velocity_1; - PHX::MDField - _grad_velocity_2; - PHX::MDField - _grad_temperature; - PHX::MDField - _grad_lagrange_pressure; - - Dependencies(const panzer::IntegrationRule& ir, - const double u0, - const double u1, - const double u2, - const bool build_tmp_equ, - const ContinuityModel continuity_model) - : _u0(u0) - , _u1(u1) - , _u2(u2) - , _build_tmp_equ(build_tmp_equ) - , _continuity_model(continuity_model) - , _velocity_0("velocity_0", ir.dl_scalar) - , _velocity_1("velocity_1", ir.dl_scalar) - , _velocity_2("velocity_2", ir.dl_scalar) - , _temperature("temperature", ir.dl_scalar) - , _grad_velocity_0("GRAD_velocity_0", ir.dl_vector) - , _grad_velocity_1("GRAD_velocity_1", ir.dl_vector) - , _grad_velocity_2("GRAD_velocity_2", ir.dl_vector) - , _grad_temperature("GRAD_temperature", ir.dl_vector) - , _grad_lagrange_pressure("GRAD_lagrange_pressure", ir.dl_vector) - { - this->addEvaluatedField(_velocity_0); - this->addEvaluatedField(_velocity_1); - this->addEvaluatedField(_velocity_2); - if (_build_tmp_equ) - this->addEvaluatedField(_temperature); - this->addEvaluatedField(_grad_velocity_0); - this->addEvaluatedField(_grad_velocity_1); - this->addEvaluatedField(_grad_velocity_2); - if (_build_tmp_equ) - this->addEvaluatedField(_grad_temperature); - if (_continuity_model == ContinuityModel::EDAC) - this->addEvaluatedField(_grad_lagrange_pressure); - this->setName( - "Incompressible pressure outflow Unit Test Dependencies"); - } - - void evaluateFields(typename panzer::Traits::EvalData /**d**/) override - { - _velocity_0.deep_copy(_u0); - _velocity_1.deep_copy(_u1); - _velocity_2.deep_copy(_u2); - if (_build_tmp_equ) - _temperature.deep_copy(_u0 + _u1); - _grad_velocity_0.deep_copy(_u0 * _u0); - _grad_velocity_1.deep_copy(_u1 * _u1); - _grad_velocity_2.deep_copy(_u2 * _u2); - if (_build_tmp_equ) - _grad_temperature.deep_copy(_u0 - _u1); - if (_continuity_model == ContinuityModel::EDAC) - _grad_lagrange_pressure.deep_copy(_u0 - _u1); - } -}; - -//---------------------------------------------------------------------------// -template -void testEval(const bool build_temp_equ, const ContinuityModel continuity_model) -{ - // Test fixture - constexpr int num_space_dim = NumSpaceDim; - const int num_grad_dim = 2; - const int integration_order = 2; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_grad_dim, integration_order, basis_order); - - std::string continuity_model_name = ""; - switch (continuity_model) - { - case (ContinuityModel::AC): - continuity_model_name = "AC"; - break; - case (ContinuityModel::EDAC): - continuity_model_name = "EDAC"; - break; - } - - // Create dependencies - double nanval = std::numeric_limits::quiet_NaN(); - const double phi = 0.1; - const double u0 = 0.2; - const double u1 = 0.3; - const double u2 = num_space_dim == 3 ? 0.4 : nanval; - const double vel[3] = {u0, u1, u2}; - - const auto dep_eval = Teuchos::rcp(new Dependencies( - *test_fixture.ir, u0, u1, u2, build_temp_equ, continuity_model)); - test_fixture.registerEvaluator(dep_eval); - - // Equation of state - Teuchos::ParameterList fluid_prop_list; - fluid_prop_list.set("Kinematic viscosity", 0.375); - fluid_prop_list.set("Artificial compressibility", 2.0); - fluid_prop_list.set("Build Temperature Equation", build_temp_equ); - if (build_temp_equ) - { - fluid_prop_list.set("Thermal conductivity", 0.5); - fluid_prop_list.set("Specific heat capacity", 0.6); - } - const FluidProperties::ConstantFluidProperties fluid_prop(fluid_prop_list); - - // Create the param list to initialize the evaluator - Teuchos::ParameterList bc_params; - bc_params.set("Back Pressure", phi); - - // Create evaluator. - auto press_eval = Teuchos::rcp( - new BoundaryCondition::IncompressiblePressureOutflow( - *test_fixture.ir, fluid_prop, bc_params, continuity_model_name)); - test_fixture.registerEvaluator(press_eval); - - // Add required test fields. - test_fixture.registerTestField( - press_eval->_boundary_lagrange_pressure); - for (int vel_dim = 0; vel_dim < num_space_dim; ++vel_dim) - { - test_fixture.registerTestField( - press_eval->_boundary_velocity[vel_dim]); - test_fixture.registerTestField( - press_eval->_boundary_grad_velocity[vel_dim]); - } - if (build_temp_equ) - { - test_fixture.registerTestField( - press_eval->_boundary_temperature); - test_fixture.registerTestField( - press_eval->_boundary_grad_temperature); - } - if (continuity_model == ContinuityModel::EDAC) - { - test_fixture.registerTestField( - press_eval->_boundary_grad_lagrange_pressure); - } - - // Evaluate boundary values. - test_fixture.evaluate(); - - // Check boundary values. - const auto boundary_phi_result = test_fixture.getTestFieldData( - press_eval->_boundary_lagrange_pressure); - - const int num_point = boundary_phi_result.extent(1); - - for (int qp = 0; qp < num_point; ++qp) - { - EXPECT_DOUBLE_EQ(phi, fieldValue(boundary_phi_result, 0, qp)); - for (int vel_dim = 0; vel_dim < num_space_dim; ++vel_dim) - { - const auto boundary_velocity_d_result - = test_fixture.getTestFieldData( - press_eval->_boundary_velocity[vel_dim]); - EXPECT_DOUBLE_EQ(vel[vel_dim], - fieldValue(boundary_velocity_d_result, 0, qp)); - } - - if (build_temp_equ) - { - const auto boundary_temperature_result - = test_fixture.getTestFieldData( - press_eval->_boundary_temperature); - EXPECT_DOUBLE_EQ(vel[0] + vel[1], - fieldValue(boundary_temperature_result, 0, qp)); - } - - for (int d = 0; d < num_grad_dim; ++d) - { - for (int vel_dim = 0; vel_dim < num_space_dim; ++vel_dim) - { - const double exp_val = vel[vel_dim] * vel[vel_dim]; - const auto boundary_grad_velocity_d_result - = test_fixture.getTestFieldData( - press_eval->_boundary_grad_velocity[vel_dim]); - EXPECT_DOUBLE_EQ( - exp_val, - fieldValue(boundary_grad_velocity_d_result, 0, qp, d)); - } - - if (build_temp_equ) - { - const double exp_val = vel[0] - vel[1]; - const auto boundary_grad_temperature_result - = test_fixture.getTestFieldData( - press_eval->_boundary_grad_temperature); - EXPECT_DOUBLE_EQ( - exp_val, - fieldValue(boundary_grad_temperature_result, 0, qp, d)); - } - - if (continuity_model == ContinuityModel::EDAC) - { - const double exp_val = vel[0] - vel[1]; - const auto boundary_grad_lagrange_pressure_result - = test_fixture.getTestFieldData( - press_eval->_boundary_grad_lagrange_pressure); - EXPECT_DOUBLE_EQ( - exp_val, - fieldValue( - boundary_grad_lagrange_pressure_result, 0, qp, d)); - } - } - } -} - -//---------------------------------------------------------------------------// -// Value parameterized test fixture -struct EvaluationTest : public testing::TestWithParam -{ - // Case generator for parameterized test - struct ParamNameGenerator - { - std::string - operator()(const testing::TestParamInfo& info) const - { - const auto continuity_model = info.param; - switch (continuity_model) - { - case (ContinuityModel::AC): - return "AC"; - case (ContinuityModel::EDAC): - return "EDAC"; - default: - return "INVALID_NAME"; - } - } - }; -}; - -//---------------------------------------------------------------------------// -// 2-D incompressible isothermal pressure outflow -TEST_P(EvaluationTest, isothermalresidual2D) -{ - ContinuityModel continuity_model; - continuity_model = GetParam(); - testEval(false, continuity_model); -} - -TEST_P(EvaluationTest, isothermaljacobian2D) -{ - ContinuityModel continuity_model; - continuity_model = GetParam(); - testEval(false, continuity_model); -} - -//---------------------------------------------------------------------------// -// 3-D incompressible isothermal pressure outflow -TEST_P(EvaluationTest, isothermalresidual3D) -{ - ContinuityModel continuity_model; - continuity_model = GetParam(); - testEval(false, continuity_model); -} - -TEST_P(EvaluationTest, isothermaljacobian3D) -{ - ContinuityModel continuity_model; - continuity_model = GetParam(); - testEval(false, continuity_model); -} - -//---------------------------------------------------------------------------// -// 2-D incompressible pressure outflow -TEST_P(EvaluationTest, residual2D) -{ - ContinuityModel continuity_model; - continuity_model = GetParam(); - testEval(true, continuity_model); -} - -TEST_P(EvaluationTest, jacobian2D) -{ - ContinuityModel continuity_model; - continuity_model = GetParam(); - testEval(true, continuity_model); -} - -//---------------------------------------------------------------------------// -// 3-D incompressible pressure outflow -TEST_P(EvaluationTest, residual3D) -{ - ContinuityModel continuity_model; - continuity_model = GetParam(); - testEval(true, continuity_model); -} - -TEST_P(EvaluationTest, jacobian3D) -{ - ContinuityModel continuity_model; - continuity_model = GetParam(); - testEval(true, continuity_model); -} - -//---------------------------------------------------------------------------// -// Generate test suite with continuity models -INSTANTIATE_TEST_SUITE_P(ContinuityModelType, - EvaluationTest, - testing::Values(ContinuityModel::AC, - ContinuityModel::EDAC), - EvaluationTest::ParamNameGenerator{}); - -} // end namespace Test -} // end namespace VertexCFD diff --git a/src/incompressible_solver/boundary_conditions/unit_test/tstIncompressibleSymmetry.cpp b/src/incompressible_solver/boundary_conditions/unit_test/tstIncompressibleSymmetry.cpp deleted file mode 100644 index 2ec9c56..0000000 --- a/src/incompressible_solver/boundary_conditions/unit_test/tstIncompressibleSymmetry.cpp +++ /dev/null @@ -1,438 +0,0 @@ -#include - -#include "incompressible_solver/boundary_conditions/VertexCFD_BoundaryState_IncompressibleSymmetry.hpp" -#include "incompressible_solver/fluid_properties/VertexCFD_ConstantFluidProperties.hpp" - -#include -#include - -//---------------------------------------------------------------------------// -// TESTS -//---------------------------------------------------------------------------// -namespace VertexCFD -{ -namespace Test -{ -//---------------------------------------------------------------------------// -// Continuity Equation cases -enum class ContinuityModel -{ - AC, - EDAC -}; -//---------------------------------------------------------------------------// -// Test data dependencies. -template -struct Dependencies : public PHX::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - using scalar_type = typename EvalType::ScalarT; - - double _phi, _u_0, _u_1, _u_2; - bool _build_temp_equ; - ContinuityModel _continuity_model; - - PHX::MDField _lagrange_pressure; - PHX::MDField _temperature; - PHX::MDField _velocity_0; - PHX::MDField _velocity_1; - PHX::MDField _velocity_2; - - PHX::MDField _normals; - - PHX::MDField - _grad_velocity_0; - PHX::MDField - _grad_velocity_1; - PHX::MDField - _grad_velocity_2; - PHX::MDField - _grad_temperature; - PHX::MDField - _grad_lagrange_pressure; - - Dependencies(const panzer::IntegrationRule& ir, - const double phi, - const double u_0, - const double u_1, - const double u_2, - const bool build_temp_equ, - const ContinuityModel continuity_model) - : _phi(phi) - , _u_0(u_0) - , _u_1(u_1) - , _u_2(u_2) - , _build_temp_equ(build_temp_equ) - , _continuity_model(continuity_model) - , _lagrange_pressure("lagrange_pressure", ir.dl_scalar) - , _temperature("temperature", ir.dl_scalar) - , _velocity_0("velocity_0", ir.dl_scalar) - , _velocity_1("velocity_1", ir.dl_scalar) - , _velocity_2("velocity_2", ir.dl_scalar) - , _normals("Side Normal", ir.dl_vector) - , _grad_velocity_0("GRAD_velocity_0", ir.dl_vector) - , _grad_velocity_1("GRAD_velocity_1", ir.dl_vector) - , _grad_velocity_2("GRAD_velocity_2", ir.dl_vector) - , _grad_temperature("GRAD_temperature", ir.dl_vector) - , _grad_lagrange_pressure("GRAD_lagrange_pressure", ir.dl_vector) - { - this->addEvaluatedField(_lagrange_pressure); - if (_build_temp_equ) - this->addEvaluatedField(_temperature); - this->addEvaluatedField(_velocity_0); - this->addEvaluatedField(_velocity_1); - this->addEvaluatedField(_velocity_2); - - this->addEvaluatedField(_normals); - - this->addEvaluatedField(_grad_velocity_0); - this->addEvaluatedField(_grad_velocity_1); - this->addEvaluatedField(_grad_velocity_2); - if (_build_temp_equ) - this->addEvaluatedField(_grad_temperature); - if (_continuity_model == ContinuityModel::EDAC) - this->addEvaluatedField(_grad_lagrange_pressure); - - this->setName("Incompressible Symmetry Unit Test Dependencies"); - } - - void evaluateFields(typename panzer::Traits::EvalData d) override - { - // Set scalar variables - _lagrange_pressure.deep_copy(_phi); - _velocity_0.deep_copy(_u_0); - _velocity_1.deep_copy(_u_1); - _velocity_2.deep_copy(_u_2); - if (_build_temp_equ) - _temperature.deep_copy(_u_0 + _u_1); - - Kokkos::parallel_for( - "incompressible free slip test dependencies", - Kokkos::RangePolicy(0, d.num_cells), - *this); - } - - KOKKOS_INLINE_FUNCTION - void operator()(const int c) const - { - const int num_point = _lagrange_pressure.extent(1); - const int num_space_dim = _grad_velocity_0.extent(2); - - using std::pow; - - for (int qp = 0; qp < num_point; ++qp) - { - // Set gradient and normal vectors - for (int d = 0; d < num_space_dim; ++d) - { - const int dimqp = (d + 1) * pow(-1, d + 1); - - _normals(c, qp, d) = 0.02 * dimqp; - - _grad_velocity_0(c, qp, d) = 0.250 * dimqp; - _grad_velocity_1(c, qp, d) = 0.500 * dimqp; - _grad_velocity_2(c, qp, d) = 0.125 * dimqp; - - if (_build_temp_equ) - _grad_temperature(c, qp, d) = (_u_0 + _u_1) * dimqp; - if (_continuity_model == ContinuityModel::EDAC) - _grad_lagrange_pressure(c, qp, d) = (_u_0 - _u_1); - } - } - } -}; - -//---------------------------------------------------------------------------// -template -void testEval(const bool build_temp_equ, const ContinuityModel continuity_model) -{ - // Test fixture - constexpr int num_space_dim = NumSpaceDim; - const int integration_order = 2; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - - std::string continuity_model_name = ""; - switch (continuity_model) - { - case (ContinuityModel::AC): - continuity_model_name = "AC"; - break; - case (ContinuityModel::EDAC): - continuity_model_name = "EDAC"; - break; - } - - // Initialize values and create dependencies - const double _nanval = std::numeric_limits::quiet_NaN(); - const double phi = 1.5; - const double u_0 = 2.0; - const double u_1 = 2.5; - const double u_2 = num_space_dim == 3 ? 2.75 : _nanval; - const auto dep_eval = Teuchos::rcp(new Dependencies( - *test_fixture.ir, phi, u_0, u_1, u_2, build_temp_equ, continuity_model)); - test_fixture.registerEvaluator(dep_eval); - - // Equation of state - Teuchos::ParameterList fluid_prop_list; - fluid_prop_list.set("Kinematic viscosity", 0.375); - fluid_prop_list.set("Artificial compressibility", 2.0); - fluid_prop_list.set("Build Temperature Equation", build_temp_equ); - if (build_temp_equ) - { - fluid_prop_list.set("Thermal conductivity", 0.5); - fluid_prop_list.set("Specific heat capacity", 0.6); - } - const FluidProperties::ConstantFluidProperties fluid_prop(fluid_prop_list); - - // Create symmetry evaluator. - auto symm_eval = Teuchos::rcp( - new BoundaryCondition:: - IncompressibleSymmetry( - *test_fixture.ir, fluid_prop, continuity_model_name)); - test_fixture.registerEvaluator(symm_eval); - - // Add required test fields. - test_fixture.registerTestField( - symm_eval->_boundary_lagrange_pressure); - for (int dim = 0; dim < num_space_dim; ++dim) - { - test_fixture.registerTestField( - symm_eval->_boundary_velocity[dim]); - test_fixture.registerTestField( - symm_eval->_boundary_grad_velocity[dim]); - } - - if (build_temp_equ) - { - test_fixture.registerTestField( - symm_eval->_boundary_temperature); - test_fixture.registerTestField( - symm_eval->_boundary_grad_temperature); - } - - if (continuity_model == ContinuityModel::EDAC) - { - test_fixture.registerTestField( - symm_eval->_boundary_grad_lagrange_pressure); - } - - // Evaluate incompressible symmetry - test_fixture.evaluate(); - - // Get symmetry field - auto boundary_lagrange_pressure_result - = test_fixture.getTestFieldData( - symm_eval->_boundary_lagrange_pressure); - - // Create expected velocity gradient - const double grad_u_2D[3] = {-0.2495, -0.499, _nanval}; - const double grad_u_3D[3] = {-0.2486, -0.4972, -0.1243}; - const double* grad_u = (num_space_dim == 3) ? grad_u_3D : grad_u_2D; - - const double grad_v_2D[3] = {0.499, 0.998, _nanval}; - const double grad_v_3D[3] = {0.4972, 0.9944, 0.2486}; - const double* grad_v = (num_space_dim == 3) ? grad_v_3D : grad_v_2D; - - const double grad_w_2D[3] = {_nanval, _nanval, _nanval}; - const double grad_w_3D[3] = {-0.7458, -1.4916, -0.3729}; - const double* grad_w = (num_space_dim == 3) ? grad_w_3D : grad_w_2D; - - const double* grad_vel[3] = {grad_u, grad_v, grad_w}; - - // Loop over quadrature points and mesh dimension - const int num_point = boundary_lagrange_pressure_result.extent(1); - for (int qp = 0; qp < num_point; ++qp) - { - // Lagrange pressure - EXPECT_DOUBLE_EQ(phi, - fieldValue(boundary_lagrange_pressure_result, 0, qp)); - - // Calculate velocity boundary using normal vector - const auto normals - = test_fixture.getTestFieldData(dep_eval->_normals); - const double n0 = fieldValue(normals, 0, qp, 0); - const double n1 = fieldValue(normals, 0, qp, 1); - const double n2 = num_space_dim == 3 - ? fieldValue(normals, 0, qp, 2) - : std::numeric_limits::quiet_NaN(); - - double u_dot_n = u_0 * n0 + u_1 * n1; - if (num_space_dim == 3) - u_dot_n += u_2 * n2; - const double u_bnd = u_0 - u_dot_n * n0; - const double v_bnd = u_1 - u_dot_n * n1; - const double w_bnd = num_space_dim == 3 ? u_2 - u_dot_n * n2 : 0.0; - double vel_bnd[3] = {u_bnd, v_bnd, w_bnd}; - - double grad_T_dot_n = 0.0; - if (build_temp_equ) - { - for (int d = 0; d < num_space_dim; ++d) - { - const int dqp = (d + 1) * std::pow(-1, d + 1); - grad_T_dot_n += (u_0 + u_1) * dqp - * fieldValue(normals, 0, qp, d); - } - } - - // Temperature - if (build_temp_equ) - { - const auto boundary_temperature_result - = test_fixture.getTestFieldData( - symm_eval->_boundary_temperature); - EXPECT_DOUBLE_EQ(u_0 + u_1, - fieldValue(boundary_temperature_result, 0, qp)); - } - - // Loop over mesh dimension to assert gradient vectors - for (int d = 0; d < num_space_dim; ++d) - { - const auto boundary_velocity_d_result - = test_fixture.getTestFieldData( - symm_eval->_boundary_velocity[d]); - EXPECT_DOUBLE_EQ(vel_bnd[d], - fieldValue(boundary_velocity_d_result, 0, qp)); - - for (int vel_dim = 0; vel_dim < num_space_dim; ++vel_dim) - { - const auto boundary_grad_velocity_d_result - = test_fixture.getTestFieldData( - symm_eval->_boundary_grad_velocity[vel_dim]); - - EXPECT_DOUBLE_EQ( - grad_vel[d][vel_dim], - fieldValue(boundary_grad_velocity_d_result, 0, qp, d)); - } - - if (build_temp_equ) - { - const auto grad_temp_result - = test_fixture.getTestFieldData( - dep_eval->_grad_temperature); - const double grad_temp_ref - = fieldValue(grad_temp_result, 0, qp, d) - - grad_T_dot_n * fieldValue(normals, 0, qp, d); - const auto boundary_grad_temperature_result - = test_fixture.getTestFieldData( - symm_eval->_boundary_grad_temperature); - EXPECT_DOUBLE_EQ( - grad_temp_ref, - fieldValue(boundary_grad_temperature_result, 0, qp, d)); - } - - if (continuity_model == ContinuityModel::EDAC) - { - const double exp_val = u_0 - u_1; - const auto boundary_grad_lagrange_pressure_result - = test_fixture.getTestFieldData( - symm_eval->_boundary_grad_lagrange_pressure); - EXPECT_DOUBLE_EQ( - exp_val, - fieldValue( - boundary_grad_lagrange_pressure_result, 0, qp, d)); - } - } - } -} - -//---------------------------------------------------------------------------// -// Value parameterized test fixture -struct EvaluationTest : public testing::TestWithParam -{ - // Case generator for parameterized test - struct ParamNameGenerator - { - std::string - operator()(const testing::TestParamInfo& info) const - { - const auto continuity_model = info.param; - switch (continuity_model) - { - case (ContinuityModel::AC): - return "AC"; - case (ContinuityModel::EDAC): - return "EDAC"; - default: - return "INVALID_NAME"; - } - } - }; -}; - -//---------------------------------------------------------------------------// -// 2-D incompressible isothermal symmetry -TEST_P(EvaluationTest, isothermalresidual2D) -{ - ContinuityModel continuity_model; - continuity_model = GetParam(); - testEval(false, continuity_model); -} - -TEST_P(EvaluationTest, isothermaljacobian2D) -{ - ContinuityModel continuity_model; - continuity_model = GetParam(); - testEval(false, continuity_model); -} - -//---------------------------------------------------------------------------// -// 3-D incompressible isothermal symmetry -TEST_P(EvaluationTest, isothermalresidual3D) -{ - ContinuityModel continuity_model; - continuity_model = GetParam(); - testEval(false, continuity_model); -} - -TEST_P(EvaluationTest, isothermaljacobian3D) -{ - ContinuityModel continuity_model; - continuity_model = GetParam(); - testEval(false, continuity_model); -} - -//---------------------------------------------------------------------------// -// 2-D incompressible symmetry -TEST_P(EvaluationTest, residual2D) -{ - ContinuityModel continuity_model; - continuity_model = GetParam(); - testEval(true, continuity_model); -} - -TEST_P(EvaluationTest, jacobian2D) -{ - ContinuityModel continuity_model; - continuity_model = GetParam(); - testEval(true, continuity_model); -} - -//---------------------------------------------------------------------------// -// 3-D incompressible symmetry -TEST_P(EvaluationTest, residual3D) -{ - ContinuityModel continuity_model; - continuity_model = GetParam(); - testEval(true, continuity_model); -} - -TEST_P(EvaluationTest, jacobian3D) -{ - ContinuityModel continuity_model; - continuity_model = GetParam(); - testEval(true, continuity_model); -} - -//---------------------------------------------------------------------------// -// Generate test suite with continuity models -INSTANTIATE_TEST_SUITE_P(ContinuityModelType, - EvaluationTest, - testing::Values(ContinuityModel::AC, - ContinuityModel::EDAC), - EvaluationTest::ParamNameGenerator{}); - -} // end namespace Test -} // end namespace VertexCFD diff --git a/src/incompressible_solver/boundary_conditions/unit_test/tstIncompressibleWallFunction.cpp b/src/incompressible_solver/boundary_conditions/unit_test/tstIncompressibleWallFunction.cpp deleted file mode 100644 index 8049c8b..0000000 --- a/src/incompressible_solver/boundary_conditions/unit_test/tstIncompressibleWallFunction.cpp +++ /dev/null @@ -1,424 +0,0 @@ -#include "VertexCFD_EvaluatorTestHarness.hpp" - -#include "incompressible_solver/boundary_conditions/VertexCFD_BoundaryState_IncompressibleWallFunction.hpp" -#include "incompressible_solver/fluid_properties/VertexCFD_ConstantFluidProperties.hpp" - -#include -#include - -//---------------------------------------------------------------------------// -// TESTS -//---------------------------------------------------------------------------// -namespace VertexCFD -{ -namespace Test -{ -//---------------------------------------------------------------------------// -// Continuity Equation cases -enum class ContinuityModel -{ - AC, - EDAC -}; -//---------------------------------------------------------------------------// -// Test data dependencies. -template -struct Dependencies : public PHX::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - using scalar_type = typename EvalType::ScalarT; - - double _phi, _u_0, _u_1, _u_2; - bool _build_temp_equ; - ContinuityModel _continuity_model; - - PHX::MDField _lagrange_pressure; - PHX::MDField _temperature; - PHX::MDField _velocity_0; - PHX::MDField _velocity_1; - PHX::MDField _velocity_2; - - PHX::MDField _boundary_u_tau; - PHX::MDField _boundary_y_plus; - PHX::MDField _boundary_nu_t; - - PHX::MDField _normals; - - PHX::MDField - _grad_velocity_0; - PHX::MDField - _grad_velocity_1; - PHX::MDField - _grad_velocity_2; - PHX::MDField - _grad_temperature; - PHX::MDField - _grad_lagrange_pressure; - - Dependencies(const panzer::IntegrationRule& ir, - const double phi, - const double u_0, - const double u_1, - const double u_2, - const bool build_temp_equ, - const ContinuityModel continuity_model) - : _phi(phi) - , _u_0(u_0) - , _u_1(u_1) - , _u_2(u_2) - , _build_temp_equ(build_temp_equ) - , _continuity_model(continuity_model) - , _lagrange_pressure("lagrange_pressure", ir.dl_scalar) - , _temperature("temperature", ir.dl_scalar) - , _velocity_0("velocity_0", ir.dl_scalar) - , _velocity_1("velocity_1", ir.dl_scalar) - , _velocity_2("velocity_2", ir.dl_scalar) - , _boundary_u_tau("BOUNDARY_friction_velocity", ir.dl_scalar) - , _boundary_y_plus("BOUNDARY_y_plus", ir.dl_scalar) - , _boundary_nu_t("BOUNDARY_turbulent_eddy_viscosity", ir.dl_scalar) - , _normals("Side Normal", ir.dl_vector) - , _grad_velocity_0("GRAD_velocity_0", ir.dl_vector) - , _grad_velocity_1("GRAD_velocity_1", ir.dl_vector) - , _grad_velocity_2("GRAD_velocity_2", ir.dl_vector) - , _grad_temperature("GRAD_temperature", ir.dl_vector) - , _grad_lagrange_pressure("GRAD_lagrange_pressure", ir.dl_vector) - { - this->addEvaluatedField(_lagrange_pressure); - if (_build_temp_equ) - this->addEvaluatedField(_temperature); - this->addEvaluatedField(_velocity_0); - this->addEvaluatedField(_velocity_1); - this->addEvaluatedField(_velocity_2); - this->addEvaluatedField(_boundary_u_tau); - this->addEvaluatedField(_boundary_y_plus); - this->addEvaluatedField(_boundary_nu_t); - - this->addEvaluatedField(_normals); - - this->addEvaluatedField(_grad_velocity_0); - this->addEvaluatedField(_grad_velocity_1); - this->addEvaluatedField(_grad_velocity_2); - if (_build_temp_equ) - this->addEvaluatedField(_grad_temperature); - if (_continuity_model == ContinuityModel::EDAC) - this->addEvaluatedField(_grad_lagrange_pressure); - - this->setName("Incompressible Wall Function Unit Test Dependencies"); - } - - void evaluateFields(typename panzer::Traits::EvalData d) override - { - // Set scalar variables - _lagrange_pressure.deep_copy(_phi); - _velocity_0.deep_copy(_u_0); - _velocity_1.deep_copy(_u_1); - _velocity_2.deep_copy(_u_2); - _boundary_u_tau.deep_copy(2.0); - _boundary_y_plus.deep_copy(13.0); - _boundary_nu_t.deep_copy(5.0); - if (_build_temp_equ) - _temperature.deep_copy(_u_0 + _u_1); - - Kokkos::parallel_for( - "incompressible wall function test dependencies", - Kokkos::RangePolicy(0, d.num_cells), - *this); - } - - KOKKOS_INLINE_FUNCTION - void operator()(const int c) const - { - const int num_point = _lagrange_pressure.extent(1); - const int num_space_dim = _grad_velocity_0.extent(2); - - using std::pow; - - for (int qp = 0; qp < num_point; ++qp) - { - // Set gradient and normal vectors - for (int d = 0; d < num_space_dim; ++d) - { - const int dimqp = (d + 1) * pow(-1, d + 1); - - _normals(c, qp, d) = 0.02 * dimqp; - - _grad_velocity_0(c, qp, d) = 0.250 * dimqp; - _grad_velocity_1(c, qp, d) = 0.500 * dimqp; - _grad_velocity_2(c, qp, d) = 0.125 * dimqp; - - if (_build_temp_equ) - _grad_temperature(c, qp, d) = (_u_0 + _u_1) * dimqp; - if (_continuity_model == ContinuityModel::EDAC) - _grad_lagrange_pressure(c, qp, d) = (_u_0 - _u_1); - } - } - } -}; - -//---------------------------------------------------------------------------// -template -void testEval(const bool build_temp_equ, const ContinuityModel continuity_model) -{ - // Test fixture - constexpr int num_space_dim = NumSpaceDim; - const int integration_order = 2; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - - std::string continuity_model_name = ""; - switch (continuity_model) - { - case (ContinuityModel::AC): - continuity_model_name = "AC"; - break; - case (ContinuityModel::EDAC): - continuity_model_name = "EDAC"; - break; - } - - // Initialize values and create dependencies - const double _nanval = std::numeric_limits::quiet_NaN(); - const double phi = 1.5; - const double u_0 = 1.0; - const double u_1 = -2.0; - const double u_2 = num_space_dim == 3 ? 3.0 : _nanval; - const auto dep_eval = Teuchos::rcp(new Dependencies( - *test_fixture.ir, phi, u_0, u_1, u_2, build_temp_equ, continuity_model)); - test_fixture.registerEvaluator(dep_eval); - - // Equation of state - Teuchos::ParameterList fluid_prop_list; - fluid_prop_list.set("Kinematic viscosity", 2.5); - fluid_prop_list.set("Artificial compressibility", 2.0); - fluid_prop_list.set("Build Temperature Equation", build_temp_equ); - if (build_temp_equ) - { - fluid_prop_list.set("Thermal conductivity", 0.5); - fluid_prop_list.set("Specific heat capacity", 0.6); - } - const FluidProperties::ConstantFluidProperties fluid_prop(fluid_prop_list); - - // Create wall function evaluator. - const auto wf_eval = Teuchos::rcp( - new BoundaryCondition:: - IncompressibleWallFunction( - *test_fixture.ir, fluid_prop, continuity_model_name)); - test_fixture.registerEvaluator(wf_eval); - - // Add required test fields. - test_fixture.registerTestField( - wf_eval->_boundary_lagrange_pressure); - for (int dim = 0; dim < num_space_dim; ++dim) - { - test_fixture.registerTestField( - wf_eval->_boundary_velocity[dim]); - test_fixture.registerTestField( - wf_eval->_boundary_grad_velocity[dim]); - } - - if (build_temp_equ) - { - test_fixture.registerTestField( - wf_eval->_boundary_temperature); - test_fixture.registerTestField( - wf_eval->_boundary_grad_temperature); - } - - if (continuity_model == ContinuityModel::EDAC) - { - test_fixture.registerTestField( - wf_eval->_boundary_grad_lagrange_pressure); - } - - // Evaluate incompressible wall function - test_fixture.evaluate(); - - // Get wall function field - auto boundary_lagrange_pressure_result - = test_fixture.getTestFieldData( - wf_eval->_boundary_lagrange_pressure); - - // Create expected velocity gradient - const double grad_u_2D[3] = {-0.25, 0.020512820512820513, _nanval}; - const double grad_u_3D[3] = {-0.25, 0.020512820512820513, -0.75}; - const double* grad_u = (num_space_dim == 3) ? grad_u_3D : grad_u_2D; - - const double grad_v_2D[3] = {-0.5, 1.0, _nanval}; - const double grad_v_3D[3] = {-0.5, 1.0, -1.5}; - const double* grad_v = (num_space_dim == 3) ? grad_v_3D : grad_v_2D; - - const double grad_w_2D[3] = {_nanval, _nanval, _nanval}; - const double grad_w_3D[3] = {-0.125, 0.25, -0.375}; - const double* grad_w = (num_space_dim == 3) ? grad_w_3D : grad_w_2D; - - const double* grad_vel[3] = {grad_u, grad_v, grad_w}; - - const double grad_temp_2D[3] = {0.998, -1.996, _nanval}; - const double grad_temp_3D[3] = {0.9944, -1.9888, 2.9832}; - const double* grad_temp = (num_space_dim == 3) ? grad_temp_3D - : grad_temp_2D; - - const double* vel = grad_temp; - - // Loop over quadrature points and mesh dimension - const int num_point = boundary_lagrange_pressure_result.extent(1); - for (int qp = 0; qp < num_point; ++qp) - { - // Lagrange pressure - EXPECT_DOUBLE_EQ(phi, - fieldValue(boundary_lagrange_pressure_result, 0, qp)); - - // Temperature - if (build_temp_equ) - { - const auto boundary_temperature_result - = test_fixture.getTestFieldData( - wf_eval->_boundary_temperature); - EXPECT_DOUBLE_EQ(u_0 + u_1, - fieldValue(boundary_temperature_result, 0, qp)); - } - - // Loop over mesh dimension to assert gradient vectors - for (int d = 0; d < num_space_dim; ++d) - { - const auto boundary_velocity_d_result - = test_fixture.getTestFieldData( - wf_eval->_boundary_velocity[d]); - EXPECT_DOUBLE_EQ(vel[d], - fieldValue(boundary_velocity_d_result, 0, qp)); - - for (int vel_dim = 0; vel_dim < num_space_dim; ++vel_dim) - { - const auto boundary_grad_velocity_d_result - = test_fixture.getTestFieldData( - wf_eval->_boundary_grad_velocity[vel_dim]); - - EXPECT_DOUBLE_EQ( - grad_vel[vel_dim][d], - fieldValue(boundary_grad_velocity_d_result, 0, qp, d)); - } - - if (build_temp_equ) - { - const auto boundary_grad_temperature_result - = test_fixture.getTestFieldData( - wf_eval->_boundary_grad_temperature); - EXPECT_DOUBLE_EQ( - grad_temp[d], - fieldValue(boundary_grad_temperature_result, 0, qp, d)); - } - - if (continuity_model == ContinuityModel::EDAC) - { - const double exp_val = u_0 - u_1; - const auto boundary_grad_lagrange_pressure_result - = test_fixture.getTestFieldData( - wf_eval->_boundary_grad_lagrange_pressure); - EXPECT_DOUBLE_EQ( - exp_val, - fieldValue( - boundary_grad_lagrange_pressure_result, 0, qp, d)); - } - } - } -} - -//---------------------------------------------------------------------------// -// Value parameterized test fixture -struct EvaluationTest : public testing::TestWithParam -{ - // Case generator for parameterized test - struct ParamNameGenerator - { - std::string - operator()(const testing::TestParamInfo& info) const - { - const auto continuity_model = info.param; - switch (continuity_model) - { - case (ContinuityModel::AC): - return "AC"; - case (ContinuityModel::EDAC): - return "EDAC"; - default: - return "INVALID_NAME"; - } - } - }; -}; - -//---------------------------------------------------------------------------// -// 2-D incompressible isothermal wall function -TEST_P(EvaluationTest, isothermalresidual2D) -{ - ContinuityModel continuity_model; - continuity_model = GetParam(); - testEval(false, continuity_model); -} - -TEST_P(EvaluationTest, isothermaljacobian2D) -{ - ContinuityModel continuity_model; - continuity_model = GetParam(); - testEval(false, continuity_model); -} - -//---------------------------------------------------------------------------// -// 3-D incompressible isothermal wall function -TEST_P(EvaluationTest, isothermalresidual3D) -{ - ContinuityModel continuity_model; - continuity_model = GetParam(); - testEval(false, continuity_model); -} - -TEST_P(EvaluationTest, isothermaljacobian3D) -{ - ContinuityModel continuity_model; - continuity_model = GetParam(); - testEval(false, continuity_model); -} - -//---------------------------------------------------------------------------// -// 2-D incompressible wall function -TEST_P(EvaluationTest, residual2D) -{ - ContinuityModel continuity_model; - continuity_model = GetParam(); - testEval(true, continuity_model); -} - -TEST_P(EvaluationTest, jacobian2D) -{ - ContinuityModel continuity_model; - continuity_model = GetParam(); - testEval(true, continuity_model); -} - -//---------------------------------------------------------------------------// -// 3-D incompressible wall function -TEST_P(EvaluationTest, residual3D) -{ - ContinuityModel continuity_model; - continuity_model = GetParam(); - testEval(true, continuity_model); -} - -TEST_P(EvaluationTest, jacobian3D) -{ - ContinuityModel continuity_model; - continuity_model = GetParam(); - testEval(true, continuity_model); -} - -//---------------------------------------------------------------------------// -// Generate test suite with continuity models -INSTANTIATE_TEST_SUITE_P(ContinuityModelType, - EvaluationTest, - testing::Values(ContinuityModel::AC, - ContinuityModel::EDAC), - EvaluationTest::ParamNameGenerator{}); - -} // end namespace Test -} // end namespace VertexCFD diff --git a/src/incompressible_solver/boundary_conditions/unit_test/tstTimeTransientIncompressibleDirichlet.cpp b/src/incompressible_solver/boundary_conditions/unit_test/tstTimeTransientIncompressibleDirichlet.cpp deleted file mode 100644 index 6ba34ee..0000000 --- a/src/incompressible_solver/boundary_conditions/unit_test/tstTimeTransientIncompressibleDirichlet.cpp +++ /dev/null @@ -1,404 +0,0 @@ -#include "incompressible_solver/boundary_conditions/VertexCFD_BoundaryState_IncompressibleDirichlet.hpp" -#include - -#include -#include -#include - -#include - -#include - -//---------------------------------------------------------------------------// -// TESTS -//---------------------------------------------------------------------------// -namespace VertexCFD -{ -namespace Test -{ -//---------------------------------------------------------------------------// -// Continuity Equation cases -enum class ContinuityModel -{ - AC, - EDAC -}; -//---------------------------------------------------------------------------// -// Test data dependencies. -template -struct Dependencies : public PHX::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - using scalar_type = typename EvalType::ScalarT; - - double _phi, _u0, _u1, _u2; - ContinuityModel _continuity_model; - - PHX::MDField _lagrange_pressure; - PHX::MDField - _grad_velocity_0; - PHX::MDField - _grad_velocity_1; - PHX::MDField - _grad_velocity_2; - PHX::MDField - _grad_lagrange_pressure; - - Dependencies(const panzer::IntegrationRule& ir, - const double phi, - const double u0, - const double u1, - const double u2, - const ContinuityModel continuity_model) - : _phi(phi) - , _u0(u0) - , _u1(u1) - , _u2(u2) - , _continuity_model(continuity_model) - , _lagrange_pressure("lagrange_pressure", ir.dl_scalar) - , _grad_velocity_0("GRAD_velocity_0", ir.dl_vector) - , _grad_velocity_1("GRAD_velocity_1", ir.dl_vector) - , _grad_velocity_2("GRAD_velocity_2", ir.dl_vector) - , _grad_lagrange_pressure("GRAD_lagrange_pressure", ir.dl_vector) - { - this->addEvaluatedField(_lagrange_pressure); - this->addEvaluatedField(_grad_velocity_0); - this->addEvaluatedField(_grad_velocity_1); - this->addEvaluatedField(_grad_velocity_2); - if (_continuity_model == ContinuityModel::EDAC) - this->addEvaluatedField(_grad_lagrange_pressure); - this->setName( - "Time Transient Incompressible Dirichlet Unit Test Dependencies"); - } - - void evaluateFields(typename panzer::Traits::EvalData /**d**/) override - { - _lagrange_pressure.deep_copy(_phi); - _grad_velocity_0.deep_copy(_u0); - _grad_velocity_1.deep_copy(_u1); - _grad_velocity_2.deep_copy(_u2); - if (_continuity_model == ContinuityModel::EDAC) - _grad_lagrange_pressure.deep_copy(_u0 - _u1); - } -}; - -//---------------------------------------------------------------------------// -template -void testEval(const Kokkos::Array time_values, - const Kokkos::Array final_values, - const Kokkos::Array init_values, - const Kokkos::Array exp_fields, - const ContinuityModel continuity_model) -{ - // Test fixture - constexpr int num_space_dim = NumSpaceDim; - const int num_grad_dim = 2; - const int integration_order = 2; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_grad_dim, integration_order, basis_order); - - std::string continuity_model_name = ""; - switch (continuity_model) - { - case (ContinuityModel::AC): - continuity_model_name = "AC"; - break; - case (ContinuityModel::EDAC): - continuity_model_name = "EDAC"; - break; - } - - // Create dependencies - const double phi = 3.0; - const double u0 = final_values[0]; - const double u1 = final_values[1]; - const double u2 = num_space_dim == 3 ? final_values[2] : 0.0; - const double u0_init = init_values[0]; - const double u1_init = init_values[1]; - const double u2_init = num_space_dim == 3 ? init_values[2] : -1.0; - const double time_init = time_values[0]; - const double time_final = time_values[1]; - const double time = time_values[2]; - - const auto dep_eval = Teuchos::rcp(new Dependencies( - *test_fixture.ir, phi, u0, u1, u2, continuity_model)); - test_fixture.registerEvaluator(dep_eval); - - // Equation of state - const bool build_temp_equ = false; - Teuchos::ParameterList fluid_prop_list; - fluid_prop_list.set("Kinematic viscosity", 0.375); - fluid_prop_list.set("Artificial compressibility", 2.0); - fluid_prop_list.set("Build Temperature Equation", build_temp_equ); - if (build_temp_equ) - { - fluid_prop_list.set("Thermal conductivity", 0.5); - fluid_prop_list.set("Specific heat capacity", 0.6); - } - const FluidProperties::ConstantFluidProperties fluid_prop(fluid_prop_list); - - // Create the param list to initialize the evaluator - Teuchos::ParameterList bc_params; - bc_params.set("velocity_0", u0); - bc_params.set("velocity_1", u1); - if (num_space_dim == 3) - bc_params.set("velocity_2", u2); - if (u0_init > 0.0) - bc_params.set("velocity_0_init", u0_init); - if (u1_init > 0.0) - bc_params.set("velocity_1_init", u1_init); - if (u2_init > 0.0) - bc_params.set("velocity_2_init", u2_init); - if (time_init > 0.0) - bc_params.set("Time Initial", time_init); - if (time_final > 0.0) - bc_params.set("Time Final", time_final); - - // Create dirichlet evaluator. - auto dirichlet_eval = Teuchos::rcp( - new BoundaryCondition::IncompressibleDirichlet( - *test_fixture.ir, fluid_prop, bc_params, continuity_model_name)); - test_fixture.registerEvaluator(dirichlet_eval); - - // Add required test fields. - test_fixture.registerTestField( - dirichlet_eval->_boundary_lagrange_pressure); - for (int vel_dim = 0; vel_dim < num_space_dim; ++vel_dim) - { - test_fixture.registerTestField( - dirichlet_eval->_boundary_velocity[vel_dim]); - test_fixture.registerTestField( - dirichlet_eval->_boundary_grad_velocity[vel_dim]); - } - - if (continuity_model == ContinuityModel::EDAC) - { - test_fixture.registerTestField( - dirichlet_eval->_boundary_grad_lagrange_pressure); - } - - // Set time - test_fixture.setTime(time); - - // Evaluate time transient dirichlet BC. - test_fixture.evaluate(); - - // Check the time transient dirichlet BC. - const auto boundary_phi_result = test_fixture.getTestFieldData( - dirichlet_eval->_boundary_lagrange_pressure); - - const int num_point = boundary_phi_result.extent(1); - - for (int qp = 0; qp < num_point; ++qp) - { - EXPECT_DOUBLE_EQ(phi, fieldValue(boundary_phi_result, 0, qp)); - for (int vel_dim = 0; vel_dim < num_space_dim; ++vel_dim) - { - const auto boundary_velocity_d_result - = test_fixture.getTestFieldData( - dirichlet_eval->_boundary_velocity[vel_dim]); - EXPECT_DOUBLE_EQ(exp_fields[vel_dim], - fieldValue(boundary_velocity_d_result, 0, qp)); - } - - for (int d = 0; d < num_grad_dim; ++d) - { - for (int vel_dim = 0; vel_dim < num_space_dim; ++vel_dim) - { - // The gradients are initialized with entries from - // `final_values`. - const double exp_val = final_values[vel_dim]; - const auto boundary_grad_velocity_d_result - = test_fixture.getTestFieldData( - dirichlet_eval->_boundary_grad_velocity[vel_dim]); - EXPECT_DOUBLE_EQ( - exp_val, - fieldValue(boundary_grad_velocity_d_result, 0, qp, d)); - } - - if (continuity_model == ContinuityModel::EDAC) - { - const double exp_val = final_values[0] - final_values[1]; - const auto boundary_grad_lagrange_pressure_result - = test_fixture.getTestFieldData( - dirichlet_eval->_boundary_grad_lagrange_pressure); - EXPECT_DOUBLE_EQ( - exp_val, - fieldValue( - boundary_grad_lagrange_pressure_result, 0, qp, d)); - } - } - } -} - -//---------------------------------------------------------------------------// -// Value parameterized test fixture -struct EvaluationTest : public testing::TestWithParam -{ - // Case generator for parameterized test - struct ParamNameGenerator - { - std::string - operator()(const testing::TestParamInfo& info) const - { - const auto continuity_model = info.param; - switch (continuity_model) - { - case (ContinuityModel::AC): - return "AC"; - case (ContinuityModel::EDAC): - return "EDAC"; - default: - return "INVALID_NAME"; - } - } - }; -}; - -//---------------------------------------------------------------------------// -// 2-D: time transient dirichlet - steady -TEST_P(EvaluationTest, steadyresidual2D) -{ - const Kokkos::Array time_values = {-0.5, -2.0, 3.0}; - const Kokkos::Array final_values = {2.0, 3.0}; - const Kokkos::Array init_values = {-1.0, -1.2}; - const Kokkos::Array exp_fields = {2.0, 3.0}; - ContinuityModel continuity_model; - continuity_model = GetParam(); - testEval( - time_values, final_values, init_values, exp_fields, continuity_model); -} - -TEST_P(EvaluationTest, steadyjacobian2D) -{ - const Kokkos::Array time_values = {-0.5, -2.0, 3.0}; - const Kokkos::Array final_values = {2.0, 3.0}; - const Kokkos::Array init_values = {-1.0, -1.2}; - const Kokkos::Array exp_fields = {2.0, 3.0}; - ContinuityModel continuity_model; - continuity_model = GetParam(); - testEval( - time_values, final_values, init_values, exp_fields, continuity_model); -} - -//---------------------------------------------------------------------------// -// 2-D: time transient dirichlet - time > time_final -TEST_P(EvaluationTest, timefinalresidual2D) -{ - const Kokkos::Array time_values = {0.5, 2.0, 3.0}; - const Kokkos::Array final_values = {2.0, 3.0}; - const Kokkos::Array init_values = {1.0, 1.2}; - const Kokkos::Array exp_fields = {2.0, 3.0}; - ContinuityModel continuity_model; - continuity_model = GetParam(); - - testEval( - time_values, final_values, init_values, exp_fields, continuity_model); -} - -TEST_P(EvaluationTest, timefinaljacobian2D) -{ - const Kokkos::Array time_values = {0.5, 2.0, 3.0}; - const Kokkos::Array final_values = {2.0, 3.0}; - const Kokkos::Array init_values = {1.0, 1.2}; - const Kokkos::Array exp_fields = {2.0, 3.0}; - ContinuityModel continuity_model; - continuity_model = GetParam(); - - testEval( - time_values, final_values, init_values, exp_fields, continuity_model); -} - -//---------------------------------------------------------------------------// -// 2-D: time transient dirichlet - time < time_init -TEST_P(EvaluationTest, timeinitresidual2D) -{ - const Kokkos::Array time_values = {0.5, 1.0, 0.2}; - const Kokkos::Array final_values = {2.0, 3.0}; - const Kokkos::Array init_values = {1.0, 1.2}; - const Kokkos::Array exp_fields = {1.0, 1.2}; - ContinuityModel continuity_model; - continuity_model = GetParam(); - testEval( - time_values, final_values, init_values, exp_fields, continuity_model); -} - -TEST_P(EvaluationTest, timeinitjacobian2D) -{ - const Kokkos::Array time_values = {0.5, 1.0, 0.2}; - const Kokkos::Array final_values = {2.0, 3.0}; - const Kokkos::Array init_values = {1.0, 1.2}; - const Kokkos::Array exp_fields = {1.0, 1.2}; - ContinuityModel continuity_model; - continuity_model = GetParam(); - testEval( - time_values, final_values, init_values, exp_fields, continuity_model); -} - -//---------------------------------------------------------------------------// -// 2-D: time transient dirichlet - time_init < time < -// time_final -TEST_P(EvaluationTest, timeintermediateresidual2D) -{ - const Kokkos::Array time_values = {1.0, 2.0, 1.5}; - const Kokkos::Array final_values = {2.0, 3.0}; - const Kokkos::Array init_values = {1.0, 2.0}; - const Kokkos::Array exp_fields = {1.5, 2.5}; - ContinuityModel continuity_model; - continuity_model = GetParam(); - testEval( - time_values, final_values, init_values, exp_fields, continuity_model); -} - -TEST_P(EvaluationTest, timeintermediatejacobian2D) -{ - const Kokkos::Array time_values = {1.0, 2.0, 1.5}; - const Kokkos::Array final_values = {2.0, 3.0}; - const Kokkos::Array init_values = {1.0, 2.0}; - const Kokkos::Array exp_fields = {1.5, 2.5}; - ContinuityModel continuity_model; - continuity_model = GetParam(); - testEval( - time_values, final_values, init_values, exp_fields, continuity_model); -} - -//---------------------------------------------------------------------------// -// 3-D: time transient dirichlet - time_init < time < -// time_final -TEST_P(EvaluationTest, timeintermediateresidual3D) -{ - const Kokkos::Array time_values = {1.0, 2.0, 1.5}; - const Kokkos::Array final_values = {2.0, 3.0, 4.0}; - const Kokkos::Array init_values = {1.0, 2.0, 3.0}; - const Kokkos::Array exp_fields = {1.5, 2.5, 3.5}; - ContinuityModel continuity_model; - continuity_model = GetParam(); - testEval( - time_values, final_values, init_values, exp_fields, continuity_model); -} - -TEST_P(EvaluationTest, timeintermediatejacobian3D) -{ - const Kokkos::Array time_values = {1.0, 2.0, 1.5}; - const Kokkos::Array final_values = {2.0, 3.0, 4.0}; - const Kokkos::Array init_values = {1.0, 2.0, 3.0}; - const Kokkos::Array exp_fields = {1.5, 2.5, 3.5}; - ContinuityModel continuity_model; - continuity_model = GetParam(); - testEval( - time_values, final_values, init_values, exp_fields, continuity_model); -} - -//---------------------------------------------------------------------------// -// Generate test suite with continuity models -INSTANTIATE_TEST_SUITE_P(ContinuityModelType, - EvaluationTest, - testing::Values(ContinuityModel::AC, - ContinuityModel::EDAC), - EvaluationTest::ParamNameGenerator{}); - -} // end namespace Test -} // end namespace VertexCFD diff --git a/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleBuoyancySource.cpp b/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleBuoyancySource.cpp deleted file mode 100644 index eaa5950..0000000 --- a/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleBuoyancySource.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_Closure_IncompressibleBuoyancySource.hpp" -#include "VertexCFD_Closure_IncompressibleBuoyancySource_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS_NUMSPACEDIM( - VertexCFD::ClosureModel::IncompressibleBuoyancySource) diff --git a/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleBuoyancySource.hpp b/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleBuoyancySource.hpp deleted file mode 100644 index dd1e004..0000000 --- a/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleBuoyancySource.hpp +++ /dev/null @@ -1,65 +0,0 @@ -#ifndef VERTEXCFD_CLOSURE_INCOMPRESSIBLEBUOYANCYSOURCE_HPP -#define VERTEXCFD_CLOSURE_INCOMPRESSIBLEBUOYANCYSOURCE_HPP - -#include "incompressible_solver/fluid_properties/VertexCFD_ConstantFluidProperties.hpp" - -#include -#include - -#include -#include -#include -#include - -#include - -#include - -namespace VertexCFD -{ -namespace ClosureModel -{ -//---------------------------------------------------------------------------// -// Thermal buoyancy source evaluation. -//---------------------------------------------------------------------------// -template -class IncompressibleBuoyancySource - : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - static constexpr int num_space_dim = NumSpaceDim; - - IncompressibleBuoyancySource( - const panzer::IntegrationRule& ir, - const FluidProperties::ConstantFluidProperties& fluid_prop, - const Teuchos::ParameterList& user_params); - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - PHX::MDField - _buoyancy_continuity_source; - PHX::MDField _buoyancy_energy_source; - - Kokkos::Array, - num_space_dim> - _buoyancy_momentum_source; - - private: - PHX::MDField _temperature; - double _beta_T; - double _T_ref; - Kokkos::Array _gravity; -}; - -//---------------------------------------------------------------------------// - -} // end namespace ClosureModel -} // end namespace VertexCFD - -#endif // end VERTEXCFD_CLOSURE_INCOMPRESSIBLEBUOYANCYSOURCE_HPP diff --git a/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleConstantSource.cpp b/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleConstantSource.cpp deleted file mode 100644 index 32817f2..0000000 --- a/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleConstantSource.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_Closure_IncompressibleConstantSource.hpp" -#include "VertexCFD_Closure_IncompressibleConstantSource_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS_NUMSPACEDIM( - VertexCFD::ClosureModel::IncompressibleConstantSource) diff --git a/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleConstantSource.hpp b/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleConstantSource.hpp deleted file mode 100644 index b960cc4..0000000 --- a/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleConstantSource.hpp +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef VERTEXCFD_CLOSURE_INCOMPRESSIBLECONSTANTSOURCE_HPP -#define VERTEXCFD_CLOSURE_INCOMPRESSIBLECONSTANTSOURCE_HPP - -#include "incompressible_solver/fluid_properties/VertexCFD_ConstantFluidProperties.hpp" - -#include -#include - -#include -#include -#include -#include - -#include - -#include - -namespace VertexCFD -{ -namespace ClosureModel -{ -//---------------------------------------------------------------------------// -// Multi-dimension constant source evaluation. -//---------------------------------------------------------------------------// -template -class IncompressibleConstantSource - : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - static constexpr int num_space_dim = NumSpaceDim; - - IncompressibleConstantSource( - const panzer::IntegrationRule& ir, - const FluidProperties::ConstantFluidProperties& fluid_prop, - const Teuchos::ParameterList& user_params); - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - PHX::MDField _continuity_source; - Kokkos::Array, - num_space_dim> - _momentum_source; - PHX::MDField _energy_source; - - private: - bool _solve_temp; - Kokkos::Array _mom_input_source; - double _energy_input_source; -}; - -//---------------------------------------------------------------------------// - -} // end namespace ClosureModel -} // end namespace VertexCFD - -#endif // end VERTEXCFD_CLOSURE_INCOMPRESSIBLECONSTANTSOURCE_HPP diff --git a/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleConvectiveFlux.cpp b/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleConvectiveFlux.cpp deleted file mode 100644 index 45d0c20..0000000 --- a/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleConvectiveFlux.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_Closure_IncompressibleConvectiveFlux.hpp" -#include "VertexCFD_Closure_IncompressibleConvectiveFlux_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS_NUMSPACEDIM( - VertexCFD::ClosureModel::IncompressibleConvectiveFlux) diff --git a/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleConvectiveFlux.hpp b/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleConvectiveFlux.hpp deleted file mode 100644 index 76bd645..0000000 --- a/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleConvectiveFlux.hpp +++ /dev/null @@ -1,72 +0,0 @@ -#ifndef VERTEXCFD_CLOSURE_INCOMPRESSIBLECONVECTIVEFLUX_HPP -#define VERTEXCFD_CLOSURE_INCOMPRESSIBLECONVECTIVEFLUX_HPP - -#include "incompressible_solver/fluid_properties/VertexCFD_ConstantFluidProperties.hpp" - -#include -#include - -#include -#include -#include -#include - -#include - -#include - -namespace VertexCFD -{ -namespace ClosureModel -{ -//---------------------------------------------------------------------------// -// Multi-dimension convective flux evaluation. -//---------------------------------------------------------------------------// -template -class IncompressibleConvectiveFlux - : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - static constexpr int num_space_dim = NumSpaceDim; - - IncompressibleConvectiveFlux( - const panzer::IntegrationRule& ir, - const FluidProperties::ConstantFluidProperties& fluid_prop, - const std::string& flux_prefix = "", - const std::string& field_prefix = ""); - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - PHX::MDField - _continuity_flux; - PHX::MDField - _energy_flux; - Kokkos::Array< - PHX::MDField, - num_space_dim> - _momentum_flux; - - private: - PHX::MDField _lagrange_pressure; - PHX::MDField _temperature; - Kokkos::Array, - num_space_dim> - _velocity; - - double _rho; - double _rhoCp; - bool _solve_temp; -}; - -//---------------------------------------------------------------------------// - -} // end namespace ClosureModel -} // end namespace VertexCFD - -#endif // end VERTEXCFD_CLOSURE_INCOMPRESSIBLECONVECTIVEFLUX_HPP diff --git a/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleErrorNorms.hpp b/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleErrorNorms.hpp deleted file mode 100644 index 0524502..0000000 --- a/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleErrorNorms.hpp +++ /dev/null @@ -1,78 +0,0 @@ -#ifndef VERTEXCFD_CLOSURE_INCOMPRESSIBLEERRORNORMS_HPP -#define VERTEXCFD_CLOSURE_INCOMPRESSIBLEERRORNORMS_HPP - -#include -#include - -#include -#include -#include -#include - -#include - -#include - -namespace VertexCFD -{ -namespace ClosureModel -{ -//---------------------------------------------------------------------------// -// Compute error norms between exact solution and numerical solutions -//---------------------------------------------------------------------------// -template -class IncompressibleErrorNorms : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - static constexpr int num_space_dim = NumSpaceDim; - - IncompressibleErrorNorms(const panzer::IntegrationRule& ir, - const Teuchos::ParameterList& user_params); - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - PHX::MDField _L1_error_continuity; - Kokkos::Array, - num_space_dim> - _L1_error_momentum; - PHX::MDField _L1_error_energy; - - PHX::MDField _L2_error_continuity; - Kokkos::Array, - num_space_dim> - _L2_error_momentum; - PHX::MDField _L2_error_energy; - - PHX::MDField _volume; - - private: - PHX::MDField - _exact_lagrange_pressure; - Kokkos::Array, - num_space_dim> - _exact_velocity; - PHX::MDField _exact_temperature; - - PHX::MDField _lagrange_pressure; - Kokkos::Array, - num_space_dim> - _velocity; - PHX::MDField _temperature; - - bool _use_temp; -}; - -//---------------------------------------------------------------------------// - -} // namespace ClosureModel -} // end namespace VertexCFD - -#include "VertexCFD_Closure_IncompressibleErrorNorms_impl.hpp" - -#endif // VERTEXCFD_CLOSURE_INCOMPRESSIBLEERRORNORMS_HPP diff --git a/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleLiftDrag.cpp b/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleLiftDrag.cpp deleted file mode 100644 index 859ac96..0000000 --- a/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleLiftDrag.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_Closure_IncompressibleLiftDrag.hpp" -#include "VertexCFD_Closure_IncompressibleLiftDrag_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS_NUMSPACEDIM( - VertexCFD::ClosureModel::IncompressibleLiftDrag) diff --git a/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleLiftDrag.hpp b/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleLiftDrag.hpp deleted file mode 100644 index 7ef16ec..0000000 --- a/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleLiftDrag.hpp +++ /dev/null @@ -1,76 +0,0 @@ -#ifndef VERTEXCFD_CLOSURE_INCOMPRESSIBLELIFTDRAG_HPP -#define VERTEXCFD_CLOSURE_INCOMPRESSIBLELIFTDRAG_HPP - -#include "incompressible_solver/fluid_properties/VertexCFD_ConstantFluidProperties.hpp" - -#include -#include - -#include -#include -#include -#include - -#include - -#include - -namespace VertexCFD -{ -namespace ClosureModel -{ -//---------------------------------------------------------------------------// -// Aerodyanmic force evaluation. -//---------------------------------------------------------------------------// -template -class IncompressibleLiftDrag : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - static constexpr int num_space_dim = NumSpaceDim; - - IncompressibleLiftDrag( - const panzer::IntegrationRule& ir, - const FluidProperties::ConstantFluidProperties& fluid_prop, - const Teuchos::ParameterList& user_params); - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - Kokkos::Array, - num_space_dim> - _shear_tensor; - Kokkos::Array, - num_space_dim> - _viscous_force; - Kokkos::Array, - num_space_dim> - _pressure_force; - Kokkos::Array, - num_space_dim> - _total_force; - - private: - PHX::MDField - _normals; - PHX::MDField _lagrange_pressure; - Kokkos::Array< - PHX::MDField, - num_space_dim> - _grad_velocity; - - double _nu; - double _rho; - bool _use_compressible_formula; -}; - -//---------------------------------------------------------------------------// - -} // end namespace ClosureModel -} // end namespace VertexCFD - -#endif // end VERTEXCFD_CLOSURE_INCOMPRESSIBLELIFTDRAG_HPP diff --git a/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleLocalTimeStepSize.cpp b/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleLocalTimeStepSize.cpp deleted file mode 100644 index 7453a4d..0000000 --- a/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleLocalTimeStepSize.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_Closure_IncompressibleLocalTimeStepSize.hpp" -#include "VertexCFD_Closure_IncompressibleLocalTimeStepSize_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS_NUMSPACEDIM( - VertexCFD::ClosureModel::IncompressibleLocalTimeStepSize) diff --git a/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleLocalTimeStepSize.hpp b/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleLocalTimeStepSize.hpp deleted file mode 100644 index 480cee2..0000000 --- a/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleLocalTimeStepSize.hpp +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef VERTEXCFD_CLOSURE_INCOMPRESSIBLELOCALTIMESTEPSIZE_HPP -#define VERTEXCFD_CLOSURE_INCOMPRESSIBLELOCALTIMESTEPSIZE_HPP - -#include -#include - -#include -#include -#include -#include - -#include - -namespace VertexCFD -{ -namespace ClosureModel -{ -//---------------------------------------------------------------------------// -// Compute local time step size based on the mesh size and maximum eigenvalue. -// The time step size used by the solver and based on the CFL condition is -// computed in the observer -// 'VertexCFD_TempusTimeStepControl_GlobalCFL_impl.hpp' -//---------------------------------------------------------------------------// -template -class IncompressibleLocalTimeStepSize - : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - static constexpr int num_space_dim = NumSpaceDim; - - IncompressibleLocalTimeStepSize(const panzer::IntegrationRule& ir); - - void evaluateFields(typename Traits::EvalData d) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - public: - PHX::MDField _local_dt; - - private: - PHX::MDField - _element_length; - Kokkos::Array, - num_space_dim> - _velocity; -}; - -//---------------------------------------------------------------------------// - -} // end namespace ClosureModel -} // end namespace VertexCFD - -#endif // end VERTEXCFD_CLOSURE_INCOMPRESSIBLELOCALTIMESTEPSIZE_HPP diff --git a/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressiblePlanarPoiseuilleExact.cpp b/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressiblePlanarPoiseuilleExact.cpp deleted file mode 100644 index 6826921..0000000 --- a/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressiblePlanarPoiseuilleExact.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_Closure_IncompressiblePlanarPoiseuilleExact.hpp" -#include "VertexCFD_Closure_IncompressiblePlanarPoiseuilleExact_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS_NUMSPACEDIM( - VertexCFD::ClosureModel::IncompressiblePlanarPoiseuilleExact) diff --git a/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressiblePlanarPoiseuilleExact.hpp b/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressiblePlanarPoiseuilleExact.hpp deleted file mode 100644 index 4fa2c48..0000000 --- a/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressiblePlanarPoiseuilleExact.hpp +++ /dev/null @@ -1,74 +0,0 @@ -#ifndef VERTEXCFD_CLOSURE_INCOMPRESSIBLEPLANARPOISEUILLEEXACT_HPP -#define VERTEXCFD_CLOSURE_INCOMPRESSIBLEPLANARPOISEUILLEEXACT_HPP - -#include "incompressible_solver/fluid_properties/VertexCFD_ConstantFluidProperties.hpp" - -#include -#include - -#include -#include -#include -#include - -#include - -namespace VertexCFD -{ -namespace ClosureModel -{ -//---------------------------------------------------------------------------// -// Exact solution for planar Poiseuille flow with viscous dissipation -//---------------------------------------------------------------------------// -template -class IncompressiblePlanarPoiseuilleExact - : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - static constexpr int num_space_dim = NumSpaceDim; - - IncompressiblePlanarPoiseuilleExact( - const panzer::IntegrationRule& ir, - const FluidProperties::ConstantFluidProperties& fluid_prop, - const Teuchos::ParameterList& user_params); - - void postRegistrationSetup(typename Traits::SetupData sd, - PHX::FieldManager& fm) override; - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - public: - PHX::MDField _temperature; - PHX::MDField _lagrange_pressure; - Kokkos::Array, num_space_dim> - _velocity; - - private: - double _nu; - double _rho; - double _k; - double _cp; - double _h_min; - double _h_max; - double _T_l; - double _T_u; - double _S_u; - - int _ir_degree; - int _ir_index; - - PHX::MDField _ip_coords; -}; - -//---------------------------------------------------------------------------// - -} // end namespace ClosureModel -} // end namespace VertexCFD - -#endif // end VERTEXCFD_CLOSURE_INCOMPRESSIBLEPLANARPOISEUILLEEXACT_HPP diff --git a/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleRotatingAnnulusExact.cpp b/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleRotatingAnnulusExact.cpp deleted file mode 100644 index 3191dea..0000000 --- a/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleRotatingAnnulusExact.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_Closure_IncompressibleRotatingAnnulusExact.hpp" -#include "VertexCFD_Closure_IncompressibleRotatingAnnulusExact_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS_NUMSPACEDIM( - VertexCFD::ClosureModel::IncompressibleRotatingAnnulusExact) diff --git a/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleRotatingAnnulusExact.hpp b/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleRotatingAnnulusExact.hpp deleted file mode 100644 index ab65d7f..0000000 --- a/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleRotatingAnnulusExact.hpp +++ /dev/null @@ -1,76 +0,0 @@ -#ifndef VERTEXCFD_CLOSURE_INCOMPRESSIBLEROTATINGANNULUSEXACT_HPP -#define VERTEXCFD_CLOSURE_INCOMPRESSIBLEROTATINGANNULUSEXACT_HPP - -#include "incompressible_solver/fluid_properties/VertexCFD_ConstantFluidProperties.hpp" - -#include -#include - -#include -#include -#include -#include - -#include - -#include - -namespace VertexCFD -{ -namespace ClosureModel -{ -//---------------------------------------------------------------------------// -// Exact solution for rotating annulus with viscous heating -//---------------------------------------------------------------------------// -template -class IncompressibleRotatingAnnulusExact - : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - static constexpr int num_space_dim = NumSpaceDim; - - IncompressibleRotatingAnnulusExact( - const panzer::IntegrationRule& ir, - const FluidProperties::ConstantFluidProperties& fluid_prop, - const Teuchos::ParameterList& user_params); - - void postRegistrationSetup(typename Traits::SetupData sd, - PHX::FieldManager& fm) override; - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - PHX::MDField _temperature; - PHX::MDField _lagrange_pressure; - Kokkos::Array, num_space_dim> - _velocity; - - private: - double _nu; - double _rho; - double _k; - double _ro; - double _ri; - double _kappa; - double _omega; - double _To; - double _Ti; - double _N; - - int _ir_degree; - int _ir_index; - - PHX::MDField _ip_coords; -}; - -//---------------------------------------------------------------------------// - -} // end namespace ClosureModel -} // end namespace VertexCFD - -#endif // end VERTEXCFD_CLOSURE_INCOMPRESSIBLEROTATINGANNULUSEXACT_HPP diff --git a/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleShearVariables.cpp b/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleShearVariables.cpp deleted file mode 100644 index ab73ed8..0000000 --- a/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleShearVariables.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_Closure_IncompressibleShearVariables.hpp" -#include "VertexCFD_Closure_IncompressibleShearVariables_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS_NUMSPACEDIM( - VertexCFD::ClosureModel::IncompressibleShearVariables) diff --git a/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleShearVariables.hpp b/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleShearVariables.hpp deleted file mode 100644 index 40b8305..0000000 --- a/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleShearVariables.hpp +++ /dev/null @@ -1,64 +0,0 @@ -#ifndef VERTEXCFD_CLOSURE_INCOMPRESSIBLESHEARVARIABLES_HPP -#define VERTEXCFD_CLOSURE_INCOMPRESSIBLESHEARVARIABLES_HPP - -#include "incompressible_solver/fluid_properties/VertexCFD_ConstantFluidProperties.hpp" - -#include -#include - -#include -#include -#include -#include - -#include - -#include - -namespace VertexCFD -{ -namespace ClosureModel -{ -//---------------------------------------------------------------------------// -// Multi-dimension shear variables evaluation. -//---------------------------------------------------------------------------// -template -class IncompressibleShearVariables - : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - static constexpr int num_space_dim = NumSpaceDim; - - IncompressibleShearVariables( - const panzer::IntegrationRule& ir, - const FluidProperties::ConstantFluidProperties& fluid_prop); - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - PHX::MDField _tau_w; - PHX::MDField _u_tau; - - private: - PHX::MDField - _normals; - Kokkos::Array< - PHX::MDField, - num_space_dim> - _grad_velocity; - - double _nu; - double _rho; -}; - -//---------------------------------------------------------------------------// - -} // end namespace ClosureModel -} // end namespace VertexCFD - -#endif // end VERTEXCFD_CLOSURE_INCOMPRESSIBLESHEARVARIABLES_HPP diff --git a/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleTaylorGreenVortexExactSolution.cpp b/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleTaylorGreenVortexExactSolution.cpp deleted file mode 100644 index 6767b5e..0000000 --- a/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleTaylorGreenVortexExactSolution.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_Closure_IncompressibleTaylorGreenVortexExactSolution.hpp" -#include "VertexCFD_Closure_IncompressibleTaylorGreenVortexExactSolution_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS_NUMSPACEDIM( - VertexCFD::ClosureModel::IncompressibleTaylorGreenVortexExactSolution) diff --git a/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleTaylorGreenVortexExactSolution.hpp b/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleTaylorGreenVortexExactSolution.hpp deleted file mode 100644 index 0edc39d..0000000 --- a/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleTaylorGreenVortexExactSolution.hpp +++ /dev/null @@ -1,66 +0,0 @@ -#ifndef VERTEXCFD_CLOSURE_INCOMPRESSIBLETAYLORGREENVORTEXEXACTSOLUTION_HPP -#define VERTEXCFD_CLOSURE_INCOMPRESSIBLETAYLORGREENVORTEXEXACTSOLUTION_HPP - -#include "incompressible_solver/fluid_properties/VertexCFD_ConstantFluidProperties.hpp" - -#include -#include - -#include -#include -#include -#include - -#include - -#include - -namespace VertexCFD -{ -namespace ClosureModel -{ -//---------------------------------------------------------------------------// -// Taylor-Green vortex exact solution. -//---------------------------------------------------------------------------// -template -class IncompressibleTaylorGreenVortexExactSolution - : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - static constexpr int num_space_dim = NumSpaceDim; - - IncompressibleTaylorGreenVortexExactSolution( - const panzer::IntegrationRule& ir, - const FluidProperties::ConstantFluidProperties& fluid_prop); - - void postRegistrationSetup(typename Traits::SetupData sd, - PHX::FieldManager& fm) override; - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - PHX::MDField _lagrange_pressure; - Kokkos::Array, num_space_dim> - _velocity; - - private: - int _ir_degree; - int _ir_index; - - PHX::MDField _ip_coords; - const double _nu; - double _Ft; - double _time; -}; - -//---------------------------------------------------------------------------// - -} // namespace ClosureModel -} // end namespace VertexCFD - -#endif // VERTEXCFD_CLOSURE_INCOMPRESSIBLETAYLORGREENVORTEXEXACTSOLUTION_HPP diff --git a/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleTimeDerivative.cpp b/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleTimeDerivative.cpp deleted file mode 100644 index c9c8a23..0000000 --- a/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleTimeDerivative.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_Closure_IncompressibleTimeDerivative.hpp" -#include "VertexCFD_Closure_IncompressibleTimeDerivative_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS_NUMSPACEDIM( - VertexCFD::ClosureModel::IncompressibleTimeDerivative) diff --git a/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleTimeDerivative.hpp b/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleTimeDerivative.hpp deleted file mode 100644 index b9d84d2..0000000 --- a/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleTimeDerivative.hpp +++ /dev/null @@ -1,66 +0,0 @@ -#ifndef VERTEXCFD_CLOSURE_INCOMPRESSIBLETIMEDERIVATIVE_HPP -#define VERTEXCFD_CLOSURE_INCOMPRESSIBLETIMEDERIVATIVE_HPP - -#include "incompressible_solver/fluid_properties/VertexCFD_ConstantFluidProperties.hpp" - -#include -#include - -#include -#include -#include -#include - -#include - -namespace VertexCFD -{ -namespace ClosureModel -{ -//---------------------------------------------------------------------------// -template -class IncompressibleTimeDerivative - : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - static constexpr int num_space_dim = NumSpaceDim; - - IncompressibleTimeDerivative( - const panzer::IntegrationRule& ir, - const FluidProperties::ConstantFluidProperties& fluid_prop); - - void evaluateFields(typename Traits::EvalData d) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - public: - PHX::MDField _dqdt_continuity; - PHX::MDField _dqdt_energy; - Kokkos::Array, - num_space_dim> - _dqdt_momentum; - - private: - PHX::MDField - _dxdt_lagrange_pressure; - Kokkos::Array, - num_space_dim> - _dxdt_velocity; - PHX::MDField _dxdt_temperature; - - double _rho; - bool _solve_temp; - double _rhoCp; - double _beta; -}; - -//---------------------------------------------------------------------------// - -} // end namespace ClosureModel -} // namespace VertexCFD - -#endif // end VERTEXCFD_CLOSURE_INCOMPRESSIBLETIMEDERIVATIVE_HPP diff --git a/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleVariableTimeDerivative.cpp b/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleVariableTimeDerivative.cpp deleted file mode 100644 index b8584f2..0000000 --- a/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleVariableTimeDerivative.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_Closure_IncompressibleVariableTimeDerivative.hpp" -#include "VertexCFD_Closure_IncompressibleVariableTimeDerivative_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS( - VertexCFD::ClosureModel::IncompressibleVariableTimeDerivative) diff --git a/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleVariableTimeDerivative.hpp b/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleVariableTimeDerivative.hpp deleted file mode 100644 index 4d7f230..0000000 --- a/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleVariableTimeDerivative.hpp +++ /dev/null @@ -1,54 +0,0 @@ -#ifndef VERTEXCFD_CLOSURE_INCOMPRESSIBLEVARIABLETIMEDERIVATIVE_HPP -#define VERTEXCFD_CLOSURE_INCOMPRESSIBLEVARIABLETIMEDERIVATIVE_HPP - -#include -#include - -#include -#include -#include -#include - -#include - -namespace VertexCFD -{ -namespace ClosureModel -{ -// Time derivative term for incompressible turbulence variable equation -//---------------------------------------------------------------------------// -template -class IncompressibleVariableTimeDerivative - : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - - IncompressibleVariableTimeDerivative( - const panzer::IntegrationRule& ir, - const Teuchos::ParameterList& closure_params); - - void evaluateFields(typename Traits::EvalData d) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - private: - std::string _variable_name; - std::string _equation_name; - - public: - PHX::MDField _dqdt_var_eq; - - private: - PHX::MDField _dxdt_var; -}; - -//---------------------------------------------------------------------------// - -} // end namespace ClosureModel -} // namespace VertexCFD - -#endif // end VERTEXCFD_CLOSURE_INCOMPRESSIBLEVARIABLETIMEDERIVATIVE_HPP diff --git a/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleViscousFlux.cpp b/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleViscousFlux.cpp deleted file mode 100644 index cceddbd..0000000 --- a/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleViscousFlux.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_Closure_IncompressibleViscousFlux.hpp" -#include "VertexCFD_Closure_IncompressibleViscousFlux_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS_NUMSPACEDIM( - VertexCFD::ClosureModel::IncompressibleViscousFlux) diff --git a/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleViscousFlux.hpp b/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleViscousFlux.hpp deleted file mode 100644 index 569624d..0000000 --- a/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleViscousFlux.hpp +++ /dev/null @@ -1,87 +0,0 @@ -#ifndef VERTEXCFD_CLOSURE_INCOMPRESSIBLEVISCOUSFLUX_HPP -#define VERTEXCFD_CLOSURE_INCOMPRESSIBLEVISCOUSFLUX_HPP - -#include "incompressible_solver/fluid_properties/VertexCFD_ConstantFluidProperties.hpp" - -#include -#include - -#include -#include -#include -#include - -#include - -#include - -namespace VertexCFD -{ -namespace ClosureModel -{ -//---------------------------------------------------------------------------// -// Multi-dimension viscous flux evaluation. -//---------------------------------------------------------------------------// -template -class IncompressibleViscousFlux - : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - static constexpr int num_space_dim = NumSpaceDim; - - IncompressibleViscousFlux( - const panzer::IntegrationRule& ir, - const FluidProperties::ConstantFluidProperties& fluid_prop, - const Teuchos::ParameterList& user_params, - const bool use_turbulence_model, - const std::string& flux_prefix = "", - const std::string& gradient_prefix = ""); - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - PHX::MDField - _continuity_flux; - PHX::MDField - _energy_flux; - Kokkos::Array< - PHX::MDField, - num_space_dim> - _momentum_flux; - - private: - Kokkos::Array< - PHX::MDField, - num_space_dim> - _grad_velocity; - - PHX::MDField - _grad_press; - PHX::MDField - _grad_temp; - PHX::MDField _nu_t; - PHX::MDField _kappa_t; - - double _rho; - double _nu; - double _kappa; - double _beta; - bool _solve_temp; - bool _use_turbulence_model; - std::string _continuity_model_name; - bool _is_edac; - double _rhoCp; - double _Pr_t; -}; - -//---------------------------------------------------------------------------// - -} // end namespace ClosureModel -} // end namespace VertexCFD - -#endif // end VERTEXCFD_CLOSURE_INCOMPRESSIBLEVISCOUSFLUX_HPP diff --git a/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleViscousHeat.cpp b/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleViscousHeat.cpp deleted file mode 100644 index 58914ab..0000000 --- a/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleViscousHeat.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_Closure_IncompressibleViscousHeat.hpp" -#include "VertexCFD_Closure_IncompressibleViscousHeat_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS_NUMSPACEDIM( - VertexCFD::ClosureModel::IncompressibleViscousHeat) diff --git a/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleViscousHeat.hpp b/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleViscousHeat.hpp deleted file mode 100644 index 30c23a9..0000000 --- a/src/incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleViscousHeat.hpp +++ /dev/null @@ -1,69 +0,0 @@ -#ifndef VERTEXCFD_CLOSURE_INCOMPRESSIBLEVISCOUSHEAT_HPP -#define VERTEXCFD_CLOSURE_INCOMPRESSIBLEVISCOUSHEAT_HPP - -#include "incompressible_solver/fluid_properties/VertexCFD_ConstantFluidProperties.hpp" - -#include -#include - -#include -#include -#include -#include - -#include - -#include - -namespace VertexCFD -{ -namespace ClosureModel -{ -//---------------------------------------------------------------------------// -// Viscous heat source evaluation. -//---------------------------------------------------------------------------// -template -class IncompressibleViscousHeat - : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - static constexpr int num_space_dim = NumSpaceDim; - - IncompressibleViscousHeat( - const panzer::IntegrationRule& ir, - const FluidProperties::ConstantFluidProperties& fluid_prop, - const std::string& gradient_prefix = ""); - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - PHX::MDField - _viscous_heat_continuity_source; - PHX::MDField - _viscous_heat_energy_source; - - Kokkos::Array, - num_space_dim> - _viscous_heat_momentum_source; - - private: - const double _rho; - const double _nu; - - Kokkos::Array< - PHX::MDField, - num_space_dim> - _grad_velocity; -}; - -//---------------------------------------------------------------------------// - -} // end namespace ClosureModel -} // end namespace VertexCFD - -#endif // end VERTEXCFD_CLOSURE_INCOMPRESSIBLEVISCOUSHEAT_HPP diff --git a/src/incompressible_solver/closure_models/VertexCFD_IncompressibleClosureModelFactory.hpp b/src/incompressible_solver/closure_models/VertexCFD_IncompressibleClosureModelFactory.hpp deleted file mode 100644 index be02edb..0000000 --- a/src/incompressible_solver/closure_models/VertexCFD_IncompressibleClosureModelFactory.hpp +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef VERTEXCFD_INCOMPRESSIBLECLOSUREMODELFACTORY_HPP -#define VERTEXCFD_INCOMPRESSIBLECLOSUREMODELFACTORY_HPP - -#include - -#include - -#include -#include - -namespace VertexCFD -{ -namespace ClosureModel -{ -//---------------------------------------------------------------------------// -template -class IncompressibleFactory -{ - public: - void buildClosureModel( - const std::string& closure_type, - const Teuchos::RCP& ir, - const Teuchos::ParameterList& user_params, - const Teuchos::ParameterList& closure_params, - const bool use_turbulence_model, - bool& found_model, - std::string& error_msg, - Teuchos::RCP>>> - evaluators); -}; - -//---------------------------------------------------------------------------// - -} // end namespace ClosureModel -} // end namespace VertexCFD - -#endif // end VERTEXCFD_INCOMPRESSIBLECLOSUREMODELFACTORY_HPP diff --git a/src/incompressible_solver/closure_models/VertexCFD_IncompressibleClosureModelFactory_Hessian2d.cpp b/src/incompressible_solver/closure_models/VertexCFD_IncompressibleClosureModelFactory_Hessian2d.cpp deleted file mode 100644 index f2a5d1a..0000000 --- a/src/incompressible_solver/closure_models/VertexCFD_IncompressibleClosureModelFactory_Hessian2d.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include "VertexCFD_IncompressibleClosureModelFactory.hpp" -#include "VertexCFD_IncompressibleClosureModelFactory_impl.hpp" - -template class VertexCFD::ClosureModel:: - IncompressibleFactory; diff --git a/src/incompressible_solver/closure_models/VertexCFD_IncompressibleClosureModelFactory_Hessian3d.cpp b/src/incompressible_solver/closure_models/VertexCFD_IncompressibleClosureModelFactory_Hessian3d.cpp deleted file mode 100644 index 79fdeeb..0000000 --- a/src/incompressible_solver/closure_models/VertexCFD_IncompressibleClosureModelFactory_Hessian3d.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include "VertexCFD_IncompressibleClosureModelFactory.hpp" -#include "VertexCFD_IncompressibleClosureModelFactory_impl.hpp" - -template class VertexCFD::ClosureModel:: - IncompressibleFactory; diff --git a/src/incompressible_solver/closure_models/VertexCFD_IncompressibleClosureModelFactory_Jacobian2d.cpp b/src/incompressible_solver/closure_models/VertexCFD_IncompressibleClosureModelFactory_Jacobian2d.cpp deleted file mode 100644 index 5b122c0..0000000 --- a/src/incompressible_solver/closure_models/VertexCFD_IncompressibleClosureModelFactory_Jacobian2d.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include "VertexCFD_IncompressibleClosureModelFactory.hpp" -#include "VertexCFD_IncompressibleClosureModelFactory_impl.hpp" - -template class VertexCFD::ClosureModel:: - IncompressibleFactory; diff --git a/src/incompressible_solver/closure_models/VertexCFD_IncompressibleClosureModelFactory_Jacobian3d.cpp b/src/incompressible_solver/closure_models/VertexCFD_IncompressibleClosureModelFactory_Jacobian3d.cpp deleted file mode 100644 index 68a76b8..0000000 --- a/src/incompressible_solver/closure_models/VertexCFD_IncompressibleClosureModelFactory_Jacobian3d.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include "VertexCFD_IncompressibleClosureModelFactory.hpp" -#include "VertexCFD_IncompressibleClosureModelFactory_impl.hpp" - -template class VertexCFD::ClosureModel:: - IncompressibleFactory; diff --git a/src/incompressible_solver/closure_models/VertexCFD_IncompressibleClosureModelFactory_Residual2d.cpp b/src/incompressible_solver/closure_models/VertexCFD_IncompressibleClosureModelFactory_Residual2d.cpp deleted file mode 100644 index c2392e6..0000000 --- a/src/incompressible_solver/closure_models/VertexCFD_IncompressibleClosureModelFactory_Residual2d.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include "VertexCFD_IncompressibleClosureModelFactory.hpp" -#include "VertexCFD_IncompressibleClosureModelFactory_impl.hpp" - -template class VertexCFD::ClosureModel:: - IncompressibleFactory; diff --git a/src/incompressible_solver/closure_models/VertexCFD_IncompressibleClosureModelFactory_Residual3d.cpp b/src/incompressible_solver/closure_models/VertexCFD_IncompressibleClosureModelFactory_Residual3d.cpp deleted file mode 100644 index 0961f5b..0000000 --- a/src/incompressible_solver/closure_models/VertexCFD_IncompressibleClosureModelFactory_Residual3d.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include "VertexCFD_IncompressibleClosureModelFactory.hpp" -#include "VertexCFD_IncompressibleClosureModelFactory_impl.hpp" - -template class VertexCFD::ClosureModel:: - IncompressibleFactory; diff --git a/src/incompressible_solver/closure_models/VertexCFD_IncompressibleClosureModelFactory_Tangent2d.cpp b/src/incompressible_solver/closure_models/VertexCFD_IncompressibleClosureModelFactory_Tangent2d.cpp deleted file mode 100644 index 0a23541..0000000 --- a/src/incompressible_solver/closure_models/VertexCFD_IncompressibleClosureModelFactory_Tangent2d.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include "VertexCFD_IncompressibleClosureModelFactory.hpp" -#include "VertexCFD_IncompressibleClosureModelFactory_impl.hpp" - -template class VertexCFD::ClosureModel:: - IncompressibleFactory; diff --git a/src/incompressible_solver/closure_models/VertexCFD_IncompressibleClosureModelFactory_Tangent3d.cpp b/src/incompressible_solver/closure_models/VertexCFD_IncompressibleClosureModelFactory_Tangent3d.cpp deleted file mode 100644 index cd7d781..0000000 --- a/src/incompressible_solver/closure_models/VertexCFD_IncompressibleClosureModelFactory_Tangent3d.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include "VertexCFD_IncompressibleClosureModelFactory.hpp" -#include "VertexCFD_IncompressibleClosureModelFactory_impl.hpp" - -template class VertexCFD::ClosureModel:: - IncompressibleFactory; diff --git a/src/incompressible_solver/closure_models/VertexCFD_IncompressibleClosureModelFactory_impl.hpp b/src/incompressible_solver/closure_models/VertexCFD_IncompressibleClosureModelFactory_impl.hpp deleted file mode 100644 index fcda876..0000000 --- a/src/incompressible_solver/closure_models/VertexCFD_IncompressibleClosureModelFactory_impl.hpp +++ /dev/null @@ -1,212 +0,0 @@ -#ifndef VERTEXCFD_INCOMPRESSIBLECLOSUREMODELFACTORY_IMPL_HPP -#define VERTEXCFD_INCOMPRESSIBLECLOSUREMODELFACTORY_IMPL_HPP - -#include "incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleBuoyancySource.hpp" -#include "incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleConstantSource.hpp" -#include "incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleConvectiveFlux.hpp" -#include "incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleErrorNorms.hpp" -#include "incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleLiftDrag.hpp" -#include "incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleLocalTimeStepSize.hpp" -#include "incompressible_solver/closure_models/VertexCFD_Closure_IncompressiblePlanarPoiseuilleExact.hpp" -#include "incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleRotatingAnnulusExact.hpp" -#include "incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleShearVariables.hpp" -#include "incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleTaylorGreenVortexExactSolution.hpp" -#include "incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleTimeDerivative.hpp" -#include "incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleViscousFlux.hpp" -#include "incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleViscousHeat.hpp" -#include "incompressible_solver/closure_models/VertexCFD_IncompressibleClosureModelFactory.hpp" -#include "incompressible_solver/fluid_properties/VertexCFD_ConstantFluidProperties.hpp" - -namespace VertexCFD -{ -namespace ClosureModel -{ -//---------------------------------------------------------------------------// -template -void IncompressibleFactory::buildClosureModel( - const std::string& closure_type, - const Teuchos::RCP& ir, - const Teuchos::ParameterList& user_params, - const Teuchos::ParameterList& /**closure_params**/, - const bool use_turbulence_model, - bool& found_model, - std::string& error_msg, - Teuchos::RCP>>> - evaluators) -{ - // Define local variables - constexpr int num_space_dim = NumSpaceDim; - Teuchos::RCP> eval; - - // Fluid properties - Teuchos::ParameterList fluid_prop_list - = user_params.sublist("Fluid Properties"); - const bool build_temp_equ - = user_params.isType("Build Temperature Equation") - ? user_params.get("Build Temperature Equation") - : false; - const bool build_buoyancy_source - = user_params.isType("Build Buoyancy Source") - ? user_params.get("Build Buoyancy Source") - : false; - const bool build_ind_less_equ - = user_params.isType("Build Inductionless MHD Equation") - ? user_params.get("Build Inductionless MHD Equation") - : false; - fluid_prop_list.set("Build Temperature Equation", build_temp_equ); - fluid_prop_list.set("Build Buoyancy Source", build_buoyancy_source); - fluid_prop_list.set("Build Inductionless MHD Equation", - build_ind_less_equ); - FluidProperties::ConstantFluidProperties incompressible_fluidprop_params - = FluidProperties::ConstantFluidProperties(fluid_prop_list); - - // Closure models - if (closure_type == "IncompressibleTimeDerivative") - { - auto eval = Teuchos::rcp( - new IncompressibleTimeDerivative( - *ir, incompressible_fluidprop_params)); - evaluators->push_back(eval); - found_model = true; - } - - if (closure_type == "IncompressibleLiftDrag") - { - auto eval = Teuchos::rcp( - new IncompressibleLiftDrag( - *ir, incompressible_fluidprop_params, user_params)); - evaluators->push_back(eval); - found_model = true; - } - - if (closure_type == "IncompressibleConvectiveFlux") - { - auto eval = Teuchos::rcp( - new IncompressibleConvectiveFlux( - *ir, incompressible_fluidprop_params)); - evaluators->push_back(eval); - found_model = true; - } - - if (closure_type == "IncompressibleViscousFlux") - { - auto eval = Teuchos::rcp( - new IncompressibleViscousFlux( - *ir, - incompressible_fluidprop_params, - user_params, - use_turbulence_model)); - evaluators->push_back(eval); - found_model = true; - } - - if (closure_type == "IncompressibleLocalTimeStepSize") - { - auto eval = Teuchos::rcp( - new IncompressibleLocalTimeStepSize(*ir)); - evaluators->push_back(eval); - found_model = true; - } - - if (closure_type == "IncompressibleConstantSource") - { - auto eval = Teuchos::rcp( - new IncompressibleConstantSource( - *ir, incompressible_fluidprop_params, user_params)); - evaluators->push_back(eval); - found_model = true; - } - - if (closure_type == "IncompressibleBuoyancySource") - { - auto eval = Teuchos::rcp( - new IncompressibleBuoyancySource( - *ir, incompressible_fluidprop_params, user_params)); - evaluators->push_back(eval); - found_model = true; - } - - if (closure_type == "IncompressibleViscousHeat") - { - auto eval = Teuchos::rcp( - new IncompressibleViscousHeat( - *ir, incompressible_fluidprop_params)); - evaluators->push_back(eval); - found_model = true; - } - - if (closure_type == "IncompressibleRotatingAnnulusExact") - { - auto eval = Teuchos::rcp( - new IncompressibleRotatingAnnulusExact( - *ir, incompressible_fluidprop_params, user_params)); - evaluators->push_back(eval); - found_model = true; - } - - if (closure_type == "IncompressiblePlanarPoiseuilleExact") - { - auto eval = Teuchos::rcp( - new IncompressiblePlanarPoiseuilleExact( - *ir, incompressible_fluidprop_params, user_params)); - evaluators->push_back(eval); - found_model = true; - } - - if (closure_type == "IncompressibleErrorNorm") - { - auto eval = Teuchos::rcp( - new IncompressibleErrorNorms( - *ir, user_params)); - evaluators->push_back(eval); - found_model = true; - } - - if (closure_type == "IncompressibleTaylorGreenVortexExactSolution") - { - auto eval = Teuchos::rcp( - new IncompressibleTaylorGreenVortexExactSolution( - *ir, incompressible_fluidprop_params)); - evaluators->push_back(eval); - found_model = true; - } - - if (closure_type == "IncompressibleShearVariables") - { - auto eval = Teuchos::rcp( - new IncompressibleShearVariables( - *ir, incompressible_fluidprop_params)); - evaluators->push_back(eval); - found_model = true; - } - - // Initialize 'error_msg' with list of closure models for incompressible - // NS equations - error_msg += "IncompressibleBuoyancySource\n"; - error_msg += "IncompressibleConstantSource\n"; - error_msg += "IncompressibleConvectiveFlux\n"; - error_msg += "IncompressibleErrorNorm\n"; - error_msg += "IncompressibleLiftDrag\n"; - error_msg += "IncompressibleLocalTimeStepSize\n"; - error_msg += "IncompressiblePlanarPoiseuilleExact\n"; - error_msg += "IncompressibleRotatingAnnulusExact\n"; - error_msg += "IncompressibleShearVariables\n"; - error_msg += "IncompressibleTimeDerivative\n"; - error_msg += "IncompressibleViscousFlux\n"; - error_msg += "IncompressibleViscousHeat\n"; -} - -//---------------------------------------------------------------------------// - -} // end namespace ClosureModel -} // end namespace VertexCFD - -#endif // end VERTEXCFD_INCOMPRESSIBLECLOSUREMODELFACTORY_IMPL_HPP diff --git a/src/incompressible_solver/closure_models/unit_test/CMakeLists.txt b/src/incompressible_solver/closure_models/unit_test/CMakeLists.txt deleted file mode 100644 index 9a0675e..0000000 --- a/src/incompressible_solver/closure_models/unit_test/CMakeLists.txt +++ /dev/null @@ -1,21 +0,0 @@ -set(TEST_HARNESS_DIR ${CMAKE_SOURCE_DIR}/src/test_harness) -include(${TEST_HARNESS_DIR}/TestHarness.cmake) - -VertexCFD_add_tests( - LIBS VertexCFD - NAMES - IncompressibleTimeDerivative - IncompressibleConvectiveFlux - IncompressibleLiftDrag - IncompressibleViscousFlux - IncompressibleViscousHeat - IncompressibleLocalTimeStepSize - IncompressibleConstantSource - IncompressibleBuoyancySource - IncompressibleRotatingAnnulusExact - IncompressiblePlanarPoiseuilleExact - IncompressibleTaylorGreenVortexExactSolution - IncompressibleErrorNorms - IncompressibleVariableTimeDerivative - IncompressibleShearVariables - ) diff --git a/src/incompressible_solver/closure_models/unit_test/doc/convective_flux_reference.py b/src/incompressible_solver/closure_models/unit_test/doc/convective_flux_reference.py deleted file mode 100644 index 3945805..0000000 --- a/src/incompressible_solver/closure_models/unit_test/doc/convective_flux_reference.py +++ /dev/null @@ -1,42 +0,0 @@ -import numpy as np - -rho = 1.0 -Cp = 5.0 -u = 0.25 -v = 0.5 -w = 0.125 -p = 0.75 # lagrange pressure -T = u + v - -print("\nFlux with scaled density:\n") -fc_continuity = rho * np.array([u, v, w]) -print(fc_continuity) - -fc_momentum_0 = rho * np.array([u * u + p, u * v, u * w]) -print(fc_momentum_0) - -fc_momentum_1 = rho * np.array([u * v, v * v + p, v * w]) -print(fc_momentum_1) - -fc_momentum_2 = rho * np.array([u * w, v * w, w * w + p]) -print(fc_momentum_2) - -fc_energy = rho * Cp * np.array([u * T, v * T, w * T]) -print(fc_energy) - -print("\nFlux with unscaled density:\n") -rho = 3.0 -fc_continuity = rho * np.array([u, v, w]) -print(fc_continuity) - -fc_momentum_0 = np.array([rho * u * u + p, rho * u * v, rho * u * w]) -print(fc_momentum_0) - -fc_momentum_1 = np.array([rho * u * v, rho * v * v + p, rho * v * w]) -print(fc_momentum_1) - -fc_momentum_2 = np.array([rho * u * w, rho * v * w, rho * w * w + p]) -print(fc_momentum_2) - -fc_energy = rho * Cp * np.array([u * T, v * T, w * T]) -print(fc_energy) diff --git a/src/incompressible_solver/closure_models/unit_test/doc/error_norms_reference.py b/src/incompressible_solver/closure_models/unit_test/doc/error_norms_reference.py deleted file mode 100644 index 6684898..0000000 --- a/src/incompressible_solver/closure_models/unit_test/doc/error_norms_reference.py +++ /dev/null @@ -1,17 +0,0 @@ -import math - -# computational/mms solution -comp = [0.1, 0.3, 0.4, 0.5, 0.8] -mms = [0.2, 0.7, 0.9, 1.1, 1.2] - -var_id = range(len(comp)) - -# L1 error norm -print("L1 norm (phi, vec{u}, T):") -for i in var_id: - print(abs(comp[i] - mms[i])) - -# L2 error norm -print("L2 norm (phi, vec{u}, T):") -for i in var_id: - print((comp[i] - mms[i])**2.0) diff --git a/src/incompressible_solver/closure_models/unit_test/doc/liftdrag_reference.py b/src/incompressible_solver/closure_models/unit_test/doc/liftdrag_reference.py deleted file mode 100644 index 0913083..0000000 --- a/src/incompressible_solver/closure_models/unit_test/doc/liftdrag_reference.py +++ /dev/null @@ -1,67 +0,0 @@ -import numpy as np - -# NOTE: -# - The lift and drag calculations assume that the drag is -# in x-direction and lift is in y-direction. -# - Currently, lift/drag calculation ignores the turbulence model. - - -def twosym(t): - return t + t.T - - -def dev(t): - return t - (1 / t.shape[0]) * np.eye(t.shape[0]) * np.trace(t) - - -def lift_drag(rho, - nu, - lagrange_pressure, - normals, - grad_velocity, - dim, - is_compressible=False): - # Calculate shear stress with grad.U + transpose(grad.U) - tau = twosym(grad_velocity[0:dim, 0:dim]) - if is_compressible: tau = dev(tau) - viscous_force = -rho * nu * np.dot(tau, normals[0:dim]) - pressure_force = lagrange_pressure * normals[0:dim] - total_force = viscous_force + pressure_force - - return viscous_force, pressure_force, total_force - - -# Coefficients -# rho is given within the for loop for unscaled_density case -nu = 0.375 - -# Velocity vector, velocity and temperature gradients for viscous flux -velocity = np.array([0.25, 0.5, 0.125]) -grad_vel = np.array([[-0.25, 0.5, -0.75], [-0.5, 1.0, -1.5], - [-0.125, 0.25, -0.375]]) -normals = np.array([-0.75, 1.5, -2.25]) -lagrange_pres = 0.75 - -# Create expected values for every mesh dimension and -# Scaled/Unscaled density cases -dims = [2, 3] -density_type = ['Scaled', 'Unscaled'] -calculation_types = ['Incompressible', 'Compressible'] -for cal_type in calculation_types: - print("\n" + cal_type + " case:") - for dim in dims: - print("\n" + str(dim) + "-D case:") - for den_type in density_type: - print("\n" + den_type + " Density:") - if den_type == 'Scaled': rho = 1.0 - if den_type == 'Unscaled': rho = 3.0 - - if cal_type == 'Incompressible': - viscous_force, pressure_force, total_force = lift_drag( - rho, nu, lagrange_pres, normals, grad_vel, dim) - if cal_type == 'Compressible': - viscous_force, pressure_force, total_force = lift_drag( - rho, nu, lagrange_pres, normals, grad_vel, dim, True) - print("Viscous Force:", viscous_force) - print("Pressure Force:", pressure_force) - print("Total Force:", total_force) diff --git a/src/incompressible_solver/closure_models/unit_test/doc/local_time_step_size_reference.py b/src/incompressible_solver/closure_models/unit_test/doc/local_time_step_size_reference.py deleted file mode 100644 index b5ceb8a..0000000 --- a/src/incompressible_solver/closure_models/unit_test/doc/local_time_step_size_reference.py +++ /dev/null @@ -1,15 +0,0 @@ -# Dependent values -u = -1.5 -v = 2.0 -w = -0.5 -h0 = 0.25 -h1 = 0.5 -h2 = 0.75 - -# 2-D case -dt = 1.0 / (abs(u) / h0 + abs(v) / h1) -print("2-D dt: ", dt) - -# 3-D case -dt = 1.0 / (abs(u) / h0 + abs(v) / h1 + abs(w) / h2) -print("3-D dt: ", dt) diff --git a/src/incompressible_solver/closure_models/unit_test/doc/planar_poiseuille_reference.py b/src/incompressible_solver/closure_models/unit_test/doc/planar_poiseuille_reference.py deleted file mode 100644 index 28e0bbe..0000000 --- a/src/incompressible_solver/closure_models/unit_test/doc/planar_poiseuille_reference.py +++ /dev/null @@ -1,35 +0,0 @@ -# Coefficients -nu = 50 -rho = 1.0 -k = 0.5 -cp = 100 -h_min = -4.0 -h_max = 4.0 -T_l = 305.0 -T_u = 300.0 -S_u = 24000 - -# Coordinates -x = 2.25 -y = 2.20 - -# Exact solution calculations -H = (h_max - h_min) / 2.0 -dT = T_l - T_u -U_avg = S_u * H * H / 3 / nu -Pr = cp * rho * nu / k -E = U_avg * U_avg / cp / dT - -## Velocity -u = 3.0 / 2.0 * U_avg * (1.0 - pow(y / H, 2.0)) -v = 0.0 - -print("x velocity: ", u) -print("y velocity: ", v) - -## Temperature -T_star = 0.5 * (1.0 - (y / H)) + 3.0 / 4.0 * Pr * E * (1.0 - pow(y / H, 4.0)) - -temp = T_star * dT + T_u - -print("Temperature: ", temp) diff --git a/src/incompressible_solver/closure_models/unit_test/doc/rotating_annulus_exact_reference.py b/src/incompressible_solver/closure_models/unit_test/doc/rotating_annulus_exact_reference.py deleted file mode 100644 index 5b2f09e..0000000 --- a/src/incompressible_solver/closure_models/unit_test/doc/rotating_annulus_exact_reference.py +++ /dev/null @@ -1,40 +0,0 @@ -import numpy as np - -# Coefficients -nu = 50 -rho = 1.0 -k = 0.5 -Ro = 4.0 -Ri = 2.0 -omega = 0.5 -To = 274.0 -Ti = 273.0 - -# Coordinates -x = 2.25 -y = 2.20 - -# Exact solution calculations -r = np.sqrt(x * x + y * y) -xi = r / Ro -kappa = Ri / Ro - -## Velocity -u_phi = omega * Ro * Ro / (Ro * Ro - Ri * Ri) * (r - (Ri * Ri) / r) -u = -u_phi * y / r -v = u_phi * x / r - -print("x velocity: ", u) -print("y velocity: ", v) - -## Temperature -N = nu * rho * omega * omega * Ro * Ro / k / (To - Ti) * pow(kappa, 4.0) / pow( - 1.0 - pow(kappa, 2.0), 2.0) - -theta = (1.0 - np.log(xi) / np.log(kappa)) + N * ( - (1 - 1 / (xi * xi)) - (1 - 1 / - (kappa * kappa)) * np.log(xi) / np.log(kappa)) - -temp = theta * (To - Ti) + Ti - -print("Temperature: ", temp) diff --git a/src/incompressible_solver/closure_models/unit_test/doc/shear_variables_reference.py b/src/incompressible_solver/closure_models/unit_test/doc/shear_variables_reference.py deleted file mode 100644 index 4db438b..0000000 --- a/src/incompressible_solver/closure_models/unit_test/doc/shear_variables_reference.py +++ /dev/null @@ -1,29 +0,0 @@ -import numpy as np - -# Coefficients -nu = 0.375 -rho = 1.5 - -# 2-D case -print("\n2-D case:") -grad_vel = np.array([[-0.25, 0.5], [-0.5, 1.0]]) -normals = np.array([-0.125, 0.25]) - -tau_dot_n = grad_vel.dot(normals) -tau_dot_n = np.linalg.norm(tau_dot_n) - -print("Shear stress:", rho * nu * tau_dot_n) -print("Friction velocity:", np.sqrt(tau_dot_n * nu)) - -# 3-D case -print("\n3-D case:") -grad_vel = np.array([[-0.25, 0.5, -0.75], [-0.5, 1.0, -1.5], - [-0.725, 1.45, -2.175]]) -normals = np.array([-0.125, 0.25, -0.375]) - -tau_dot_n = grad_vel.dot(normals) -tau_dot_n = np.linalg.norm(tau_dot_n) - -print("Shear stress:", rho * nu * tau_dot_n) -print("Friction velocity:", np.sqrt(tau_dot_n * nu), "\n") -strain_rate = 0.5 * (grad_vel + grad_vel.transpose()) diff --git a/src/incompressible_solver/closure_models/unit_test/doc/taylor_green_vortex_reference.py b/src/incompressible_solver/closure_models/unit_test/doc/taylor_green_vortex_reference.py deleted file mode 100644 index a3f505c..0000000 --- a/src/incompressible_solver/closure_models/unit_test/doc/taylor_green_vortex_reference.py +++ /dev/null @@ -1,32 +0,0 @@ -import math - -# Node coordinates (set in the unit test) -x_list = [-0.15, -0.05, 0.05, 0.15] -y_list = [-0.05, 0.15, 0.35, 0.55] - - -# Function -def ic(x, y, time, nu): - Ft = math.exp(-2.0 * nu * time) - u = math.cos(x) * math.sin(y) * Ft - v = -math.sin(x) * math.cos(y) * Ft - p = -0.25 * (math.cos(2.0 * x) + math.cos(2.0 * y)) * Ft * Ft - return u, v, p - - -# Compute ic values -time = 0.5 -nu = 0.325 -p_list = [] -u_list = [] -v_list = [] -for x, y in zip(x_list, y_list): - u, v, p = ic(x, y, time, nu) - p_list.append(p) - u_list.append(u) - v_list.append(v) - -# Print ic values -print("phi: ", p_list) -print("u: ", u_list) -print("v: ", v_list) diff --git a/src/incompressible_solver/closure_models/unit_test/doc/viscous_flux_reference.py b/src/incompressible_solver/closure_models/unit_test/doc/viscous_flux_reference.py deleted file mode 100644 index a4ec4e6..0000000 --- a/src/incompressible_solver/closure_models/unit_test/doc/viscous_flux_reference.py +++ /dev/null @@ -1,87 +0,0 @@ -import numpy as np - -# NOTE: -# - all momentum fluxes have to be multiplied by `nu` for -# laminar case and `nu + nu_t` for turbulent cases. -# - with unscaled density, all viscous fluxes are to be -# multiplied by rho -# - energy flux is multiplied by `k` for laminar case and -# `k + k_t` for turbulent cases. - - -def continuity_flux(rho, nu, nu_t, beta, grad_lagrange_pres, - build_turbulence_model, num_space_dim): - fv_continuity_flux = rho * nu * grad_lagrange_pres / beta - - return fv_continuity_flux[0:num_space_dim] - - -def momentum_flux(rho, nu, nu_t, grad_vel, build_turbulence_model, - num_space_dim): - fv_momentum_flux = rho * nu * grad_vel - if build_turbulence_model: fv_momentum_flux = rho * (nu + nu_t) * grad_vel - - return fv_momentum_flux[0:num_space_dim] - - -def energy_flux(kappa, kappa_t, grad_temp, build_turbulence_model, - num_space_dim): - fv_energy = kappa * grad_temp - if build_turbulence_model: fv_energy = (kappa + kappa_t) * grad_temp - - return fv_energy[0:num_space_dim] - - -# Coefficients -# rho and kappa_t is given within the for loop for unscaled_density case -kappa = 0.5 -nu = 0.375 -nu_t = 4.0 -cp = 0.2 -Pr_t = 0.8 -beta = 2.0 - -# Velocity vector, velocity and temperature gradients for viscous flux -velocity = np.array([0.25, 0.5, 0.125]) -grad_vel = np.array([[-0.25, 0.5, -0.75], [-0.5, 1.0, -1.5], - [-0.125, 0.25, -0.375]]) -grad_temp = np.array([-0.75, 1.5, -2.25]) -grad_lagrange_pres = np.array([-0.75, 1.5, -2.25]) - -# Create expected values for every mesh dimension and -# Scaled/Unscaled density cases with/without turbulence model -dims = [2, 3] -density_type = ['Scaled', 'Unscaled'] -for dim in dims: - print("\n" + str(dim) + "-D case:") - for den_type in density_type: - print("\n" + den_type + " Density:") - for build_turbulence_model in [True, False]: - if den_type == 'Scaled': rho = 1.0 - if den_type == 'Unscaled': rho = 3.0 - kappa_t = rho * nu_t * cp / Pr_t - - print("\nTurbulence Model is " + str(build_turbulence_model) + - "\n") - - fv_continuity = continuity_flux(rho, nu, nu_t, beta, - grad_lagrange_pres, - build_turbulence_model, dim) - print("fv_continuity for AC Model:", np.zeros([dim])) - print("fv_continuity for EDAC Model:", fv_continuity) - - fv_momentum_0 = momentum_flux(rho, nu, nu_t, grad_vel[0], - build_turbulence_model, dim) - print("fv_momentum_0:", fv_momentum_0) - - fv_momentum_1 = momentum_flux(rho, nu, nu_t, grad_vel[1], - build_turbulence_model, dim) - print("fv_momentum_1:", fv_momentum_1) - - fv_momentum_2 = momentum_flux(rho, nu, nu_t, grad_vel[2], - build_turbulence_model, dim) - if dim > 2: print("fv_momentum_2:", fv_momentum_2) - - fv_energy = energy_flux(kappa, kappa_t, grad_temp, - build_turbulence_model, dim) - print("fv_energy:", fv_energy) diff --git a/src/incompressible_solver/closure_models/unit_test/doc/viscous_heat_reference.py b/src/incompressible_solver/closure_models/unit_test/doc/viscous_heat_reference.py deleted file mode 100644 index 3d93ce0..0000000 --- a/src/incompressible_solver/closure_models/unit_test/doc/viscous_heat_reference.py +++ /dev/null @@ -1,28 +0,0 @@ -import numpy as np - -# Coefficients -nu = 0.375 -rho = 1.0 - -# 2-D case -grad_vel = np.array([[-0.25, 0.5], [-0.5, 1.0]]) -print("\n2-D case:") - -strain_rate_2D = 0.5 * (grad_vel + grad_vel.transpose()) - -fv_viscous_heat_2D = 2.0 * rho * nu * np.tensordot(strain_rate_2D, - strain_rate_2D) - -print("fv_viscous_heat:", fv_viscous_heat_2D) - -# 3-D case -grad_vel = np.array([[-0.25, 0.5, -0.75], [-0.5, 1.0, -1.5], - [-0.125, 0.25, -0.375]]) - -strain_rate = 0.5 * (grad_vel + grad_vel.transpose()) - -print("\n3-D case:\n") - -fv_viscous_heat = 2.0 * rho * nu * np.tensordot(strain_rate, strain_rate) - -print("fv_viscous_heat:", fv_viscous_heat) diff --git a/src/incompressible_solver/closure_models/unit_test/tstIncompressibleBuoyancySource.cpp b/src/incompressible_solver/closure_models/unit_test/tstIncompressibleBuoyancySource.cpp deleted file mode 100644 index 4b391b6..0000000 --- a/src/incompressible_solver/closure_models/unit_test/tstIncompressibleBuoyancySource.cpp +++ /dev/null @@ -1,197 +0,0 @@ -#include -#include - -#include "incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleBuoyancySource.hpp" -#include "incompressible_solver/fluid_properties/VertexCFD_ConstantFluidProperties.hpp" - -#include - -namespace VertexCFD -{ -namespace Test -{ - -template -struct Dependencies : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - using scalar_type = typename EvalType::ScalarT; - - double _T; - - PHX::MDField temperature; - - Dependencies(const panzer::IntegrationRule& ir, const double T) - : _T(T) - , temperature("temperature", ir.dl_scalar) - { - this->addEvaluatedField(temperature); - - this->setName("Incompressible Buoyancy Source Unit Test Dependencies"); - } - - void evaluateFields(typename panzer::Traits::EvalData d) override - { - Kokkos::parallel_for( - "buoyancy source test dependencies", - Kokkos::RangePolicy(0, d.num_cells), - *this); - } - - KOKKOS_INLINE_FUNCTION void operator()(const int c) const - { - const int num_point = temperature.extent(1); - - for (int qp = 0; qp < num_point; ++qp) - { - temperature(c, qp) = _T; - } - } -}; - -template -void testEval() -{ - constexpr int num_space_dim = NumSpaceDim; - const int integration_order = 2; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - - auto& ir = *test_fixture.ir; - - // Initialize class object to test - const double T = 330.0; - Teuchos::Array gravity(num_space_dim); - gravity[0] = 2.0; - gravity[1] = 3.0; - if (num_space_dim == 3) - gravity[2] = 4.0; - Teuchos::ParameterList user_params; - Teuchos::ParameterList fluid_prop_list; - fluid_prop_list.set("Kinematic viscosity", 0.375); - fluid_prop_list.set("Artificial compressibility", 2.0); - fluid_prop_list.set("Build Temperature Equation", true); - fluid_prop_list.set("Thermal conductivity", 0.5); - fluid_prop_list.set("Specific heat capacity", 5.0); - fluid_prop_list.set("Build Buoyancy Source", true); - fluid_prop_list.set("Reference temperature", 300.0); - fluid_prop_list.set("Expansion coefficient", 1.0e-2); - user_params.set("Build Buoyancy Source", true); - user_params.set("Gravity", gravity); - - const FluidProperties::ConstantFluidProperties fluid_prop(fluid_prop_list); - - auto deps = Teuchos::rcp(new Dependencies(ir, T)); - test_fixture.registerEvaluator(deps); - - auto eval = Teuchos::rcp( - new ClosureModel::IncompressibleBuoyancySource( - ir, fluid_prop, user_params)); - test_fixture.registerEvaluator(eval); - test_fixture.registerTestField(eval->_buoyancy_continuity_source); - test_fixture.registerTestField(eval->_buoyancy_energy_source); - for (int dim = 0; dim < num_space_dim; ++dim) - test_fixture.registerTestField( - eval->_buoyancy_momentum_source[dim]); - - test_fixture.evaluate(); - - const auto fc_cont = test_fixture.getTestFieldData( - eval->_buoyancy_continuity_source); - const auto fc_energy = test_fixture.getTestFieldData( - eval->_buoyancy_energy_source); - const auto fc_mom_0 = test_fixture.getTestFieldData( - eval->_buoyancy_momentum_source[0]); - const auto fc_mom_1 = test_fixture.getTestFieldData( - eval->_buoyancy_momentum_source[1]); - - const int num_point = ir.num_points; - - const double exp_mom_source[3] = {-0.6, -0.9, -1.2}; - - // Assert values - for (int qp = 0; qp < num_point; ++qp) - { - EXPECT_DOUBLE_EQ(0.0, fieldValue(fc_cont, 0, qp)); - EXPECT_DOUBLE_EQ(0.0, fieldValue(fc_energy, 0, qp)); - - EXPECT_DOUBLE_EQ(exp_mom_source[0], fieldValue(fc_mom_0, 0, qp)); - EXPECT_DOUBLE_EQ(exp_mom_source[1], fieldValue(fc_mom_1, 0, qp)); - if (num_space_dim > 2) // 3D mesh - { - const auto fc_mom_2 = test_fixture.getTestFieldData( - eval->_buoyancy_momentum_source[2]); - EXPECT_DOUBLE_EQ(exp_mom_source[2], fieldValue(fc_mom_2, 0, qp)); - } - } -} - -//-----------------------------------------------------------------// -TEST(IncompressibleBuoyancySource2D, residual_test) -{ - testEval(); -} - -//-----------------------------------------------------------------// -TEST(IncompressibleBuoyancySource2D, jacobian_test) -{ - testEval(); -} - -//-----------------------------------------------------------------// -TEST(IncompressibleBuoyancySource3D, residual_test) -{ - testEval(); -} - -//-----------------------------------------------------------------// -TEST(IncompressibleBuoyancySource3D, jacobian_test) -{ - testEval(); -} - -//-----------------------------------------------------------------// -template -void testFactory() -{ - constexpr int num_space_dim = NumSpaceDim; - ClosureModelFactoryTestFixture test_fixture; - const Teuchos::Array gravity(num_space_dim); - test_fixture.user_params.set("Gravity", gravity); - test_fixture.user_params.set("Build Temperature Equation", false); - test_fixture.user_params.sublist("Fluid Properties") - .set("Kinematic viscosity", 0.1) - .set("Artificial compressibility", 2.0); - test_fixture.type_name = "IncompressibleBuoyancySource"; - test_fixture.eval_name = "Incompressible Buoyancy Source " - + std::to_string(num_space_dim) + "D"; - test_fixture.template buildAndTest< - ClosureModel::IncompressibleBuoyancySource, - num_space_dim>(); -} - -TEST(IncompressibleBuoyancySource_Factory2D, residual_test) -{ - testFactory(); -} - -TEST(IncompressibleBuoyancySource_Factory2D, jacobian_test) -{ - testFactory(); -} - -TEST(IncompressibleBuoyancySource_Factory3D, residual_test) -{ - testFactory(); -} - -TEST(IncompressibleBuoyancySource_Factory3D, jacobian_test) -{ - testFactory(); -} - -} // namespace Test -} // namespace VertexCFD diff --git a/src/incompressible_solver/closure_models/unit_test/tstIncompressibleConstantSource.cpp b/src/incompressible_solver/closure_models/unit_test/tstIncompressibleConstantSource.cpp deleted file mode 100644 index 6222088..0000000 --- a/src/incompressible_solver/closure_models/unit_test/tstIncompressibleConstantSource.cpp +++ /dev/null @@ -1,165 +0,0 @@ -#include -#include - -#include "incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleConstantSource.hpp" -#include "incompressible_solver/fluid_properties/VertexCFD_ConstantFluidProperties.hpp" - -#include - -namespace VertexCFD -{ -namespace Test -{ - -template -void testEval(const bool build_temp_equ) -{ - constexpr int num_space_dim = NumSpaceDim; - const int integration_order = 2; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - - auto& ir = *test_fixture.ir; - - // Initialize class object to test - Teuchos::Array mom_input_source(num_space_dim); - mom_input_source[0] = 0.1; - mom_input_source[1] = 0.2; - if (num_space_dim == 3) - mom_input_source[2] = 0.3; - Teuchos::ParameterList user_params; - user_params.set("Momentum Source", mom_input_source); - Teuchos::ParameterList fluid_prop_list; - fluid_prop_list.set("Kinematic viscosity", 0.375); - fluid_prop_list.set("Artificial compressibility", 2.0); - fluid_prop_list.set("Build Temperature Equation", build_temp_equ); - const double energy_input_source - = build_temp_equ ? 0.4 : std::numeric_limits::quiet_NaN(); - if (build_temp_equ) - { - user_params.set("Energy Source", energy_input_source); - fluid_prop_list.set("Thermal conductivity", 0.5); - fluid_prop_list.set("Specific heat capacity", 5.0); - } - const FluidProperties::ConstantFluidProperties fluid_prop(fluid_prop_list); - auto eval = Teuchos::rcp( - new ClosureModel::IncompressibleConstantSource( - ir, fluid_prop, user_params)); - test_fixture.registerEvaluator(eval); - test_fixture.registerTestField(eval->_continuity_source); - for (int dim = 0; dim < num_space_dim; ++dim) - test_fixture.registerTestField(eval->_momentum_source[dim]); - - test_fixture.evaluate(); - - const auto fc_cont - = test_fixture.getTestFieldData(eval->_continuity_source); - const auto fc_mom_0 - = test_fixture.getTestFieldData(eval->_momentum_source[0]); - const auto fc_mom_1 - = test_fixture.getTestFieldData(eval->_momentum_source[1]); - - const int num_point = ir.num_points; - - // Assert values - for (int qp = 0; qp < num_point; ++qp) - { - EXPECT_EQ(0.0, fieldValue(fc_cont, 0, qp)); - EXPECT_EQ(mom_input_source[0], fieldValue(fc_mom_0, 0, qp)); - EXPECT_EQ(mom_input_source[1], fieldValue(fc_mom_1, 0, qp)); - if (num_space_dim > 2) // 3D mesh - { - const auto fc_mom_2 = test_fixture.getTestFieldData( - eval->_momentum_source[2]); - EXPECT_EQ(mom_input_source[2], fieldValue(fc_mom_2, 0, qp)); - } - if (build_temp_equ) - { - const auto fc_energy = test_fixture.getTestFieldData( - eval->_energy_source); - EXPECT_EQ(energy_input_source, fieldValue(fc_energy, 0, qp)); - } - } -} - -//-----------------------------------------------------------------// -TEST(IncompressibleConstantSourceIsothermal2D, residual_test) -{ - testEval(false); -} - -//-----------------------------------------------------------------// -TEST(IncompressibleConstantSourceIsothermal2D, jacobian_test) -{ - testEval(false); -} - -//-----------------------------------------------------------------// -TEST(IncompressibleConstantSourceIsothermal3D, residual_test) -{ - testEval(false); -} - -//-----------------------------------------------------------------// -TEST(IncompressibleConstantSourceIsothermal3D, jacobian_test) -{ - testEval(false); -} - -//-----------------------------------------------------------------// -TEST(IncompressibleConstantSource3D, residual_test) -{ - testEval(true); -} - -//-----------------------------------------------------------------// -TEST(IncompressibleConstantSource3D, jacobian_test) -{ - testEval(true); -} - -//-----------------------------------------------------------------// -template -void testFactory() -{ - constexpr int num_space_dim = NumSpaceDim; - ClosureModelFactoryTestFixture test_fixture; - const Teuchos::Array mom_input_source(num_space_dim); - test_fixture.user_params.set("Momentum Source", mom_input_source); - test_fixture.user_params.set("Build Temperature Equation", false); - test_fixture.user_params.sublist("Fluid Properties") - .set("Kinematic viscosity", 0.1) - .set("Artificial compressibility", 2.0); - test_fixture.type_name = "IncompressibleConstantSource"; - test_fixture.eval_name = "Incompressible Constant Source " - + std::to_string(num_space_dim) + "D"; - test_fixture.template buildAndTest< - ClosureModel::IncompressibleConstantSource, - num_space_dim>(); -} - -TEST(IncompressibleConstantSource_Factory2D, residual_test) -{ - testFactory(); -} - -TEST(IncompressibleConstantSource_Factory2D, jacobian_test) -{ - testFactory(); -} - -TEST(IncompressibleConstantSource_Factory3D, residual_test) -{ - testFactory(); -} - -TEST(IncompressibleConstantSource_Factory3D, jacobian_test) -{ - testFactory(); -} - -} // namespace Test -} // namespace VertexCFD diff --git a/src/incompressible_solver/closure_models/unit_test/tstIncompressibleConvectiveFlux.cpp b/src/incompressible_solver/closure_models/unit_test/tstIncompressibleConvectiveFlux.cpp deleted file mode 100644 index 800293f..0000000 --- a/src/incompressible_solver/closure_models/unit_test/tstIncompressibleConvectiveFlux.cpp +++ /dev/null @@ -1,274 +0,0 @@ -#include -#include - -#include "incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleConvectiveFlux.hpp" -#include "incompressible_solver/fluid_properties/VertexCFD_ConstantFluidProperties.hpp" - -#include - -namespace VertexCFD -{ -namespace Test -{ -template -struct Dependencies : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - using scalar_type = typename EvalType::ScalarT; - - double _u; - double _v; - double _w; - bool _build_temp; - - PHX::MDField lagrange_pressure; - PHX::MDField vel_0; - PHX::MDField vel_1; - PHX::MDField vel_2; - PHX::MDField temperature; - - Dependencies(const panzer::IntegrationRule& ir, - const double u, - const double v, - const double w, - const bool build_temp) - : _u(u) - , _v(v) - , _w(w) - , _build_temp(build_temp) - , lagrange_pressure("lagrange_pressure", ir.dl_scalar) - , vel_0("velocity_0", ir.dl_scalar) - , vel_1("velocity_1", ir.dl_scalar) - , vel_2("velocity_2", ir.dl_scalar) - , temperature("temperature", ir.dl_scalar) - - { - this->addEvaluatedField(lagrange_pressure); - this->addEvaluatedField(vel_0); - this->addEvaluatedField(vel_1); - this->addEvaluatedField(vel_2); - if (_build_temp) - this->addEvaluatedField(temperature); - - this->setName("Incompressible Convective Flux Unit Test Dependencies"); - } - - void evaluateFields(typename panzer::Traits::EvalData) override - { - lagrange_pressure.deep_copy(0.75); - vel_0.deep_copy(_u); - vel_1.deep_copy(_v); - vel_2.deep_copy(_w); - if (_build_temp) - temperature.deep_copy(_u + _v); - } -}; - -template -void testEval(const bool unscaled_density, const bool build_temp) -{ - constexpr int num_space_dim = NumSpaceDim; - const int integration_order = 2; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - - auto& ir = *test_fixture.ir; - - // Initialize velocity components and dependents - const double u = 0.25; - const double v = 0.5; - const double w - = num_space_dim > 2 ? 0.125 : std::numeric_limits::quiet_NaN(); - - auto deps - = Teuchos::rcp(new Dependencies(ir, u, v, w, build_temp)); - test_fixture.registerEvaluator(deps); - - // Initialize class object to test - double rho = 1.0; - Teuchos::ParameterList fluid_prop_list; - fluid_prop_list.set("Kinematic viscosity", 0.375); - fluid_prop_list.set("Artificial compressibility", 2.0); - fluid_prop_list.set("Build Temperature Equation", build_temp); - if (unscaled_density) - { - rho = 3.0; - fluid_prop_list.set("Density", rho); - } - if (build_temp) - { - fluid_prop_list.set("Thermal conductivity", 0.5); - fluid_prop_list.set("Specific heat capacity", 5.0); - } - const FluidProperties::ConstantFluidProperties fluid_prop(fluid_prop_list); - auto eval = Teuchos::rcp( - new ClosureModel::IncompressibleConvectiveFlux( - ir, fluid_prop)); - test_fixture.registerEvaluator(eval); - test_fixture.registerTestField(eval->_continuity_flux); - for (int dim = 0; dim < num_space_dim; ++dim) - test_fixture.registerTestField(eval->_momentum_flux[dim]); - - test_fixture.evaluate(); - - auto fc_cont - = test_fixture.getTestFieldData(eval->_continuity_flux); - auto fc_mom_0 - = test_fixture.getTestFieldData(eval->_momentum_flux[0]); - - const int num_point = ir.num_points; - - // Expected values - const double exp_cont_flux[3] = {rho * u, rho * v, rho * w}; - const double exp_mom_0_flux[3] - = {unscaled_density ? 0.9375 : 0.8125, - unscaled_density ? 0.375 : 0.125, - num_space_dim == 3 ? unscaled_density ? 0.09375 : 0.03125 - : std::numeric_limits::quiet_NaN()}; - const double exp_mom_1_flux[3] - = {unscaled_density ? 0.375 : 0.125, - unscaled_density ? 1.5 : 1., - num_space_dim == 3 ? unscaled_density ? 0.1875 : 0.0625 - : std::numeric_limits::quiet_NaN()}; - const double exp_mom_2_flux[3] - = {unscaled_density ? 0.09375 : 0.03125, - unscaled_density ? 0.1875 : 0.0625, - num_space_dim == 3 ? unscaled_density ? 0.796875 : 0.765625 - : std::numeric_limits::quiet_NaN()}; - const double exp_ener_flux[3] - = {unscaled_density ? 2.8125 : 0.9375, - unscaled_density ? 5.625 : 1.875, - num_space_dim == 3 ? unscaled_density ? 1.40625 : 0.46875 - : std::numeric_limits::quiet_NaN()}; - - // Assert values - for (int qp = 0; qp < num_point; ++qp) - { - for (int dim = 0; dim < num_space_dim; dim++) - { - EXPECT_EQ(exp_cont_flux[dim], fieldValue(fc_cont, 0, qp, dim)); - EXPECT_EQ(exp_mom_0_flux[dim], fieldValue(fc_mom_0, 0, qp, dim)); - const auto fc_mom_1 = test_fixture.getTestFieldData( - eval->_momentum_flux[1]); - EXPECT_EQ(exp_mom_1_flux[dim], fieldValue(fc_mom_1, 0, qp, dim)); - if (num_space_dim > 2) // 3D mesh - { - const auto fc_mom_2 = test_fixture.getTestFieldData( - eval->_momentum_flux[2]); - EXPECT_EQ(exp_mom_2_flux[dim], - fieldValue(fc_mom_2, 0, qp, dim)); - } - if (build_temp) - { - const auto fc_energy = test_fixture.getTestFieldData( - eval->_energy_flux); - EXPECT_EQ(exp_ener_flux[dim], - fieldValue(fc_energy, 0, qp, dim)); - } - } - } -} - -//-----------------------------------------------------------------// -TEST(IncompressibleConvectiveFluxScaledDensityIsothermal2D, residual_test) -{ - testEval(false, false); -} - -//-----------------------------------------------------------------// -TEST(IncompressibleConvectiveFluxScaledDensityIsothermal2D, jacobian_test) -{ - testEval(false, false); -} - -//-----------------------------------------------------------------// -TEST(IncompressibleConvectiveFluxScaledDensity2D, residual_test) -{ - testEval(false, true); -} - -//-----------------------------------------------------------------// -TEST(IncompressibleConvectiveFluxScaledDensity2D, jacobian_test) -{ - testEval(false, true); -} - -//-----------------------------------------------------------------// -TEST(IncompressibleConvectiveFluxScaledDensityIsothermal3D, residual_test) -{ - testEval(false, false); -} - -//-----------------------------------------------------------------// -TEST(IncompressibleConvectiveFluxScaledDensityIsothermal3D, jacobian_test) -{ - testEval(false, false); -} - -//-----------------------------------------------------------------// -TEST(IncompressibleConvectiveFluxUnscaledDensityIsothermal3D, residual_test) -{ - testEval(true, false); -} - -//-----------------------------------------------------------------// -TEST(IncompressibleConvectiveFluxUnscaledDensityIsothermal3D, jacobian_test) -{ - testEval(true, false); -} - -//-----------------------------------------------------------------// -TEST(IncompressibleConvectiveFluxUnscaledDensity3D, residual_test) -{ - testEval(true, true); -} - -//-----------------------------------------------------------------// -TEST(IncompressibleConvectiveFluxUnscaledDensity3D, jacobian_test) -{ - testEval(true, true); -} - -//-----------------------------------------------------------------// -template -void testFactory() -{ - constexpr int num_space_dim = NumSpaceDim; - ClosureModelFactoryTestFixture test_fixture; - test_fixture.user_params.set("Build Temperature Equation", false); - test_fixture.user_params.sublist("Fluid Properties") - .set("Kinematic viscosity", 0.1) - .set("Artificial compressibility", 2.0); - test_fixture.type_name = "IncompressibleConvectiveFlux"; - test_fixture.eval_name = "Incompressible Convective Flux " - + std::to_string(num_space_dim) + "D"; - test_fixture.template buildAndTest< - ClosureModel::IncompressibleConvectiveFlux, - num_space_dim>(); -} - -TEST(IncompressibleConvectiveFlux_Factory2D, residual_test) -{ - testFactory(); -} - -TEST(IncompressibleConvectiveFlux_Factory2D, jacobian_test) -{ - testFactory(); -} - -TEST(IncompressibleConvectiveFlux_Factory3D, residual_test) -{ - testFactory(); -} - -TEST(IncompressibleConvectiveFlux_Factory3D, jacobian_test) -{ - testFactory(); -} - -} // namespace Test -} // namespace VertexCFD diff --git a/src/incompressible_solver/closure_models/unit_test/tstIncompressibleErrorNorms.cpp b/src/incompressible_solver/closure_models/unit_test/tstIncompressibleErrorNorms.cpp deleted file mode 100644 index afde8da..0000000 --- a/src/incompressible_solver/closure_models/unit_test/tstIncompressibleErrorNorms.cpp +++ /dev/null @@ -1,260 +0,0 @@ -#include -#include - -#include - -#include - -//---------------------------------------------------------------------------// -// TESTS -//---------------------------------------------------------------------------// -namespace VertexCFD -{ -namespace Test -{ -//---------------------------------------------------------------------------// -template -struct Dependencies : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - using scalar_type = typename EvalType::ScalarT; - static constexpr int num_space_dim = NumSpaceDim; - - // exact solution - PHX::MDField exact_phi; - Kokkos::Array, num_space_dim> - exact_velocity; - PHX::MDField exact_T; - - // numerical solution - PHX::MDField phi; - Kokkos::Array, - num_space_dim> - velocity; - PHX::MDField T; - - Dependencies(const panzer::IntegrationRule& ir) - : exact_phi("Exact_lagrange_pressure", ir.dl_scalar) - , exact_T("Exact_temperature", ir.dl_scalar) - , phi("lagrange_pressure", ir.dl_scalar) - , T("temperature", ir.dl_scalar) - { - // exact solution - this->addEvaluatedField(exact_phi); - Utils::addEvaluatedVectorField( - *this, ir.dl_scalar, exact_velocity, "Exact_velocity_"); - this->addEvaluatedField(exact_T); - - // numerical solution - this->addEvaluatedField(phi); - Utils::addEvaluatedVectorField( - *this, ir.dl_scalar, velocity, "velocity_"); - this->addEvaluatedField(T); - - this->setName("Incompressible Error Norms Unit Test Dependencies"); - } - - void evaluateFields(typename panzer::Traits::EvalData) override - { - // assign prescribed values to exact and numerical solution - exact_phi.deep_copy(0.1); - phi.deep_copy(0.2); - for (int i = 0; i < num_space_dim; ++i) - { - exact_velocity[i].deep_copy(0.3 + 0.1 * i); - velocity[i].deep_copy(0.7 + 0.2 * i); - } - exact_T.deep_copy(0.8); - T.deep_copy(1.2); - } -}; - -template -void testEval(const bool solve_temp) -{ - // Setup test fixture. - constexpr int num_space_dim = NumSpaceDim; - const int integration_order = 0; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - - const auto& ir = *test_fixture.ir; - - const auto deps - = Teuchos::rcp(new Dependencies(ir)); - test_fixture.registerEvaluator(deps); - - // Create the param list to initialize the evaluator - Teuchos::ParameterList user_params; - user_params.set("Build Temperature Equation", solve_temp); - - // Create evaluator. - const auto eval = Teuchos::rcp( - new ClosureModel:: - IncompressibleErrorNorms( - ir, user_params)); - test_fixture.registerEvaluator(eval); - - // Add required test fields. - test_fixture.registerTestField(eval->_L1_error_continuity); - test_fixture.registerTestField(eval->_L2_error_continuity); - for (int dim = 0; dim < num_space_dim; ++dim) - { - test_fixture.registerTestField(eval->_L1_error_momentum[dim]); - test_fixture.registerTestField(eval->_L2_error_momentum[dim]); - } - if (solve_temp) - { - test_fixture.registerTestField(eval->_L1_error_energy); - test_fixture.registerTestField(eval->_L2_error_energy); - } - - // Evaluate - test_fixture.evaluate(); - - // Check the values - const auto L1_error_continuity - = test_fixture.getTestFieldData(eval->_L1_error_continuity); - const auto L1_error_momentum_0 - = test_fixture.getTestFieldData(eval->_L1_error_momentum[0]); - const auto L1_error_momentum_1 - = test_fixture.getTestFieldData(eval->_L1_error_momentum[1]); - const auto L2_error_continuity - = test_fixture.getTestFieldData(eval->_L2_error_continuity); - const auto L2_error_momentum_0 - = test_fixture.getTestFieldData(eval->_L2_error_momentum[0]); - const auto L2_error_momentum_1 - = test_fixture.getTestFieldData(eval->_L2_error_momentum[1]); - - // Reference values - const double L1_ref[5] = { - 0.1, 0.39999999999999997, 0.5, 0.6000000000000001, 0.3999999999999999}; - const double L2_ref[5] = {0.010000000000000002, - 0.15999999999999998, - 0.25, - 0.3600000000000001, - 0.15999999999999992}; - - // Check the L1/L2 error solutions - const int num_point = ir.num_points; - for (int qp = 0; qp < num_point; ++qp) - { - EXPECT_DOUBLE_EQ(L1_ref[0], fieldValue(L1_error_continuity, 0, qp)); - EXPECT_DOUBLE_EQ(L1_ref[1], fieldValue(L1_error_momentum_0, 0, qp)); - EXPECT_DOUBLE_EQ(L1_ref[2], fieldValue(L1_error_momentum_1, 0, qp)); - - EXPECT_DOUBLE_EQ(L2_ref[0], fieldValue(L2_error_continuity, 0, qp)); - EXPECT_DOUBLE_EQ(L2_ref[1], fieldValue(L2_error_momentum_0, 0, qp)); - EXPECT_DOUBLE_EQ(L2_ref[2], fieldValue(L2_error_momentum_1, 0, qp)); - - if (solve_temp) - { - const auto L1_error_energy - = test_fixture.getTestFieldData( - eval->_L1_error_energy); - const auto L2_error_energy - = test_fixture.getTestFieldData( - eval->_L2_error_energy); - EXPECT_DOUBLE_EQ(L1_ref[num_space_dim + 1], - fieldValue(L1_error_energy, 0, qp)); - EXPECT_DOUBLE_EQ(L2_ref[num_space_dim + 1], - fieldValue(L2_error_energy, 0, qp)); - } - - if (num_space_dim == 3) - { - const auto L1_error_momentum_2 - = test_fixture.getTestFieldData( - eval->_L1_error_momentum[2]); - const auto L2_error_momentum_2 - = test_fixture.getTestFieldData( - eval->_L2_error_momentum[2]); - - EXPECT_DOUBLE_EQ(L1_ref[num_space_dim], - fieldValue(L1_error_momentum_2, 0, qp)); - EXPECT_DOUBLE_EQ(L2_ref[num_space_dim], - fieldValue(L2_error_momentum_2, 0, qp)); - } - } -} - -//---------------------------------------------------------------------------// -TEST(IncompressibleL1L2Isothermal_Error2D, residual_test) -{ - testEval(false); -} - -//---------------------------------------------------------------------------// -TEST(IncompressibleL1L2Isothermal_Error2D, jacobian_test) -{ - testEval(false); -} - -//---------------------------------------------------------------------------// -TEST(IncompressibleL1L2Isothermal_Error3D, residual_test) -{ - testEval(false); -} - -//---------------------------------------------------------------------------// -TEST(IncompressibleL1L2Isothermal_Error3D, jacobian_test) -{ - testEval(false); -} - -//---------------------------------------------------------------------------// -TEST(IncompressibleL1L2_Error3D, residual_test) -{ - testEval(true); -} - -//---------------------------------------------------------------------------// -TEST(IncompressibleL1L2_Error3D, jacobian_test) -{ - testEval(true); -} - -//---------------------------------------------------------------------------// - -template -void testFactory() -{ - constexpr int num_space_dim = NumSpaceDim; - ClosureModelFactoryTestFixture test_fixture; - test_fixture.type_name = "IncompressibleErrorNorm"; - test_fixture.user_params.sublist("Fluid Properties") - .set("Kinematic viscosity", 0.1) - .set("Artificial compressibility", 2.0); - if (num_space_dim == 2) - test_fixture.eval_name = "Incompressible Error Norms 2D"; - else if (num_space_dim == 3) - test_fixture.eval_name = "Incompressible Error Norms 3D"; - test_fixture.user_params.set("Build Temperature Equation", false); - test_fixture.template buildAndTest< - ClosureModel::IncompressibleErrorNorms, - num_space_dim>(); -} - -TEST(IncompressibleErrorNorms_Factory2D, residual_test) -{ - testFactory(); -} - -TEST(IncompressibleErrorNorms_Factory2D, jacobian_test) -{ - testFactory(); -} - -TEST(IncompressibleErrorNorms_Factory3D, residual_test) -{ - testFactory(); -} - -TEST(IncompressibleErrorNorms_Factory3D, jacobian_test) -{ - testFactory(); -} - -} // end namespace Test -} // end namespace VertexCFD diff --git a/src/incompressible_solver/closure_models/unit_test/tstIncompressibleLiftDrag.cpp b/src/incompressible_solver/closure_models/unit_test/tstIncompressibleLiftDrag.cpp deleted file mode 100644 index cd17eb9..0000000 --- a/src/incompressible_solver/closure_models/unit_test/tstIncompressibleLiftDrag.cpp +++ /dev/null @@ -1,372 +0,0 @@ -#include -#include - -#include "incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleLiftDrag.hpp" -#include "incompressible_solver/fluid_properties/VertexCFD_ConstantFluidProperties.hpp" - -#include - -namespace VertexCFD -{ -namespace Test -{ -template -struct Dependencies : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - using scalar_type = typename EvalType::ScalarT; - - double _u; - double _v; - double _w; - bool _use_compressible_formula; - - PHX::MDField grad_vel_0; - PHX::MDField grad_vel_1; - PHX::MDField grad_vel_2; - - PHX::MDField normals; - - PHX::MDField lagrange_pressure; - - Dependencies(const panzer::IntegrationRule& ir, - const double u, - const double v, - const double w, - const bool use_compressible_formula) - : _u(u) - , _v(v) - , _w(w) - , _use_compressible_formula(use_compressible_formula) - , grad_vel_0("GRAD_velocity_0", ir.dl_vector) - , grad_vel_1("GRAD_velocity_1", ir.dl_vector) - , grad_vel_2("GRAD_velocity_2", ir.dl_vector) - , normals("Side Normal", ir.dl_vector) - , lagrange_pressure("lagrange_pressure", ir.dl_scalar) - { - this->addEvaluatedField(grad_vel_0); - this->addEvaluatedField(grad_vel_1); - this->addEvaluatedField(grad_vel_2); - - this->addEvaluatedField(normals); - - this->addEvaluatedField(lagrange_pressure); - - this->setName("Incompressible Lift Drag Unit Test Dependencies"); - } - - void evaluateFields(typename panzer::Traits::EvalData d) override - { - Kokkos::parallel_for( - "lift drag test dependencies", - Kokkos::RangePolicy(0, d.num_cells), - *this); - } - - KOKKOS_INLINE_FUNCTION void operator()(const int c) const - { - const int num_point = grad_vel_0.extent(1); - const int num_space_dim = grad_vel_0.extent(2); - using std::pow; - for (int qp = 0; qp < num_point; ++qp) - { - for (int dim = 0; dim < num_space_dim; ++dim) - { - const int sign = pow(-1, dim + 1); - const int dimqp = (dim + 1) * sign; - grad_vel_0(c, qp, dim) = _u * dimqp; - grad_vel_1(c, qp, dim) = _v * dimqp; - grad_vel_2(c, qp, dim) = _w * dimqp; - - normals(c, qp, dim) = (_u + _v) * dimqp; - } - - lagrange_pressure(c, qp) = (_u + _v); - } - } -}; - -template -void testEval(const bool unscaled_density, const bool use_compressible_formula) -{ - constexpr int num_space_dim = NumSpaceDim; - const int integration_order = 2; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - - const auto& ir = *test_fixture.ir; - const double nan_val = std::numeric_limits::quiet_NaN(); - - // Initialize velocity components and dependents - const double u = 0.25; - const double v = 0.5; - const double w = num_space_dim == 3 - ? 0.125 - : std::numeric_limits::quiet_NaN(); - - auto deps = Teuchos::rcp( - new Dependencies(ir, u, v, w, use_compressible_formula)); - test_fixture.registerEvaluator(deps); - - // Initialize class object to test - double rho = 1.0; - const double nu = 0.375; - - Teuchos::ParameterList fluid_prop_list; - fluid_prop_list.set("Kinematic viscosity", nu); - fluid_prop_list.set("Artificial compressibility", 2.0); - fluid_prop_list.set("Build Temperature Equation", false); - if (unscaled_density) - { - rho = 3.0; - fluid_prop_list.set("Density", rho); - } - - Teuchos::ParameterList user_params; - user_params.set("Compressible Formula", use_compressible_formula); - const FluidProperties::ConstantFluidProperties fluid_prop(fluid_prop_list); - auto eval = Teuchos::rcp( - new ClosureModel:: - IncompressibleLiftDrag( - ir, fluid_prop, user_params)); - test_fixture.registerEvaluator(eval); - - for (int dim = 0; dim < num_space_dim; ++dim) - { - test_fixture.registerTestField(eval->_total_force[dim]); - test_fixture.registerTestField(eval->_viscous_force[dim]); - test_fixture.registerTestField(eval->_pressure_force[dim]); - } - - test_fixture.evaluate(); - - const auto calc_total_force_0 - = test_fixture.getTestFieldData(eval->_total_force[0]); - const auto calc_viscous_force_0 - = test_fixture.getTestFieldData(eval->_viscous_force[0]); - const auto calc_pressure_force_0 - = test_fixture.getTestFieldData(eval->_pressure_force[0]); - const auto calc_total_force_1 - = test_fixture.getTestFieldData(eval->_total_force[1]); - const auto calc_viscous_force_1 - = test_fixture.getTestFieldData(eval->_viscous_force[1]); - const auto calc_pressure_force_1 - = test_fixture.getTestFieldData(eval->_pressure_force[1]); - - const int num_point = ir.num_points; - - // Expected values - const double exp_pressure_force_3d[3] = {-0.5625, 1.125, -1.6875}; - const double exp_pressure_force_2d[3] - = {exp_pressure_force_3d[0], exp_pressure_force_3d[1], nan_val}; - const double* exp_pressure_force - = num_space_dim == 3 ? exp_pressure_force_3d : exp_pressure_force_2d; - - const double exp_viscous_force_3d[3] - = {(unscaled_density ? -2.63671875 : -0.87890625), - (unscaled_density ? -6.5390625 : -2.1796875), - (unscaled_density ? -0.52734375 : -0.17578125)}; - const double exp_viscous_force_2d[3] - = {(unscaled_density ? -0.421875 : -0.140625), - (unscaled_density ? -3.375 : -1.125), - nan_val}; - const double exp_compressible_viscous_force_3d[3] - = {(unscaled_density ? -2.84765625 : -0.94921875), - (unscaled_density ? -6.1171875 : -2.0390625), - (unscaled_density ? -1.16015625 : -0.38671875)}; - const double exp_compressible_viscous_force_2d[3] - = {(unscaled_density ? -1.0546875 : -0.3515625), - (unscaled_density ? -2.109375 : -0.703125), - nan_val}; - const double* exp_viscous_force - = use_compressible_formula - ? (num_space_dim == 3 ? exp_compressible_viscous_force_3d - : exp_compressible_viscous_force_2d) - : (num_space_dim == 3 ? exp_viscous_force_3d - : exp_viscous_force_2d); - - const double exp_total_force_3d[3] - = {(unscaled_density ? -3.19921875 : -1.44140625), - (unscaled_density ? -5.4140625 : -1.0546875), - (unscaled_density ? -2.21484375 : -1.86328125)}; - const double exp_total_force_2d[3] - = {(unscaled_density ? -0.984375 : -0.703125), - (unscaled_density ? -2.25 : 0.), - nan_val}; - const double exp_compressible_total_force_3d[3] - = {(unscaled_density ? -3.41015625 : -1.51171875), - (unscaled_density ? -4.9921875 : -0.9140625), - (unscaled_density ? -2.84765625 : -2.07421875)}; - const double exp_compressible_total_force_2d[3] - = {(unscaled_density ? -1.6171875 : -0.9140625), - (unscaled_density ? -0.984375 : 0.421875), - nan_val}; - const double* exp_total_force - = use_compressible_formula - ? (num_space_dim == 3 ? exp_compressible_total_force_3d - : exp_compressible_total_force_2d) - : (num_space_dim == 3 ? exp_total_force_3d : exp_total_force_2d); - - // Assert values - for (int qp = 0; qp < num_point; ++qp) - { - for (int dim = 0; dim < num_space_dim; dim++) - { - const auto calc_total_force - = test_fixture.getTestFieldData( - eval->_total_force[dim]); - const auto calc_viscous_force - = test_fixture.getTestFieldData( - eval->_viscous_force[dim]); - const auto calc_pressure_force - = test_fixture.getTestFieldData( - eval->_pressure_force[dim]); - - EXPECT_EQ(exp_total_force[dim], - fieldValue(calc_total_force, 0, qp)); - EXPECT_EQ(exp_viscous_force[dim], - fieldValue(calc_viscous_force, 0, qp)); - EXPECT_EQ(exp_pressure_force[dim], - fieldValue(calc_pressure_force, 0, qp)); - } - } -} - -//-----------------------------------------------------------------// -struct IncompressibleLiftDragTestParams -{ - std::string test_name; - bool unscaled_density; - bool use_compressible_formula; - int num_space_dim; -}; - -class IncompressibleLiftDragTest - : public testing::TestWithParam -{ - public: - struct PrintToStringParamName - { - template - std::string operator()(const testing::TestParamInfo& info) const - { - auto testParam - = static_cast(info.param); - return testParam.test_name; - } - }; -}; - -//-----------------------------------------------------------------// -TEST_P(IncompressibleLiftDragTest, cartesian) -{ - const auto params = GetParam(); - if (std::string::npos != params.test_name.find("residual")) - { - if (params.num_space_dim == 2) - { - testEval( - params.unscaled_density, params.use_compressible_formula); - } - else - { - testEval( - params.unscaled_density, params.use_compressible_formula); - } - } - else if (std::string::npos != params.test_name.find("jacobian")) - { - if (params.num_space_dim == 2) - { - testEval( - params.unscaled_density, params.use_compressible_formula); - } - else - { - testEval( - params.unscaled_density, params.use_compressible_formula); - } - } -} - -//-----------------------------------------------------------------// -INSTANTIATE_TEST_SUITE_P( - Test, - IncompressibleLiftDragTest, - testing::Values( - IncompressibleLiftDragTestParams{ - "ScaledDensity2D_residual", false, false, 2}, - IncompressibleLiftDragTestParams{ - "ScaledDensity2D_jacobian", false, false, 2}, - IncompressibleLiftDragTestParams{ - "UnScaledDensity2D_residual", true, false, 2}, - IncompressibleLiftDragTestParams{ - "UnScaledDensity2D_jacobian", true, false, 2}, - IncompressibleLiftDragTestParams{ - "ScaledDensity3D_residual", false, false, 3}, - IncompressibleLiftDragTestParams{ - "ScaledDensity3D_jacobian", false, false, 3}, - IncompressibleLiftDragTestParams{ - "UnScaledDensity3D_residual", true, false, 3}, - IncompressibleLiftDragTestParams{ - "UnScaledDensity3D_jacobian", true, false, 3}, - IncompressibleLiftDragTestParams{ - "ScaledDensityCompressible2D_residual", false, true, 2}, - IncompressibleLiftDragTestParams{ - "ScaledDensityCompressible2D_jacobian", false, true, 2}, - IncompressibleLiftDragTestParams{ - "UnScaledDensityCompressible2D_residual", true, true, 2}, - IncompressibleLiftDragTestParams{ - "UnScaledDensityCompressible2D_jacobian", true, true, 2}, - IncompressibleLiftDragTestParams{ - "ScaledDensityCompressible3D_residual", false, true, 3}, - IncompressibleLiftDragTestParams{ - "ScaledDensityCompressible3D_jacobian", false, true, 3}, - IncompressibleLiftDragTestParams{ - "UnScaledDensityCompressible3D_residual", true, true, 3}, - IncompressibleLiftDragTestParams{ - "UnScaledDensityCompressible3D_jacobian", true, true, 3}), - - IncompressibleLiftDragTest::PrintToStringParamName()); - -//-----------------------------------------------------------------// -template -void testFactory() -{ - constexpr int num_space_dim = NumSpaceDim; - ClosureModelFactoryTestFixture test_fixture; - test_fixture.user_params.set("Compressible Formula", true); - test_fixture.user_params.sublist("Fluid Properties") - .set("Kinematic viscosity", 0.1) - .set("Artificial compressibility", 2.0); - test_fixture.type_name = "IncompressibleLiftDrag"; - test_fixture.eval_name = "Incompressible Lift/Drag " - + std::to_string(num_space_dim) + "D"; - test_fixture.template buildAndTest< - ClosureModel::IncompressibleLiftDrag, - num_space_dim>(); -} - -TEST(IncompressibleLiftDrag_Factory2D, residual_test) -{ - testFactory(); -} - -TEST(IncompressibleLiftDrag_Factory2D, jacobian_test) -{ - testFactory(); -} - -TEST(IncompressibleLiftDrag_Factory3D, residual_test) -{ - testFactory(); -} - -TEST(IncompressibleLiftDrag_Factory3D, jacobian_test) -{ - testFactory(); -} - -} // namespace Test -} // namespace VertexCFD diff --git a/src/incompressible_solver/closure_models/unit_test/tstIncompressibleLocalTimeStepSize.cpp b/src/incompressible_solver/closure_models/unit_test/tstIncompressibleLocalTimeStepSize.cpp deleted file mode 100644 index 19acd5f..0000000 --- a/src/incompressible_solver/closure_models/unit_test/tstIncompressibleLocalTimeStepSize.cpp +++ /dev/null @@ -1,190 +0,0 @@ -#include -#include - -#include "incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleLocalTimeStepSize.hpp" - -#include - -#include -#include - -#include - -#include - -#include - -//---------------------------------------------------------------------------// -// TESTS -//---------------------------------------------------------------------------// -namespace VertexCFD -{ -namespace Test -{ -//---------------------------------------------------------------------------// -// Test data dependencies. -template -struct Dependencies : public PHX::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - using scalar_type = typename EvalType::ScalarT; - - double _u; - double _v; - double _w; - Kokkos::Array _h; - - PHX::MDField _element_length; - PHX::MDField _velocity_0; - PHX::MDField _velocity_1; - PHX::MDField _velocity_2; - - Dependencies(const panzer::IntegrationRule& ir, - const double u, - const double v, - const double w, - const Kokkos::Array h) - : _u(u) - , _v(v) - , _w(w) - , _h(h) - , _element_length("element_length", ir.dl_vector) - , _velocity_0("velocity_0", ir.dl_scalar) - , _velocity_1("velocity_1", ir.dl_scalar) - , _velocity_2("velocity_2", ir.dl_scalar) - { - this->addEvaluatedField(_element_length); - this->addEvaluatedField(_velocity_0); - this->addEvaluatedField(_velocity_1); - this->addEvaluatedField(_velocity_2); - this->setName( - "Incompressible LocalTimeStepSize Unit Test Dependencies"); - } - - void evaluateFields(typename panzer::Traits::EvalData d) override - { - Kokkos::parallel_for( - "test dependencies", - Kokkos::RangePolicy(0, d.num_cells), - *this); - } - - KOKKOS_INLINE_FUNCTION void operator()(const int c) const - { - int num_point = _element_length.extent(1); - for (int qp = 0; qp < num_point; ++qp) - { - _element_length(c, qp, 0) = _h[0]; - _element_length(c, qp, 1) = _h[1]; - _element_length(c, qp, 2) = _h[2]; - _velocity_0(c, qp) = _u; - _velocity_1(c, qp) = _v; - _velocity_2(c, qp) = _w; - } - } -}; - -//---------------------------------------------------------------------------// -template -void testEval() -{ - // Setup test fixture. - constexpr int num_space_dim = NumSpaceDim; - const int integration_order = 2; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - - // Eval dependencies. - const double u = -1.5; - const double v = 2.0; - const double w - = num_space_dim == 3 ? -0.5 : std::numeric_limits::quiet_NaN(); - const Kokkos::Array h = { - 0.25, - 0.5, - num_space_dim == 3 ? 0.75 : std::numeric_limits::quiet_NaN()}; - - auto dep_eval = Teuchos::rcp( - new Dependencies(*test_fixture.ir, u, v, w, h)); - test_fixture.registerEvaluator(dep_eval); - - // Create test evaluator. - auto dt_eval = Teuchos::rcp( - new ClosureModel::IncompressibleLocalTimeStepSize( - *test_fixture.ir)); - test_fixture.registerEvaluator(dt_eval); - - // Add required test fields. - test_fixture.registerTestField(dt_eval->_local_dt); - - // Evaluate test fields. - test_fixture.evaluate(); - - // Check the test fields. - auto local_dt_result - = test_fixture.getTestFieldData(dt_eval->_local_dt); - - const int num_qp = num_space_dim == 2 ? 4 : 8; - const double result = num_space_dim == 2 ? 0.1 : 0.09375; - for (int qp = 0; qp < num_qp; ++qp) - EXPECT_DOUBLE_EQ(result, fieldValue(local_dt_result, 0, qp)); -} - -//---------------------------------------------------------------------------// -TEST(IncompressibleLocalTimeStepSize2D, residual_test) -{ - testEval(); -} - -//---------------------------------------------------------------------------// -TEST(IncompressibleLocalTimeStepSize2D, jacobian_test) -{ - testEval(); -} - -//---------------------------------------------------------------------------// -TEST(IncompressibleLocalTimeStepSize3D, residual_test) -{ - testEval(); -} - -//---------------------------------------------------------------------------// -TEST(IncompressibleLocalTimeStepSize3D, jacobian_test) -{ - testEval(); -} - -//---------------------------------------------------------------------------// - -template -void testFactory() -{ - constexpr int num_space_dim = NumSpaceDim; - ClosureModelFactoryTestFixture test_fixture; - test_fixture.type_name = "IncompressibleLocalTimeStepSize"; - test_fixture.eval_name = "Incompressible Local Time Step Size"; - test_fixture.user_params.sublist("Fluid Properties") - .set("Kinematic viscosity", 0.1) - .set("Artificial compressibility", 2.0); - test_fixture.template buildAndTest< - ClosureModel::IncompressibleLocalTimeStepSize, - num_space_dim>(); -} - -TEST(IncompressibleLocalTimeStepSize_Factory2D, residual_test) -{ - testFactory(); -} - -TEST(IncompressibleLocalTimeStepSize_Factory2D, jacobian_test) -{ - testFactory(); -} - -} // end namespace Test -} // end namespace VertexCFD diff --git a/src/incompressible_solver/closure_models/unit_test/tstIncompressiblePlanarPoiseuilleExact.cpp b/src/incompressible_solver/closure_models/unit_test/tstIncompressiblePlanarPoiseuilleExact.cpp deleted file mode 100644 index 52db360..0000000 --- a/src/incompressible_solver/closure_models/unit_test/tstIncompressiblePlanarPoiseuilleExact.cpp +++ /dev/null @@ -1,164 +0,0 @@ -#include -#include - -#include "incompressible_solver/closure_models/VertexCFD_Closure_IncompressiblePlanarPoiseuilleExact.hpp" -#include "incompressible_solver/fluid_properties/VertexCFD_ConstantFluidProperties.hpp" - -#include - -namespace VertexCFD -{ -namespace Test -{ - -template -void testEval() -{ - // Set up test fixture - constexpr int num_space_dim = NumSpaceDim; - const int integration_order = 1; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - - // Set non-trivial quadrature point coordinates - auto ip_coord_view - = test_fixture.int_values->ip_coordinates.get_static_view(); - auto ip_coord_mirror = Kokkos::create_mirror(ip_coord_view); - ip_coord_mirror(0, 0, 0) = 2.25; - ip_coord_mirror(0, 0, 1) = 2.20; - Kokkos::deep_copy(ip_coord_view, ip_coord_mirror); - - // Get test fixture integrator rule - const auto& ir = *test_fixture.ir; - - // Set list of parameters to pass to the test evaluator - Teuchos::ParameterList user_params; - user_params.sublist("Planar Poiseuille Exact") - .set("H min", -4.0) - .set("H max", 4.0) - .set("Lower wall temperature", 305.0) - .set("Upper wall temperature", 300.0) - .set("Momentum source", 24000.0); - - Teuchos::ParameterList fluid_prop_list; - fluid_prop_list.set("Kinematic viscosity", 50.0); - fluid_prop_list.set("Artificial compressibility", 2.0); - fluid_prop_list.set("Build Temperature Equation", true); - fluid_prop_list.set("Thermal conductivity", 0.5); - fluid_prop_list.set("Specific heat capacity", 100.0); - - const FluidProperties::ConstantFluidProperties fluid_prop(fluid_prop_list); - - // Create test evaluator - auto eval = Teuchos::rcp( - new ClosureModel::IncompressiblePlanarPoiseuilleExact( - ir, fluid_prop, user_params)); - - test_fixture.registerEvaluator(eval); - test_fixture.registerTestField(eval->_lagrange_pressure); - for (int dim = 0; dim < num_space_dim; ++dim) - test_fixture.registerTestField(eval->_velocity[dim]); - test_fixture.registerTestField(eval->_temperature); - - test_fixture.evaluate(); - - const auto fc_pressure - = test_fixture.getTestFieldData(eval->_lagrange_pressure); - const auto fc_mom_0 - = test_fixture.getTestFieldData(eval->_velocity[0]); - const auto fc_mom_1 - = test_fixture.getTestFieldData(eval->_velocity[1]); - const auto fc_energy - = test_fixture.getTestFieldData(eval->_temperature); - - // Assert values - const int num_point = ir.num_points; - for (int qp = 0; qp < num_point; ++qp) - { - EXPECT_DOUBLE_EQ(0.0, fieldValue(fc_pressure, 0, qp)); - EXPECT_DOUBLE_EQ(2678.4, fieldValue(fc_mom_0, 0, qp)); - EXPECT_DOUBLE_EQ(0.0, fieldValue(fc_mom_1, 0, qp)); - if (num_space_dim == 3) - { - const auto fc_mom_2 - = test_fixture.getTestFieldData(eval->_velocity[2]); - EXPECT_EQ(0.0, fieldValue(fc_mom_2, 0, qp)); - } - - EXPECT_EQ(446543149.12499994, fieldValue(fc_energy, 0, qp)); - } -} - -//-----------------------------------------------------------------// -TEST(IncompressiblePlanarPoiseuilleExact2D, residual_test) -{ - testEval(); -} - -//-----------------------------------------------------------------// -TEST(IncompressiblePlanarPoiseuilleExact2D, jacobian_test) -{ - testEval(); -} - -//-----------------------------------------------------------------// -TEST(IncompressiblePlanarPoiseuilleExact3D, residual_test) -{ - testEval(); -} - -//-----------------------------------------------------------------// -TEST(IncompressiblePlanarPoiseuilleExact3D, jacobian_test) -{ - testEval(); -} - -//-----------------------------------------------------------------// -template -void testFactory() -{ - constexpr int num_space_dim = NumSpaceDim; - ClosureModelFactoryTestFixture test_fixture; - test_fixture.type_name = "IncompressiblePlanarPoiseuilleExact"; - test_fixture.eval_name = "Exact Solution Planar Poiseuille"; - test_fixture.user_params.sublist("Fluid Properties") - .set("Kinematic viscosity", 0.1) - .set("Artificial compressibility", 2.0); - test_fixture.user_params.sublist("Planar Poiseuille Exact") - .set("H min", -4.0) - .set("H max", 4.0) - .set("Lower wall temperature", 305.0) - .set("Upper wall temperature", 300.0) - .set("Momentum source", 24000.0); - test_fixture.template buildAndTest< - ClosureModel::IncompressiblePlanarPoiseuilleExact, - num_space_dim>(); -} - -TEST(IncompressiblePlanarPoiseuilleExact_Factory2D, residual_test) -{ - testFactory(); -} - -TEST(IncompressiblePlanarPoiseuilleExact_Factory2D, jacobian_test) -{ - testFactory(); -} - -TEST(IncompressiblePlanarPoiseuilleExact_Factory3D, residual_test) -{ - testFactory(); -} - -TEST(IncompressiblePlanarPoiseuilleExact_Factory3D, jacobian_test) -{ - testFactory(); -} - -} // namespace Test -} // namespace VertexCFD diff --git a/src/incompressible_solver/closure_models/unit_test/tstIncompressibleRotatingAnnulusExact.cpp b/src/incompressible_solver/closure_models/unit_test/tstIncompressibleRotatingAnnulusExact.cpp deleted file mode 100644 index a65145a..0000000 --- a/src/incompressible_solver/closure_models/unit_test/tstIncompressibleRotatingAnnulusExact.cpp +++ /dev/null @@ -1,163 +0,0 @@ -#include -#include - -#include "incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleRotatingAnnulusExact.hpp" -#include "incompressible_solver/fluid_properties/VertexCFD_ConstantFluidProperties.hpp" - -#include - -namespace VertexCFD -{ -namespace Test -{ - -template -void testEval() -{ - // Set up test fixture - constexpr int num_space_dim = NumSpaceDim; - const int integration_order = 0; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - - // Set non-trivial quadrature point coordinates - auto ip_coord_view - = test_fixture.int_values->ip_coordinates.get_static_view(); - auto ip_coord_mirror = Kokkos::create_mirror(ip_coord_view); - ip_coord_mirror(0, 0, 0) = 2.25; - ip_coord_mirror(0, 0, 1) = 2.20; - Kokkos::deep_copy(ip_coord_view, ip_coord_mirror); - - // Get test fixture integrator rule - auto& ir = *test_fixture.ir; - - // Set list of parameters to pass to the test evaluator - Teuchos::ParameterList user_params; - user_params.set("Outer radius", 4.0); - user_params.set("Inner radius", 2.0); - user_params.set("Angular velocity", 0.5); - user_params.set("Outer wall temperature", 274.0); - user_params.set("Inner wall temperature", 273.0); - - Teuchos::ParameterList fluid_prop_list; - fluid_prop_list.set("Kinematic viscosity", 50.0); - fluid_prop_list.set("Artificial compressibility", 2.0); - fluid_prop_list.set("Build Temperature Equation", true); - fluid_prop_list.set("Thermal conductivity", 0.5); - fluid_prop_list.set("Specific heat capacity", 5.0); - - const FluidProperties::ConstantFluidProperties fluid_prop(fluid_prop_list); - - // Create test evaluator - auto eval = Teuchos::rcp( - new ClosureModel::IncompressibleRotatingAnnulusExact( - ir, fluid_prop, user_params)); - - test_fixture.registerEvaluator(eval); - test_fixture.registerTestField(eval->_lagrange_pressure); - for (int dim = 0; dim < num_space_dim; ++dim) - test_fixture.registerTestField(eval->_velocity[dim]); - test_fixture.registerTestField(eval->_temperature); - - test_fixture.evaluate(); - - const auto fc_pressure - = test_fixture.getTestFieldData(eval->_lagrange_pressure); - const auto fc_mom_0 - = test_fixture.getTestFieldData(eval->_velocity[0]); - const auto fc_mom_1 - = test_fixture.getTestFieldData(eval->_velocity[1]); - const auto fc_energy - = test_fixture.getTestFieldData(eval->_temperature); - - const int num_point = ir.num_points; - - // Assert values - for (int qp = 0; qp < num_point; ++qp) - { - EXPECT_DOUBLE_EQ(0.0, fieldValue(fc_pressure, 0, qp)); - EXPECT_DOUBLE_EQ(-0.8742236808886645, fieldValue(fc_mom_0, 0, qp)); - EXPECT_DOUBLE_EQ(0.8940924009088613, fieldValue(fc_mom_1, 0, qp)); - if (num_space_dim == 3) - { - const auto fc_mom_2 - = test_fixture.getTestFieldData(eval->_velocity[2]); - EXPECT_EQ(0.0, fieldValue(fc_mom_2, 0, qp)); - } - - EXPECT_EQ(292.43421676378887, fieldValue(fc_energy, 0, qp)); - } -} - -//-----------------------------------------------------------------// -TEST(IncompressibleRotatingAnnulusExact2D, residual_test) -{ - testEval(); -} - -//-----------------------------------------------------------------// -TEST(IncompressibleRotatingAnnulusExact2D, jacobian_test) -{ - testEval(); -} - -//-----------------------------------------------------------------// -TEST(IncompressibleRotatingAnnulusExact3D, residual_test) -{ - testEval(); -} - -//-----------------------------------------------------------------// -TEST(IncompressibleRotatingAnnulusExact3D, jacobian_test) -{ - testEval(); -} - -//-----------------------------------------------------------------// -template -void testFactory() -{ - constexpr int num_space_dim = NumSpaceDim; - ClosureModelFactoryTestFixture test_fixture; - test_fixture.type_name = "IncompressibleRotatingAnnulusExact"; - test_fixture.eval_name = "Exact Solution Rotating Annulus"; - test_fixture.user_params.sublist("Fluid Properties") - .set("Kinematic viscosity", 0.1) - .set("Artificial compressibility", 2.0); - test_fixture.user_params.set("Outer radius", 2.0) - .set("Inner radius", 3.0) - .set("Angular velocity", 4.0) - .set("Outer wall temperature", 5.0) - .set("Inner wall temperature", 6.0); - test_fixture.template buildAndTest< - ClosureModel::IncompressibleRotatingAnnulusExact, - num_space_dim>(); -} - -TEST(IncompressibleRotatingAnnulusExact_Factory2D, residual_test) -{ - testFactory(); -} - -TEST(IncompressibleRotatingAnnulusExact_Factory2D, jacobian_test) -{ - testFactory(); -} - -TEST(IncompressibleRotatingAnnulusExact_Factory3D, residual_test) -{ - testFactory(); -} - -TEST(IncompressibleRotatingAnnulusExact_Factory3D, jacobian_test) -{ - testFactory(); -} - -} // namespace Test -} // namespace VertexCFD diff --git a/src/incompressible_solver/closure_models/unit_test/tstIncompressibleShearVariables.cpp b/src/incompressible_solver/closure_models/unit_test/tstIncompressibleShearVariables.cpp deleted file mode 100644 index 23c2881..0000000 --- a/src/incompressible_solver/closure_models/unit_test/tstIncompressibleShearVariables.cpp +++ /dev/null @@ -1,187 +0,0 @@ -#include -#include - -#include "incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleShearVariables.hpp" -#include "incompressible_solver/fluid_properties/VertexCFD_ConstantFluidProperties.hpp" - -#include - -namespace VertexCFD -{ -namespace Test -{ - -template -struct Dependencies : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - using scalar_type = typename EvalType::ScalarT; - - // quiet_NaN is a host-side function so we store the value - const double _nanval = std::numeric_limits::quiet_NaN(); - - PHX::MDField grad_vel_0; - PHX::MDField grad_vel_1; - PHX::MDField grad_vel_2; - - PHX::MDField normals; - - Dependencies(const panzer::IntegrationRule& ir) - : grad_vel_0("GRAD_velocity_0", ir.dl_vector) - , grad_vel_1("GRAD_velocity_1", ir.dl_vector) - , grad_vel_2("GRAD_velocity_2", ir.dl_vector) - , normals("Side Normal", ir.dl_vector) - { - this->addEvaluatedField(grad_vel_0); - this->addEvaluatedField(grad_vel_1); - this->addEvaluatedField(grad_vel_2); - this->addEvaluatedField(normals); - - this->setName("Incompressible Shear Variables Unit Test Dependencies"); - } - - void evaluateFields(typename panzer::Traits::EvalData d) override - { - Kokkos::parallel_for( - "shear variables test dependencies", - Kokkos::RangePolicy(0, d.num_cells), - *this); - } - - KOKKOS_INLINE_FUNCTION void operator()(const int c) const - { - const int num_point = grad_vel_0.extent(1); - const int num_space_dim = grad_vel_0.extent(2); - using std::pow; - for (int qp = 0; qp < num_point; ++qp) - { - for (int dim = 0; dim < num_space_dim; ++dim) - { - const int sign = pow(-1, dim + 1); - const int dimqp = (dim + 1) * sign; - grad_vel_0(c, qp, dim) = 0.250 * dimqp; - grad_vel_1(c, qp, dim) = 0.500 * dimqp; - grad_vel_2(c, qp, dim) = num_space_dim == 3 ? 0.725 * dimqp - : _nanval; - normals(c, qp, dim) = 0.125 * dimqp; - } - } - } -}; - -template -void testEval() -{ - constexpr int num_space_dim = NumSpaceDim; - const int integration_order = 1; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - - const auto& ir = *test_fixture.ir; - - // Initialize velocity gradient and dependents - auto deps = Teuchos::rcp(new Dependencies(ir)); - test_fixture.registerEvaluator(deps); - - // Initialize class object to test - Teuchos::ParameterList fluid_prop_list; - fluid_prop_list.set("Build Temperature Equation", false); - fluid_prop_list.set("Kinematic viscosity", 0.375); - fluid_prop_list.set("Density", 1.5); - fluid_prop_list.set("Artificial compressibility", 1.0); - const FluidProperties::ConstantFluidProperties fluid_prop(fluid_prop_list); - auto eval = Teuchos::rcp( - new ClosureModel::IncompressibleShearVariables( - ir, fluid_prop)); - - test_fixture.registerEvaluator(eval); - test_fixture.registerTestField(eval->_tau_w); - test_fixture.registerTestField(eval->_u_tau); - - test_fixture.evaluate(); - - const auto tau_w = test_fixture.getTestFieldData(eval->_tau_w); - const auto u_tau = test_fixture.getTestFieldData(eval->_u_tau); - - const int num_point = ir.num_points; - - // Expected values - const double exp_tau_w = num_space_dim == 3 ? 0.9011871138178397 - : 0.19652941208494246; - const double exp_u_tau = num_space_dim == 3 ? 0.7751073533465498 - : 0.3619663079025841; - - // Assert values - for (int qp = 0; qp < num_point; ++qp) - { - EXPECT_DOUBLE_EQ(exp_tau_w, fieldValue(tau_w, 0, qp)); - EXPECT_DOUBLE_EQ(exp_u_tau, fieldValue(u_tau, 0, qp)); - } -} - -//-----------------------------------------------------------------// -TEST(IncompressibleShearVariables2D, residual_test) -{ - testEval(); -} - -//-----------------------------------------------------------------// -TEST(IncompressibleShearVariables2D, jacobian_test) -{ - testEval(); -} - -//-----------------------------------------------------------------// -TEST(IncompressibleShearVariables3D, residual_test) -{ - testEval(); -} - -//-----------------------------------------------------------------// -TEST(IncompressibleShearVariables3D, jacobian_test) -{ - testEval(); -} - -//-----------------------------------------------------------------// -template -void testFactory() -{ - constexpr int num_space_dim = NumSpaceDim; - ClosureModelFactoryTestFixture test_fixture; - test_fixture.type_name = "IncompressibleShearVariables"; - test_fixture.eval_name = "Incompressible Shear/Friction Variables " - + std::to_string(num_space_dim) + "D"; - test_fixture.user_params.sublist("Fluid Properties") - .set("Kinematic viscosity", 0.1) - .set("Artificial compressibility", 2.0); - test_fixture.template buildAndTest< - ClosureModel::IncompressibleShearVariables, - num_space_dim>(); -} - -TEST(IncompressibleShearVariables_Factory2D, residual_test) -{ - testFactory(); -} - -TEST(IncompressibleShearVariables_Factory2D, jacobian_test) -{ - testFactory(); -} - -TEST(IncompressibleShearVariables_Factory3D, residual_test) -{ - testFactory(); -} - -TEST(IncompressibleShearVariables_Factory3D, jacobian_test) -{ - testFactory(); -} - -} // namespace Test -} // namespace VertexCFD diff --git a/src/incompressible_solver/closure_models/unit_test/tstIncompressibleTaylorGreenVortexExactSolution.cpp b/src/incompressible_solver/closure_models/unit_test/tstIncompressibleTaylorGreenVortexExactSolution.cpp deleted file mode 100644 index 7db0b18..0000000 --- a/src/incompressible_solver/closure_models/unit_test/tstIncompressibleTaylorGreenVortexExactSolution.cpp +++ /dev/null @@ -1,132 +0,0 @@ -#include -#include - -#include "incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleTaylorGreenVortexExactSolution.hpp" -#include "incompressible_solver/fluid_properties/VertexCFD_ConstantFluidProperties.hpp" - -#include - -namespace VertexCFD -{ -namespace Test -{ - -template -void testEval() -{ - constexpr int num_space_dim = 2; - const int integration_order = 2; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - const auto& ir = *test_fixture.ir; - const double time = 0.5; - test_fixture.setTime(time); - - // Set non-trivial coordinates for the degree of freedom - const int num_point = ir.num_points; - auto ip_coord_view - = test_fixture.int_values->ip_coordinates.get_static_view(); - auto ip_coord_mirror = Kokkos::create_mirror(ip_coord_view); - for (int dim = 0; dim < num_space_dim; dim++) - { - for (int qp = 0; qp < num_point; ++qp) - { - ip_coord_mirror(0, qp, dim) = 0.1 * (dim + 1) * (qp + 1) - 0.25; - } - } - Kokkos::deep_copy(ip_coord_view, ip_coord_mirror); - - // Initialize class object to test - Teuchos::ParameterList fluid_prop_list; - fluid_prop_list.set("Kinematic viscosity", 0.325); - fluid_prop_list.set("Artificial compressibility", 2.0); - fluid_prop_list.set("Build Temperature Equation", false); - const FluidProperties::ConstantFluidProperties fluid_prop(fluid_prop_list); - const auto eval = Teuchos::rcp( - new ClosureModel::IncompressibleTaylorGreenVortexExactSolution< - EvalType, - panzer::Traits, - num_space_dim>(ir, fluid_prop)); - - test_fixture.registerEvaluator(eval); - test_fixture.registerTestField(eval->_lagrange_pressure); - for (int dim = 0; dim < num_space_dim; ++dim) - test_fixture.registerTestField(eval->_velocity[dim]); - test_fixture.evaluate(); - - const auto exact_cont - = test_fixture.getTestFieldData(eval->_lagrange_pressure); - const auto exact_mom_0 - = test_fixture.getTestFieldData(eval->_velocity[0]); - const auto exact_mom_1 - = test_fixture.getTestFieldData(eval->_velocity[1]); - - // Reference values - const double phi_ref[4] = {-0.2545417754691831, - -0.2545417754691831, - -0.2296800890258847, - -0.18388182976977963}; - const double u_ref[4] = {-0.035705825747158935, - 0.10783820008203808, - 0.2474434185973639, - 0.37341515252860846}; - const double v_ref[4] = {0.10783820008203808, - 0.035705825747158935, - -0.03392198573058794, - -0.09204974820065662}; - - // Assert values - const double tol = 1.0e-16; - for (int qp = 0; qp < num_point; ++qp) - { - EXPECT_NEAR(phi_ref[qp], fieldValue(exact_cont, 0, qp), tol); - EXPECT_NEAR(u_ref[qp], fieldValue(exact_mom_0, 0, qp), tol); - EXPECT_NEAR(v_ref[qp], fieldValue(exact_mom_1, 0, qp), tol); - } -} - -//-----------------------------------------------------------------// -TEST(IncompressibleTaylorGreenVortexExactSolution, residual_test) -{ - testEval(); -} - -//-----------------------------------------------------------------// -TEST(IncompressibleTaylorGreenVortexExactSolution, jacobian_test) -{ - testEval(); -} - -//-----------------------------------------------------------------// -template -void testFactory() -{ - constexpr int num_space_dim = NumSpaceDim; - ClosureModelFactoryTestFixture test_fixture; - test_fixture.user_params.set("Build Temperature Equation", false); - test_fixture.type_name = "IncompressibleTaylorGreenVortexExactSolution"; - test_fixture.user_params.sublist("Fluid Properties") - .set("Kinematic viscosity", 0.1) - .set("Artificial compressibility", 2.0); - test_fixture.eval_name - = "Incompressible Taylor Green Vortex Exact Solution"; - test_fixture.template buildAndTest< - ClosureModel::IncompressibleTaylorGreenVortexExactSolution, - num_space_dim>(); -} - -TEST(IncompressibleTaylorGreenVortexExactSolution_Factory2D, residual_test) -{ - testFactory(); -} - -TEST(IncompressibleTaylorGreenVortexExactSolution_Factory2D, jacobian_test) -{ - testFactory(); -} - -} // namespace Test -} // namespace VertexCFD diff --git a/src/incompressible_solver/closure_models/unit_test/tstIncompressibleTimeDerivative.cpp b/src/incompressible_solver/closure_models/unit_test/tstIncompressibleTimeDerivative.cpp deleted file mode 100644 index e1daf25..0000000 --- a/src/incompressible_solver/closure_models/unit_test/tstIncompressibleTimeDerivative.cpp +++ /dev/null @@ -1,272 +0,0 @@ -#include -#include - -#include "incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleTimeDerivative.hpp" -#include "incompressible_solver/fluid_properties/VertexCFD_ConstantFluidProperties.hpp" - -#include - -#include -#include - -#include - -#include - -#include - -//---------------------------------------------------------------------------// -// TESTS -//---------------------------------------------------------------------------// -namespace VertexCFD -{ -namespace Test -{ -//---------------------------------------------------------------------------// -// Test data dependencies. -template -struct Dependencies : public PHX::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - using scalar_type = typename EvalType::ScalarT; - - double _dphi_dt; - double _du_dt; - double _dv_dt; - double _dw_dt; - bool _build_temp_equ; - - PHX::MDField _dvdt_lagrange_pressure; - PHX::MDField _dvdt_velocity_0; - PHX::MDField _dvdt_velocity_1; - PHX::MDField _dvdt_velocity_2; - PHX::MDField _dvdt_temperature; - - Dependencies(const panzer::IntegrationRule& ir, - const double dphi_dt, - const double du_dt, - const double dv_dt, - const double dw_dt, - const bool build_temp_equ) - : _dphi_dt(dphi_dt) - , _du_dt(du_dt) - , _dv_dt(dv_dt) - , _dw_dt(dw_dt) - , _build_temp_equ(build_temp_equ) - , _dvdt_lagrange_pressure("DXDT_lagrange_pressure", ir.dl_scalar) - , _dvdt_velocity_0("DXDT_velocity_0", ir.dl_scalar) - , _dvdt_velocity_1("DXDT_velocity_1", ir.dl_scalar) - , _dvdt_velocity_2("DXDT_velocity_2", ir.dl_scalar) - , _dvdt_temperature("DXDT_temperature", ir.dl_scalar) - { - this->addEvaluatedField(_dvdt_lagrange_pressure); - this->addEvaluatedField(_dvdt_velocity_0); - this->addEvaluatedField(_dvdt_velocity_1); - this->addEvaluatedField(_dvdt_velocity_2); - if (_build_temp_equ) - this->addEvaluatedField(_dvdt_temperature); - this->setName("Incompressible Time Derivative Unit Test Dependencies"); - } - - void evaluateFields(typename panzer::Traits::EvalData) override - { - _dvdt_lagrange_pressure.deep_copy(_dphi_dt); - _dvdt_velocity_0.deep_copy(_du_dt); - _dvdt_velocity_1.deep_copy(_dv_dt); - _dvdt_velocity_2.deep_copy(_dw_dt); - if (_build_temp_equ) - _dvdt_temperature.deep_copy(_du_dt + _dv_dt); - } -}; - -//---------------------------------------------------------------------------// -template -void testEval(const bool unscaled_density, const bool build_temp_equ) -{ - // Setup test fixture. - constexpr int num_space_dim = NumSpaceDim; - const int integration_order = 1; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - - // Eval dependencies. - double dphi_dt = 0.125; - double du_dt = 1.25; - double dv_dt = 1.5; - double dw_dt - = num_space_dim == 3 ? 1.75 : std::numeric_limits::quiet_NaN(); - auto dep_eval = Teuchos::rcp(new Dependencies( - *test_fixture.ir, dphi_dt, du_dt, dv_dt, dw_dt, build_temp_equ)); - test_fixture.registerEvaluator(dep_eval); - - // Fluid properties - const double beta = 0.1; - double rho = 1.0; - const double Cp - = build_temp_equ ? 5.0 : std::numeric_limits::quiet_NaN(); - Teuchos::ParameterList fluid_prop_list; - fluid_prop_list.set("Kinematic viscosity", 0.375); - fluid_prop_list.set("Artificial compressibility", beta); - fluid_prop_list.set("Build Temperature Equation", build_temp_equ); - if (unscaled_density) - { - rho = 2.0; - fluid_prop_list.set("Density", rho); - } - if (build_temp_equ) - { - fluid_prop_list.set("Thermal conductivity", 0.5); - fluid_prop_list.set("Specific heat capacity", Cp); - } - const FluidProperties::ConstantFluidProperties fluid_prop(fluid_prop_list); - - // Create test evaluator. - auto dqdt_eval = Teuchos::rcp( - new ClosureModel::IncompressibleTimeDerivative( - *test_fixture.ir, fluid_prop)); - test_fixture.registerEvaluator(dqdt_eval); - - // Add required test fields. - test_fixture.registerTestField(dqdt_eval->_dqdt_continuity); - for (int dim = 0; dim < num_space_dim; dim++) - { - test_fixture.registerTestField( - dqdt_eval->_dqdt_momentum[dim]); - } - - // Evaluate test fields. - test_fixture.evaluate(); - - // Expected momentum values - const double exp_mom[3] = {rho * du_dt, rho * dv_dt, rho * dw_dt}; - - // Expected energy values - const double exp_ener = rho * Cp * (du_dt + dv_dt); - - // Check the test fields. - auto continuity_result - = test_fixture.getTestFieldData(dqdt_eval->_dqdt_continuity); - - EXPECT_DOUBLE_EQ(0.125 / beta, fieldValue(continuity_result, 0, 0)); - for (int dim = 0; dim < num_space_dim; dim++) - { - auto momentum_dim_result = test_fixture.getTestFieldData( - dqdt_eval->_dqdt_momentum[dim]); - EXPECT_DOUBLE_EQ(exp_mom[dim], fieldValue(momentum_dim_result, 0, 0)); - } - if (build_temp_equ) - { - const auto energy_result - = test_fixture.getTestFieldData(dqdt_eval->_dqdt_energy); - EXPECT_DOUBLE_EQ(exp_ener, fieldValue(energy_result, 0, 0)); - } -} // namespace Test - -//---------------------------------------------------------------------------// -TEST(IncompressibleTimeDerivativeScaledDensityIsothermal2D, residual_test) -{ - testEval(false, false); -} - -//---------------------------------------------------------------------------// -TEST(IncompressibleTimeDerivativeScaledDensityIsothermal2D, jacobian_test) -{ - testEval(false, false); -} - -//---------------------------------------------------------------------------// -TEST(IncompressibleTimeDerivativeScaledDensity2D, residual_test) -{ - testEval(false, true); -} - -//---------------------------------------------------------------------------// -TEST(IncompressibleTimeDerivativeScaledDensity2D, jacobian_test) -{ - testEval(false, true); -} - -//---------------------------------------------------------------------------// -TEST(IncompressibleTimeDerivativeScaledDensityIsothermal3D, residual_test) -{ - testEval(false, false); -} - -//---------------------------------------------------------------------------// -TEST(IncompressibleTimeDerivativeScaledDensityIsothermal3D, jacobian_test) -{ - testEval(false, false); -} - -//---------------------------------------------------------------------------// -TEST(IncompressibleTimeDerivativeUnscaledDensityIsothermal3D, residual_test) -{ - testEval(true, false); -} - -//---------------------------------------------------------------------------// -TEST(IncompressibleTimeDerivativeUnscaledDensityIsothermal3D, jacobian_test) -{ - testEval(true, false); -} - -//---------------------------------------------------------------------------// -TEST(IncompressibleTimeDerivativeUnscaledDensity3D, residual_test) -{ - testEval(true, true); -} - -//---------------------------------------------------------------------------// -TEST(IncompressibleTimeDerivativeUnscaledDensity3D, jacobian_test) -{ - testEval(true, true); -} - -//---------------------------------------------------------------------------// - -template -void testFactory() -{ - constexpr int num_space_dim = NumSpaceDim; - ClosureModelFactoryTestFixture test_fixture; - test_fixture.user_params.set("Build Temperature Equation", false); - test_fixture.user_params.sublist("Fluid Properties") - .set("Kinematic viscosity", 0.1) - .set("Artificial compressibility", 2.0); - test_fixture.type_name = "IncompressibleTimeDerivative"; - test_fixture.eval_name = "Incompressible Time Derivative " - + std::to_string(num_space_dim) + "D"; - test_fixture.template buildAndTest< - ClosureModel::IncompressibleTimeDerivative, - num_space_dim>(); -} - -//---------------------------------------------------------------------------// -TEST(IncompressibleTimeDerivative_Factory2D, residual_test) -{ - testFactory(); -} - -//---------------------------------------------------------------------------// -TEST(IncompressibleTimeDerivative_Factory2D, jacobian_test) -{ - testFactory(); -} - -//---------------------------------------------------------------------------// -TEST(IncompressibleTimeDerivative_Factory3D, residual_test) -{ - testFactory(); -} - -//---------------------------------------------------------------------------// -TEST(IncompressibleTimeDerivative_Factory3D, jacobian_test) -{ - testFactory(); -} - -} // namespace Test -} // end namespace VertexCFD diff --git a/src/incompressible_solver/closure_models/unit_test/tstIncompressibleVariableTimeDerivative.cpp b/src/incompressible_solver/closure_models/unit_test/tstIncompressibleVariableTimeDerivative.cpp deleted file mode 100644 index 63472d8..0000000 --- a/src/incompressible_solver/closure_models/unit_test/tstIncompressibleVariableTimeDerivative.cpp +++ /dev/null @@ -1,91 +0,0 @@ -#include -#include - -#include - -#include - -//---------------------------------------------------------------------------// -// TESTS -//---------------------------------------------------------------------------// -namespace VertexCFD -{ -namespace Test -{ -//---------------------------------------------------------------------------// -// Test data dependencies. -template -struct Dependencies : public PHX::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - using scalar_type = typename EvalType::ScalarT; - - PHX::MDField _dxdt_sav; - - Dependencies(const panzer::IntegrationRule& ir) - : _dxdt_sav("DXDT_spalart_allmaras_variable", ir.dl_scalar) - { - this->addEvaluatedField(_dxdt_sav); - this->setName( - "IncompressibleVariableTimeDerivative Unit Test Dependencies"); - } - - void evaluateFields(typename panzer::Traits::EvalData) override - { - _dxdt_sav.deep_copy(2.0); - } -}; - -//---------------------------------------------------------------------------// -template -void testEval() -{ - // Setup test fixture. - const int num_space_dim = 2; - const int integration_order = 1; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - - // Eval dependencies. - auto dep_eval = Teuchos::rcp(new Dependencies(*test_fixture.ir)); - test_fixture.registerEvaluator(dep_eval); - - // Closure parameters - Teuchos::ParameterList closure_params; - closure_params.set("Field Name", "spalart_allmaras_variable"); - closure_params.set("Equation Name", "spalart_allmaras_equation"); - - // Create test evaluator. - auto dqdt_eval = Teuchos::rcp( - new ClosureModel::IncompressibleVariableTimeDerivative( - *test_fixture.ir, closure_params)); - test_fixture.registerEvaluator(dqdt_eval); - - // Add required test fields. - test_fixture.registerTestField(dqdt_eval->_dqdt_var_eq); - - // Evaluate test fields. - test_fixture.evaluate(); - - // Check the test fields. - const auto sae_result - = test_fixture.getTestFieldData(dqdt_eval->_dqdt_var_eq); - EXPECT_DOUBLE_EQ(2.0, fieldValue(sae_result, 0, 0)); -} - -//---------------------------------------------------------------------------// -TEST(IncompressibleVariableTimeDerivative, residual_test) -{ - testEval(); -} - -//---------------------------------------------------------------------------// -TEST(IncompressibleVariableTimeDerivative, jacobian_test) -{ - testEval(); -} - -} // namespace Test -} // end namespace VertexCFD diff --git a/src/incompressible_solver/closure_models/unit_test/tstIncompressibleViscousFlux.cpp b/src/incompressible_solver/closure_models/unit_test/tstIncompressibleViscousFlux.cpp deleted file mode 100644 index 68e187a..0000000 --- a/src/incompressible_solver/closure_models/unit_test/tstIncompressibleViscousFlux.cpp +++ /dev/null @@ -1,602 +0,0 @@ -#include -#include - -#include "incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleViscousFlux.hpp" -#include "incompressible_solver/fluid_properties/VertexCFD_ConstantFluidProperties.hpp" - -#include - -namespace VertexCFD -{ -namespace Test -{ -//---------------------------------------------------------------------------// -// Continuity Equation cases -enum class ContinuityModel -{ - AC, - EDAC -}; -//---------------------------------------------------------------------------// -// Test data dependencies. -template -struct Dependencies : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - using scalar_type = typename EvalType::ScalarT; - - // quiet_NaN is a host-side function so we store the value - const double _nanval = std::numeric_limits::quiet_NaN(); - - double _u; - double _v; - double _w; - bool _build_temp_equ; - bool _build_turbulence_model; - ContinuityModel _continuity_model; - - PHX::MDField velocity_0; - PHX::MDField velocity_1; - PHX::MDField velocity_2; - PHX::MDField nu_t; - - PHX::MDField grad_vel_0; - PHX::MDField grad_vel_1; - PHX::MDField grad_vel_2; - - PHX::MDField - grad_temperature; - - PHX::MDField - grad_lagrange_pressure; - - Dependencies(const panzer::IntegrationRule& ir, - const double u, - const double v, - const double w, - const bool build_temp_equ, - const bool build_turbulence_model, - const ContinuityModel continuity_model) - : _u(u) - , _v(v) - , _w(w) - , _build_temp_equ(build_temp_equ) - , _build_turbulence_model(build_turbulence_model) - , _continuity_model(continuity_model) - , velocity_0("velocity_0", ir.dl_scalar) - , velocity_1("velocity_1", ir.dl_scalar) - , velocity_2("velocity_2", ir.dl_scalar) - , nu_t("turbulent_eddy_viscosity", ir.dl_scalar) - , grad_vel_0("GRAD_velocity_0", ir.dl_vector) - , grad_vel_1("GRAD_velocity_1", ir.dl_vector) - , grad_vel_2("GRAD_velocity_2", ir.dl_vector) - , grad_temperature("GRAD_temperature", ir.dl_vector) - , grad_lagrange_pressure("GRAD_lagrange_pressure", ir.dl_vector) - { - this->addEvaluatedField(velocity_0); - this->addEvaluatedField(velocity_1); - this->addEvaluatedField(velocity_2); - - if (_build_turbulence_model) - { - this->addEvaluatedField(nu_t); - } - - this->addEvaluatedField(grad_vel_0); - this->addEvaluatedField(grad_vel_1); - this->addEvaluatedField(grad_vel_2); - - if (_build_temp_equ) - this->addEvaluatedField(grad_temperature); - - this->addEvaluatedField(grad_lagrange_pressure); - - this->setName("Incompressible Viscous Flux Unit Test Dependencies"); - } - - void evaluateFields(typename panzer::Traits::EvalData d) override - { - Kokkos::parallel_for( - "viscous flux test dependencies", - Kokkos::RangePolicy(0, d.num_cells), - *this); - } - - KOKKOS_INLINE_FUNCTION void operator()(const int c) const - { - const int num_point = grad_vel_0.extent(1); - const int num_space_dim = grad_vel_0.extent(2); - using std::pow; - for (int qp = 0; qp < num_point; ++qp) - { - for (int dim = 0; dim < num_space_dim; ++dim) - { - const int sign = pow(-1, dim + 1); - const int dimqp = (dim + 1) * sign; - grad_vel_0(c, qp, dim) = _u * dimqp; - grad_vel_1(c, qp, dim) = _v * dimqp; - grad_vel_2(c, qp, dim) = _w * dimqp; - if (_build_temp_equ) - grad_temperature(c, qp, dim) = (_u + _v) * dimqp; - - grad_lagrange_pressure(c, qp, dim) - = _continuity_model == ContinuityModel::EDAC - ? (_u + _v) * dimqp - : _nanval; - } - - velocity_0(c, qp) = _u; - velocity_1(c, qp) = _v; - velocity_2(c, qp) = _w; - - if (_build_turbulence_model) - { - nu_t(c, qp) = 4.0; - } - } - } -}; - -template -void testEval(const bool unscaled_density, - const bool build_temp_equ, - const bool build_turbulence_model, - const ContinuityModel continuity_model) -{ - constexpr int num_space_dim = NumSpaceDim; - const int integration_order = 2; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - - auto& ir = *test_fixture.ir; - const double nan_val = std::numeric_limits::quiet_NaN(); - - // Initialize velocity components and dependents - const double u = 0.25; - const double v = 0.5; - const double w = num_space_dim == 3 ? 0.125 : nan_val; - const double Pr_t = 0.8; - - const auto deps = Teuchos::rcp(new Dependencies( - ir, u, v, w, build_temp_equ, build_turbulence_model, continuity_model)); - test_fixture.registerEvaluator(deps); - - // Initialize class object to test - double rho = 1.0; - const double nu = 0.375; - const double cp = 0.2; - const double beta = 2.0; - const double kappa = build_temp_equ ? 0.5 : nan_val; - - Teuchos::ParameterList fluid_prop_list; - fluid_prop_list.set("Kinematic viscosity", nu); - fluid_prop_list.set("Artificial compressibility", beta); - fluid_prop_list.set("Build Temperature Equation", build_temp_equ); - if (unscaled_density) - { - rho = 3.0; - fluid_prop_list.set("Density", rho); - } - if (build_temp_equ) - { - fluid_prop_list.set("Thermal conductivity", kappa); - fluid_prop_list.set("Specific heat capacity", cp); - } - - Teuchos::ParameterList user_params; - if (build_turbulence_model && build_temp_equ) - user_params.set("Turbulent Prandtl Number", Pr_t); - if (continuity_model == ContinuityModel::EDAC) - user_params.set("Continuity Model", "EDAC"); - - const FluidProperties::ConstantFluidProperties fluid_prop(fluid_prop_list); - auto eval = Teuchos::rcp( - new ClosureModel:: - IncompressibleViscousFlux( - ir, fluid_prop, user_params, build_turbulence_model)); - test_fixture.registerEvaluator(eval); - test_fixture.registerTestField(eval->_continuity_flux); - for (int dim = 0; dim < num_space_dim; ++dim) - test_fixture.registerTestField(eval->_momentum_flux[dim]); - - test_fixture.evaluate(); - - const auto fc_cont - = test_fixture.getTestFieldData(eval->_continuity_flux); - const auto fc_mom_0 - = test_fixture.getTestFieldData(eval->_momentum_flux[0]); - - const int num_point = ir.num_points; - - const double exp_cont_flux_3d_ac[3] = {0.0, 0.0, 0.0}; - const double exp_cont_flux_3d_edac[3] - = {unscaled_density ? -0.421875 : -0.140625, - unscaled_density ? 0.84375 : 0.28125, - unscaled_density ? -1.265625 : -0.421875}; - - const double exp_cont_flux_2d_ac[3] - = {exp_cont_flux_3d_ac[0], exp_cont_flux_3d_ac[1], nan_val}; - - const double exp_cont_flux_2d_edac[3] - = {exp_cont_flux_3d_edac[0], exp_cont_flux_3d_edac[1], nan_val}; - - const double* exp_cont_flux - = continuity_model == ContinuityModel::EDAC - ? (num_space_dim == 3 ? exp_cont_flux_3d_edac - : exp_cont_flux_2d_edac) - : (num_space_dim == 3 ? exp_cont_flux_3d_ac - : exp_cont_flux_2d_ac); - - const double exp_mom_0_flux_3d[3] - = {build_turbulence_model ? (unscaled_density ? -3.28125 : -1.09375) - : (unscaled_density ? -0.28125 : -0.09375), - build_turbulence_model ? (unscaled_density ? 6.5625 : 2.1875) - : (unscaled_density ? 0.5625 : 0.1875), - build_turbulence_model ? (unscaled_density ? -9.84375 : -3.28125) - : (unscaled_density ? -0.84375 : -0.28125)}; - const double exp_mom_0_flux_2d[3] - = {exp_mom_0_flux_3d[0], exp_mom_0_flux_3d[1], nan_val}; - const double* exp_mom_0_flux = num_space_dim == 3 ? exp_mom_0_flux_3d - : exp_mom_0_flux_2d; - const double exp_mom_1_flux_3d[3] - = {build_turbulence_model ? (unscaled_density ? -6.5625 : -2.1875) - : (unscaled_density ? -0.5625 : -0.1875), - build_turbulence_model ? (unscaled_density ? 13.125 : 4.375) - : (unscaled_density ? 1.125 : 0.375), - build_turbulence_model ? (unscaled_density ? -19.6875 : -6.5625) - : (unscaled_density ? -1.6875 : -0.5625)}; - const double exp_mom_1_flux_2d[3] - = {exp_mom_1_flux_3d[0], exp_mom_1_flux_3d[1], nan_val}; - const double* exp_mom_1_flux = num_space_dim == 3 ? exp_mom_1_flux_3d - : exp_mom_1_flux_2d; - const double exp_mom_2_flux_3d[3] = { - build_turbulence_model ? (unscaled_density ? -1.640625 : -0.546875) - : (unscaled_density ? -0.140625 : -0.046875), - build_turbulence_model ? (unscaled_density ? 3.28125 : 1.09375) - : (unscaled_density ? 0.28125 : 0.09375), - build_turbulence_model ? (unscaled_density ? -4.921875 : -1.640625) - : (unscaled_density ? -0.421875 : -0.140625)}; - const double exp_mom_2_flux_2d[3] = {nan_val, nan_val, nan_val}; - const double* exp_mom_2_flux = num_space_dim == 3 ? exp_mom_2_flux_3d - : exp_mom_2_flux_2d; - - const double exp_ene_flux_3d[3] = { - build_turbulence_model ? (unscaled_density ? -2.625 : -1.125) : -0.375, - build_turbulence_model ? (unscaled_density ? 5.25 : 2.25) : 0.75, - build_turbulence_model ? (unscaled_density ? -7.875 : -3.375) : -1.125}; - - const double exp_ene_flux_2d[3] - = {exp_ene_flux_3d[0], exp_ene_flux_3d[1], nan_val}; - const double* exp_ene_flux = num_space_dim == 3 ? exp_ene_flux_3d - : exp_ene_flux_2d; - // Assert values - for (int qp = 0; qp < num_point; ++qp) - { - for (int dim = 0; dim < num_space_dim; dim++) - { - EXPECT_EQ(exp_cont_flux[dim], fieldValue(fc_cont, 0, qp, dim)); - EXPECT_EQ(exp_mom_0_flux[dim], fieldValue(fc_mom_0, 0, qp, dim)); - const auto fc_mom_1 = test_fixture.getTestFieldData( - eval->_momentum_flux[1]); - EXPECT_EQ(exp_mom_1_flux[dim], fieldValue(fc_mom_1, 0, qp, dim)); - if (num_space_dim > 2) // 3D mesh - { - const auto fc_mom_2 = test_fixture.getTestFieldData( - eval->_momentum_flux[2]); - EXPECT_EQ(exp_mom_2_flux[dim], - fieldValue(fc_mom_2, 0, qp, dim)); - } - if (build_temp_equ) - { - const auto fc_ene = test_fixture.getTestFieldData( - eval->_energy_flux); - EXPECT_DOUBLE_EQ(exp_ene_flux[dim], - fieldValue(fc_ene, 0, qp, dim)); - } - } - } -} - -//-----------------------------------------------------------------// -struct IncompressibleViscousFluxTestParams -{ - std::string test_name; - bool unscaled_density; - bool build_temp_equ; - bool build_turbulence_model; - ContinuityModel continuity_model; - int num_space_dim; -}; - -class IncompressibleViscousFluxTest - : public testing::TestWithParam -{ - public: - struct PrintToStringParamName - { - template - std::string operator()(const testing::TestParamInfo& info) const - { - auto testParam - = static_cast(info.param); - return testParam.test_name; - } - }; -}; - -//-----------------------------------------------------------------// -TEST_P(IncompressibleViscousFluxTest, cartesian) -{ - const auto params = GetParam(); - if (std::string::npos != params.test_name.find("residual")) - { - if (params.num_space_dim == 2) - { - testEval(params.unscaled_density, - params.build_temp_equ, - params.build_turbulence_model, - params.continuity_model); - } - else - { - testEval(params.unscaled_density, - params.build_temp_equ, - params.build_turbulence_model, - params.continuity_model); - } - } - else if (std::string::npos != params.test_name.find("jacobian")) - { - if (params.num_space_dim == 2) - { - testEval(params.unscaled_density, - params.build_temp_equ, - params.build_turbulence_model, - params.continuity_model); - } - else - { - testEval(params.unscaled_density, - params.build_temp_equ, - params.build_turbulence_model, - params.continuity_model); - } - } -} - -//-----------------------------------------------------------------// -INSTANTIATE_TEST_SUITE_P( - Test, - IncompressibleViscousFluxTest, - testing::Values( - IncompressibleViscousFluxTestParams{"ScaledDensityIsothermal2D_" - "residual", - false, - false, - false, - ContinuityModel::AC, - 2}, - IncompressibleViscousFluxTestParams{"ScaledDensityIsothermal2D_" - "jacobian", - false, - false, - false, - ContinuityModel::AC, - 2}, - IncompressibleViscousFluxTestParams{"ScaledDensity2D_residual", - false, - true, - false, - ContinuityModel::AC, - 2}, - IncompressibleViscousFluxTestParams{"ScaledDensity2D_jacobian", - false, - true, - false, - ContinuityModel::AC, - 2}, - IncompressibleViscousFluxTestParams{"ScaledDensityIsothermal3D_" - "residual", - false, - false, - false, - ContinuityModel::AC, - 3}, - IncompressibleViscousFluxTestParams{"ScaledDensityIsothermal3D_" - "jacobian", - false, - false, - false, - ContinuityModel::AC, - 3}, - IncompressibleViscousFluxTestParams{"UnScaledDensityIsothermal3D_" - "residual", - true, - false, - false, - ContinuityModel::AC, - 3}, - IncompressibleViscousFluxTestParams{"UnScaledDensityIsothermal3D_" - "jacobian", - true, - false, - false, - ContinuityModel::AC, - 3}, - IncompressibleViscousFluxTestParams{"ScaledDensity3D_residual", - false, - true, - false, - ContinuityModel::AC, - 3}, - IncompressibleViscousFluxTestParams{"ScaledDensity3D_jacobian", - false, - true, - false, - ContinuityModel::AC, - 3}, - IncompressibleViscousFluxTestParams{"TurbulentScaledDensity3D_" - "residual", - false, - true, - true, - ContinuityModel::AC, - 3}, - IncompressibleViscousFluxTestParams{"TurbulentScaledDensity3D_" - "jacobian", - false, - true, - true, - ContinuityModel::AC, - 3}, - IncompressibleViscousFluxTestParams{"TurbulentUnScaledDensity3D_" - "residual", - true, - true, - true, - ContinuityModel::AC, - 3}, - IncompressibleViscousFluxTestParams{"TurbulentUnScaledDensity3D_" - "jacobian", - true, - true, - true, - ContinuityModel::AC, - 3}, - IncompressibleViscousFluxTestParams{"ScaledDensityIsothermalEDAC2D_" - "residual", - false, - false, - false, - ContinuityModel::EDAC, - 2}, - IncompressibleViscousFluxTestParams{"ScaledDensityIsothermalEDAC2D_" - "jacobian", - false, - false, - false, - ContinuityModel::EDAC, - 2}, - IncompressibleViscousFluxTestParams{"ScaledDensityEDAC2D_residual", - false, - true, - false, - ContinuityModel::EDAC, - 2}, - IncompressibleViscousFluxTestParams{"ScaledDensityEDAC2D_jacobian", - false, - true, - false, - ContinuityModel::EDAC, - 2}, - IncompressibleViscousFluxTestParams{"ScaledDensityIsothermalEDAC3D_" - "residual", - false, - false, - false, - ContinuityModel::EDAC, - 3}, - IncompressibleViscousFluxTestParams{"ScaledDensityIsothermalEDAC3D_" - "jacobian", - false, - false, - false, - ContinuityModel::EDAC, - 3}, - IncompressibleViscousFluxTestParams{"UnScaledDensityIsothermalEDAC3D_" - "residual", - true, - false, - false, - ContinuityModel::EDAC, - 3}, - IncompressibleViscousFluxTestParams{"UnScaledDensityIsothermalEDAC3D_" - "jacobian", - true, - false, - false, - ContinuityModel::EDAC, - 3}, - IncompressibleViscousFluxTestParams{"ScaledDensityEDAC3D_residual", - false, - true, - false, - ContinuityModel::EDAC, - 3}, - IncompressibleViscousFluxTestParams{"ScaledDensityEDAC3D_jacobian", - false, - true, - false, - ContinuityModel::EDAC, - 3}, - IncompressibleViscousFluxTestParams{"TurbulentScaledDensityEDAC3D_" - "residual", - false, - true, - true, - ContinuityModel::EDAC, - 3}, - IncompressibleViscousFluxTestParams{"TurbulentScaledDensityEDAC3D_" - "jacobian", - false, - true, - true, - ContinuityModel::EDAC, - 3}, - IncompressibleViscousFluxTestParams{"TurbulentUnScaledDensityEDAC3D_" - "residual", - true, - true, - true, - ContinuityModel::EDAC, - 3}, - IncompressibleViscousFluxTestParams{"TurbulentUnScaledDensityEDAC3D_" - "jacobian", - true, - true, - true, - ContinuityModel::EDAC, - 3}), - IncompressibleViscousFluxTest::PrintToStringParamName()); - -//-----------------------------------------------------------------// -template -void testFactory() -{ - constexpr int num_space_dim = NumSpaceDim; - ClosureModelFactoryTestFixture test_fixture; - test_fixture.user_params.set("Build Temperature Equation", false); - test_fixture.user_params.sublist("Fluid Properties") - .set("Kinematic viscosity", 0.1) - .set("Artificial compressibility", 2.0); - test_fixture.type_name = "IncompressibleViscousFlux"; - test_fixture.eval_name = "Incompressible Viscous Flux " - + std::to_string(num_space_dim) + "D"; - test_fixture.template buildAndTest< - ClosureModel::IncompressibleViscousFlux, - num_space_dim>(); -} - -TEST(IncompressibleViscousFlux_Factory2D, residual_test) -{ - testFactory(); -} - -TEST(IncompressibleViscousFlux_Factory2D, jacobian_test) -{ - testFactory(); -} - -TEST(IncompressibleViscousFlux_Factory3D, residual_test) -{ - testFactory(); -} - -TEST(IncompressibleViscousFlux_Factory3D, jacobian_test) -{ - testFactory(); -} - -} // namespace Test -} // namespace VertexCFD diff --git a/src/incompressible_solver/closure_models/unit_test/tstIncompressibleViscousHeat.cpp b/src/incompressible_solver/closure_models/unit_test/tstIncompressibleViscousHeat.cpp deleted file mode 100644 index c716777..0000000 --- a/src/incompressible_solver/closure_models/unit_test/tstIncompressibleViscousHeat.cpp +++ /dev/null @@ -1,199 +0,0 @@ -#include -#include - -#include "incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleViscousHeat.hpp" -#include "incompressible_solver/fluid_properties/VertexCFD_ConstantFluidProperties.hpp" - -#include - -namespace VertexCFD -{ -namespace Test -{ - -template -struct Dependencies : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - using scalar_type = typename EvalType::ScalarT; - - // quiet_NaN is a host-side function so we store the value - const double _nanval = std::numeric_limits::quiet_NaN(); - - PHX::MDField grad_vel_0; - PHX::MDField grad_vel_1; - PHX::MDField grad_vel_2; - - Dependencies(const panzer::IntegrationRule& ir) - : grad_vel_0("GRAD_velocity_0", ir.dl_vector) - , grad_vel_1("GRAD_velocity_1", ir.dl_vector) - , grad_vel_2("GRAD_velocity_2", ir.dl_vector) - - { - this->addEvaluatedField(grad_vel_0); - this->addEvaluatedField(grad_vel_1); - this->addEvaluatedField(grad_vel_2); - - this->setName("Incompressible Viscous Heat Unit Test Dependencies"); - } - - void evaluateFields(typename panzer::Traits::EvalData d) override - { - Kokkos::parallel_for( - "viscous heat test dependencies", - Kokkos::RangePolicy(0, d.num_cells), - *this); - } - - KOKKOS_INLINE_FUNCTION void operator()(const int c) const - { - const int num_point = grad_vel_0.extent(1); - const int num_space_dim = grad_vel_0.extent(2); - using std::pow; - for (int qp = 0; qp < num_point; ++qp) - { - for (int dim = 0; dim < num_space_dim; ++dim) - { - const int sign = pow(-1, dim + 1); - const int dimqp = (dim + 1) * sign; - grad_vel_0(c, qp, dim) = 0.250 * dimqp; - grad_vel_1(c, qp, dim) = 0.500 * dimqp; - grad_vel_2(c, qp, dim) = num_space_dim == 3 ? 0.125 * dimqp - : _nanval; - } - } - } -}; - -template -void testEval() -{ - constexpr int num_space_dim = NumSpaceDim; - const int integration_order = 2; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - - const auto& ir = *test_fixture.ir; - - // Initialize velocity gradient and dependents - auto deps = Teuchos::rcp(new Dependencies(ir)); - test_fixture.registerEvaluator(deps); - - // Initialize class object to test - Teuchos::ParameterList fluid_prop_list; - fluid_prop_list.set("Build Temperature Equation", true); - fluid_prop_list.set("Kinematic viscosity", 0.375); - fluid_prop_list.set("Density", 1.0); - fluid_prop_list.set("Artificial compressibility", 1.0); - fluid_prop_list.set("Thermal conductivity", 1.0); - fluid_prop_list.set("Specific heat capacity", 1.0); - const FluidProperties::ConstantFluidProperties fluid_prop(fluid_prop_list); - auto eval = Teuchos::rcp( - new ClosureModel:: - IncompressibleViscousHeat( - ir, fluid_prop)); - - test_fixture.registerEvaluator(eval); - test_fixture.registerTestField( - eval->_viscous_heat_continuity_source); - test_fixture.registerTestField(eval->_viscous_heat_energy_source); - for (int dim = 0; dim < num_space_dim; ++dim) - test_fixture.registerTestField( - eval->_viscous_heat_momentum_source[dim]); - - test_fixture.evaluate(); - - const auto fc_cont = test_fixture.getTestFieldData( - eval->_viscous_heat_continuity_source); - const auto fc_mom_0 = test_fixture.getTestFieldData( - eval->_viscous_heat_momentum_source[0]); - const auto fc_mom_1 = test_fixture.getTestFieldData( - eval->_viscous_heat_momentum_source[1]); - const auto fc_energy = test_fixture.getTestFieldData( - eval->_viscous_heat_energy_source); - - const int num_point = ir.num_points; - - // Expected energy - see ./doc/viscous_heat_reference.py - const double exp_energy = num_space_dim == 3 ? 1.775390625 : 0.796875; - - // Assert values - for (int qp = 0; qp < num_point; ++qp) - { - EXPECT_EQ(0.0, fieldValue(fc_cont, 0, qp)); - EXPECT_EQ(0.0, fieldValue(fc_mom_0, 0, qp)); - EXPECT_EQ(0.0, fieldValue(fc_mom_1, 0, qp)); - if (num_space_dim == 3) - { - const auto fc_mom_2 = test_fixture.getTestFieldData( - eval->_viscous_heat_momentum_source[2]); - EXPECT_EQ(0.0, fieldValue(fc_mom_2, 0, qp)); - } - EXPECT_EQ(exp_energy, fieldValue(fc_energy, 0, qp)); - } -} - -//-----------------------------------------------------------------// -TEST(IncompressibleViscousHeat2D, residual_test) -{ - testEval(); -} - -//-----------------------------------------------------------------// -TEST(IncompressibleViscousHeat2D, jacobian_test) -{ - testEval(); -} - -//-----------------------------------------------------------------// -TEST(IncompressibleViscousHeat3D, residual_test) -{ - testEval(); -} - -//-----------------------------------------------------------------// -TEST(IncompressibleViscousHeat3D, jacobian_test) -{ - testEval(); -} - -//-----------------------------------------------------------------// -template -void testFactory() -{ - constexpr int num_space_dim = NumSpaceDim; - ClosureModelFactoryTestFixture test_fixture; - test_fixture.type_name = "IncompressibleViscousHeat"; - test_fixture.eval_name = "Incompressible Viscous Heat " - + std::to_string(num_space_dim) + "D"; - test_fixture.user_params.sublist("Fluid Properties") - .set("Kinematic viscosity", 0.1) - .set("Artificial compressibility", 2.0); - test_fixture.template buildAndTest< - ClosureModel::IncompressibleViscousHeat, - num_space_dim>(); -} - -TEST(IncompressibleViscousHeat_Factory2D, residual_test) -{ - testFactory(); -} - -TEST(IncompressibleViscousHeat_Factory2D, jacobian_test) -{ - testFactory(); -} - -TEST(IncompressibleViscousHeat_Factory3D, residual_test) -{ - testFactory(); -} - -TEST(IncompressibleViscousHeat_Factory3D, jacobian_test) -{ - testFactory(); -} - -} // namespace Test -} // namespace VertexCFD diff --git a/src/incompressible_solver/fluid_properties/VertexCFD_ConstantFluidProperties.hpp b/src/incompressible_solver/fluid_properties/VertexCFD_ConstantFluidProperties.hpp deleted file mode 100644 index 1ea3f94..0000000 --- a/src/incompressible_solver/fluid_properties/VertexCFD_ConstantFluidProperties.hpp +++ /dev/null @@ -1,159 +0,0 @@ -#ifndef VERTEXCFD_CONSTANTFLUIDPROPERTIES_HPP -#define VERTEXCFD_CONSTANTFLUIDPROPERTIES_HPP - -#include - -#include - -namespace VertexCFD -{ -namespace FluidProperties -{ -//---------------------------------------------------------------------------// -// Constant fluid properties -//---------------------------------------------------------------------------// - -class ConstantFluidProperties -{ - public: - ConstantFluidProperties() = default; - explicit ConstantFluidProperties(const Teuchos::ParameterList& params) - : _kinematic_viscosity(params.get("Kinematic viscosity")) - , _beta(params.get("Artificial compressibility")) - , _solve_temp(params.get("Build Temperature Equation")) - , _build_ind_less_equ(false) - , _build_buoyancy(false) - { - // Density - if (params.isType("Density")) - { - _density = params.get("Density"); - } - else - { - _density = 1.0; - } - - // Thermal parameters - if (_solve_temp) - { - _thermal_conductivity = params.get("Thermal conductivity"); - _Cp = params.get("Specific heat capacity"); - - // Check for buoyancy bool - if (params.isType("Build Buoyancy Source")) - { - _build_buoyancy = params.get("Build Buoyancy Source"); - } - } - else - { - _thermal_conductivity = std::numeric_limits::quiet_NaN(); - _Cp = std::numeric_limits::quiet_NaN(); - } - - // Buoyancy source term - - if (_build_buoyancy) - { - _beta_T = params.get("Expansion coefficient"); - _T_ref = params.get("Reference temperature"); - } - else - { - _beta_T = std::numeric_limits::quiet_NaN(); - _T_ref = std::numeric_limits::quiet_NaN(); - } - - // Inductionless MHD equation - if (params.isType("Build Inductionless MHD Equation")) - { - _build_ind_less_equ - = params.get("Build Inductionless MHD Equation"); - } - - if (_build_ind_less_equ) - { - _sigma = params.get("Electrical conductivity"); - } - else - { - _sigma = std::numeric_limits::quiet_NaN(); - } - } - - // Constant density - KOKKOS_INLINE_FUNCTION double constantDensity() const { return _density; } - - // Constant kinematic viscosity - KOKKOS_INLINE_FUNCTION double constantKinematicViscosity() const - { - return _kinematic_viscosity; - } - - // Constant thermal conductivity - KOKKOS_INLINE_FUNCTION double constantThermalConductivity() const - { - return _thermal_conductivity; - } - - // Constant heat capacity - KOKKOS_INLINE_FUNCTION double constantHeatCapacity() const - { - return _density * _Cp; - } - - // Constant electrical conductivity - KOKKOS_INLINE_FUNCTION double constantElectricalConductivity() const - { - return _sigma; - } - - // Solve temperature equation - KOKKOS_INLINE_FUNCTION bool solveTemperature() const - { - return _solve_temp; - } - - // Include buoyancy effects - KOKKOS_INLINE_FUNCTION bool buildBuoyancy() const - { - return _build_buoyancy; - } - - // Expansion coefficient - KOKKOS_INLINE_FUNCTION double expansionCoefficient() const - { - return _beta_T; - } - - // Reference temperature - KOKKOS_INLINE_FUNCTION double referenceTemperature() const - { - return _T_ref; - } - - // Artificial compressibility - KOKKOS_INLINE_FUNCTION double artificialCompressibility() const - { - return _beta; - } - - private: - double _kinematic_viscosity; - double _beta; - double _density; - double _Cp; - double _thermal_conductivity; - double _sigma; - double _beta_T; - double _T_ref; - bool _solve_temp; - bool _build_ind_less_equ; - bool _build_buoyancy; -}; - -} // namespace FluidProperties -} // namespace VertexCFD - -#endif // VERTEXCFD_CONSTANTFLUIDPROPERTIES_HPP diff --git a/src/incompressible_solver/fluid_properties/unit_test/CMakeLists.txt b/src/incompressible_solver/fluid_properties/unit_test/CMakeLists.txt deleted file mode 100644 index 0d91d21..0000000 --- a/src/incompressible_solver/fluid_properties/unit_test/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -set(TEST_HARNESS_DIR ${CMAKE_SOURCE_DIR}/src/test_harness) -include(${TEST_HARNESS_DIR}/TestHarness.cmake) - -VertexCFD_add_tests( - LIBS VertexCFD - NAMES - IncompressibleConstantFluidProperties - ) diff --git a/src/incompressible_solver/fluid_properties/unit_test/tstIncompressibleConstantFluidProperties.cpp b/src/incompressible_solver/fluid_properties/unit_test/tstIncompressibleConstantFluidProperties.cpp deleted file mode 100644 index 92a77ef..0000000 --- a/src/incompressible_solver/fluid_properties/unit_test/tstIncompressibleConstantFluidProperties.cpp +++ /dev/null @@ -1,157 +0,0 @@ -#include "incompressible_solver/fluid_properties/VertexCFD_ConstantFluidProperties.hpp" - -#include - -#include - -using namespace VertexCFD::FluidProperties; - -//---------------------------------------------------------------------------// -// TESTS -//---------------------------------------------------------------------------// -namespace Test -{ -class IncompressibleConstantFluidPropertiesTest : public ::testing::Test -{ - protected: - std::unique_ptr cfp; - - virtual void SetUp() override; - virtual void SetUpDensity(); - virtual void SetUpTemperature(); - virtual void SetUpBuoyancy(); - virtual void SetUpElectricPotential(); -}; - -// Set up all variables but density -void IncompressibleConstantFluidPropertiesTest::SetUp() -{ - Teuchos::ParameterList cfp_params; - cfp_params.set("Kinematic viscosity", 0.2); - cfp_params.set("Artificial compressibility", 2.0); - cfp_params.set("Build Temperature Equation", false); - cfp = std::make_unique(cfp_params); -} - -// Initialize density -void IncompressibleConstantFluidPropertiesTest::SetUpDensity() -{ - Teuchos::ParameterList cfp_params; - cfp_params.set("Density", 1.5); - cfp_params.set("Kinematic viscosity", 0.2); - cfp_params.set("Artificial compressibility", 2.0); - cfp_params.set("Build Temperature Equation", false); - cfp = std::make_unique(cfp_params); -} - -// With temperature equation -void IncompressibleConstantFluidPropertiesTest::SetUpTemperature() -{ - Teuchos::ParameterList cfp_params; - cfp_params.set("Kinematic viscosity", 0.2); - cfp_params.set("Artificial compressibility", 2.0); - cfp_params.set("Build Temperature Equation", true); - cfp_params.set("Thermal conductivity", 0.3); - cfp_params.set("Specific heat capacity", 0.4); - cfp = std::make_unique(cfp_params); -} - -// With buoyancy -void IncompressibleConstantFluidPropertiesTest::SetUpBuoyancy() -{ - Teuchos::ParameterList cfp_params; - cfp_params.set("Kinematic viscosity", 0.2); - cfp_params.set("Artificial compressibility", 2.0); - cfp_params.set("Build Temperature Equation", true); - cfp_params.set("Build Buoyancy Source", true); - cfp_params.set("Thermal conductivity", 0.3); - cfp_params.set("Specific heat capacity", 0.4); - cfp_params.set("Expansion coefficient", 0.5); - cfp_params.set("Reference temperature", 0.6); - cfp = std::make_unique(cfp_params); -} - -// With electric potential equation -void IncompressibleConstantFluidPropertiesTest::SetUpElectricPotential() -{ - Teuchos::ParameterList cfp_params; - cfp_params.set("Kinematic viscosity", 0.2); - cfp_params.set("Artificial compressibility", 2.0); - cfp_params.set("Build Temperature Equation", false); - cfp_params.set("Build Inductionless MHD Equation", true); - cfp_params.set("Electrical conductivity", 0.3); - cfp = std::make_unique(cfp_params); -} - -// Density - specified -TEST_F(IncompressibleConstantFluidPropertiesTest, unscaled_density) -{ - IncompressibleConstantFluidPropertiesTest::SetUpDensity(); - const double rho_expect = 1.5; - const double rho = cfp->constantDensity(); - EXPECT_DOUBLE_EQ(rho_expect, rho); - - const double nu_expect = 0.2; - const double nu = cfp->constantKinematicViscosity(); - EXPECT_DOUBLE_EQ(nu_expect, nu); - - const double beta_expect = 2.0; - const double beta = cfp->artificialCompressibility(); - EXPECT_DOUBLE_EQ(beta_expect, beta); -} - -// Density - not specified -TEST_F(IncompressibleConstantFluidPropertiesTest, scaled_density) -{ - IncompressibleConstantFluidPropertiesTest::SetUp(); - const double rho_expect = 1.0; - const double rho = cfp->constantDensity(); - EXPECT_DOUBLE_EQ(rho_expect, rho); - - const double nu_expect = 0.2; - const double nu = cfp->constantKinematicViscosity(); - EXPECT_DOUBLE_EQ(nu_expect, nu); - - const double beta_expect = 2.0; - const double beta = cfp->artificialCompressibility(); - EXPECT_DOUBLE_EQ(beta_expect, beta); -} - -// Temperature equation -TEST_F(IncompressibleConstantFluidPropertiesTest, temperature_equation) -{ - IncompressibleConstantFluidPropertiesTest::SetUpTemperature(); - const double k_expect = 0.3; - const double k = cfp->constantThermalConductivity(); - EXPECT_DOUBLE_EQ(k_expect, k); - - const double cp_expect = 0.4; - const double cp = cfp->constantHeatCapacity(); - EXPECT_DOUBLE_EQ(cp_expect, cp); -} - -// Buoyancy -TEST_F(IncompressibleConstantFluidPropertiesTest, bouyancy) -{ - IncompressibleConstantFluidPropertiesTest::SetUpBuoyancy(); - const double beta_expect = 0.5; - const double beta = cfp->expansionCoefficient(); - EXPECT_DOUBLE_EQ(beta_expect, beta); - - const double T0_expect = 0.6; - const double T0 = cfp->referenceTemperature(); - EXPECT_DOUBLE_EQ(T0_expect, T0); -} - -// Inductionless mhd equation -TEST_F(IncompressibleConstantFluidPropertiesTest, inductionless_mhd_equation) -{ - IncompressibleConstantFluidPropertiesTest::SetUpElectricPotential(); - const double sigma_expect = 0.3; - const double sigma = cfp->constantElectricalConductivity(); - EXPECT_DOUBLE_EQ(sigma_expect, sigma); -} - -//---------------------------------------------------------------------------// - -} // end namespace Test diff --git a/src/incompressible_solver/initial_conditions/VertexCFD_InitialCondition_IncompressibleLaminarFlow.cpp b/src/incompressible_solver/initial_conditions/VertexCFD_InitialCondition_IncompressibleLaminarFlow.cpp deleted file mode 100644 index 4522e3e..0000000 --- a/src/incompressible_solver/initial_conditions/VertexCFD_InitialCondition_IncompressibleLaminarFlow.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_InitialCondition_IncompressibleLaminarFlow.hpp" -#include "VertexCFD_InitialCondition_IncompressibleLaminarFlow_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS_NUMSPACEDIM( - VertexCFD::InitialCondition::IncompressibleLaminarFlow) diff --git a/src/incompressible_solver/initial_conditions/VertexCFD_InitialCondition_IncompressibleLaminarFlow.hpp b/src/incompressible_solver/initial_conditions/VertexCFD_InitialCondition_IncompressibleLaminarFlow.hpp deleted file mode 100644 index 8e53712..0000000 --- a/src/incompressible_solver/initial_conditions/VertexCFD_InitialCondition_IncompressibleLaminarFlow.hpp +++ /dev/null @@ -1,73 +0,0 @@ -#ifndef VERTEXCFD_INITIALCONDITION_INCOMPRESSIBLELAMINARFLOW_HPP -#define VERTEXCFD_INITIALCONDITION_INCOMPRESSIBLELAMINARFLOW_HPP - -#include "incompressible_solver/fluid_properties/VertexCFD_ConstantFluidProperties.hpp" - -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include - -namespace VertexCFD -{ -namespace InitialCondition -{ -//---------------------------------------------------------------------------// -template -class IncompressibleLaminarFlow - : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - using view_layout = typename PHX::DevLayout::type; - static constexpr int num_space_dim = NumSpaceDim; - - IncompressibleLaminarFlow( - const Teuchos::ParameterList& ic_params, - const FluidProperties::ConstantFluidProperties& fluid_prop, - const panzer::PureBasis& basis); - - void postRegistrationSetup(typename Traits::SetupData sd, - PHX::FieldManager& fm) override; - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - public: - PHX::MDField _lagrange_pressure; - Kokkos::Array, - num_space_dim> - _velocity; - PHX::MDField _temperature; - - private: - std::string _basis_name; - int _basis_index; - PHX::MDField _basis_coords; - - bool _solve_temp; - double _min; - double _max; - double _vel_avg; - double _vel_max; - double _T_init; -}; - -//---------------------------------------------------------------------------// - -} // end namespace InitialCondition -} // end namespace VertexCFD - -#endif // end VERTEXCFD_INITIALCONDITION_INCOMPRESSIBLELAMINARFLOW_HPP diff --git a/src/incompressible_solver/initial_conditions/VertexCFD_InitialCondition_IncompressibleTaylorGreenVortex.cpp b/src/incompressible_solver/initial_conditions/VertexCFD_InitialCondition_IncompressibleTaylorGreenVortex.cpp deleted file mode 100644 index 5d2133f..0000000 --- a/src/incompressible_solver/initial_conditions/VertexCFD_InitialCondition_IncompressibleTaylorGreenVortex.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_InitialCondition_IncompressibleTaylorGreenVortex.hpp" -#include "VertexCFD_InitialCondition_IncompressibleTaylorGreenVortex_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS_NUMSPACEDIM( - VertexCFD::InitialCondition::IncompressibleTaylorGreenVortex) diff --git a/src/incompressible_solver/initial_conditions/VertexCFD_InitialCondition_IncompressibleTaylorGreenVortex.hpp b/src/incompressible_solver/initial_conditions/VertexCFD_InitialCondition_IncompressibleTaylorGreenVortex.hpp deleted file mode 100644 index f98962f..0000000 --- a/src/incompressible_solver/initial_conditions/VertexCFD_InitialCondition_IncompressibleTaylorGreenVortex.hpp +++ /dev/null @@ -1,60 +0,0 @@ -#ifndef VERTEXCFD_INITIALCONDITION_INCOMPRESSIBLETAYLORGREENVORTEX_HPP -#define VERTEXCFD_INITIALCONDITION_INCOMPRESSIBLETAYLORGREENVORTEX_HPP - -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include - -namespace VertexCFD -{ -namespace InitialCondition -{ -//---------------------------------------------------------------------------// -template -class IncompressibleTaylorGreenVortex - : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - using view_layout = typename PHX::DevLayout::type; - static constexpr int num_space_dim = NumSpaceDim; - - IncompressibleTaylorGreenVortex(const panzer::PureBasis& basis); - - void postRegistrationSetup(typename Traits::SetupData sd, - PHX::FieldManager& fm) override; - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - public: - PHX::MDField _lagrange_pressure; - Kokkos::Array, - num_space_dim> - _velocity; - - private: - std::string _basis_name; - int _basis_index; - PHX::MDField _basis_coords; -}; - -//---------------------------------------------------------------------------// - -} // end namespace InitialCondition -} // end namespace VertexCFD - -#endif // end VERTEXCFD_INITIALCONDITION_INCOMPRESSIBLETAYLORGREENVORTEX_HPP diff --git a/src/incompressible_solver/initial_conditions/VertexCFD_InitialCondition_IncompressibleVortexInBox.cpp b/src/incompressible_solver/initial_conditions/VertexCFD_InitialCondition_IncompressibleVortexInBox.cpp deleted file mode 100644 index 52c3c23..0000000 --- a/src/incompressible_solver/initial_conditions/VertexCFD_InitialCondition_IncompressibleVortexInBox.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_InitialCondition_IncompressibleVortexInBox.hpp" -#include "VertexCFD_InitialCondition_IncompressibleVortexInBox_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS( - VertexCFD::InitialCondition::IncompressibleVortexInBox) diff --git a/src/incompressible_solver/initial_conditions/VertexCFD_InitialCondition_IncompressibleVortexInBox.hpp b/src/incompressible_solver/initial_conditions/VertexCFD_InitialCondition_IncompressibleVortexInBox.hpp deleted file mode 100644 index 7c956a5..0000000 --- a/src/incompressible_solver/initial_conditions/VertexCFD_InitialCondition_IncompressibleVortexInBox.hpp +++ /dev/null @@ -1,58 +0,0 @@ -#ifndef VERTEXCFD_INITIALCONDITION_INCOMPRESSIBLEVORTEXINBOX_HPP -#define VERTEXCFD_INITIALCONDITION_INCOMPRESSIBLEVORTEXINBOX_HPP - -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include - -namespace VertexCFD -{ -namespace InitialCondition -{ -//---------------------------------------------------------------------------// -template -class IncompressibleVortexInBox - : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - using view_layout = typename PHX::DevLayout::type; - - IncompressibleVortexInBox(const panzer::PureBasis& basis); - - void postRegistrationSetup(typename Traits::SetupData sd, - PHX::FieldManager& fm) override; - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - public: - PHX::MDField _velocity_0; - PHX::MDField _velocity_1; - PHX::MDField _lagrange_pressure; - - private: - std::string _basis_name; - int _basis_index; - PHX::MDField _basis_coords; -}; - -//---------------------------------------------------------------------------// - -} // end namespace InitialCondition -} // end namespace VertexCFD - -#endif // end VERTEXCFD_INITIALCONDITION_INCOMPRESSIBLEVORTEXINBOX_HPP diff --git a/src/incompressible_solver/initial_conditions/unit_test/CMakeLists.txt b/src/incompressible_solver/initial_conditions/unit_test/CMakeLists.txt deleted file mode 100644 index e482df5..0000000 --- a/src/incompressible_solver/initial_conditions/unit_test/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -set(TEST_HARNESS_DIR ${CMAKE_SOURCE_DIR}/src/test_harness) -include(${TEST_HARNESS_DIR}/TestHarness.cmake) - -VertexCFD_add_tests( - LIBS VertexCFD - NAMES - IncompressibleVortexInBox - IncompressibleLaminarFlow - IncompressibleTaylorGreenVortex - ) diff --git a/src/incompressible_solver/initial_conditions/unit_test/doc/incompressible_laminar_flow_reference.py b/src/incompressible_solver/initial_conditions/unit_test/doc/incompressible_laminar_flow_reference.py deleted file mode 100644 index b1fbb0f..0000000 --- a/src/incompressible_solver/initial_conditions/unit_test/doc/incompressible_laminar_flow_reference.py +++ /dev/null @@ -1,56 +0,0 @@ -# Functions -def ic2d(y, h_min, h_max, vel_avg): - coeff = 3.0 / 2.0 - H = 0.5 * (h_max - h_min) - u = vel_avg * coeff * (1.0 - y * y / (H * H)) - return u, 0.0 - - -def ic3d(y, z, h_min, h_max, vel_avg): - coeff = 2.0 - H = 0.5 * (h_max - h_min) - r2 = y * y + z * z - u = vel_avg * coeff * (1.0 - r2 / (H * H)) - return u, 0.0, 0.0 - - -# IC parameters -h_min = -2.0 -h_max = 2.2 -vel_avg = 3.0 - -# Compute ic values in 2D -num_points = 4 -y_list = [(basis + 1) * 0.125 for basis in range(0, num_points)] -u_list = [] -v_list = [] -for y in y_list: - u, v = ic2d(y, h_max, h_min, vel_avg) - u_list.append(u) - v_list.append(v) - -# Print ic values -print("\n2D laminar flow:") -print("phi: ", 0.0) -print("u: ", u_list) -print("v: ", v_list) - -# Compute ic values in 3D -num_points = 8 -y_list = [(basis + 1) * 0.125 for basis in range(0, num_points)] -z_list = [h_min + y for y in y_list] -u_list = [] -v_list = [] -w_list = [] -for y, z in zip(y_list, z_list): - u, v, w = ic3d(y, z, h_min, h_max, vel_avg) - u_list.append(u) - v_list.append(v) - w_list.append(w) - -# Print ic values -print("\n3D laminar flow:") -print("phi: ", 0.0) -print("u: ", u_list) -print("v: ", v_list) -print("w: ", w_list) diff --git a/src/incompressible_solver/initial_conditions/unit_test/doc/incompressible_taylor_green_vortex_reference.py b/src/incompressible_solver/initial_conditions/unit_test/doc/incompressible_taylor_green_vortex_reference.py deleted file mode 100644 index 207421b..0000000 --- a/src/incompressible_solver/initial_conditions/unit_test/doc/incompressible_taylor_green_vortex_reference.py +++ /dev/null @@ -1,29 +0,0 @@ -import math - -# Node coordinates (set in the unit test) -x_list = [-0.15, -0.05, 0.05, 0.15] -y_list = [-0.05, 0.15, 0.35, 0.55] - - -# Function -def ic(x, y): - u = math.cos(x) * math.sin(y) - v = -math.sin(x) * math.cos(y) - p = -0.25 * (math.cos(2.0 * x) + math.cos(2.0 * y)) - return u, v, p - - -# Compute ic values -u_list = [] -v_list = [] -p_list = [] -for x, y in zip(x_list, y_list): - u, v, p = ic(x, y) - p_list.append(p) - u_list.append(u) - v_list.append(v) - -# Print ic values -print("phi: ", p_list) -print("u: ", u_list) -print("v: ", v_list) diff --git a/src/incompressible_solver/initial_conditions/unit_test/doc/incompressible_vortex_box_reference.py b/src/incompressible_solver/initial_conditions/unit_test/doc/incompressible_vortex_box_reference.py deleted file mode 100644 index a480333..0000000 --- a/src/incompressible_solver/initial_conditions/unit_test/doc/incompressible_vortex_box_reference.py +++ /dev/null @@ -1,30 +0,0 @@ -import math - -pi = math.pi - -# Node coordinates (set in the unit test) -x_list = [-0.15, -0.05, 0.05, 0.15] -y_list = [-0.05, 0.15, 0.35, 0.55] - - -# Function -def ic(x, y): - u = -2.0 * math.cos(pi * y) * math.sin(pi * y) * math.sin( - pi * x) * math.sin(pi * x) - v = 2.0 * math.cos(pi * x) * math.sin(pi * x) * math.sin( - pi * y) * math.sin(pi * y) - return u, v - - -# Compute ic values -u_list = [] -v_list = [] -for x, y in zip(x_list, y_list): - u, v = ic(x, y) - u_list.append(u) - v_list.append(v) - -# Print ic values -print("phi: ", 0.0) -print("u: ", u_list) -print("v: ", v_list) diff --git a/src/incompressible_solver/initial_conditions/unit_test/tstIncompressibleLaminarFlow.cpp b/src/incompressible_solver/initial_conditions/unit_test/tstIncompressibleLaminarFlow.cpp deleted file mode 100644 index fd64e1c..0000000 --- a/src/incompressible_solver/initial_conditions/unit_test/tstIncompressibleLaminarFlow.cpp +++ /dev/null @@ -1,166 +0,0 @@ -#include - -#include "incompressible_solver/initial_conditions/VertexCFD_InitialCondition_IncompressibleLaminarFlow.hpp" - -#include - -#include - -namespace VertexCFD -{ -namespace Test -{ -//---------------------------------------------------------------------------// -template -void testEval(const bool build_temp_equ) -{ - constexpr int num_space_dim = NumSpaceDim; - const int integration_order = 1; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - - // Set non-trivial coordinates for the degree of freedom - const int num_coord = test_fixture.cell_topo->getNodeCount(); - Kokkos::View x( - "coordinate", num_space_dim, num_coord); - auto basis_coord_view - = test_fixture.workset->bases[0]->basis_coordinates.get_static_view(); - auto basis_coord_mirror = Kokkos::create_mirror(basis_coord_view); - for (int basis = 0; basis < num_coord; basis++) - { - // random coordinate assigned - basis_coord_mirror(0, basis, 1) = 0.125 * (basis + 1); - if (num_space_dim == 3) - basis_coord_mirror(0, basis, 2) = -2.0 + 0.125 * (basis + 1); - } - - Kokkos::deep_copy(basis_coord_view, basis_coord_mirror); - - Teuchos::ParameterList ic_params; - ic_params.set("Minimum height", -2.0); - ic_params.set("Maximum height", 2.2); - ic_params.set("Average velocity", 3.0); - const double temp_ref - = build_temp_equ ? 4.0 : std::numeric_limits::quiet_NaN(); - if (build_temp_equ) - ic_params.set("Temperature", temp_ref); - Teuchos::ParameterList fluid_prop_list; - fluid_prop_list.set("Kinematic viscosity", 0.375); - fluid_prop_list.set("Artificial compressibility", 2.0); - fluid_prop_list.set("Build Temperature Equation", build_temp_equ); - if (build_temp_equ) - { - fluid_prop_list.set("Thermal conductivity", 0.5); - fluid_prop_list.set("Specific heat capacity", 0.6); - } - const FluidProperties::ConstantFluidProperties fluid_prop(fluid_prop_list); - - // Register and evaluate fields - auto eval = Teuchos::rcp( - new InitialCondition::IncompressibleLaminarFlow( - ic_params, fluid_prop, *test_fixture.basis_ir_layout->getBasis())); - test_fixture.registerEvaluator(eval); - - test_fixture.registerTestField(eval->_lagrange_pressure); - for (int dim = 0; dim < num_space_dim; ++dim) - test_fixture.registerTestField(eval->_velocity[dim]); - if (build_temp_equ) - test_fixture.registerTestField(eval->_temperature); - - test_fixture.evaluate(); - - const auto phi - = test_fixture.getTestFieldData(eval->_lagrange_pressure); - const auto u = test_fixture.getTestFieldData(eval->_velocity[0]); - const auto v = test_fixture.getTestFieldData(eval->_velocity[1]); - - // Check number of degree of freedoms - const int num_dofs = num_space_dim == 2 ? 4 : 8; - EXPECT_EQ(num_dofs, phi.extent(1)); - EXPECT_EQ(num_dofs, u.extent(1)); - EXPECT_EQ(num_dofs, v.extent(1)); - - // Reference values - const double phi_ref = 0.0; - const double u_ref_2d[4] = {4.48405612244898, - 4.436224489795919, - 4.356505102040816, - 4.244897959183674}; - const double u_ref_3d[8] = {1.195578231292517, - 1.7482993197278913, - 2.2159863945578238, - 2.5986394557823127, - 2.896258503401361, - 3.1088435374149666, - 3.2363945578231297, - 3.278911564625851}; - const double v_ref = 0.0; - const double w_ref = 0.0; - - // Check values - for (int n = 0; n < num_dofs; ++n) - { - EXPECT_DOUBLE_EQ(phi_ref, fieldValue(phi, 0, n)); - const double u_ref = num_space_dim == 2 ? u_ref_2d[n] : u_ref_3d[n]; - EXPECT_FLOAT_EQ(u_ref, fieldValue(u, 0, n)); - EXPECT_FLOAT_EQ(v_ref, fieldValue(v, 0, n)); - if (num_space_dim == 3) - { - const auto w - = test_fixture.getTestFieldData(eval->_velocity[2]); - EXPECT_EQ(num_dofs, w.extent(1)); - EXPECT_FLOAT_EQ(w_ref, fieldValue(w, 0, n)); - } - if (build_temp_equ) - { - const auto temp - = test_fixture.getTestFieldData(eval->_temperature); - EXPECT_EQ(num_dofs, temp.extent(1)); - EXPECT_FLOAT_EQ(temp_ref, fieldValue(temp, 0, n)); - } - } -} - -//---------------------------------------------------------------------------// -TEST(IncompressibleLaminarFLowIsothermal2D, residual_test) -{ - testEval(false); -} - -//---------------------------------------------------------------------------// -TEST(IncompressibleLaminarFLowIsothermal2D, jacobian_test) -{ - testEval(false); -} - -//---------------------------------------------------------------------------// -TEST(IncompressibleLaminarFLowIsothermal3D, residual_test) -{ - testEval(false); -} - -//---------------------------------------------------------------------------// -TEST(IncompressibleLaminarFLowIsothermal3D, jacobian_test) -{ - testEval(false); -} - -//---------------------------------------------------------------------------// -TEST(IncompressibleLaminarFLow3D, residual_test) -{ - testEval(true); -} - -//---------------------------------------------------------------------------// -TEST(IncompressibleLaminarFLow3D, jacobian_test) -{ - testEval(true); -} - -//---------------------------------------------------------------------------// - -} // namespace Test -} // namespace VertexCFD diff --git a/src/incompressible_solver/initial_conditions/unit_test/tstIncompressibleTaylorGreenVortex.cpp b/src/incompressible_solver/initial_conditions/unit_test/tstIncompressibleTaylorGreenVortex.cpp deleted file mode 100644 index c1f9707..0000000 --- a/src/incompressible_solver/initial_conditions/unit_test/tstIncompressibleTaylorGreenVortex.cpp +++ /dev/null @@ -1,103 +0,0 @@ -#include - -#include "incompressible_solver/initial_conditions/VertexCFD_InitialCondition_IncompressibleTaylorGreenVortex.hpp" - -#include - -#include - -namespace VertexCFD -{ -namespace Test -{ -//---------------------------------------------------------------------------// -template -void testEval() -{ - const int num_space_dim = 2; - const int integration_order = 1; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - - // Set non-trivial coordinates for the degree of freedom - const int num_coord = test_fixture.cell_topo->getNodeCount(); - Kokkos::View x( - "coordinate", num_space_dim, num_coord); - auto basis_coord_view - = test_fixture.workset->bases[0]->basis_coordinates.get_static_view(); - auto basis_coord_mirror = Kokkos::create_mirror(basis_coord_view); - for (int dim = 0; dim < num_space_dim; dim++) - { - for (int basis = 0; basis < num_coord; basis++) - { - // random coordinate assigned - x(dim, basis) = 0.1 * (dim + 1) * (basis + 1) - 0.25; - basis_coord_mirror(0, basis, dim) = x(dim, basis); - } - } - - Kokkos::deep_copy(basis_coord_view, basis_coord_mirror); - - // Register and evaluate fields - const auto eval = Teuchos::rcp( - new InitialCondition:: - IncompressibleTaylorGreenVortex( - *test_fixture.basis_ir_layout->getBasis())); - test_fixture.registerEvaluator(eval); - test_fixture.registerTestField(eval->_lagrange_pressure); - for (int dim = 0; dim < num_space_dim; ++dim) - test_fixture.registerTestField(eval->_velocity[dim]); - - test_fixture.evaluate(); - - const auto phi - = test_fixture.getTestFieldData(eval->_lagrange_pressure); - const auto u = test_fixture.getTestFieldData(eval->_velocity[0]); - const auto v = test_fixture.getTestFieldData(eval->_velocity[1]); - - // Check number of degree of freedoms - const int num_dofs = 4; - EXPECT_EQ(num_dofs, phi.extent(1)); - EXPECT_EQ(num_dofs, u.extent(1)); - EXPECT_EQ(num_dofs, v.extent(1)); - - // Reference values - const double phi_ref[4] = {-0.487585163600908, - -0.487585163600908, - -0.4399615881406286, - -0.3522331526377958}; - const double u_ref[4] = {-0.04941795707411653, - 0.14925137372094469, - 0.34246927448499503, - 0.5168180147731708}; - const double v_ref[4] = {0.14925137372094469, - 0.04941795707411653, - -0.04694906782365546, - -0.12739967246452027}; - - // Check values - for (int n = 0; n < num_dofs; ++n) - { - EXPECT_DOUBLE_EQ(phi_ref[n], fieldValue(phi, 0, n)); - EXPECT_FLOAT_EQ(u_ref[n], fieldValue(u, 0, n)); - EXPECT_FLOAT_EQ(v_ref[n], fieldValue(v, 0, n)); - } -} - -//---------------------------------------------------------------------------// -TEST(IncompressibleTaylorGreenVortex2D, residual_test) -{ - testEval(); -} - -//---------------------------------------------------------------------------// -TEST(IncompressibleTaylorGreenVortex2D, jacobian_test) -{ - testEval(); -} - -//---------------------------------------------------------------------------// - -} // namespace Test -} // namespace VertexCFD diff --git a/src/incompressible_solver/initial_conditions/unit_test/tstIncompressibleVortexInBox.cpp b/src/incompressible_solver/initial_conditions/unit_test/tstIncompressibleVortexInBox.cpp deleted file mode 100644 index bf71c22..0000000 --- a/src/incompressible_solver/initial_conditions/unit_test/tstIncompressibleVortexInBox.cpp +++ /dev/null @@ -1,99 +0,0 @@ -#include - -#include "incompressible_solver/initial_conditions/VertexCFD_InitialCondition_IncompressibleVortexInBox.hpp" - -#include - -#include - -namespace VertexCFD -{ -namespace Test -{ -//---------------------------------------------------------------------------// -template -void testEval() -{ - const int num_space_dim = 2; - const int integration_order = 1; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - - // Set non-trivial coordinates for the degree of freedom - const int num_coord = test_fixture.cell_topo->getNodeCount(); - Kokkos::View x( - "coordinate", num_space_dim, num_coord); - auto basis_coord_view - = test_fixture.workset->bases[0]->basis_coordinates.get_static_view(); - auto basis_coord_mirror = Kokkos::create_mirror(basis_coord_view); - for (int dim = 0; dim < num_space_dim; dim++) - { - for (int basis = 0; basis < num_coord; basis++) - { - // random coordinate assigned - x(dim, basis) = 0.1 * (dim + 1) * (basis + 1) - 0.25; - basis_coord_mirror(0, basis, dim) = x(dim, basis); - } - } - - Kokkos::deep_copy(basis_coord_view, basis_coord_mirror); - - // Register and evaluate fields - auto eval = Teuchos::rcp( - new InitialCondition::IncompressibleVortexInBox( - *test_fixture.basis_ir_layout->getBasis())); - test_fixture.registerEvaluator(eval); - test_fixture.registerTestField(eval->_lagrange_pressure); - test_fixture.registerTestField(eval->_velocity_0); - test_fixture.registerTestField(eval->_velocity_1); - - test_fixture.evaluate(); - - const auto phi - = test_fixture.getTestFieldData(eval->_lagrange_pressure); - const auto u = test_fixture.getTestFieldData(eval->_velocity_0); - const auto v = test_fixture.getTestFieldData(eval->_velocity_1); - - // Check number of degree of freedoms - const int num_dofs = 4; - EXPECT_EQ(num_dofs, phi.extent(1)); - EXPECT_EQ(num_dofs, u.extent(1)); - EXPECT_EQ(num_dofs, v.extent(1)); - - // Reference values - const double phi_ref = 0.0; - const double u_ref[4] = {0.0636906811868036, - -0.019798055040567034, - -0.019798055040567034, - 0.06369068118680365}; - const double v_ref[4] = {-0.019798055040567034, - -0.0636906811868036, - 0.2453263131881438, - 0.7892189393343801}; - - // Check values - for (int n = 0; n < num_dofs; ++n) - { - EXPECT_DOUBLE_EQ(phi_ref, fieldValue(phi, 0, n)); - EXPECT_FLOAT_EQ(u_ref[n], fieldValue(u, 0, n)); - EXPECT_FLOAT_EQ(v_ref[n], fieldValue(v, 0, n)); - } -} - -//---------------------------------------------------------------------------// -TEST(IncompressibleVortexInBox, residual_test) -{ - testEval(); -} - -//---------------------------------------------------------------------------// -TEST(IncompressibleVortexInBox, jacobian_test) -{ - testEval(); -} - -//---------------------------------------------------------------------------// - -} // namespace Test -} // namespace VertexCFD diff --git a/src/induction_less_mhd_solver/boundary_conditions/VertexCFD_BoundaryState_ElectricPotentialFixed.cpp b/src/induction_less_mhd_solver/boundary_conditions/VertexCFD_BoundaryState_ElectricPotentialFixed.cpp deleted file mode 100644 index 566710e..0000000 --- a/src/induction_less_mhd_solver/boundary_conditions/VertexCFD_BoundaryState_ElectricPotentialFixed.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_BoundaryState_ElectricPotentialFixed.hpp" -#include "VertexCFD_BoundaryState_ElectricPotentialFixed_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS( - VertexCFD::BoundaryCondition::ElectricPotentialFixed) diff --git a/src/induction_less_mhd_solver/boundary_conditions/VertexCFD_BoundaryState_ElectricPotentialFixed.hpp b/src/induction_less_mhd_solver/boundary_conditions/VertexCFD_BoundaryState_ElectricPotentialFixed.hpp deleted file mode 100644 index 4cbd443..0000000 --- a/src/induction_less_mhd_solver/boundary_conditions/VertexCFD_BoundaryState_ElectricPotentialFixed.hpp +++ /dev/null @@ -1,59 +0,0 @@ -#ifndef VERTEXCFD_BOUNDARYSTATE_ELECTRICPOTENTIALFIXED_HPP -#define VERTEXCFD_BOUNDARYSTATE_ELECTRICPOTENTIALFIXED_HPP - -#include -#include - -#include -#include -#include -#include - -#include - -namespace VertexCFD -{ -namespace BoundaryCondition -{ -//---------------------------------------------------------------------------// -template -class ElectricPotentialFixed : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - - ElectricPotentialFixed(const panzer::IntegrationRule& ir, - const Teuchos::ParameterList& bc_params); - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - public: - PHX::MDField - _boundary_electric_potential; - - PHX::MDField - _boundary_grad_electric_potential; - - private: - int _num_grad_dim; - double _time; - double _time_init; - double _time_final; - double _a_sc; - double _b_sc; - - PHX::MDField - _grad_electric_potential; -}; - -//---------------------------------------------------------------------------// - -} // end namespace BoundaryCondition -} // end namespace VertexCFD - -#endif // VERTEXCFD_BOUNDARYSTATE_ELECTRICPOTENTIALFIXED_HPP diff --git a/src/induction_less_mhd_solver/boundary_conditions/VertexCFD_BoundaryState_ElectricPotentialInsulatingWall.cpp b/src/induction_less_mhd_solver/boundary_conditions/VertexCFD_BoundaryState_ElectricPotentialInsulatingWall.cpp deleted file mode 100644 index 1ad8618..0000000 --- a/src/induction_less_mhd_solver/boundary_conditions/VertexCFD_BoundaryState_ElectricPotentialInsulatingWall.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_BoundaryState_ElectricPotentialInsulatingWall.hpp" -#include "VertexCFD_BoundaryState_ElectricPotentialInsulatingWall_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS( - VertexCFD::BoundaryCondition::ElectricPotentialInsulatingWall) diff --git a/src/induction_less_mhd_solver/boundary_conditions/VertexCFD_BoundaryState_ElectricPotentialInsulatingWall.hpp b/src/induction_less_mhd_solver/boundary_conditions/VertexCFD_BoundaryState_ElectricPotentialInsulatingWall.hpp deleted file mode 100644 index b40e505..0000000 --- a/src/induction_less_mhd_solver/boundary_conditions/VertexCFD_BoundaryState_ElectricPotentialInsulatingWall.hpp +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef VERTEXCFD_BOUNDARYSTATE_ELECTRICPOTENTIALINSULATINGWALL_HPP -#define VERTEXCFD_BOUNDARYSTATE_ELECTRICPOTENTIALINSULATINGWALL_HPP - -#include -#include - -#include -#include -#include -#include - -#include - -namespace VertexCFD -{ -namespace BoundaryCondition -{ -//---------------------------------------------------------------------------// -template -class ElectricPotentialInsulatingWall - : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - - ElectricPotentialInsulatingWall(const panzer::IntegrationRule& ir); - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - public: - PHX::MDField - _boundary_electric_potential; - PHX::MDField - _boundary_grad_electric_potential; - - private: - PHX::MDField - _electric_potential; - PHX::MDField - _grad_electric_potential; - PHX::MDField - _normals; -}; - -//---------------------------------------------------------------------------// - -} // end namespace BoundaryCondition -} // end namespace VertexCFD - -#endif // VERTEXCFD_BOUNDARYSTATE_ELECTRICPOTENTIALINSULATINGWALL_HPP diff --git a/src/induction_less_mhd_solver/boundary_conditions/VertexCFD_ElectricPotentialBoundaryState_Factory.cpp b/src/induction_less_mhd_solver/boundary_conditions/VertexCFD_ElectricPotentialBoundaryState_Factory.cpp deleted file mode 100644 index dbbc7f0..0000000 --- a/src/induction_less_mhd_solver/boundary_conditions/VertexCFD_ElectricPotentialBoundaryState_Factory.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "induction_less_mhd_solver/boundary_conditions/VertexCFD_ElectricPotentialBoundaryState_Factory.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS_NUMSPACEDIM( - VertexCFD::BoundaryCondition::ElectricPotentialBoundaryStateFactory) diff --git a/src/induction_less_mhd_solver/boundary_conditions/VertexCFD_ElectricPotentialBoundaryState_Factory.hpp b/src/induction_less_mhd_solver/boundary_conditions/VertexCFD_ElectricPotentialBoundaryState_Factory.hpp deleted file mode 100644 index 4556812..0000000 --- a/src/induction_less_mhd_solver/boundary_conditions/VertexCFD_ElectricPotentialBoundaryState_Factory.hpp +++ /dev/null @@ -1,69 +0,0 @@ -#ifndef VERTEXCFD_ELECTRICPOTENTIALBOUNDARYSTATE_FACTORY_HPP -#define VERTEXCFD_ELECTRICPOTENTIALBOUNDARYSTATE_FACTORY_HPP - -#include "induction_less_mhd_solver/boundary_conditions/VertexCFD_BoundaryState_ElectricPotentialFixed.hpp" -#include "induction_less_mhd_solver/boundary_conditions/VertexCFD_BoundaryState_ElectricPotentialInsulatingWall.hpp" - -#include - -#include -#include - -namespace VertexCFD -{ -namespace BoundaryCondition -{ -//---------------------------------------------------------------------------// -template -class ElectricPotentialBoundaryStateFactory -{ - public: - static Teuchos::RCP> - create(const panzer::IntegrationRule& ir, - const Teuchos::ParameterList& bc_params, - const Teuchos::ParameterList& /*user_params*/) - { - // Loop over boundary conditions - Teuchos::RCP> state; - bool found_model = false; - - if (bc_params.isType("Type")) - { - if (bc_params.get("Type") == "Fixed") - { - state = Teuchos::rcp( - new ElectricPotentialFixed(ir, bc_params)); - found_model = true; - } - - if (bc_params.get("Type") == "InsulatingWall") - { - state = Teuchos::rcp( - new ElectricPotentialInsulatingWall(ir)); - found_model = true; - } - } - - if (!found_model) - { - std::string msg = "\n\nBoundary state " - + bc_params.get("Type") - + " failed to build.\n"; - msg += "The boundary conditions implemented in VertexCFD\n"; - msg += "for the electric potential equation are:\n"; - msg += "Fixed,\n"; - msg += "InsulatingWall,\n"; - msg += "\n"; - throw std::runtime_error(msg); - } - - return state; - } -}; - -//---------------------------------------------------------------------------// - -} // end namespace BoundaryCondition -} // end namespace VertexCFD - -#endif // end VERTEXCFD_ELECTRICPOTENTIALBOUNDARYSTATE_FACTORY_HPP diff --git a/src/induction_less_mhd_solver/boundary_conditions/unit_test/CMakeLists.txt b/src/induction_less_mhd_solver/boundary_conditions/unit_test/CMakeLists.txt deleted file mode 100644 index 34549a3..0000000 --- a/src/induction_less_mhd_solver/boundary_conditions/unit_test/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -set(TEST_HARNESS_DIR ${CMAKE_SOURCE_DIR}/src/test_harness) -include(${TEST_HARNESS_DIR}/TestHarness.cmake) - -VertexCFD_add_tests( - LIBS VertexCFD - NAMES - TimeTransientElectricPotentialFixed - ElectricPotentialInsulatingWall - ) diff --git a/src/induction_less_mhd_solver/boundary_conditions/unit_test/doc/insulating_wall_reference.py b/src/induction_less_mhd_solver/boundary_conditions/unit_test/doc/insulating_wall_reference.py deleted file mode 100644 index 79e34bd..0000000 --- a/src/induction_less_mhd_solver/boundary_conditions/unit_test/doc/insulating_wall_reference.py +++ /dev/null @@ -1,23 +0,0 @@ -import numpy as np - -# 2-D case -normals = np.array([3.0, 6.0]) -ep_grad = np.array([0.1, 0.2]) - -ep_dot_n = np.dot(normals, ep_grad) -print(ep_dot_n) - -print("\n2-D case:") -print("x-boundary value: ", ep_grad[0] - ep_dot_n * normals[0]) -print("y-boundary value: ", ep_grad[1] - ep_dot_n * normals[1]) - -# 3-D case -normals = np.array([3.0, 6.0, 9.0]) -ep_grad = np.array([0.1, 0.2, 0.3]) - -ep_dot_n = np.dot(normals, ep_grad) - -print("\n3-D case:") -print("x-boundary value: ", ep_grad[0] - ep_dot_n * normals[0]) -print("y-boundary value: ", ep_grad[1] - ep_dot_n * normals[1]) -print("z-boundary value: ", ep_grad[2] - ep_dot_n * normals[2]) diff --git a/src/induction_less_mhd_solver/boundary_conditions/unit_test/tstElectricPotentialInsulatingWall.cpp b/src/induction_less_mhd_solver/boundary_conditions/unit_test/tstElectricPotentialInsulatingWall.cpp deleted file mode 100644 index f57bb63..0000000 --- a/src/induction_less_mhd_solver/boundary_conditions/unit_test/tstElectricPotentialInsulatingWall.cpp +++ /dev/null @@ -1,149 +0,0 @@ -#include "induction_less_mhd_solver/boundary_conditions/VertexCFD_BoundaryState_ElectricPotentialInsulatingWall.hpp" -#include - -#include -#include -#include - -//---------------------------------------------------------------------------// -// TESTS -//---------------------------------------------------------------------------// -namespace VertexCFD -{ -namespace Test - -{ -//---------------------------------------------------------------------------// -// Test data dependencies. -template -struct Dependencies : public PHX::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - using scalar_type = typename EvalType::ScalarT; - - PHX::MDField _electric_potential; - PHX::MDField - _grad_electric_potential; - PHX::MDField _normals; - - Dependencies(const panzer::IntegrationRule& ir) - : _electric_potential("electric_potential", ir.dl_scalar) - , _grad_electric_potential("GRAD_electric_potential", ir.dl_vector) - , _normals("Side Normal", ir.dl_vector) - { - this->addEvaluatedField(_electric_potential); - this->addEvaluatedField(_grad_electric_potential); - this->addEvaluatedField(_normals); - this->setName( - "Electric Potential Insulating Wall Unit Test Dependencies"); - } - - void evaluateFields(typename panzer::Traits::EvalData d) override - { - _electric_potential.deep_copy(2.0); - - Kokkos::parallel_for( - "electric potential insulating wall test dependencies", - Kokkos::RangePolicy(0, d.num_cells), - *this); - } - - KOKKOS_INLINE_FUNCTION void operator()(const int c) const - { - const int num_point = _grad_electric_potential.extent(1); - const int num_grad_dim = _grad_electric_potential.extent(2); - for (int qp = 0; qp < num_point; ++qp) - { - for (int d = 0; d < num_grad_dim; ++d) - { - const int dqp = (qp + 1) * (d + 1); - _grad_electric_potential(c, qp, d) = dqp * 3.0; - _normals(c, qp, d) = dqp * 0.1; - } - } - } -}; - -//---------------------------------------------------------------------------// -template -void testEval(const int num_grad_dim) -{ - // Test fixture - const int integration_order = 1; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_grad_dim, integration_order, basis_order); - - // Create dependencies - const auto dep_eval - = Teuchos::rcp(new Dependencies(*test_fixture.ir)); - test_fixture.registerEvaluator(dep_eval); - - // Create evaluator. - const auto fixed_eval = Teuchos::rcp( - new BoundaryCondition::ElectricPotentialInsulatingWall( - *test_fixture.ir)); - test_fixture.registerEvaluator(fixed_eval); - - // Add required test fields. - test_fixture.registerTestField( - fixed_eval->_boundary_electric_potential); - test_fixture.registerTestField( - fixed_eval->_boundary_grad_electric_potential); - - // Evaluate variables. - test_fixture.evaluate(); - - // Check values. - const auto boundary_ep_result = test_fixture.getTestFieldData( - fixed_eval->_boundary_electric_potential); - const auto boundary_grad_ep_result - = test_fixture.getTestFieldData( - fixed_eval->_boundary_grad_electric_potential); - - const int num_point = boundary_ep_result.extent(1); - const double ep_dot_n = num_grad_dim == 2 ? 1.5 : 4.2; - - for (int qp = 0; qp < num_point; ++qp) - { - EXPECT_DOUBLE_EQ(2.0, fieldValue(boundary_ep_result, 0, qp)); - - for (int d = 0; d < num_grad_dim; ++d) - { - const int dqp = (qp + 1) * (d + 1); - EXPECT_DOUBLE_EQ(dqp * 3.0 - ep_dot_n * dqp * 0.1, - fieldValue(boundary_grad_ep_result, 0, qp, d)); - } - } -} - -//---------------------------------------------------------------------------// -// 2-D residual -TEST(InsulatingWall2D, residual) -{ - testEval(2); -} - -// 2-D jacobian -TEST(InsulatingWall2D, jacobian) -{ - testEval(2); -} - -//---------------------------------------------------------------------------// -// 3-D residual -TEST(InsulatingWall3D, residual) -{ - testEval(3); -} - -// 3-D jacobian -TEST(InsulatingWall3D, jacobian) -{ - testEval(3); -} - -//---------------------------------------------------------------------------// -} // end namespace Test -} // end namespace VertexCFD diff --git a/src/induction_less_mhd_solver/boundary_conditions/unit_test/tstTimeTransientElectricPotentialFixed.cpp b/src/induction_less_mhd_solver/boundary_conditions/unit_test/tstTimeTransientElectricPotentialFixed.cpp deleted file mode 100644 index 7eff867..0000000 --- a/src/induction_less_mhd_solver/boundary_conditions/unit_test/tstTimeTransientElectricPotentialFixed.cpp +++ /dev/null @@ -1,276 +0,0 @@ -#include "induction_less_mhd_solver/boundary_conditions/VertexCFD_BoundaryState_ElectricPotentialFixed.hpp" -#include - -#include -#include -#include - -#include - -#include - -//---------------------------------------------------------------------------// -// TESTS -//---------------------------------------------------------------------------// -namespace VertexCFD -{ -namespace Test - -{ -//---------------------------------------------------------------------------// -// Input type -enum class InputType -{ - steady, - pastFinalTime, - transient, - preInitialTime -}; - -//---------------------------------------------------------------------------// -// Test data dependencies. -template -struct Dependencies : public PHX::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - using scalar_type = typename EvalType::ScalarT; - - PHX::MDField _electric_potential; - PHX::MDField - _grad_electric_potential; - - Dependencies(const panzer::IntegrationRule& ir) - : _electric_potential("electric_potential", ir.dl_scalar) - , _grad_electric_potential("GRAD_electric_potential", ir.dl_vector) - { - this->addEvaluatedField(_electric_potential); - this->addEvaluatedField(_grad_electric_potential); - this->setName( - "Time Transient Electric Potential Fixed Unit Test Dependencies"); - } - - void evaluateFields(typename panzer::Traits::EvalData d) override - { - _electric_potential.deep_copy(2.0); - - Kokkos::parallel_for( - "time transient electric potential fixed test dependencies", - Kokkos::RangePolicy(0, d.num_cells), - *this); - } - - KOKKOS_INLINE_FUNCTION void operator()(const int c) const - { - const int num_point = _grad_electric_potential.extent(1); - const int num_grad_dim = _grad_electric_potential.extent(2); - for (int qp = 0; qp < num_point; ++qp) - { - for (int d = 0; d < num_grad_dim; ++d) - { - const int dqp = (qp + 1) * (d + num_point + 1); - _grad_electric_potential(c, qp, d) = dqp * 3.0; - } - } - } -}; - -//---------------------------------------------------------------------------// -template -void testEval(const int num_grad_dim, const InputType input_type) -{ - // Test fixture - const int integration_order = 2; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_grad_dim, integration_order, basis_order); - - // Create dependencies - const auto dep_eval - = Teuchos::rcp(new Dependencies(*test_fixture.ir)); - test_fixture.registerEvaluator(dep_eval); - - // Create the param list to initialize the evaluator - Teuchos::ParameterList bc_params; - double time = 0.0; - double exp_value = 0.0; - switch (input_type) - { - case (InputType::steady): - exp_value = 2.0; - bc_params.set("Final Value", exp_value); - break; - case (InputType::pastFinalTime): - exp_value = 2.0; - bc_params.set("Final Value", exp_value); - bc_params.set("Initial Value", 0.5); - time = 1.5; - bc_params.set("Time Final", 1.0); - bc_params.set("Time Initial", 0.1); - break; - case (InputType::transient): - exp_value = 3.5; - bc_params.set("Final Value", 3.0); - bc_params.set("Initial Value", 4.0); - time = 1.5; - bc_params.set("Time Final", 2.0); - bc_params.set("Time Initial", 1.0); - break; - case (InputType::preInitialTime): - exp_value = 3.0; - bc_params.set("Final Value", 4.0); - bc_params.set("Initial Value", exp_value); - time = 0.5; - bc_params.set("Time Final", 2.0); - bc_params.set("Time Initial", 1.0); - break; - } - - // Create fixed evaluator. - auto fixed_eval = Teuchos::rcp( - new BoundaryCondition::ElectricPotentialFixed( - *test_fixture.ir, bc_params)); - test_fixture.registerEvaluator(fixed_eval); - - // Add required test fields. - test_fixture.registerTestField( - fixed_eval->_boundary_electric_potential); - test_fixture.registerTestField( - fixed_eval->_boundary_grad_electric_potential); - - // Set time - test_fixture.setTime(time); - - // Evaluate time transient fixed BC. - test_fixture.evaluate(); - - // Check the time transient fixed BC. - const auto boundary_ep_result = test_fixture.getTestFieldData( - fixed_eval->_boundary_electric_potential); - const auto boundary_grad_ep_result - = test_fixture.getTestFieldData( - fixed_eval->_boundary_grad_electric_potential); - - const int num_point = boundary_ep_result.extent(1); - - for (int qp = 0; qp < num_point; ++qp) - { - EXPECT_DOUBLE_EQ(exp_value, fieldValue(boundary_ep_result, 0, qp)); - - for (int d = 0; d < num_grad_dim; ++d) - { - const int dqp = (qp + 1) * (d + num_point + 1); - EXPECT_DOUBLE_EQ(dqp * 3.0, - fieldValue(boundary_grad_ep_result, 0, qp, d)); - } - } -} - -//---------------------------------------------------------------------------// -// 2-D: time transient fixed - steady -template -void testTimeTransientElectricPotentialFixedSteady2D() -{ - testEval(2, InputType::steady); -} - -// 2-D time transient fixed residual -TEST(TimeTransientElectricPotentialFixedSteady2D, residual) -{ - testTimeTransientElectricPotentialFixedSteady2D(); -} - -// 2-D time transient fixed jacobian -TEST(TimeTransientElectricPotentialFixedSteady2D, jacobian) -{ - testTimeTransientElectricPotentialFixedSteady2D(); -} - -//---------------------------------------------------------------------------// -// 2-D time transient fixed - time > time_final -template -void testTimeTransientElectricPotentialFixedTimeFinal2D() -{ - testEval(2, InputType::pastFinalTime); -} - -// 2-D time transient fixed residual -TEST(TimeTransientElectricPotentialFixedTimeFinal2D, residual) -{ - testTimeTransientElectricPotentialFixedTimeFinal2D(); -} - -// 2-D time transient fixed jacobian -TEST(TimeTransientElectricPotentialFixedTimeFinal2D, jacobian) -{ - testTimeTransientElectricPotentialFixedTimeFinal2D(); -} - -//---------------------------------------------------------------------------// -// 2-D time transient fixed - time < time_init -template -void testTimeTransientElectricPotentialFixedTimeInit2D() -{ - testEval(2, InputType::preInitialTime); -} - -// 2-D time transient fixed residual -TEST(TimeTransientElectricPotentialFixedTimeInit2D, residual) -{ - testTimeTransientElectricPotentialFixedTimeInit2D(); -} - -// 2-D time transient fixed jacobian -TEST(TimeTransientElectricPotentialFixedTimeInit2D, jacobian) -{ - testTimeTransientElectricPotentialFixedTimeInit2D(); -} - -//---------------------------------------------------------------------------// -// 2-D time transient fixed - time_init < time < time_final. The expected -// values should be the average value between the final and the initial values. -template -void testTimeTransientElectricPotentialFixedTimeIntermediate2D() -{ - testEval(2, InputType::transient); -} - -// 2-D time transient fixed residual -TEST(TimeTransientElectricPotentialFixedTimeIntermediate2D, residual) -{ - testTimeTransientElectricPotentialFixedTimeIntermediate2D< - panzer::Traits::Residual>(); -} - -// 2-D time transient fixed jacobian -TEST(TimeTransientElectricPotentialFixedTimeIntermediate2D, jacobian) -{ - testTimeTransientElectricPotentialFixedTimeIntermediate2D< - panzer::Traits::Jacobian>(); -} - -//---------------------------------------------------------------------------// -// 3-D time transient fixed - time_init < time < time_final. The expected -// values should be the average value between the final and the initial values -template -void testTimeTransientElectricPotentialFixedTimeIntermediate3D() -{ - testEval(3, InputType::transient); -} - -// 3-D time transient fixed residual -TEST(TimeTransientElectricPotentialFixedTimeIntermediate3D, residual) -{ - testTimeTransientElectricPotentialFixedTimeIntermediate3D< - panzer::Traits::Residual>(); -} - -// 3-D time transient fixed jacobian -TEST(TimeTransientElectricPotentialFixedTimeIntermediate3D, jacobian) -{ - testTimeTransientElectricPotentialFixedTimeIntermediate2D< - panzer::Traits::Jacobian>(); -} - -//---------------------------------------------------------------------------// -} // end namespace Test -} // end namespace VertexCFD diff --git a/src/induction_less_mhd_solver/closure_models/VertexCFD_Closure_ElectricCurrentDensity.cpp b/src/induction_less_mhd_solver/closure_models/VertexCFD_Closure_ElectricCurrentDensity.cpp deleted file mode 100644 index ca0e730..0000000 --- a/src/induction_less_mhd_solver/closure_models/VertexCFD_Closure_ElectricCurrentDensity.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_Closure_ElectricCurrentDensity.hpp" -#include "VertexCFD_Closure_ElectricCurrentDensity_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS_NUMSPACEDIM( - VertexCFD::ClosureModel::ElectricCurrentDensity) diff --git a/src/induction_less_mhd_solver/closure_models/VertexCFD_Closure_ElectricCurrentDensity.hpp b/src/induction_less_mhd_solver/closure_models/VertexCFD_Closure_ElectricCurrentDensity.hpp deleted file mode 100644 index 987c831..0000000 --- a/src/induction_less_mhd_solver/closure_models/VertexCFD_Closure_ElectricCurrentDensity.hpp +++ /dev/null @@ -1,66 +0,0 @@ -#ifndef VERTEXCFD_CLOSURE_ELECTRICCURRENTDENSITY_HPP -#define VERTEXCFD_CLOSURE_ELECTRICCURRENTDENSITY_HPP - -#include "incompressible_solver/fluid_properties/VertexCFD_ConstantFluidProperties.hpp" - -#include -#include - -#include -#include -#include -#include - -#include - -#include - -namespace VertexCFD -{ -namespace ClosureModel -{ -//---------------------------------------------------------------------------// -// Electric current density -//---------------------------------------------------------------------------// -template -class ElectricCurrentDensity : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - static constexpr int num_space_dim = NumSpaceDim; - static constexpr int field_size = 3; - - ElectricCurrentDensity( - const panzer::IntegrationRule& ir, - const FluidProperties::ConstantFluidProperties& fluid_prop); - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - Kokkos::Array, - num_space_dim> - _electric_current_density; - - private: - PHX::MDField - _grad_electric_potential; - Kokkos::Array, - num_space_dim> - _velocity; - Kokkos::Array, - field_size> - _ext_magn_field; - - double _sigma; -}; - -//---------------------------------------------------------------------------// - -} // end namespace ClosureModel -} // end namespace VertexCFD - -#endif // end VERTEXCFD_CLOSURE_ELECTRICCURRENTDENSITY_HPP diff --git a/src/induction_less_mhd_solver/closure_models/VertexCFD_Closure_ElectricPotentialCrossProductFlux.cpp b/src/induction_less_mhd_solver/closure_models/VertexCFD_Closure_ElectricPotentialCrossProductFlux.cpp deleted file mode 100644 index 3e4b739..0000000 --- a/src/induction_less_mhd_solver/closure_models/VertexCFD_Closure_ElectricPotentialCrossProductFlux.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_Closure_ElectricPotentialCrossProductFlux.hpp" -#include "VertexCFD_Closure_ElectricPotentialCrossProductFlux_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS_NUMSPACEDIM( - VertexCFD::ClosureModel::ElectricPotentialCrossProductFlux) diff --git a/src/induction_less_mhd_solver/closure_models/VertexCFD_Closure_ElectricPotentialCrossProductFlux.hpp b/src/induction_less_mhd_solver/closure_models/VertexCFD_Closure_ElectricPotentialCrossProductFlux.hpp deleted file mode 100644 index 8c9eaa6..0000000 --- a/src/induction_less_mhd_solver/closure_models/VertexCFD_Closure_ElectricPotentialCrossProductFlux.hpp +++ /dev/null @@ -1,69 +0,0 @@ -#ifndef VERTEXCFD_CLOSURE_ELECTRICPOTENTIALCROSSPRODUCTFLUX_HPP -#define VERTEXCFD_CLOSURE_ELECTRICPOTENTIALCROSSPRODUCTFLUX_HPP - -#include "incompressible_solver/fluid_properties/VertexCFD_ConstantFluidProperties.hpp" - -#include -#include - -#include -#include -#include -#include - -#include - -#include - -namespace VertexCFD -{ -namespace ClosureModel -{ -//---------------------------------------------------------------------------// -// Multi-dimension cross product flux evaluation for electric potential -// equation. -//---------------------------------------------------------------------------// -template -class ElectricPotentialCrossProductFlux - : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - static constexpr int num_space_dim = NumSpaceDim; - static constexpr int field_size = 3; - - ElectricPotentialCrossProductFlux( - const panzer::IntegrationRule& ir, - const FluidProperties::ConstantFluidProperties& fluid_prop, - const std::string& flux_prefix = "", - const std::string& field_prefix = ""); - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - PHX::MDField - _electric_potential_flux; - - private: - PHX::MDField - _grad_electric_potential; - Kokkos::Array, - num_space_dim> - _velocity; - Kokkos::Array, - field_size> - _ext_magn_field; - - double _sigma; -}; - -//---------------------------------------------------------------------------// - -} // end namespace ClosureModel -} // end namespace VertexCFD - -#endif // end VERTEXCFD_CLOSURE_ELECTRICPOTENTIALCROSSPRODUCTFLUX_HPP diff --git a/src/induction_less_mhd_solver/closure_models/VertexCFD_Closure_ElectricPotentialDiffusionFlux.cpp b/src/induction_less_mhd_solver/closure_models/VertexCFD_Closure_ElectricPotentialDiffusionFlux.cpp deleted file mode 100644 index 93e62a0..0000000 --- a/src/induction_less_mhd_solver/closure_models/VertexCFD_Closure_ElectricPotentialDiffusionFlux.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_Closure_ElectricPotentialDiffusionFlux.hpp" -#include "VertexCFD_Closure_ElectricPotentialDiffusionFlux_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS( - VertexCFD::ClosureModel::ElectricPotentialDiffusionFlux) diff --git a/src/induction_less_mhd_solver/closure_models/VertexCFD_Closure_ElectricPotentialDiffusionFlux.hpp b/src/induction_less_mhd_solver/closure_models/VertexCFD_Closure_ElectricPotentialDiffusionFlux.hpp deleted file mode 100644 index 47ceacf..0000000 --- a/src/induction_less_mhd_solver/closure_models/VertexCFD_Closure_ElectricPotentialDiffusionFlux.hpp +++ /dev/null @@ -1,61 +0,0 @@ -#ifndef VERTEXCFD_CLOSURE_ELECTRICPOTENTIALDIFFUSIONFLUX_HPP -#define VERTEXCFD_CLOSURE_ELECTRICPOTENTIALDIFFUSIONFLUX_HPP - -#include "incompressible_solver/fluid_properties/VertexCFD_ConstantFluidProperties.hpp" - -#include -#include - -#include -#include -#include -#include - -#include - -#include - -namespace VertexCFD -{ -namespace ClosureModel -{ -//---------------------------------------------------------------------------// -// Multi-dimension diffusion flux evaluation for electric potential equation. -//---------------------------------------------------------------------------// -template -class ElectricPotentialDiffusionFlux - : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - - ElectricPotentialDiffusionFlux( - const panzer::IntegrationRule& ir, - const FluidProperties::ConstantFluidProperties& fluid_prop, - const std::string& flux_prefix = "", - const std::string& gradient_prefix = ""); - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - PHX::MDField - _electric_potential_flux; - - private: - PHX::MDField - _grad_electric_potential; - - double _sigma; - int _num_grad_dim; -}; - -//---------------------------------------------------------------------------// - -} // end namespace ClosureModel -} // end namespace VertexCFD - -#endif // end VERTEXCFD_CLOSURE_ELECTRICPOTENTIALDIFFUSIONFLUX_HPP diff --git a/src/induction_less_mhd_solver/closure_models/VertexCFD_Closure_HartmannProblemExact.cpp b/src/induction_less_mhd_solver/closure_models/VertexCFD_Closure_HartmannProblemExact.cpp deleted file mode 100644 index 446ac82..0000000 --- a/src/induction_less_mhd_solver/closure_models/VertexCFD_Closure_HartmannProblemExact.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_Closure_HartmannProblemExact.hpp" -#include "VertexCFD_Closure_HartmannProblemExact_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS_NUMSPACEDIM( - VertexCFD::ClosureModel::HartmannProblemExact) diff --git a/src/induction_less_mhd_solver/closure_models/VertexCFD_Closure_HartmannProblemExact.hpp b/src/induction_less_mhd_solver/closure_models/VertexCFD_Closure_HartmannProblemExact.hpp deleted file mode 100644 index b87bca7..0000000 --- a/src/induction_less_mhd_solver/closure_models/VertexCFD_Closure_HartmannProblemExact.hpp +++ /dev/null @@ -1,71 +0,0 @@ -#ifndef VERTEXCFD_CLOSURE_HARTMANNPROBLEMEXACT_HPP -#define VERTEXCFD_CLOSURE_HARTMANNPROBLEMEXACT_HPP - -#include "incompressible_solver/fluid_properties/VertexCFD_ConstantFluidProperties.hpp" - -#include -#include - -#include -#include -#include -#include - -#include - -#include - -namespace VertexCFD -{ -namespace ClosureModel -{ -//---------------------------------------------------------------------------// -// Hartmann Problem Exact Solution -//---------------------------------------------------------------------------// -template -class HartmannProblemExact : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - static constexpr int num_space_dim = NumSpaceDim; - - HartmannProblemExact( - const panzer::IntegrationRule& ir, - const FluidProperties::ConstantFluidProperties& fluid_prop, - const Teuchos::ParameterList& user_params); - - void postRegistrationSetup(typename Traits::SetupData sd, - PHX::FieldManager& fm) override; - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - PHX::MDField _exact_lagrange_pressure; - Kokkos::Array, - num_space_dim> - _exact_velocity; - PHX::MDField _exact_elec_pot; - - private: - double _sigma; - double _rho; - double _nu; - double _L; - double _B; - double _M; - int _ir_degree; - int _ir_index; - - PHX::MDField _ip_coords; -}; - -//---------------------------------------------------------------------------// - -} // end namespace ClosureModel -} // end namespace VertexCFD - -#endif // end VERTEXCFD_CLOSURE_HARTMANNPROBLEMEXACT_HPP diff --git a/src/induction_less_mhd_solver/closure_models/VertexCFD_Closure_LorentzForce.cpp b/src/induction_less_mhd_solver/closure_models/VertexCFD_Closure_LorentzForce.cpp deleted file mode 100644 index c71bd20..0000000 --- a/src/induction_less_mhd_solver/closure_models/VertexCFD_Closure_LorentzForce.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_Closure_LorentzForce.hpp" -#include "VertexCFD_Closure_LorentzForce_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS_NUMSPACEDIM( - VertexCFD::ClosureModel::LorentzForce) diff --git a/src/induction_less_mhd_solver/closure_models/VertexCFD_Closure_LorentzForce.hpp b/src/induction_less_mhd_solver/closure_models/VertexCFD_Closure_LorentzForce.hpp deleted file mode 100644 index 6fb63e9..0000000 --- a/src/induction_less_mhd_solver/closure_models/VertexCFD_Closure_LorentzForce.hpp +++ /dev/null @@ -1,67 +0,0 @@ -#ifndef VERTEXCFD_CLOSURE_LORENTZFORCE_HPP -#define VERTEXCFD_CLOSURE_LORENTZFORCE_HPP - -#include "incompressible_solver/fluid_properties/VertexCFD_ConstantFluidProperties.hpp" - -#include -#include - -#include -#include -#include -#include - -#include - -#include - -namespace VertexCFD -{ -namespace ClosureModel -{ -//---------------------------------------------------------------------------// -// Lorentz force -//---------------------------------------------------------------------------// -template -class LorentzForce : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - static constexpr int num_space_dim = NumSpaceDim; - static constexpr int field_size = 3; - - LorentzForce(const panzer::IntegrationRule& ir, - const FluidProperties::ConstantFluidProperties& fluid_prop); - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - Kokkos::Array, - num_space_dim> - _lorentz_force; - - private: - double _sigma; - PHX::MDField - _grad_electric_potential; - Kokkos::Array, - num_space_dim> - _electric_current_density; - Kokkos::Array, - num_space_dim> - _velocity; - Kokkos::Array, - field_size> - _ext_magn_field; -}; - -//---------------------------------------------------------------------------// - -} // end namespace ClosureModel -} // end namespace VertexCFD - -#endif // end VERTEXCFD_CLOSURE_LORENTZFORCE_HPP diff --git a/src/induction_less_mhd_solver/closure_models/VertexCFD_InductionlessClosureModelFactory.hpp b/src/induction_less_mhd_solver/closure_models/VertexCFD_InductionlessClosureModelFactory.hpp deleted file mode 100644 index 17b232c..0000000 --- a/src/induction_less_mhd_solver/closure_models/VertexCFD_InductionlessClosureModelFactory.hpp +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef VERTEXCFD_INDUCTIONLESSCLOSUREMODELFACTORY_HPP -#define VERTEXCFD_INDUCTIONLESSCLOSUREMODELFACTORY_HPP - -#include - -#include - -#include -#include - -namespace VertexCFD -{ -namespace ClosureModel -{ -//---------------------------------------------------------------------------// -template -class InductionlessFactory -{ - public: - void buildClosureModel( - const std::string& closure_type, - const Teuchos::RCP& ir, - const Teuchos::ParameterList& user_params, - const Teuchos::ParameterList& closure_params, - bool& found_model, - std::string& error_msg, - Teuchos::RCP>>> - evaluators); -}; - -//---------------------------------------------------------------------------// - -} // end namespace ClosureModel -} // end namespace VertexCFD - -#endif // end VERTEXCFD_INDUCTIONLESSCLOSUREMODELFACTORY_HPP diff --git a/src/induction_less_mhd_solver/closure_models/VertexCFD_InductionlessClosureModelFactory_Hessian2d.cpp b/src/induction_less_mhd_solver/closure_models/VertexCFD_InductionlessClosureModelFactory_Hessian2d.cpp deleted file mode 100644 index 243cd35..0000000 --- a/src/induction_less_mhd_solver/closure_models/VertexCFD_InductionlessClosureModelFactory_Hessian2d.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include "VertexCFD_InductionlessClosureModelFactory.hpp" -#include "VertexCFD_InductionlessClosureModelFactory_impl.hpp" - -template class VertexCFD::ClosureModel:: - InductionlessFactory; diff --git a/src/induction_less_mhd_solver/closure_models/VertexCFD_InductionlessClosureModelFactory_Hessian3d.cpp b/src/induction_less_mhd_solver/closure_models/VertexCFD_InductionlessClosureModelFactory_Hessian3d.cpp deleted file mode 100644 index 5dcd2f0..0000000 --- a/src/induction_less_mhd_solver/closure_models/VertexCFD_InductionlessClosureModelFactory_Hessian3d.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include "VertexCFD_InductionlessClosureModelFactory.hpp" -#include "VertexCFD_InductionlessClosureModelFactory_impl.hpp" - -template class VertexCFD::ClosureModel:: - InductionlessFactory; diff --git a/src/induction_less_mhd_solver/closure_models/VertexCFD_InductionlessClosureModelFactory_Jacobian2d.cpp b/src/induction_less_mhd_solver/closure_models/VertexCFD_InductionlessClosureModelFactory_Jacobian2d.cpp deleted file mode 100644 index 223675b..0000000 --- a/src/induction_less_mhd_solver/closure_models/VertexCFD_InductionlessClosureModelFactory_Jacobian2d.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include "VertexCFD_InductionlessClosureModelFactory.hpp" -#include "VertexCFD_InductionlessClosureModelFactory_impl.hpp" - -template class VertexCFD::ClosureModel:: - InductionlessFactory; diff --git a/src/induction_less_mhd_solver/closure_models/VertexCFD_InductionlessClosureModelFactory_Jacobian3d.cpp b/src/induction_less_mhd_solver/closure_models/VertexCFD_InductionlessClosureModelFactory_Jacobian3d.cpp deleted file mode 100644 index a692221..0000000 --- a/src/induction_less_mhd_solver/closure_models/VertexCFD_InductionlessClosureModelFactory_Jacobian3d.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include "VertexCFD_InductionlessClosureModelFactory.hpp" -#include "VertexCFD_InductionlessClosureModelFactory_impl.hpp" - -template class VertexCFD::ClosureModel:: - InductionlessFactory; diff --git a/src/induction_less_mhd_solver/closure_models/VertexCFD_InductionlessClosureModelFactory_Residual2d.cpp b/src/induction_less_mhd_solver/closure_models/VertexCFD_InductionlessClosureModelFactory_Residual2d.cpp deleted file mode 100644 index 1129d98..0000000 --- a/src/induction_less_mhd_solver/closure_models/VertexCFD_InductionlessClosureModelFactory_Residual2d.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include "VertexCFD_InductionlessClosureModelFactory.hpp" -#include "VertexCFD_InductionlessClosureModelFactory_impl.hpp" - -template class VertexCFD::ClosureModel:: - InductionlessFactory; diff --git a/src/induction_less_mhd_solver/closure_models/VertexCFD_InductionlessClosureModelFactory_Residual3d.cpp b/src/induction_less_mhd_solver/closure_models/VertexCFD_InductionlessClosureModelFactory_Residual3d.cpp deleted file mode 100644 index 6c2ac12..0000000 --- a/src/induction_less_mhd_solver/closure_models/VertexCFD_InductionlessClosureModelFactory_Residual3d.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include "VertexCFD_InductionlessClosureModelFactory.hpp" -#include "VertexCFD_InductionlessClosureModelFactory_impl.hpp" - -template class VertexCFD::ClosureModel:: - InductionlessFactory; diff --git a/src/induction_less_mhd_solver/closure_models/VertexCFD_InductionlessClosureModelFactory_Tangent2d.cpp b/src/induction_less_mhd_solver/closure_models/VertexCFD_InductionlessClosureModelFactory_Tangent2d.cpp deleted file mode 100644 index 088d5ee..0000000 --- a/src/induction_less_mhd_solver/closure_models/VertexCFD_InductionlessClosureModelFactory_Tangent2d.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include "VertexCFD_InductionlessClosureModelFactory.hpp" -#include "VertexCFD_InductionlessClosureModelFactory_impl.hpp" - -template class VertexCFD::ClosureModel:: - InductionlessFactory; diff --git a/src/induction_less_mhd_solver/closure_models/VertexCFD_InductionlessClosureModelFactory_Tangent3d.cpp b/src/induction_less_mhd_solver/closure_models/VertexCFD_InductionlessClosureModelFactory_Tangent3d.cpp deleted file mode 100644 index 9f3bc2c..0000000 --- a/src/induction_less_mhd_solver/closure_models/VertexCFD_InductionlessClosureModelFactory_Tangent3d.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include "VertexCFD_InductionlessClosureModelFactory.hpp" -#include "VertexCFD_InductionlessClosureModelFactory_impl.hpp" - -template class VertexCFD::ClosureModel:: - InductionlessFactory; diff --git a/src/induction_less_mhd_solver/closure_models/VertexCFD_InductionlessClosureModelFactory_impl.hpp b/src/induction_less_mhd_solver/closure_models/VertexCFD_InductionlessClosureModelFactory_impl.hpp deleted file mode 100644 index 132a6e7..0000000 --- a/src/induction_less_mhd_solver/closure_models/VertexCFD_InductionlessClosureModelFactory_impl.hpp +++ /dev/null @@ -1,117 +0,0 @@ -#ifndef VERTEXCFD_INDUCTIONLESSCLOSUREMODELFACTORY_IMPL_HPP -#define VERTEXCFD_INDUCTIONLESSCLOSUREMODELFACTORY_IMPL_HPP - -#include "incompressible_solver/fluid_properties/VertexCFD_ConstantFluidProperties.hpp" -#include "induction_less_mhd_solver/closure_models/VertexCFD_Closure_ElectricCurrentDensity.hpp" -#include "induction_less_mhd_solver/closure_models/VertexCFD_Closure_ElectricPotentialCrossProductFlux.hpp" -#include "induction_less_mhd_solver/closure_models/VertexCFD_Closure_ElectricPotentialDiffusionFlux.hpp" -#include "induction_less_mhd_solver/closure_models/VertexCFD_Closure_HartmannProblemExact.hpp" -#include "induction_less_mhd_solver/closure_models/VertexCFD_Closure_LorentzForce.hpp" -#include "induction_less_mhd_solver/closure_models/VertexCFD_InductionlessClosureModelFactory.hpp" - -namespace VertexCFD -{ -namespace ClosureModel -{ -//---------------------------------------------------------------------------// -template -void InductionlessFactory::buildClosureModel( - const std::string& closure_type, - const Teuchos::RCP& ir, - const Teuchos::ParameterList& user_params, - const Teuchos::ParameterList& /**closure_params**/, - bool& found_model, - std::string& error_msg, - Teuchos::RCP>>> - evaluators) -{ - // Define local variables - constexpr int num_space_dim = NumSpaceDim; - Teuchos::RCP> eval; - - // Fluid properties - Teuchos::ParameterList fluid_prop_list - = user_params.sublist("Fluid Properties"); - const bool build_temp_equ - = user_params.isType("Build Temperature Equation") - ? user_params.get("Build Temperature Equation") - : false; - const bool build_buoyancy_source - = user_params.isType("Build Buoyancy Source") - ? user_params.get("Build Buoyancy Source") - : false; - bool build_ind_less_equ - = user_params.isType("Build Inductionless MHD Equation") - ? user_params.get("Build Inductionless MHD Equation") - : false; - fluid_prop_list.set("Build Inductionless MHD Equation", - build_ind_less_equ); - fluid_prop_list.set("Build Temperature Equation", build_temp_equ); - fluid_prop_list.set("Build Buoyancy Source", build_buoyancy_source); - FluidProperties::ConstantFluidProperties incompressible_fluidprop_params - = FluidProperties::ConstantFluidProperties(fluid_prop_list); - - // Closure models - if (closure_type == "ElectricCurrentDensity") - { - auto eval = Teuchos::rcp( - new ElectricCurrentDensity( - *ir, incompressible_fluidprop_params)); - evaluators->push_back(eval); - found_model = true; - } - - if (closure_type == "ElectricPotentialCrossProductFlux") - { - auto eval = Teuchos::rcp( - new ElectricPotentialCrossProductFlux( - *ir, incompressible_fluidprop_params)); - evaluators->push_back(eval); - found_model = true; - } - - if (closure_type == "ElectricPotentialDiffusionFlux") - { - auto eval = Teuchos::rcp( - new ElectricPotentialDiffusionFlux( - *ir, incompressible_fluidprop_params)); - evaluators->push_back(eval); - found_model = true; - } - - if (closure_type == "HartmannProblemExact") - { - auto eval = Teuchos::rcp( - new HartmannProblemExact( - *ir, incompressible_fluidprop_params, user_params)); - evaluators->push_back(eval); - found_model = true; - } - - if (closure_type == "LorentzForce") - { - auto eval = Teuchos::rcp( - new LorentzForce( - *ir, incompressible_fluidprop_params)); - evaluators->push_back(eval); - found_model = true; - } - - // Initialize 'error_msg' with list of closure models for Inductionless - // MHD equations - error_msg = "ElectricCurrentDensity\n"; - error_msg += "ElectricPotentialCrossProductFlux\n"; - error_msg += "ElectricPotentialDiffusionFlux\n"; - error_msg += "ExternalMagneticField\n"; - error_msg += "HartmannProblemExact\n"; - error_msg += "LorentzForce\n"; -} - -//---------------------------------------------------------------------------// - -} // end namespace ClosureModel -} // end namespace VertexCFD - -#endif // end VERTEXCFD_INDUCTIONLESSCLOSUREMODELFACTORY_IMPL_HPP diff --git a/src/induction_less_mhd_solver/closure_models/unit_test/CMakeLists.txt b/src/induction_less_mhd_solver/closure_models/unit_test/CMakeLists.txt deleted file mode 100644 index 906b85b..0000000 --- a/src/induction_less_mhd_solver/closure_models/unit_test/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -set(TEST_HARNESS_DIR ${CMAKE_SOURCE_DIR}/src/test_harness) -include(${TEST_HARNESS_DIR}/TestHarness.cmake) - -VertexCFD_add_tests( - LIBS VertexCFD - NAMES - ElectricPotentialDiffusionFlux - ElectricPotentialCrossProductFlux - ElectricCurrentDensity - LorentzForce - HartmannProblem - ) diff --git a/src/induction_less_mhd_solver/closure_models/unit_test/doc/elec_pot_equ_cross_product_flux.py b/src/induction_less_mhd_solver/closure_models/unit_test/doc/elec_pot_equ_cross_product_flux.py deleted file mode 100644 index 7921b93..0000000 --- a/src/induction_less_mhd_solver/closure_models/unit_test/doc/elec_pot_equ_cross_product_flux.py +++ /dev/null @@ -1,18 +0,0 @@ -import numpy as np - -# electrical conductivity -sigma = 6.25 - -# 2D -B = np.array([0.0, 0.0, 0.3]) -v = np.array([0.5, 1.5, 0.0]) - -flux = sigma * np.cross(v, B) -print("2-D flux:", flux) - -# 3D -B = np.array([1.1, 2.0, -0.3]) -v = np.array([0.5, 1.5, 2.5]) - -flux = sigma * np.cross(v, B) -print("3-D flux:", flux) diff --git a/src/induction_less_mhd_solver/closure_models/unit_test/doc/elec_pot_equ_current_density_reference.py b/src/induction_less_mhd_solver/closure_models/unit_test/doc/elec_pot_equ_current_density_reference.py deleted file mode 100644 index 4d2c7f6..0000000 --- a/src/induction_less_mhd_solver/closure_models/unit_test/doc/elec_pot_equ_current_density_reference.py +++ /dev/null @@ -1,20 +0,0 @@ -import numpy as np - -# electrical conductivity -sigma = 6.25 - -# 2D -grad_phi = np.array([0.1, -0.2, 0.0]) -B = np.array([0.0, 0.0, 0.3]) -v = np.array([0.5, 1.5, 0.0]) - -J = sigma * (np.cross(v, B) - grad_phi) -print("2-D J:", J) - -# 3D -grad_phi = np.array([0.1, -0.2, 0.3]) -B = np.array([1.1, 2.0, -0.3]) -v = np.array([0.5, 1.5, 2.5]) - -J = sigma * (np.cross(v, B) - grad_phi) -print("3-D J:", J) diff --git a/src/induction_less_mhd_solver/closure_models/unit_test/doc/elec_pot_equ_lorentz_force_reference.py b/src/induction_less_mhd_solver/closure_models/unit_test/doc/elec_pot_equ_lorentz_force_reference.py deleted file mode 100644 index 02d2fb6..0000000 --- a/src/induction_less_mhd_solver/closure_models/unit_test/doc/elec_pot_equ_lorentz_force_reference.py +++ /dev/null @@ -1,25 +0,0 @@ -import numpy as np - -# Dependent variables -sigma = 3.0 -B = np.array([1.1, 2.0, -0.3]) -vel = np.array([0.1, -0.2, 0.3]) - - -# Function to compute Lorentz force -def lorentz_force(sigma, grad_phi, B, dim): - lf = -np.cross(grad_phi, B)[0:dim] - print(lf) - lf += np.dot(B[0:dim], vel[0:dim]) * B[0:dim] - lf -= np.dot(B[0:dim], B[0:dim]) * vel[0:dim] - lf *= sigma - return lf - - -# 2D -grad_phi = np.array([0.6, 0.4, 0.0]) -print("2-D Florentz:", lorentz_force(sigma, grad_phi, B, 2)) - -# 3D -grad_phi = np.array([0.6, 0.4, 0.5]) -print("3-D Florentz:", lorentz_force(sigma, grad_phi, B, 3)) diff --git a/src/induction_less_mhd_solver/closure_models/unit_test/doc/elec_pot_hartmann_problem.py b/src/induction_less_mhd_solver/closure_models/unit_test/doc/elec_pot_hartmann_problem.py deleted file mode 100644 index 6eb2961..0000000 --- a/src/induction_less_mhd_solver/closure_models/unit_test/doc/elec_pot_hartmann_problem.py +++ /dev/null @@ -1,18 +0,0 @@ -import numpy as np - - -def hartmann_pb_exact(M, L, y): - return (np.cosh(M) - np.cosh(M * y / L)) / (np.cosh(M) - 1.0) - - -B = np.array([1.5, 2.0, 3.0]) -B_magn = np.linalg.norm(B) -L = 2.5 -sigma = 3.5 -rho = 4.0 -nu = 4.5 -M = B_magn * L * np.sqrt(sigma / (rho * nu)) - -# output value -y = 0.5 -print("Exact value:", hartmann_pb_exact(M, L, y)) diff --git a/src/induction_less_mhd_solver/closure_models/unit_test/tstElectricCurrentDensity.cpp b/src/induction_less_mhd_solver/closure_models/unit_test/tstElectricCurrentDensity.cpp deleted file mode 100644 index 3f7ca55..0000000 --- a/src/induction_less_mhd_solver/closure_models/unit_test/tstElectricCurrentDensity.cpp +++ /dev/null @@ -1,211 +0,0 @@ -#include -#include - -#include "incompressible_solver/fluid_properties/VertexCFD_ConstantFluidProperties.hpp" -#include "induction_less_mhd_solver/closure_models/VertexCFD_Closure_ElectricCurrentDensity.hpp" - -#include - -namespace VertexCFD -{ -namespace Test -{ - -template -struct Dependencies : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - using scalar_type = typename EvalType::ScalarT; - - int num_grad_dim; - - // quiet_NaN is a host-side function so we store the value - const double _nanval = std::numeric_limits::quiet_NaN(); - - PHX::MDField velocity_0; - PHX::MDField velocity_1; - PHX::MDField velocity_2; - PHX::MDField ext_magn_field_0; - PHX::MDField ext_magn_field_1; - PHX::MDField ext_magn_field_2; - PHX::MDField - grad_electric_potential; - - Dependencies(const panzer::IntegrationRule& ir) - : num_grad_dim(ir.spatial_dimension) - , velocity_0("velocity_0", ir.dl_scalar) - , velocity_1("velocity_1", ir.dl_scalar) - , velocity_2("velocity_2", ir.dl_scalar) - , ext_magn_field_0("external_magnetic_field_0", ir.dl_scalar) - , ext_magn_field_1("external_magnetic_field_1", ir.dl_scalar) - , ext_magn_field_2("external_magnetic_field_2", ir.dl_scalar) - , grad_electric_potential("GRAD_electric_potential", ir.dl_vector) - { - this->addEvaluatedField(velocity_0); - this->addEvaluatedField(velocity_1); - this->addEvaluatedField(velocity_2); - this->addEvaluatedField(ext_magn_field_0); - this->addEvaluatedField(ext_magn_field_1); - this->addEvaluatedField(ext_magn_field_2); - this->addEvaluatedField(grad_electric_potential); - this->setName( - "Electric Potential Electric Current Density Unit Test " - "Dependencies"); - } - - void evaluateFields(typename panzer::Traits::EvalData d) override - { - Kokkos::parallel_for( - "electric potential electric current density test dependencies", - Kokkos::RangePolicy(0, d.num_cells), - *this); - } - - KOKKOS_INLINE_FUNCTION void operator()(const int c) const - { - const int num_point = velocity_0.extent(1); - for (int qp = 0; qp < num_point; ++qp) - { - velocity_0(c, qp) = 0.5; - velocity_1(c, qp) = 1.5; - grad_electric_potential(c, qp, 0) = 0.1; - grad_electric_potential(c, qp, 1) = -0.2; - if (num_grad_dim == 3) - { - velocity_2(c, qp) = 2.5; - grad_electric_potential(c, qp, 2) = 0.3; - ext_magn_field_0(c, qp) = 1.1; - ext_magn_field_1(c, qp) = 2.0; - ext_magn_field_2(c, qp) = -0.3; - } - else - { - velocity_2(c, qp) = _nanval; - ext_magn_field_0(c, qp) = 0.0; - ext_magn_field_1(c, qp) = 0.0; - ext_magn_field_2(c, qp) = 0.3; - } - } - } -}; - -template -void testEval() -{ - // Test fixture - constexpr int num_space_dim = NumSpaceDim; - const int integration_order = 2; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - - const auto& ir = *test_fixture.ir; - - // Initialize dependents - const auto deps = Teuchos::rcp(new Dependencies(ir)); - test_fixture.registerEvaluator(deps); - - // Initialize class object to test - Teuchos::ParameterList fluid_prop_list; - fluid_prop_list.set("Kinematic viscosity", 0.375); - fluid_prop_list.set("Artificial compressibility", 2.0); - fluid_prop_list.set("Build Temperature Equation", false); - fluid_prop_list.set("Build Inductionless MHD Equation", true); - fluid_prop_list.set("Electrical conductivity", 6.25); - const FluidProperties::ConstantFluidProperties fluid_prop(fluid_prop_list); - const auto eval = Teuchos::rcp( - new ClosureModel:: - ElectricCurrentDensity( - ir, fluid_prop)); - - // Register - test_fixture.registerEvaluator(eval); - for (int dim = 0; dim < num_space_dim; ++dim) - { - test_fixture.registerTestField( - eval->_electric_current_density[dim]); - } - - test_fixture.evaluate(); - - const int num_point = ir.num_points; - - // Assert values - double exp_values[num_space_dim]; - if (num_space_dim == 2) - { - exp_values[0] = 2.1875; - exp_values[1] = 0.3125; - } - else - { - exp_values[0] = -34.6875; - exp_values[1] = 19.375; - exp_values[2] = -5.9375; - } - - for (int qp = 0; qp < num_point; ++qp) - for (int dim = 0; dim < num_space_dim; ++dim) - { - const auto Jdim = test_fixture.getTestFieldData( - eval->_electric_current_density[dim]); - EXPECT_NEAR(exp_values[dim], fieldValue(Jdim, 0, qp), 1.0e-15); - } -} - -//-----------------------------------------------------------------// -TEST(ElectricCurrentDensity2D, residual_test) -{ - testEval(); -} - -//-----------------------------------------------------------------// -TEST(ElectricCurrentDensity2D, jacobian_test) -{ - testEval(); -} - -//-----------------------------------------------------------------// -TEST(ElectricCurrentDensity3D, residual_test) -{ - testEval(); -} - -//-----------------------------------------------------------------// -TEST(ElectricCurrentDensity3D, jacobian_test) -{ - testEval(); -} - -//-----------------------------------------------------------------// -template -void testFactory() -{ - constexpr int num_space_dim = NumSpaceDim; - ClosureModelFactoryTestFixture test_fixture; - test_fixture.user_params.set("Build Inductionless MHD Equation", true); - test_fixture.user_params.set("Build Temperature Equation", false); - test_fixture.user_params.sublist("Fluid Properties") - .set("Kinematic viscosity", 0.1) - .set("Artificial compressibility", 2.0) - .set("Electrical conductivity", 3.0); - test_fixture.type_name = "ElectricCurrentDensity"; - test_fixture.eval_name = "Electric Potential Electric Current Density " - + std::to_string(num_space_dim) + "D"; - test_fixture.template buildAndTest< - ClosureModel::ElectricCurrentDensity, - num_space_dim>(); -} - -TEST(ElectricCurrentDensity_Factory2D, residual_test) -{ - testFactory(); -} - -TEST(ElectricCurrentDensity_Factory2D, jacobian_test) -{ - testFactory(); -} - -} // namespace Test -} // namespace VertexCFD diff --git a/src/induction_less_mhd_solver/closure_models/unit_test/tstElectricPotentialCrossProductFlux.cpp b/src/induction_less_mhd_solver/closure_models/unit_test/tstElectricPotentialCrossProductFlux.cpp deleted file mode 100644 index 352b6ec..0000000 --- a/src/induction_less_mhd_solver/closure_models/unit_test/tstElectricPotentialCrossProductFlux.cpp +++ /dev/null @@ -1,205 +0,0 @@ -#include -#include - -#include "incompressible_solver/fluid_properties/VertexCFD_ConstantFluidProperties.hpp" -#include "induction_less_mhd_solver/closure_models/VertexCFD_Closure_ElectricPotentialCrossProductFlux.hpp" - -#include - -namespace VertexCFD -{ -namespace Test -{ - -template -struct Dependencies : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - using scalar_type = typename EvalType::ScalarT; - - int num_grad_dim; - - // quiet_NaN is a host-side function so we store the value - const double _nanval = std::numeric_limits::quiet_NaN(); - - PHX::MDField velocity_0; - PHX::MDField velocity_1; - PHX::MDField velocity_2; - PHX::MDField ext_magn_field_0; - PHX::MDField ext_magn_field_1; - PHX::MDField ext_magn_field_2; - - Dependencies(const panzer::IntegrationRule& ir, std::string field_prefix) - : num_grad_dim(ir.spatial_dimension) - , velocity_0(field_prefix + "velocity_0", ir.dl_scalar) - , velocity_1(field_prefix + "velocity_1", ir.dl_scalar) - , velocity_2(field_prefix + "velocity_2", ir.dl_scalar) - , ext_magn_field_0("external_magnetic_field_0", ir.dl_scalar) - , ext_magn_field_1("external_magnetic_field_1", ir.dl_scalar) - , ext_magn_field_2("external_magnetic_field_2", ir.dl_scalar) - { - this->addEvaluatedField(velocity_0); - this->addEvaluatedField(velocity_1); - this->addEvaluatedField(velocity_2); - this->addEvaluatedField(ext_magn_field_0); - this->addEvaluatedField(ext_magn_field_1); - this->addEvaluatedField(ext_magn_field_2); - this->setName( - "Electric Potential Cross Product Flux Unit Test Dependencies"); - } - - void evaluateFields(typename panzer::Traits::EvalData d) override - { - Kokkos::parallel_for( - "electric potential cross product flux test dependencies", - Kokkos::RangePolicy(0, d.num_cells), - *this); - } - - KOKKOS_INLINE_FUNCTION void operator()(const int c) const - { - const int num_point = velocity_0.extent(1); - for (int qp = 0; qp < num_point; ++qp) - { - velocity_0(c, qp) = 0.5; - velocity_1(c, qp) = 1.5; - if (num_grad_dim == 3) - { - velocity_2(c, qp) = 2.5; - ext_magn_field_0(c, qp) = 1.1; - ext_magn_field_1(c, qp) = 2.0; - ext_magn_field_2(c, qp) = -0.3; - } - else - { - velocity_2(c, qp) = _nanval; - ext_magn_field_0(c, qp) = 0.0; - ext_magn_field_1(c, qp) = 0.0; - ext_magn_field_2(c, qp) = 0.3; - } - } - } -}; - -template -void testEval(const std::string field_prefix = "") -{ - // Test fixture - constexpr int num_space_dim = NumSpaceDim; - const int integration_order = 2; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - - const auto& ir = *test_fixture.ir; - - // Initialize dependents - const auto deps - = Teuchos::rcp(new Dependencies(ir, field_prefix)); - test_fixture.registerEvaluator(deps); - - // Initialize class object to test - Teuchos::ParameterList fluid_prop_list; - fluid_prop_list.set("Kinematic viscosity", 0.375); - fluid_prop_list.set("Artificial compressibility", 2.0); - fluid_prop_list.set("Build Temperature Equation", false); - fluid_prop_list.set("Build Inductionless MHD Equation", true); - fluid_prop_list.set("Electrical conductivity", 6.25); - const FluidProperties::ConstantFluidProperties fluid_prop(fluid_prop_list); - const auto eval = Teuchos::rcp( - new ClosureModel::ElectricPotentialCrossProductFlux( - ir, fluid_prop)); - - // Register - test_fixture.registerEvaluator(eval); - test_fixture.registerTestField(eval->_electric_potential_flux); - - test_fixture.evaluate(); - - const auto ind_flux = test_fixture.getTestFieldData( - eval->_electric_potential_flux); - - const int num_point = ir.num_points; - - // Assert values - double exp_values[num_space_dim]; - if (num_space_dim == 2) - { - exp_values[0] = 2.8125; - exp_values[1] = -0.9375; - } - else - { - exp_values[0] = -34.0625; - exp_values[1] = 18.125; - exp_values[2] = -4.0625; - } - - for (int qp = 0; qp < num_point; ++qp) - for (int dim = 0; dim < num_space_dim; ++dim) - { - EXPECT_NEAR( - exp_values[dim], fieldValue(ind_flux, 0, qp, dim), 1.0e-15); - } -} - -//-----------------------------------------------------------------// -TEST(ElectricPotentialCrossProduct2D, residual_test) -{ - testEval(); -} - -//-----------------------------------------------------------------// -TEST(ElectricPotentialCrossProduct2D, jacobian_test) -{ - testEval(); -} - -//-----------------------------------------------------------------// -TEST(ElectricPotentialCrossProduct3D, residual_test) -{ - testEval(); -} - -//-----------------------------------------------------------------// -TEST(ElectricPotentialCrossProduct3D, jacobian_test) -{ - testEval(); -} - -//-----------------------------------------------------------------// -template -void testFactory() -{ - constexpr int num_space_dim = NumSpaceDim; - ClosureModelFactoryTestFixture test_fixture; - test_fixture.user_params.set("Build Inductionless MHD Equation", true); - test_fixture.user_params.set("Build Temperature Equation", false); - test_fixture.user_params.sublist("Fluid Properties") - .set("Kinematic viscosity", 0.1) - .set("Artificial compressibility", 2.0) - .set("Electrical conductivity", 3.0); - test_fixture.type_name = "ElectricPotentialCrossProductFlux"; - test_fixture.eval_name = "Electric Potential Cross Product Flux " - + std::to_string(num_space_dim) + "D"; - test_fixture.template buildAndTest< - ClosureModel::ElectricPotentialCrossProductFlux, - num_space_dim>(); -} - -TEST(ElectricPotentialCrossProduct_Factory2D, residual_test) -{ - testFactory(); -} - -TEST(ElectricPotentialCrossProduct_Factory2D, jacobian_test) -{ - testFactory(); -} - -} // namespace Test -} // namespace VertexCFD diff --git a/src/induction_less_mhd_solver/closure_models/unit_test/tstElectricPotentialDiffusionFlux.cpp b/src/induction_less_mhd_solver/closure_models/unit_test/tstElectricPotentialDiffusionFlux.cpp deleted file mode 100644 index e142247..0000000 --- a/src/induction_less_mhd_solver/closure_models/unit_test/tstElectricPotentialDiffusionFlux.cpp +++ /dev/null @@ -1,168 +0,0 @@ -#include -#include - -#include "incompressible_solver/fluid_properties/VertexCFD_ConstantFluidProperties.hpp" -#include "induction_less_mhd_solver/closure_models/VertexCFD_Closure_ElectricPotentialDiffusionFlux.hpp" - -#include - -namespace VertexCFD -{ -namespace Test -{ -template -struct Dependencies : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - using scalar_type = typename EvalType::ScalarT; - - PHX::MDField - grad_electric_potential; - - Dependencies(const panzer::IntegrationRule& ir, std::string grad_prefix) - : grad_electric_potential(grad_prefix + "GRAD_electric_potential", - ir.dl_vector) - { - this->addEvaluatedField(grad_electric_potential); - this->setName( - "Electric Potential Diffusion Flux Unit Test Dependencies"); - } - - void evaluateFields(typename panzer::Traits::EvalData d) override - { - Kokkos::parallel_for( - "electric potential diffusion flux test dependencies", - Kokkos::RangePolicy(0, d.num_cells), - *this); - } - - KOKKOS_INLINE_FUNCTION void operator()(const int c) const - { - const int num_point = grad_electric_potential.extent(1); - const int num_grad_dim = grad_electric_potential.extent(2); - for (int qp = 0; qp < num_point; ++qp) - for (int dim = 0; dim < num_grad_dim; ++dim) - grad_electric_potential(c, qp, dim) = 1.5 * (qp + 1) - * (dim + 1); - } -}; - -//-----------------------------------------------------------------------------// -template -void testEval(const int num_grad_dim, - const std::string flux_prefix = "", - const std::string grad_prefix = "") -{ - // Test fixture - const int integration_order = 2; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_grad_dim, integration_order, basis_order); - - const auto& ir = *test_fixture.ir; - - // Initialize dependents - const auto deps = Teuchos::rcp(new Dependencies(ir, grad_prefix)); - test_fixture.registerEvaluator(deps); - - // Initialize closure model constructor - const double sigma = 3.0; - Teuchos::ParameterList fluid_prop_list; - fluid_prop_list.set("Kinematic viscosity", 0.375); - fluid_prop_list.set("Artificial compressibility", 2.0); - fluid_prop_list.set("Build Temperature Equation", false); - fluid_prop_list.set("Build Inductionless MHD Equation", true); - fluid_prop_list.set("Electrical conductivity", sigma); - const FluidProperties::ConstantFluidProperties fluid_prop(fluid_prop_list); - - const auto eval = Teuchos::rcp( - new ClosureModel::ElectricPotentialDiffusionFlux( - ir, fluid_prop, flux_prefix, grad_prefix)); - - test_fixture.registerEvaluator(eval); - test_fixture.registerTestField(eval->_electric_potential_flux); - test_fixture.evaluate(); - - const auto diff_flux = test_fixture.getTestFieldData( - eval->_electric_potential_flux); - - // Assert values - const int num_point = ir.num_points; - for (int qp = 0; qp < num_point; ++qp) - { - for (int dim = 0; dim < num_grad_dim; dim++) - { - const auto exp_value = sigma * 1.5 * (qp + 1) * (dim + 1); - EXPECT_EQ(-exp_value, fieldValue(diff_flux, 0, qp, dim)); - } - } -} - -//-----------------------------------------------------------------// -TEST(ElectricPotentialDiffusion2D, residual_test) -{ - testEval(2); -} - -//-----------------------------------------------------------------// -TEST(ElectricPotentialDiffusion2D, jacobian_test) -{ - testEval(2); -} - -//-----------------------------------------------------------------// -TEST(ElectricPotentialDiffusion3D, residual_test) -{ - testEval(3); -} - -//-----------------------------------------------------------------// -TEST(ElectricPotentialDiffusion3D, jacobian_test) -{ - testEval(3); -} - -//-----------------------------------------------------------------// -TEST(ElectricPotentialDiffusion3DPrefix, residual_test) -{ - testEval(3, "BAR_", "BOO_"); -} - -//-----------------------------------------------------------------// -TEST(ElectricPotentialDiffusion3DPrefix, jacobian_test) -{ - testEval(3, "BAR_", "BOO_"); -} - -//-----------------------------------------------------------------// -template -void testFactory() -{ - constexpr int num_space_dim = NumSpaceDim; - ClosureModelFactoryTestFixture test_fixture; - test_fixture.user_params.set("Build Inductionless MHD Equation", true); - test_fixture.user_params.set("Build Temperature Equation", false); - test_fixture.user_params.sublist("Fluid Properties") - .set("Kinematic viscosity", 0.1) - .set("Artificial compressibility", 2.0) - .set("Electrical conductivity", 3.0); - test_fixture.type_name = "ElectricPotentialDiffusionFlux"; - test_fixture.eval_name = "Electric Potential Diffusion Flux " - + std::to_string(num_space_dim) + "D"; - test_fixture.template buildAndTest< - ClosureModel::ElectricPotentialDiffusionFlux, - num_space_dim>(); -} - -TEST(ElectricPotentialFlux_Factory2D, residual_test) -{ - testFactory(); -} - -TEST(ElectricPotentialFlux_Factory2D, jacobian_test) -{ - testFactory(); -} - -} // namespace Test -} // namespace VertexCFD diff --git a/src/induction_less_mhd_solver/closure_models/unit_test/tstLorentzForce.cpp b/src/induction_less_mhd_solver/closure_models/unit_test/tstLorentzForce.cpp deleted file mode 100644 index bddd2bb..0000000 --- a/src/induction_less_mhd_solver/closure_models/unit_test/tstLorentzForce.cpp +++ /dev/null @@ -1,205 +0,0 @@ -#include -#include - -#include "incompressible_solver/fluid_properties/VertexCFD_ConstantFluidProperties.hpp" -#include "induction_less_mhd_solver/closure_models/VertexCFD_Closure_LorentzForce.hpp" - -#include - -namespace VertexCFD -{ -namespace Test -{ - -template -struct Dependencies : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - using scalar_type = typename EvalType::ScalarT; - - int num_grad_dim; - - // quiet_NaN is a host-side function so we store the value - const double _nanval = std::numeric_limits::quiet_NaN(); - - PHX::MDField velocity_0; - PHX::MDField velocity_1; - PHX::MDField velocity_2; - PHX::MDField - grad_electric_potential; - PHX::MDField ext_magn_field_0; - PHX::MDField ext_magn_field_1; - PHX::MDField ext_magn_field_2; - - Dependencies(const panzer::IntegrationRule& ir) - : num_grad_dim(ir.spatial_dimension) - , velocity_0("velocity_0", ir.dl_scalar) - , velocity_1("velocity_1", ir.dl_scalar) - , velocity_2("velocity_2", ir.dl_scalar) - , grad_electric_potential("GRAD_electric_potential", ir.dl_vector) - , ext_magn_field_0("external_magnetic_field_0", ir.dl_scalar) - , ext_magn_field_1("external_magnetic_field_1", ir.dl_scalar) - , ext_magn_field_2("external_magnetic_field_2", ir.dl_scalar) - { - this->addEvaluatedField(velocity_0); - this->addEvaluatedField(velocity_1); - this->addEvaluatedField(velocity_2); - this->addEvaluatedField(grad_electric_potential); - this->addEvaluatedField(ext_magn_field_0); - this->addEvaluatedField(ext_magn_field_1); - this->addEvaluatedField(ext_magn_field_2); - this->setName( - "Electric Potential Lorentz Force Unit Test " - "Dependencies"); - } - - void evaluateFields(typename panzer::Traits::EvalData d) override - { - Kokkos::parallel_for( - "electric potential lorentz force test dependencies", - Kokkos::RangePolicy(0, d.num_cells), - *this); - } - - KOKKOS_INLINE_FUNCTION void operator()(const int c) const - { - const int num_point = velocity_0.extent(1); - for (int qp = 0; qp < num_point; ++qp) - { - velocity_0(c, qp) = 0.1; - velocity_1(c, qp) = -0.2; - grad_electric_potential(c, qp, 0) = 0.6; - grad_electric_potential(c, qp, 1) = 0.4; - if (num_grad_dim == 3) - { - velocity_2(c, qp) = 0.3; - grad_electric_potential(c, qp, 2) = 0.5; - } - else - { - velocity_2(c, qp) = _nanval; - } - ext_magn_field_0(c, qp) = 1.1; - ext_magn_field_1(c, qp) = 2.0; - ext_magn_field_2(c, qp) = -0.3; - } - } -}; - -template -void testEval() -{ - // Test fixture - constexpr int num_space_dim = NumSpaceDim; - const int integration_order = 2; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - - const auto& ir = *test_fixture.ir; - - // Initialize dependents - const auto deps = Teuchos::rcp(new Dependencies(ir)); - test_fixture.registerEvaluator(deps); - - // Initialize class object to test - Teuchos::ParameterList fluid_prop_list; - fluid_prop_list.set("Kinematic viscosity", 0.375); - fluid_prop_list.set("Artificial compressibility", 2.0); - fluid_prop_list.set("Build Temperature Equation", false); - fluid_prop_list.set("Build Inductionless MHD Equation", true); - fluid_prop_list.set("Electrical conductivity", 3.0); - const FluidProperties::ConstantFluidProperties fluid_prop(fluid_prop_list); - - const auto eval = Teuchos::rcp( - new ClosureModel::LorentzForce( - ir, fluid_prop)); - - // Register - test_fixture.registerEvaluator(eval); - for (int dim = 0; dim < num_space_dim; ++dim) - test_fixture.registerTestField(eval->_lorentz_force[dim]); - - test_fixture.evaluate(); - - const int num_point = ir.num_points; - - // Assert values - double exp_values[num_space_dim]; - if (num_space_dim == 2) - { - exp_values[0] = -2.16; - exp_values[1] = 0.846; - } - else - { - exp_values[0] = 0.516; - exp_values[1] = -1.29; - exp_values[2] = -6.708; - } - - for (int qp = 0; qp < num_point; ++qp) - for (int dim = 0; dim < num_space_dim; ++dim) - { - const auto Fldim = test_fixture.getTestFieldData( - eval->_lorentz_force[dim]); - EXPECT_NEAR(exp_values[dim], fieldValue(Fldim, 0, qp), 1.0e-14); - } -} - -//-----------------------------------------------------------------// -TEST(LorentzForce2D, residual_test) -{ - testEval(); -} - -//-----------------------------------------------------------------// -TEST(LorentzForce2D, jacobian_test) -{ - testEval(); -} - -//-----------------------------------------------------------------// -TEST(LorentzForce3D, residual_test) -{ - testEval(); -} - -//-----------------------------------------------------------------// -TEST(LorentzForce3D, jacobian_test) -{ - testEval(); -} - -//-----------------------------------------------------------------// -template -void testFactory() -{ - constexpr int num_space_dim = NumSpaceDim; - ClosureModelFactoryTestFixture test_fixture; - test_fixture.user_params.set("Build Inductionless MHD Equation", true); - test_fixture.user_params.set("Build Temperature Equation", false); - test_fixture.user_params.sublist("Fluid Properties") - .set("Kinematic viscosity", 0.1) - .set("Artificial compressibility", 2.0) - .set("Electrical conductivity", 3.0); - test_fixture.type_name = "LorentzForce"; - test_fixture.eval_name = "Electric Potential Lorentz Force " - + std::to_string(num_space_dim) + "D"; - test_fixture.template buildAndTest< - ClosureModel::LorentzForce, - num_space_dim>(); -} - -TEST(LorentzForce_Factory2D, residual_test) -{ - testFactory(); -} - -TEST(LorentzForce_Factory2D, jacobian_test) -{ - testFactory(); -} - -} // namespace Test -} // namespace VertexCFD diff --git a/src/initial_conditions/VertexCFD_InitialConditionFactory.cpp b/src/initial_conditions/VertexCFD_InitialConditionFactory.cpp deleted file mode 100644 index 5c66f7d..0000000 --- a/src/initial_conditions/VertexCFD_InitialConditionFactory.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_InitialConditionFactory.hpp" -#include "VertexCFD_InitialConditionFactory_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_NUMSPACEDIM( - VertexCFD::InitialCondition::Factory) diff --git a/src/initial_conditions/VertexCFD_InitialConditionFactory.hpp b/src/initial_conditions/VertexCFD_InitialConditionFactory.hpp deleted file mode 100644 index e09ef5b..0000000 --- a/src/initial_conditions/VertexCFD_InitialConditionFactory.hpp +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef VERTEXCFD_INITIALCONDITIONFACTORY_HPP -#define VERTEXCFD_INITIALCONDITIONFACTORY_HPP - -#include -#include - -#include - -namespace VertexCFD -{ -namespace InitialCondition -{ -//---------------------------------------------------------------------------// -template -class Factory : public panzer::ClosureModelFactory -{ - public: - Factory(Teuchos::RCP mesh); - - Teuchos::RCP>>> - buildClosureModels(const std::string& block_id, - const Teuchos::ParameterList& block_params, - const panzer::FieldLayoutLibrary& fl, - const Teuchos::RCP& ir, - const Teuchos::ParameterList& default_params, - const Teuchos::ParameterList& user_data, - const Teuchos::RCP& global_data, - PHX::FieldManager& fm) const override; - - private: - Teuchos::RCP _mesh; -}; - -//---------------------------------------------------------------------------// - -} // end namespace InitialCondition -} // end namespace VertexCFD - -#endif // end VERTEXCFD_INITIALCONDITIONFACTORY_HPP diff --git a/src/initial_conditions/VertexCFD_InitialConditionFactory_TemplateBuilder.hpp b/src/initial_conditions/VertexCFD_InitialConditionFactory_TemplateBuilder.hpp deleted file mode 100644 index b9d22f7..0000000 --- a/src/initial_conditions/VertexCFD_InitialConditionFactory_TemplateBuilder.hpp +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef VERTEXCFD_INITIALCONDITIONFACTORY_TEMPLATEBUILDER_HPP -#define VERTEXCFD_INITIALCONDITIONFACTORY_TEMPLATEBUILDER_HPP - -#include "VertexCFD_InitialConditionFactory.hpp" - -#include -#include - -#include - -namespace VertexCFD -{ -namespace InitialCondition -{ -//---------------------------------------------------------------------------// -template -class FactoryTemplateBuilder -{ - public: - FactoryTemplateBuilder(Teuchos::RCP mesh) - : _mesh{mesh} - { - } - - template - Teuchos::RCP build() const - { - auto ic_factory = Teuchos::rcp(new Factory(_mesh)); - return Teuchos::rcp_static_cast( - ic_factory); - } - - private: - Teuchos::RCP _mesh; -}; - -//---------------------------------------------------------------------------// - -} // end namespace InitialCondition -} // end namespace VertexCFD - -#endif // end VERTEXCFD_INITIALCONDITIONFACTORY_TEMPLATEBUILDER_HPP diff --git a/src/initial_conditions/VertexCFD_InitialConditionFactory_impl.hpp b/src/initial_conditions/VertexCFD_InitialConditionFactory_impl.hpp deleted file mode 100644 index a79eb2a..0000000 --- a/src/initial_conditions/VertexCFD_InitialConditionFactory_impl.hpp +++ /dev/null @@ -1,276 +0,0 @@ -#ifndef VERTEXCFD_INITIALCONDITIONFACTORY_IMPL_HPP -#define VERTEXCFD_INITIALCONDITIONFACTORY_IMPL_HPP - -#include "VertexCFD_InitialCondition_Circle.hpp" -#include "VertexCFD_InitialCondition_Constant.hpp" -#include "VertexCFD_InitialCondition_Gaussian.hpp" -#include "VertexCFD_InitialCondition_InverseGaussian.hpp" -#include "VertexCFD_InitialCondition_MethodManufacturedSolution.hpp" -#include "VertexCFD_InitialCondition_Step.hpp" -#include "full_induction_mhd_solver/initial_conditions/VertexCFD_FullInductionInitialConditionFactory.hpp" -#include "incompressible_solver/fluid_properties/VertexCFD_ConstantFluidProperties.hpp" -#include "incompressible_solver/initial_conditions/VertexCFD_InitialCondition_IncompressibleLaminarFlow.hpp" -#include "incompressible_solver/initial_conditions/VertexCFD_InitialCondition_IncompressibleTaylorGreenVortex.hpp" -#include "incompressible_solver/initial_conditions/VertexCFD_InitialCondition_IncompressibleVortexInBox.hpp" - -#include -#include -#include -#include - -#include - -#include - -namespace VertexCFD -{ -namespace InitialCondition -{ -//---------------------------------------------------------------------------// -template -Factory::Factory( - Teuchos::RCP mesh) - : _mesh{mesh} -{ -} - -//---------------------------------------------------------------------------// -template -Teuchos::RCP>>> -Factory::buildClosureModels( - const std::string& block_id, - const Teuchos::ParameterList& block_params, - const panzer::FieldLayoutLibrary& fl, - const Teuchos::RCP&, - const Teuchos::ParameterList&, - const Teuchos::ParameterList& user_params, - const Teuchos::RCP&, - PHX::FieldManager&) const -{ - auto evaluators = Teuchos::rcp( - new std::vector>>); - - // Space dimension - constexpr int num_dim_space = NumSpaceDim; - - if (!block_params.isSublist(block_id)) - { - throw std::runtime_error("Initial condition block id not in list"); - } - - // Initial conditions apply to the bases. - std::vector> bases; - fl.uniqueBases(bases); - - // Fluid properties. - Teuchos::ParameterList fluid_prop_list - = user_params.sublist("Fluid Properties"); - const bool build_temp_equ - = user_params.isType("Build Temperature Equation") - ? user_params.get("Build Temperature Equation") - : false; - const bool build_ind_less_equ - = user_params.isType("Build Inductionless MHD Equation") - ? user_params.get("Build Inductionless MHD Equation") - : false; - fluid_prop_list.set("Build Temperature Equation", build_temp_equ); - fluid_prop_list.set("Build Inductionless MHD Equation", - build_ind_less_equ); - FluidProperties::ConstantFluidProperties incompressible_fluidprop_params( - fluid_prop_list); - - // Full induction solver factory objects - FullInductionICFactory full_induction_factory; - std::string full_ind_error_msg = "None"; - - // Loop over initial conditions - const Teuchos::ParameterList& ic_params = block_params.sublist(block_id); - for (auto param_itr = ic_params.begin(); param_itr != ic_params.end(); - ++param_itr) - { - bool found_model = false; - - auto key = param_itr->first; - const auto& p - = Teuchos::getValue(param_itr->second); - - if (p.isType("Type")) - { - std::string type = p.get("Type"); - - // Read initial conditions from corresponding fields of the input - // mesh file. - if (type == "From File") - { - std::vector field_names; - panzer::StringTokenizer( - field_names, p.get("Field Names"), ",", true); - - // Assume we use the same basis for all DoFs. - auto basis = fl.lookupLayout(field_names.at(0)); - - auto plist - = Teuchos::ParameterList{} - .set("Field Names", Teuchos::rcpFromRef(field_names)) - .set("Basis", basis); - - auto eval = Teuchos::rcp( - new panzer_stk::GatherFields( - _mesh, plist)); - evaluators->push_back(eval); - found_model = true; - } - - if (user_params.isSublist("Full Induction MHD Properties")) - { - full_induction_factory.buildClosureModel(type, - bases, - user_params, - p, - found_model, - full_ind_error_msg, - evaluators); - } - - if (type == "Constant") - { - for (const auto& b : bases) - { - auto eval = Teuchos::rcp( - new Constant(p, *b)); - evaluators->push_back(eval); - found_model = true; - } - } - - if (type == "Gaussian") - { - for (const auto& b : bases) - { - auto eval = Teuchos::rcp( - new Gaussian( - p, *b)); - evaluators->push_back(eval); - found_model = true; - } - } - - if (type == "Step") - { - for (const auto& b : bases) - { - auto eval = Teuchos::rcp( - new Step(p, *b)); - evaluators->push_back(eval); - found_model = true; - } - } - - if (type == "Circle") - { - for (const auto& b : bases) - { - auto eval = Teuchos::rcp( - new Circle( - p, *b)); - evaluators->push_back(eval); - found_model = true; - } - } - - if (type == "InverseGaussian") - { - for (const auto& b : bases) - { - auto eval = Teuchos::rcp( - new InverseGaussian( - p, *b)); - evaluators->push_back(eval); - found_model = true; - } - } - - if (type == "MethodManufacturedSolution") - { - for (const auto& b : bases) - { - auto eval = Teuchos::rcp( - new MethodManufacturedSolution(*b)); - evaluators->push_back(eval); - found_model = true; - } - } - - if (type == "IncompressibleVortexInBox") - { - for (const auto& b : bases) - { - auto eval = Teuchos::rcp( - new IncompressibleVortexInBox( - *b)); - evaluators->push_back(eval); - found_model = true; - } - } - - if (type == "IncompressibleTaylorGreenVortex") - { - for (const auto& b : bases) - { - auto eval = Teuchos::rcp( - new IncompressibleTaylorGreenVortex(*b)); - evaluators->push_back(eval); - found_model = true; - } - } - - if (type == "IncompressibleLaminarFlow") - { - for (const auto& b : bases) - { - auto eval = Teuchos::rcp( - new IncompressibleLaminarFlow( - p, incompressible_fluidprop_params, *b)); - evaluators->push_back(eval); - found_model = true; - } - } - } - - if (!found_model) - { - std::string msg = "Initial condition " + key - + " failed to build.\n"; - msg += "The initial conditions implemented in VertexCFD are:\n"; - msg += "Circle\n"; - msg += "Constant\n"; - msg += "From File\n"; - msg += "Gaussian\n"; - msg += "IncompressibleLaminarFlow\n"; - msg += "IncompressibleTaylorGreenVortex\n"; - msg += "IncompressibleVortexInBox\n"; - msg += "InverseGaussian\n"; - msg += "MethodManufacturedSolution\n"; - msg += "Step\n"; - msg += "=================================\n"; - msg += "Full induction MHD closure models:\n"; - msg += full_ind_error_msg; - throw std::runtime_error(msg); - } - } - - return evaluators; -} - -//---------------------------------------------------------------------------// - -} // end namespace InitialCondition -} // end namespace VertexCFD - -#endif // end VERTEXCFD_INITIALCONDITIONFACTORY_IMPL_HPP diff --git a/src/initial_conditions/VertexCFD_InitialCondition_Circle.cpp b/src/initial_conditions/VertexCFD_InitialCondition_Circle.cpp deleted file mode 100644 index 482e379..0000000 --- a/src/initial_conditions/VertexCFD_InitialCondition_Circle.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_InitialCondition_Circle.hpp" -#include "VertexCFD_InitialCondition_Circle_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS_NUMSPACEDIM( - VertexCFD::InitialCondition::Circle) diff --git a/src/initial_conditions/VertexCFD_InitialCondition_Circle.hpp b/src/initial_conditions/VertexCFD_InitialCondition_Circle.hpp deleted file mode 100644 index 70a5d03..0000000 --- a/src/initial_conditions/VertexCFD_InitialCondition_Circle.hpp +++ /dev/null @@ -1,60 +0,0 @@ -#ifndef VERTEXCFD_INITIALCONDITION_CIRCLE_HPP -#define VERTEXCFD_INITIALCONDITION_CIRCLE_HPP - -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include - -namespace VertexCFD -{ -namespace InitialCondition -{ -//---------------------------------------------------------------------------// -template -class Circle : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - using view_layout = typename PHX::DevLayout::type; - - static constexpr int num_space_dim = NumSpaceDim; - - Circle(const Teuchos::ParameterList& params, - const panzer::PureBasis& basis); - - void postRegistrationSetup(typename Traits::SetupData sd, - PHX::FieldManager& fm) override; - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - public: - PHX::MDField _ic; - - private: - std::string _basis_name; - Kokkos::Array _origin; - double _inside_value, _outside_value, _radius; - int _basis_index; - PHX::MDField _basis_coords; -}; - -//---------------------------------------------------------------------------// - -} // end namespace InitialCondition -} // end namespace VertexCFD - -#endif // end VERTEXCFD_INITIALCONDITION_CIRCLE_HPP diff --git a/src/initial_conditions/VertexCFD_InitialCondition_Constant.cpp b/src/initial_conditions/VertexCFD_InitialCondition_Constant.cpp deleted file mode 100644 index c523c2e..0000000 --- a/src/initial_conditions/VertexCFD_InitialCondition_Constant.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_InitialCondition_Constant.hpp" -#include "VertexCFD_InitialCondition_Constant_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS( - VertexCFD::InitialCondition::Constant) -#include "VertexCFD_InitialCondition_Constant_impl.hpp" diff --git a/src/initial_conditions/VertexCFD_InitialCondition_Constant.hpp b/src/initial_conditions/VertexCFD_InitialCondition_Constant.hpp deleted file mode 100644 index 891d8a1..0000000 --- a/src/initial_conditions/VertexCFD_InitialCondition_Constant.hpp +++ /dev/null @@ -1,48 +0,0 @@ -#ifndef VERTEXCFD_INITIALCONDITION_CONSTANT_HPP -#define VERTEXCFD_INITIALCONDITION_CONSTANT_HPP - -#include -#include -#include - -#include -#include -#include -#include - -#include - -namespace VertexCFD -{ -namespace InitialCondition -{ -//---------------------------------------------------------------------------// -template -class Constant : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived - -{ - public: - using scalar_type = typename EvalType::ScalarT; - - Constant(const Teuchos::ParameterList& params, - const panzer::PureBasis& basis); - - void postRegistrationSetup(typename Traits::SetupData sd, - PHX::FieldManager& fm) override; - - void evaluateFields(typename Traits::EvalData workset) override; - - public: - PHX::MDField _ic; - - private: - scalar_type _value; -}; - -//---------------------------------------------------------------------------// - -} // end namespace InitialCondition -} // end namespace VertexCFD - -#endif // end VERTEXCFD_INITIALCONDITION_CONSTANT_HPP diff --git a/src/initial_conditions/VertexCFD_InitialCondition_Constant_impl.hpp b/src/initial_conditions/VertexCFD_InitialCondition_Constant_impl.hpp deleted file mode 100644 index 836a934..0000000 --- a/src/initial_conditions/VertexCFD_InitialCondition_Constant_impl.hpp +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef VERTEXCFD_INITIALCONDITION_CONSTANT_IMPL_HPP -#define VERTEXCFD_INITIALCONDITION_CONSTANT_IMPL_HPP - -#include - -namespace VertexCFD -{ -namespace InitialCondition -{ -//---------------------------------------------------------------------------// -template -Constant::Constant(const Teuchos::ParameterList& params, - const panzer::PureBasis& basis) -{ - _value = params.get("Value"); - std::string dof_name = params.get("Equation Set Name"); - _ic = PHX::MDField( - dof_name, basis.functional); - this->addEvaluatedField(_ic); - this->addUnsharedField(_ic.fieldTag().clone()); - this->setName("Constant Initial Condition: " + dof_name); -} - -//---------------------------------------------------------------------------// -template -void Constant::postRegistrationSetup( - typename Traits::SetupData, PHX::FieldManager& fm) -{ - this->utils.setFieldData(_ic, fm); - _ic.deep_copy(_value); -} - -//---------------------------------------------------------------------------// -template -void Constant::evaluateFields(typename Traits::EvalData) -{ -} - -//---------------------------------------------------------------------------// - -} // end namespace InitialCondition -} // end namespace VertexCFD - -#endif // end VERTEXCFD_INITIALCONDITION_CONSTANT_IMPL_HPP diff --git a/src/initial_conditions/VertexCFD_InitialCondition_Gaussian.cpp b/src/initial_conditions/VertexCFD_InitialCondition_Gaussian.cpp deleted file mode 100644 index 1e4b767..0000000 --- a/src/initial_conditions/VertexCFD_InitialCondition_Gaussian.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_InitialCondition_Gaussian.hpp" -#include "VertexCFD_InitialCondition_Gaussian_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS_NUMSPACEDIM( - VertexCFD::InitialCondition::Gaussian) diff --git a/src/initial_conditions/VertexCFD_InitialCondition_Gaussian.hpp b/src/initial_conditions/VertexCFD_InitialCondition_Gaussian.hpp deleted file mode 100644 index 5eef67a..0000000 --- a/src/initial_conditions/VertexCFD_InitialCondition_Gaussian.hpp +++ /dev/null @@ -1,61 +0,0 @@ -#ifndef VERTEXCFD_INITIALCONDITION_GAUSSIAN_HPP -#define VERTEXCFD_INITIALCONDITION_GAUSSIAN_HPP - -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include - -namespace VertexCFD -{ -namespace InitialCondition -{ -//---------------------------------------------------------------------------// -template -class Gaussian : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - using view_layout = typename PHX::DevLayout::type; - static constexpr int num_space_dim = NumSpaceDim; - - Gaussian(const Teuchos::ParameterList& params, - const panzer::PureBasis& basis); - - void postRegistrationSetup(typename Traits::SetupData sd, - PHX::FieldManager& fm) override; - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - public: - PHX::MDField _ic; - - private: - std::string _basis_name; - Kokkos::View _a; - Kokkos::View _b; - Kokkos::View _c; - double _d; - int _basis_index; - PHX::MDField _basis_coords; -}; - -//---------------------------------------------------------------------------// - -} // end namespace InitialCondition -} // end namespace VertexCFD - -#endif // end VERTEXCFD_INITIALCONDITION_GAUSSIAN_HPP diff --git a/src/initial_conditions/VertexCFD_InitialCondition_InverseGaussian.cpp b/src/initial_conditions/VertexCFD_InitialCondition_InverseGaussian.cpp deleted file mode 100644 index f6377ce..0000000 --- a/src/initial_conditions/VertexCFD_InitialCondition_InverseGaussian.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_InitialCondition_InverseGaussian.hpp" -#include "VertexCFD_InitialCondition_InverseGaussian_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS_NUMSPACEDIM( - VertexCFD::InitialCondition::InverseGaussian) diff --git a/src/initial_conditions/VertexCFD_InitialCondition_InverseGaussian.hpp b/src/initial_conditions/VertexCFD_InitialCondition_InverseGaussian.hpp deleted file mode 100644 index aa6f3f8..0000000 --- a/src/initial_conditions/VertexCFD_InitialCondition_InverseGaussian.hpp +++ /dev/null @@ -1,61 +0,0 @@ -#ifndef VERTEXCFD_INITIALCONDITION_INVERSEGAUSSIAN_HPP -#define VERTEXCFD_INITIALCONDITION_INVERSEGAUSSIAN_HPP - -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include - -namespace VertexCFD -{ -namespace InitialCondition -{ -//---------------------------------------------------------------------------// -template -class InverseGaussian : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - using view_layout = typename PHX::DevLayout::type; - static constexpr int num_space_dim = NumSpaceDim; - - InverseGaussian(const Teuchos::ParameterList& params, - const panzer::PureBasis& basis); - - void postRegistrationSetup(typename Traits::SetupData sd, - PHX::FieldManager& fm) override; - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - public: - PHX::MDField _ic; - - private: - std::string _basis_name; - Kokkos::View _a; - Kokkos::View _b; - Kokkos::View _c; - double _d; - int _basis_index; - PHX::MDField _basis_coords; -}; - -//---------------------------------------------------------------------------// - -} // end namespace InitialCondition -} // end namespace VertexCFD - -#endif // end VERTEXCFD_INITIALCONDITION_INVERSEGAUSSIAN_HPP diff --git a/src/initial_conditions/VertexCFD_InitialCondition_MethodManufacturedSolution.cpp b/src/initial_conditions/VertexCFD_InitialCondition_MethodManufacturedSolution.cpp deleted file mode 100644 index 8f17fc7..0000000 --- a/src/initial_conditions/VertexCFD_InitialCondition_MethodManufacturedSolution.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_InitialCondition_MethodManufacturedSolution.hpp" -#include "VertexCFD_InitialCondition_MethodManufacturedSolution_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS_NUMSPACEDIM( - VertexCFD::InitialCondition::MethodManufacturedSolution) diff --git a/src/initial_conditions/VertexCFD_InitialCondition_MethodManufacturedSolution.hpp b/src/initial_conditions/VertexCFD_InitialCondition_MethodManufacturedSolution.hpp deleted file mode 100644 index eb4b89c..0000000 --- a/src/initial_conditions/VertexCFD_InitialCondition_MethodManufacturedSolution.hpp +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef VERTEXCFD_INITIALCONDITION_METHODMANUFACTUREDSOLUTION_HPP -#define VERTEXCFD_INITIALCONDITION_METHODMANUFACTUREDSOLUTION_HPP - -#include -#include -#include - -#include -#include -#include -#include - -#include - -namespace VertexCFD -{ -namespace InitialCondition -{ -template -class MethodManufacturedSolution - : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - static constexpr int num_space_dim = NumSpaceDim; - static constexpr int num_coeff = 2 * (num_space_dim + 1); - - MethodManufacturedSolution(const panzer::PureBasis& basis); - - void postRegistrationSetup(typename Traits::SetupData sd, - PHX::FieldManager& fm) override; - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - PHX::MDField _lagrange_pressure; - Kokkos::Array, - num_space_dim> - _velocity; - PHX::MDField _temperature; - - private: - std::string _basis_name; - int _basis_index; - PHX::MDField _basis_coords; - - Kokkos::Array _phi_coeff; - Kokkos::Array, num_space_dim> _vel_coeff; - Kokkos::Array _T_coeff; -}; - -//---------------------------------------------------------------------------// - -} // end namespace InitialCondition -} // end namespace VertexCFD - -#include "VertexCFD_InitialCondition_MethodManufacturedSolution_impl.hpp" - -#endif // end VERTEXCFD_INITIALCONDITION_METHODMANUFACTUREDSOLUTION_HPP diff --git a/src/initial_conditions/VertexCFD_InitialCondition_Step.cpp b/src/initial_conditions/VertexCFD_InitialCondition_Step.cpp deleted file mode 100644 index 7cbd51e..0000000 --- a/src/initial_conditions/VertexCFD_InitialCondition_Step.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_InitialCondition_Step.hpp" -#include "VertexCFD_InitialCondition_Step_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS( - VertexCFD::InitialCondition::Step) diff --git a/src/initial_conditions/VertexCFD_InitialCondition_Step.hpp b/src/initial_conditions/VertexCFD_InitialCondition_Step.hpp deleted file mode 100644 index d057106..0000000 --- a/src/initial_conditions/VertexCFD_InitialCondition_Step.hpp +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef VERTEXCFD_INITIALCONDITION_STEP_HPP -#define VERTEXCFD_INITIALCONDITION_STEP_HPP - -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include - -namespace VertexCFD -{ -namespace InitialCondition -{ -//---------------------------------------------------------------------------// -template -class Step : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - using view_layout = typename PHX::DevLayout::type; - - Step(const Teuchos::ParameterList& params, const panzer::PureBasis& basis); - - void postRegistrationSetup(typename Traits::SetupData sd, - PHX::FieldManager& fm) override; - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - public: - PHX::MDField _ic; - - private: - std::string _basis_name; - scalar_type _left_value, _right_value, _origin; - int _basis_index; - PHX::MDField _basis_coords; -}; - -//---------------------------------------------------------------------------// - -} // end namespace InitialCondition -} // end namespace VertexCFD - -#endif // end VERTEXCFD_INITIALCONDITION_STEP_HPP diff --git a/src/initial_conditions/unit_test/CMakeLists.txt b/src/initial_conditions/unit_test/CMakeLists.txt deleted file mode 100644 index 30e4de0..0000000 --- a/src/initial_conditions/unit_test/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -set(TEST_HARNESS_DIR ${CMAKE_SOURCE_DIR}/src/test_harness) -include(${TEST_HARNESS_DIR}/TestHarness.cmake) - -VertexCFD_add_tests( - LIBS VertexCFD - NAMES - InitialConditionCircle - InitialConditionConstant - InitialConditionGaussian - InitialConditionStep - MethodManufacturedSolutionIC - ) diff --git a/src/initial_conditions/unit_test/doc/gaussian_reference.py b/src/initial_conditions/unit_test/doc/gaussian_reference.py deleted file mode 100644 index a531806..0000000 --- a/src/initial_conditions/unit_test/doc/gaussian_reference.py +++ /dev/null @@ -1,122 +0,0 @@ -from decimal import * -import math - -places = Decimal(10)**-16 - - -def show(d): - print(d.quantize(places)) - - -zero = Decimal(0) -half = Decimal(0.5) -one = Decimal(1) -two = Decimal(2) -three = Decimal(3) -twopi = two * Decimal(math.pi) -third = one / three -twothird = two * third - -center0 = third -center1 = half -center2 = twothird - -sigma0 = half -sigma1 = two -sigma2 = three - -base = third - -a0 = one / (twopi.sqrt() * sigma0) -a1 = one / (twopi.sqrt() * sigma1) -a2 = one / (twopi.sqrt() * sigma2) - -b0 = center0 -b1 = center1 -b2 = center2 - -c0 = half / (sigma0 * sigma0) -c1 = half / (sigma1 * sigma1) -c2 = half / (sigma2 * sigma2) - -r0 = zero -r1 = one -r2 = one - - -# Gaussian -def dimResult(a, b, c, x): - return a * Decimal(math.exp((b - x) * (x - b) * c)) - - -# one-dimensional mesh -print("1D case:") -print("Gaussian") -result0 = dimResult(a0, b0, c0, r0) + base -result1 = dimResult(a0, b0, c0, r1) + base - -show(result0) -show(result1) - -print("Inverse Gaussian") -show(one / result0) -show(one / result1) - -# two-dimensional mesh -print("\n2D case:") -print("Gaussian") -result0 = dimResult(a0, b0, c0, r0) * dimResult(a1, b1, c1, r0) + base -result1 = dimResult(a0, b0, c0, r1) * dimResult(a1, b1, c1, r0) + base -result2 = dimResult(a0, b0, c0, r1) * dimResult(a1, b1, c1, r1) + base -result3 = dimResult(a0, b0, c0, r0) * dimResult(a1, b1, c1, r1) + base - -show(result0) -show(result1) -show(result2) -show(result3) - -# Inverse Gaussian -print("Inverse Gaussian") -show(one / result0) -show(one / result1) -show(one / result2) -show(one / result3) - -# three-dimensional mesh -print("\n3D case:") -print("Gaussian") -result0 = dimResult(a0, b0, c0, r0) * dimResult(a1, b1, c1, r0) * dimResult( - a2, b2, c2, r0) + base -result1 = dimResult(a0, b0, c0, r1) * dimResult(a1, b1, c1, r0) * dimResult( - a2, b2, c2, r0) + base -result2 = dimResult(a0, b0, c0, r1) * dimResult(a1, b1, c1, r1) * dimResult( - a2, b2, c2, r0) + base -result3 = dimResult(a0, b0, c0, r0) * dimResult(a1, b1, c1, r1) * dimResult( - a2, b2, c2, r0) + base -result4 = dimResult(a0, b0, c0, r0) * dimResult(a1, b1, c1, r0) * dimResult( - a2, b2, c2, r2) + base -result5 = dimResult(a0, b0, c0, r1) * dimResult(a1, b1, c1, r0) * dimResult( - a2, b2, c2, r2) + base -result6 = dimResult(a0, b0, c0, r1) * dimResult(a1, b1, c1, r1) * dimResult( - a2, b2, c2, r1) + base -result7 = dimResult(a0, b0, c0, r0) * dimResult(a1, b1, c1, r1) * dimResult( - a2, b2, c2, r1) + base - -show(result0) -show(result1) -show(result2) -show(result3) -show(result4) -show(result5) -show(result6) -show(result7) - -print("Inverse Gaussian") -show(one / result0) -show(one / result1) -show(one / result2) -show(one / result3) -show(one / result4) -show(one / result5) -show(one / result6) -show(one / result7) diff --git a/src/initial_conditions/unit_test/tstInitialConditionCircle.cpp b/src/initial_conditions/unit_test/tstInitialConditionCircle.cpp deleted file mode 100644 index 0ce8ff7..0000000 --- a/src/initial_conditions/unit_test/tstInitialConditionCircle.cpp +++ /dev/null @@ -1,103 +0,0 @@ -#include "VertexCFD_EvaluatorTestHarness.hpp" - -#include "initial_conditions/VertexCFD_InitialCondition_Circle.hpp" - -#include -#include - -#include - -namespace VertexCFD -{ -namespace Test -{ -//---------------------------------------------------------------------------// -template -void testEval() -{ - const int integration_order = 1; - const int basis_order = 1; - constexpr int num_space_dim = NumSpaceDim; - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - - Teuchos::ParameterList params; - const double inside_value = 1.3; - const double outside_value = 2.5; - Teuchos::Array center(num_space_dim); - center[0] = 0.9; - center[1] = 0.92; - if (num_space_dim > 2) - center[2] = 0.95; - - const double radius = 0.2; - params.set("Inside Value", inside_value); - params.set("Outside Value", outside_value); - params.set>("Center", center); - params.set("Radius", radius); - params.set("Equation Set Name", "dof"); - auto eval = Teuchos::rcp( - new InitialCondition::Circle( - params, *test_fixture.basis_ir_layout->getBasis())); - test_fixture.registerEvaluator(eval); - test_fixture.registerTestField(eval->_ic); - - test_fixture.evaluate(); - - auto ic = test_fixture.getTestFieldData(eval->_ic); - - // Number of degree of freedom based on `num_space_dim` value - int num_dofs = 4; - if (num_space_dim == 3) - num_dofs = 8; - EXPECT_EQ(num_dofs, ic.extent(1)); - - // Check on values - if (num_space_dim == 2) - { - EXPECT_EQ(outside_value, fieldValue(ic, 0, 0)); - EXPECT_EQ(outside_value, fieldValue(ic, 0, 1)); - EXPECT_EQ(inside_value, fieldValue(ic, 0, 2)); - EXPECT_EQ(outside_value, fieldValue(ic, 0, 3)); - } - else if (num_space_dim == 3) - { - EXPECT_EQ(outside_value, fieldValue(ic, 0, 0)); - EXPECT_EQ(outside_value, fieldValue(ic, 0, 1)); - EXPECT_EQ(outside_value, fieldValue(ic, 0, 2)); - EXPECT_EQ(outside_value, fieldValue(ic, 0, 3)); - EXPECT_EQ(outside_value, fieldValue(ic, 0, 4)); - EXPECT_EQ(outside_value, fieldValue(ic, 0, 5)); - EXPECT_EQ(inside_value, fieldValue(ic, 0, 6)); - EXPECT_EQ(outside_value, fieldValue(ic, 0, 7)); - } -} - -//---------------------------------------------------------------------------// -TEST(Circle2D, residual_test) -{ - testEval(); -} - -//---------------------------------------------------------------------------// -TEST(Circle2D, jacobian_test) -{ - testEval(); -} - -//---------------------------------------------------------------------------// -TEST(Circle3D, residual_test) -{ - testEval(); -} - -//---------------------------------------------------------------------------// -TEST(Circle3D, jacobian_test) -{ - testEval(); -} - -//---------------------------------------------------------------------------// - -} // namespace Test -} // namespace VertexCFD diff --git a/src/initial_conditions/unit_test/tstInitialConditionConstant.cpp b/src/initial_conditions/unit_test/tstInitialConditionConstant.cpp deleted file mode 100644 index e679881..0000000 --- a/src/initial_conditions/unit_test/tstInitialConditionConstant.cpp +++ /dev/null @@ -1,63 +0,0 @@ -#include "VertexCFD_EvaluatorTestHarness.hpp" - -#include "initial_conditions/VertexCFD_InitialCondition_Constant.hpp" - -#include - -#include - -namespace VertexCFD -{ -namespace Test -{ -//---------------------------------------------------------------------------// -template -void testEval() -{ - const int num_space_dim = 2; - const int integration_order = 1; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - - Teuchos::ParameterList params; - const double ic_value = 1.3; - params.set("Value", ic_value); - params.set("Equation Set Name", "dof"); - auto eval = Teuchos::rcp( - new InitialCondition::Constant( - params, *test_fixture.basis_ir_layout->getBasis())); - test_fixture.registerEvaluator(eval); - test_fixture.registerTestField(eval->_ic); - - test_fixture.evaluate(); - - auto ic = test_fixture.getTestFieldData(eval->_ic); - const int num_point = ic.extent(1); - - // Number of degree of freedom - int num_dofs = 4; - EXPECT_EQ(num_dofs, num_point); - - for (int b = 0; b < num_point; ++b) - { - EXPECT_EQ(ic_value, fieldValue(ic, 0, b)); - } -} - -//---------------------------------------------------------------------------// -TEST(Constant, residual_test) -{ - testEval(); -} - -//---------------------------------------------------------------------------// -TEST(Constant, jacobian_test) -{ - testEval(); -} - -//---------------------------------------------------------------------------// - -} // namespace Test -} // namespace VertexCFD diff --git a/src/initial_conditions/unit_test/tstInitialConditionGaussian.cpp b/src/initial_conditions/unit_test/tstInitialConditionGaussian.cpp deleted file mode 100644 index 65a9cfa..0000000 --- a/src/initial_conditions/unit_test/tstInitialConditionGaussian.cpp +++ /dev/null @@ -1,190 +0,0 @@ -#include "VertexCFD_EvaluatorTestHarness.hpp" - -#include "initial_conditions/VertexCFD_InitialCondition_Gaussian.hpp" -#include "initial_conditions/VertexCFD_InitialCondition_InverseGaussian.hpp" - -#include -#include - -#include - -namespace VertexCFD -{ -namespace Test -{ -//---------------------------------------------------------------------------// -template -void testGaussian() -{ - const int integration_order = 1; - const int basis_order = 1; - constexpr int num_space_dim = NumSpaceDim; - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - - Teuchos::ParameterList params; - Teuchos::Array center(num_space_dim); - center[0] = 1.0 / 3.0; - center[1] = 0.5; - if (num_space_dim > 2) - center[2] = 2.0 / 3.0; - params.set>("Center", center); - Teuchos::Array sigma(num_space_dim); - sigma[0] = 0.5; - sigma[1] = 2.0; - if (num_space_dim > 2) - sigma[2] = 3.0; - params.set>("Sigma", sigma); - const double base = 1.0 / 3.0; - params.set("Base", base); - params.set("Equation Set Name", "dof"); - auto eval = Teuchos::rcp( - new InitialCondition::Gaussian( - params, *test_fixture.basis_ir_layout->getBasis())); - test_fixture.registerEvaluator(eval); - test_fixture.registerTestField(eval->_ic); - - test_fixture.evaluate(); - - auto ic = test_fixture.getTestFieldData(eval->_ic); - - // Number of degree of freedom based on `num_space_dim` value - int num_dofs = 4; - if (num_space_dim == 3) - num_dofs = 8; - EXPECT_EQ(num_dofs, ic.extent(1)); - - if (num_space_dim == 2) - { - EXPECT_DOUBLE_EQ(0.4568536920450875, fieldValue(ic, 0, 0)); - EXPECT_DOUBLE_EQ(0.3967508000449945, fieldValue(ic, 0, 1)); - EXPECT_DOUBLE_EQ(0.3967508000449945, fieldValue(ic, 0, 2)); - EXPECT_DOUBLE_EQ(0.4568536920450875, fieldValue(ic, 0, 3)); - } - else if (num_space_dim == 3) - { - EXPECT_DOUBLE_EQ(0.3493585546023939, fieldValue(ic, 0, 0)); - EXPECT_DOUBLE_EQ(0.3415609562691542, fieldValue(ic, 0, 1)); - EXPECT_DOUBLE_EQ(0.3415609562691542, fieldValue(ic, 0, 2)); - EXPECT_DOUBLE_EQ(0.3493585546023939, fieldValue(ic, 0, 3)); - EXPECT_DOUBLE_EQ(0.3496580828086895, fieldValue(ic, 0, 4)); - EXPECT_DOUBLE_EQ(0.3417147391778995, fieldValue(ic, 0, 5)); - EXPECT_DOUBLE_EQ(0.3417147391778995, fieldValue(ic, 0, 6)); - EXPECT_DOUBLE_EQ(0.3496580828086895, fieldValue(ic, 0, 7)); - } -} - -//---------------------------------------------------------------------------// -TEST(Gaussian2D, residual_test) -{ - testGaussian(); -} - -//---------------------------------------------------------------------------// -TEST(Gaussian2D, jacobian_test) -{ - testGaussian(); -} - -//---------------------------------------------------------------------------// -TEST(Gaussian3D, residual_test) -{ - testGaussian(); -} - -//---------------------------------------------------------------------------// -TEST(Gaussian3D, jacobian_test) -{ - testGaussian(); -} - -//---------------------------------------------------------------------------// -template -void testInverseGaussian() -{ - const int integration_order = 1; - const int basis_order = 1; - constexpr int num_space_dim = NumSpaceDim; - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - - Teuchos::ParameterList params; - Teuchos::Array center(num_space_dim); - center[0] = 1.0 / 3.0; - center[1] = 0.5; - if (num_space_dim > 2) - center[2] = 2.0 / 3.0; - params.set>("Center", center); - Teuchos::Array sigma(num_space_dim); - sigma[0] = 0.5; - sigma[1] = 2.0; - if (num_space_dim > 2) - sigma[2] = 3.0; - params.set>("Sigma", sigma); - const double base = 1.0 / 3.0; - params.set("Base", base); - params.set("Equation Set Name", "dof"); - auto eval = Teuchos::rcp( - new InitialCondition::InverseGaussian( - params, *test_fixture.basis_ir_layout->getBasis())); - test_fixture.registerEvaluator(eval); - test_fixture.registerTestField(eval->_ic); - - test_fixture.evaluate(); - - auto ic = test_fixture.getTestFieldData(eval->_ic); - - // Number of degree of freedom based on `num_space_dim` value - int num_dofs = 4; - if (num_space_dim == 3) - num_dofs = 8; - EXPECT_EQ(num_dofs, ic.extent(1)); - - if (num_space_dim == 2) - { - EXPECT_DOUBLE_EQ(2.1888845759865475, fieldValue(ic, 0, 0)); - EXPECT_DOUBLE_EQ(2.5204738084626235, fieldValue(ic, 0, 1)); - EXPECT_DOUBLE_EQ(2.5204738084626235, fieldValue(ic, 0, 2)); - EXPECT_DOUBLE_EQ(2.1888845759865475, fieldValue(ic, 0, 3)); - } - else if (num_space_dim == 3) - { - EXPECT_DOUBLE_EQ(2.8623887602755378, fieldValue(ic, 0, 0)); - EXPECT_DOUBLE_EQ(2.9277350986568493, fieldValue(ic, 0, 1)); - EXPECT_DOUBLE_EQ(2.9277350986568493, fieldValue(ic, 0, 2)); - EXPECT_DOUBLE_EQ(2.8623887602755378, fieldValue(ic, 0, 3)); - EXPECT_DOUBLE_EQ(2.8599367472569936, fieldValue(ic, 0, 4)); - EXPECT_DOUBLE_EQ(2.9264175212512321, fieldValue(ic, 0, 5)); - EXPECT_DOUBLE_EQ(2.9264175212512321, fieldValue(ic, 0, 6)); - EXPECT_DOUBLE_EQ(2.8599367472569936, fieldValue(ic, 0, 7)); - } -} - -//---------------------------------------------------------------------------// -TEST(InverseGaussian2D, residual_test) -{ - testInverseGaussian(); -} - -//---------------------------------------------------------------------------// -TEST(InverseGaussian2D, jacobian_test) -{ - testInverseGaussian(); -} - -//---------------------------------------------------------------------------// -TEST(InverseGaussian3D, residual_test) -{ - testInverseGaussian(); -} - -//---------------------------------------------------------------------------// -TEST(InverseGaussian3D, jacobian_test) -{ - testInverseGaussian(); -} - -//---------------------------------------------------------------------------// - -} // namespace Test -} // namespace VertexCFD diff --git a/src/initial_conditions/unit_test/tstInitialConditionStep.cpp b/src/initial_conditions/unit_test/tstInitialConditionStep.cpp deleted file mode 100644 index 15b4678..0000000 --- a/src/initial_conditions/unit_test/tstInitialConditionStep.cpp +++ /dev/null @@ -1,94 +0,0 @@ -#include "VertexCFD_EvaluatorTestHarness.hpp" - -#include "initial_conditions/VertexCFD_InitialCondition_Step.hpp" - -#include - -#include - -namespace VertexCFD -{ -namespace Test -{ -//---------------------------------------------------------------------------// -template -void testEval() -{ - const int integration_order = 1; - const int basis_order = 1; - constexpr int num_space_dim = NumSpaceDim; - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - - Teuchos::ParameterList params; - const double left_value = 1.3; - const double right_value = 2.5; - const double origin = 0.5; - params.set("Left Value", left_value); - params.set("Right Value", right_value); - params.set("Origin", origin); - params.set("Equation Set Name", "dof"); - auto eval - = Teuchos::rcp(new InitialCondition::Step( - params, *test_fixture.basis_ir_layout->getBasis())); - test_fixture.registerEvaluator(eval); - test_fixture.registerTestField(eval->_ic); - - test_fixture.evaluate(); - - auto ic = test_fixture.getTestFieldData(eval->_ic); - - // Number of degree of freedom based on `num_space_dim` value - int num_dofs = 4; - if (num_space_dim == 3) - num_dofs = 8; - EXPECT_EQ(num_dofs, ic.extent(1)); - - if (num_space_dim == 2) - { - EXPECT_EQ(left_value, fieldValue(ic, 0, 0)); - EXPECT_EQ(right_value, fieldValue(ic, 0, 1)); - EXPECT_EQ(right_value, fieldValue(ic, 0, 2)); - EXPECT_EQ(left_value, fieldValue(ic, 0, 3)); - } - else if (num_space_dim == 3) - { - EXPECT_EQ(left_value, fieldValue(ic, 0, 0)); - EXPECT_EQ(right_value, fieldValue(ic, 0, 1)); - EXPECT_EQ(right_value, fieldValue(ic, 0, 2)); - EXPECT_EQ(left_value, fieldValue(ic, 0, 3)); - EXPECT_EQ(left_value, fieldValue(ic, 0, 4)); - EXPECT_EQ(right_value, fieldValue(ic, 0, 5)); - EXPECT_EQ(right_value, fieldValue(ic, 0, 6)); - EXPECT_EQ(left_value, fieldValue(ic, 0, 7)); - } -} - -//---------------------------------------------------------------------------// -TEST(Step2D, residual_test) -{ - testEval(); -} - -//---------------------------------------------------------------------------// -TEST(Step2D, jacobian_test) -{ - testEval(); -} - -//---------------------------------------------------------------------------// -TEST(Step3D, residual_test) -{ - testEval(); -} - -//---------------------------------------------------------------------------// -TEST(Step3D, jacobian_test) -{ - testEval(); -} - -//---------------------------------------------------------------------------// - -} // namespace Test -} // namespace VertexCFD diff --git a/src/initial_conditions/unit_test/tstMethodManufacturedSolutionIC.cpp b/src/initial_conditions/unit_test/tstMethodManufacturedSolutionIC.cpp deleted file mode 100644 index aea2130..0000000 --- a/src/initial_conditions/unit_test/tstMethodManufacturedSolutionIC.cpp +++ /dev/null @@ -1,226 +0,0 @@ -#include "VertexCFD_EvaluatorTestHarness.hpp" - -#include "initial_conditions/VertexCFD_InitialCondition_MethodManufacturedSolution.hpp" -#include "utils/VertexCFD_Utils_Constants.hpp" - -#include - -//---------------------------------------------------------------------------// -// TESTS -//---------------------------------------------------------------------------//¬ -namespace VertexCFD -{ -namespace Test -{ -//---------------------------------------------------------------------------// -// function = B + A * sin(2*pi*f_x*(x-phi_x)) * -// sin(2*pi*f_y*(x-phi_y)) -// * sin(2*pi*f_z*(z-phi_z)) for 3D -// FIXME: warning: lambda templates are only available with ‘-std=c++20’ or -// ‘-std=gnu++20’ -// -template -double -set_function(const Kokkos::Array coeff, const SubviewType& x) -{ - using std::sin; - using VertexCFD::Constants::pi; - - double return_val = coeff[0]; - for (int i = 0; i < num_space_dim; ++i) - return_val *= sin(2.0 * pi * coeff[2 * (i + 1)] - * (x[i] - coeff[2 * (i + 1) + 1])); - return_val += coeff[1]; - return return_val; -} - -//---------------------------------------------------------------------------// -template -void testEval() -{ - // Test fixture - const int num_space_dim = NumSpaceDim; - const int num_coeff = 2 * (num_space_dim + 1); - const int integration_order = 1; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - - const int num_coord = test_fixture.cell_topo->getNodeCount(); - - // Set non-trivial coordinates for the degree of freedom - Kokkos::View x( - "coordinate", num_space_dim, num_coord); - auto basis_coord_view - = test_fixture.workset->bases[0]->basis_coordinates.get_static_view(); - auto basis_coord_mirror = Kokkos::create_mirror(basis_coord_view); - for (int dim = 0; dim < num_space_dim; dim++) - { - for (int basis = 0; basis < num_coord; basis++) - { - // random coordinate assigned - x(dim, basis) = (0.5 + dim * 4.5) * (basis + 1); - basis_coord_mirror(0, basis, dim) = x(dim, basis); - } - } - Kokkos::deep_copy(basis_coord_view, basis_coord_mirror); - - // Create mms evaluator. - auto mms_eval = Teuchos::rcp( - new InitialCondition:: - MethodManufacturedSolution( - *test_fixture.basis_ir_layout->getBasis())); - test_fixture.registerEvaluator(mms_eval); - - // Coefficients to be used with the above function to compute reference - // values for each primitive variable. They are hard coded in the source - // code - Kokkos::Array phi_coeff; - Kokkos::Array, num_space_dim> vel_coeff; - Kokkos::Array T_coeff; - - phi_coeff[0] = 0.0125; - phi_coeff[1] = 1.0; - phi_coeff[2] = 0.25; - phi_coeff[3] = 0.5; - phi_coeff[4] = 0.125; - phi_coeff[5] = 0.0; - - vel_coeff[0][0] = 0.0125; - vel_coeff[0][1] = 0.08; - vel_coeff[0][2] = 0.125; - vel_coeff[0][3] = 0.0; - vel_coeff[0][4] = 0.125; - vel_coeff[0][5] = 0.25; - - vel_coeff[1][0] = 0.0375; - vel_coeff[1][1] = 1.125; - vel_coeff[1][2] = 0.25; - vel_coeff[1][3] = 0.0; - vel_coeff[1][4] = 0.375; - vel_coeff[1][5] = 0.5; - - T_coeff[0] = 0.0625; - T_coeff[1] = 1.0; - T_coeff[2] = 0.375; - T_coeff[3] = 0.25; - T_coeff[4] = 0.25; - T_coeff[5] = 0.5; - - if (num_space_dim == 3) - { - phi_coeff[6] = 0.375; - phi_coeff[7] = 1.0; - - vel_coeff[0][6] = 0.25; - vel_coeff[0][7] = 0.0; - - vel_coeff[1][6] = 0.25; - vel_coeff[1][7] = 0.5; - - vel_coeff[2][0] = 0.025; - vel_coeff[2][1] = 0.0; - vel_coeff[2][2] = 0.125; - vel_coeff[2][3] = 1.0; - vel_coeff[2][4] = 0.25; - vel_coeff[2][5] = 0.25; - vel_coeff[2][6] = 0.25; - vel_coeff[2][7] = 0.25; - - T_coeff[6] = 0.125; - T_coeff[7] = 0.5; - } - - // Add required test fields. - test_fixture.registerTestField(mms_eval->_lagrange_pressure); - for (int dim = 0; dim < num_space_dim; ++dim) - test_fixture.registerTestField(mms_eval->_velocity[dim]); - test_fixture.registerTestField(mms_eval->_temperature); - - // Evaluate MMS IC. - test_fixture.evaluate(); - - // Check the IC value for all scalars. - const auto phi_result = test_fixture.getTestFieldData( - mms_eval->_lagrange_pressure); - const auto velocity_0_result - = test_fixture.getTestFieldData(mms_eval->_velocity[0]); - const auto velocity_1_result - = test_fixture.getTestFieldData(mms_eval->_velocity[1]); - const auto temperature_result - = test_fixture.getTestFieldData(mms_eval->_temperature); - - // Assert number of points - EXPECT_EQ(num_coord, phi_result.extent(1)); - EXPECT_EQ(num_coord, velocity_0_result.extent(1)); - EXPECT_EQ(num_coord, velocity_1_result.extent(1)); - EXPECT_EQ(num_coord, temperature_result.extent(1)); - - // Loop over number of points and compare against reference values - int num_point = phi_result.extent(1); - for (int d = 0; d < num_point; ++d) - { - auto x_subview = Kokkos::subview(x, Kokkos::ALL(), d); - - // Compute reference values - const double phi_ref - = set_function(phi_coeff, x_subview); - const double u_ref - = set_function(vel_coeff[0], x_subview); - const double v_ref - = set_function(vel_coeff[1], x_subview); - const double T_ref - = set_function(T_coeff, x_subview); - - // Assert - EXPECT_DOUBLE_EQ(phi_ref, fieldValue(phi_result, 0, d)); - EXPECT_DOUBLE_EQ(u_ref, fieldValue(velocity_0_result, 0, d)); - EXPECT_DOUBLE_EQ(v_ref, fieldValue(velocity_1_result, 0, d)); - EXPECT_DOUBLE_EQ(T_ref, fieldValue(temperature_result, 0, d)); - } - - if (num_space_dim == 3) - { - const auto velocity_2_result - = test_fixture.getTestFieldData(mms_eval->_velocity[2]); - EXPECT_EQ(num_coord, velocity_2_result.extent(1)); - - for (int d = 0; d < num_point; ++d) - { - auto x_subview = Kokkos::subview(x, Kokkos::ALL(), d); - const double w_ref = set_function( - vel_coeff[2], x_subview); - - // Assert - EXPECT_DOUBLE_EQ(w_ref, fieldValue(velocity_2_result, 0, d)); - } - } -} - -//---------------------------------------------------------------------------// -// Method of Manufactured Solution IC -// Residual -TEST(MethodManufacturedSolutionIC2D, residual_mms_ic_test) -{ - testEval(); -} - -// Jacobian -TEST(MethodManufacturedSolutionIC2D, jacobian_mms_ic_test) -{ - testEval(); -} - -TEST(MethodManufacturedSolutionIC3D, residual_mms_ic_test) -{ - testEval(); -} - -// Jacobian -TEST(MethodManufacturedSolutionIC3D, jacobian_mms_ic_test) -{ - testEval(); -} -//---------------------------------------------------------------------------// -} // end namespace Test -} // end namespace VertexCFD diff --git a/src/linear_solvers/VertexCFD_LinearSolvers_CusolverGLU.cpp b/src/linear_solvers/VertexCFD_LinearSolvers_CusolverGLU.cpp deleted file mode 100644 index ecaa8cf..0000000 --- a/src/linear_solvers/VertexCFD_LinearSolvers_CusolverGLU.cpp +++ /dev/null @@ -1,325 +0,0 @@ -#include "VertexCFD_LinearSolvers_CusolverGLU.hpp" - -#include - -#include -#include - -namespace VertexCFD -{ -namespace LinearSolvers -{ -//---------------------------------------------------------------------------// -// Constructor -//---------------------------------------------------------------------------// -CusolverGLU::CusolverGLU(const Teuchos::ParameterList& params) - : _matrix_set(false) - , _initialized(false) - , _computed(false) -{ - // Get factorization parameters - _pivot_threshold = 0.01; - if (params.isType("Pivot Threshold")) - _pivot_threshold = params.get("Pivot Threshold"); - - // Reorder parameter, 0 is no reordering, 1 uses METIS - _reorder = 1; - if (params.isType("Reorder")) - _reorder = params.get("Reorder"); -} - -//---------------------------------------------------------------------------// -// Change matrix -//---------------------------------------------------------------------------// -void CusolverGLU::setMatrix(Teuchos::RCP> A) -{ - _A = A; - - // Host-side allocation for CRS data - _A_rowptr_host.clear(); - _A_colind_host.clear(); - _A_values_host.clear(); - - // Extract matrix data for factorizations - int local_rows = this->num_local_rows(); - std::size_t num_entries; - std::size_t max_entries = this->max_entries_per_row(); - Tpetra::RowMatrix<>::nonconst_local_inds_host_view_type row_inds( - "row_indices", max_entries); - Tpetra::RowMatrix<>::nonconst_values_host_view_type row_vals("row_values", - max_entries); - _A_rowptr_host.push_back(0); - for (int row = 0; row < local_rows; ++row) - { - num_entries = _A->getNumEntriesInLocalRow(row); - _A->getLocalRowCopy(row, row_inds, row_vals, num_entries); - _A_colind_host.insert(_A_colind_host.end(), - row_inds.data(), - row_inds.data() + num_entries); - _A_values_host.insert(_A_values_host.end(), - row_vals.data(), - row_vals.data() + num_entries); - _A_rowptr_host.push_back(_A_rowptr_host.back() + num_entries); - } - - // Copy data to device - _A_rowptr = _A_rowptr_host; - _A_colind = _A_colind_host; - _A_values = _A_values_host; - - _matrix_set = true; - _computed = false; -} - -//---------------------------------------------------------------------------// -// Initialize preconditioner -//---------------------------------------------------------------------------// -void CusolverGLU::initialize() -{ - assert(_matrix_set); - assert(!_computed); - - if (_initialized) - { - return; - } - - // In future Trilinos versions (13.4+), it might be possible to access the - // internal matrix data on both host and device without making extra - // copies. For now, the only way to get the data is to extract the values - // row-by-row on the host and then explicitly copy to the device. - - int num_rows = this->num_local_rows(); - int A_nnz = this->num_local_entries(); - - cusolverStatus_t stat; - cusolverSpCreate(&_handle); - cusparseCreateMatDescr(&_A_descr); - cusparseSetMatType(_A_descr, CUSPARSE_MATRIX_TYPE_GENERAL); - cusparseSetMatIndexBase(_A_descr, CUSPARSE_INDEX_BASE_ZERO); - - cusolverSpCreateCsrluInfoHost(&_lu_info); - - // Allocate pivot data - std::vector P(num_rows); - std::vector Q(num_rows); - - stat = cusolverSpXcsrluConfigHost(_lu_info, _reorder); - check_status(stat, "cuSOLVER CSR config"); - - // Host-side analysis - stat = cusolverSpXcsrluAnalysisHost(_handle, - num_rows, - A_nnz, - _A_descr, - _A_rowptr_host.data(), - _A_colind_host.data(), - _lu_info); - check_status(stat, "cuSOLVER host analysis"); - - size_t internalDataInBytes; - size_t workspaceInBytes; - stat = cusolverSpDcsrluBufferInfoHost(_handle, - num_rows, - A_nnz, - _A_descr, - _A_values_host.data(), - _A_rowptr_host.data(), - _A_colind_host.data(), - _lu_info, - &internalDataInBytes, - &workspaceInBytes); - check_status(stat, "cuSOLVER buffer info"); - - std::vector h_work(workspaceInBytes); - stat = cusolverSpDcsrluFactorHost(_handle, - num_rows, - A_nnz, - _A_descr, - _A_values_host.data(), - _A_rowptr_host.data(), - _A_colind_host.data(), - _lu_info, - _pivot_threshold, - h_work.data()); - check_status(stat, "cuSOLVER host factorization"); - - // Prepare to extract M (compressed LU factors) - cusolverSpCreateGluInfo(&_M_info); - cusparseCreateMatDescr(&_M_descr); - cusparseSetMatType(_M_descr, CUSPARSE_MATRIX_TYPE_GENERAL); - cusparseSetMatIndexBase(_M_descr, CUSPARSE_INDEX_BASE_ZERO); - - int M_nnz; - stat = cusolverSpXcsrluNnzMHost(_handle, &M_nnz, _lu_info); - assert(CUSOLVER_STATUS_SUCCESS == stat); - check_status(stat, "cuSOLVER CSR nnz"); - - std::vector M_rowptr(num_rows + 1); - std::vector M_colind(M_nnz); - - stat = cusolverSpDcsrluExtractMHost(_handle, - P.data(), - Q.data(), - _M_descr, - NULL, /* csrValM */ - M_rowptr.data(), - M_colind.data(), - _lu_info, - h_work.data()); - check_status(stat, "cuSOLVER CSR extract"); - - // Set up GLU using host data - stat = cusolverSpDgluSetup(_handle, - num_rows, - A_nnz, - _A_descr, - _A_rowptr_host.data(), - _A_colind_host.data(), - P.data(), - Q.data(), - M_nnz, - _M_descr, - M_rowptr.data(), - M_colind.data(), - _M_info); - check_status(stat, "GLU setup"); - - size_t buffer_size; - stat = cusolverSpDgluBufferSize(_handle, _M_info, &buffer_size); - check_status(stat, "GLU buffer allocation"); - - _work.resize(buffer_size); - stat = cusolverSpDgluAnalysis(_handle, _M_info, _work.data().get()); - check_status(stat, "GLU analysis"); - - _initialized = true; -} - -//---------------------------------------------------------------------------// -// Compute preconditioner -//---------------------------------------------------------------------------// -void CusolverGLU::compute() -{ - assert(_matrix_set); - assert(_initialized); - assert(!_computed); - - int num_rows = this->num_local_rows(); - int A_nnz = this->num_local_entries(); - - cusolverStatus_t stat; - stat = cusolverSpDgluReset(_handle, - num_rows, - A_nnz, - _A_descr, - _A_values.data().get(), - _A_rowptr.data().get(), - _A_colind.data().get(), - _M_info); - check_status(stat, "GLU reset"); - - stat = cusolverSpDgluFactor(_handle, _M_info, _work.data().get()); - check_status(stat, "GLU refactor"); - - _computed = true; -} - -//---------------------------------------------------------------------------// -// Apply preconditioner -//---------------------------------------------------------------------------// -void CusolverGLU::solve(const Tpetra::MultiVector<>& b, - Tpetra::MultiVector<>& x) -{ - cudaDeviceSynchronize(); - - assert(_initialized); - assert(_computed); - - int num_rows = this->num_local_rows(); - int A_nnz = this->num_local_entries(); - - // Get Kokkos Views - auto b_view = b.getLocalViewDevice(Tpetra::Access::ReadOnly); - auto x_view = x.getLocalViewDevice(Tpetra::Access::OverwriteAll); - - cusolverStatus_t stat; - int ite_refine_succ = 0; - double r_nrminf; - stat = cusolverSpDgluSolve(_handle, - num_rows, - A_nnz, - _A_descr, - _A_values.data().get(), - _A_rowptr.data().get(), - _A_colind.data().get(), - b_view.data(), - x_view.data(), - &ite_refine_succ, - &r_nrminf, - _M_info, - _work.data().get()); - check_status(stat, "GLU solve"); - if (ite_refine_succ != 1) - { - std::stringstream ss; - ss << "GLU iterative refinement failed with status " << ite_refine_succ; - throw std::runtime_error(ss.str()); - } -} - -//---------------------------------------------------------------------------// -// Apply preconditioner -//---------------------------------------------------------------------------// -void CusolverGLU::check_status(cusolverStatus_t stat, - const std::string& msg) const -{ - cudaDeviceSynchronize(); - if (stat == CUSOLVER_STATUS_ALLOC_FAILED) - { - std::stringstream ss; - ss << msg << " failed to allocate device memory" << stat; - throw std::runtime_error(ss.str()); - } - else if (stat != CUSOLVER_STATUS_SUCCESS) - { - std::stringstream ss; - ss << msg << " failed with status " << stat; - throw std::runtime_error(ss.str()); - } -} - -//---------------------------------------------------------------------------// -// Trilinos interface functions that vary with versioning -//---------------------------------------------------------------------------// -int CusolverGLU::num_local_rows() const -{ -#if TRILINOS_MAJOR_MINOR_VERSION >= 130400 - return _A->getLocalNumRows(); -#else - return _A->getNodeNumRows(); -#endif -} - -std::size_t CusolverGLU::num_local_entries() const -{ -#if TRILINOS_MAJOR_MINOR_VERSION >= 130400 - return _A->getLocalNumEntries(); -#else - return _A->getNodeNumEntries(); -#endif -} - -std::size_t CusolverGLU::max_entries_per_row() const -{ -#if TRILINOS_MAJOR_MINOR_VERSION >= 130400 - return _A->getLocalMaxNumRowEntries(); -#else - return _A->getNodeMaxNumRowEntries(); -#endif -} - -//---------------------------------------------------------------------------// - -} // namespace LinearSolvers -} // namespace VertexCFD diff --git a/src/linear_solvers/VertexCFD_LinearSolvers_CusolverGLU.hpp b/src/linear_solvers/VertexCFD_LinearSolvers_CusolverGLU.hpp deleted file mode 100644 index e09b547..0000000 --- a/src/linear_solvers/VertexCFD_LinearSolvers_CusolverGLU.hpp +++ /dev/null @@ -1,101 +0,0 @@ -#ifndef VERTEXCFD_LINEARSOLVERS_CUSOLVERGLU_HPP -#define VERTEXCFD_LINEARSOLVERS_CUSOLVERGLU_HPP - -#include "VertexCFD_LinearSolvers_CusolverNonpublic.hpp" -#include "VertexCFD_LinearSolvers_LocalDirectSolver.hpp" - -#include -#include -#include - -#include -#include -#include - -namespace VertexCFD -{ -namespace LinearSolvers -{ -//---------------------------------------------------------------------------// -// Local preconditioner/solver using cuSOLVER GLU for on-GPU solves. -// This class uses the nonpublic GLU solver from the NVIDIA cuSOLVER library. -// This is a refactor-based solver where an initial factorization is performed -// on the host (using a corresponding cuSOLVER routine) and subsequent -// factorizations are performed on the GPU. The initial host-side -// factorization can be reused across multiple nonlinear iterations within a -// time step as well as multiple time steps. This process assumes that -// 1) the sparsity pattern of the matrix does not change, and 2) the locations -// of any necessary pivoting that are determined by the host-side -// factorization remain valid for all subsequent GPU solves. Effectively, -// the GPU solves are utilizing static pivoting. The solver does not currently -// attempt to recover if a factorization breaks down due to pivots becoming -// stale/invalid. -//---------------------------------------------------------------------------// -class CusolverGLU : public LocalDirectSolver -{ - private: - // >>> DATA - - // Matrix - Teuchos::RCP> _A; - - // Device-side matrix data - thrust::device_vector _A_rowptr; - thrust::device_vector _A_colind; - thrust::device_vector _A_values; - - // Host-side matrix data - std::vector _A_rowptr_host; - std::vector _A_colind_host; - std::vector _A_values_host; - - // Pivoting data - double _pivot_threshold; - int _reorder; - - // Scratch space - thrust::device_vector _work; - - // Persistent Cusparse info - cusolverSpHandle_t _handle; - csrluInfoHost_t _lu_info; - csrgluInfo_t _M_info; - cusparseMatDescr_t _A_descr, _M_descr; - - // Status flags - bool _matrix_set; - bool _initialized; - bool _computed; - - public: - // Constructor - CusolverGLU(const Teuchos::ParameterList& params); - - // Update internal matrix - void setMatrix(Teuchos::RCP> A) override; - - // Inherited interface from LocalDirectSolver - void initialize() override; - void compute() override; - - // Inherited interface from LocalDirectSolver - void - solve(const Tpetra::MultiVector<>& b, Tpetra::MultiVector<>& x) override; - - private: - // Check status condition and throw exception if failed - void - check_status(cusolverStatus_t stat, const std::string& identifier) const; - - // Get number of rows in matrix - int num_local_rows() const; - std::size_t num_local_entries() const; - std::size_t max_entries_per_row() const; -}; - -//---------------------------------------------------------------------------// - -} // namespace LinearSolvers -} // namespace VertexCFD - -#endif // VERTEXCFD_LINEARSOLVERS_CUSOLVERGLU_HPP diff --git a/src/linear_solvers/VertexCFD_LinearSolvers_CusolverNonpublic.hpp b/src/linear_solvers/VertexCFD_LinearSolvers_CusolverNonpublic.hpp deleted file mode 100644 index 4191be0..0000000 --- a/src/linear_solvers/VertexCFD_LinearSolvers_CusolverNonpublic.hpp +++ /dev/null @@ -1,116 +0,0 @@ -#ifndef VERTEXCFD_LINEARSOLVERS_CUSOLVERNONPUBLIC_HPP -#define VERTEXCFD_LINEARSOLVERS_CUSOLVERNONPUBLIC_HPP - -#include -#include -#include -#include - -#include - -#if defined(__cplusplus) -extern "C" -{ -#endif /* __cplusplus */ - -/* - * Prototypes not in public header file - */ -cusolverStatus_t CUSOLVERAPI cusolverSpXcsrluConfigHost(csrluInfoHost_t info, - int reorder /* 0 or 1 - */ -); - -cusolverStatus_t CUSOLVERAPI cusolverSpDcsrlucondHost(csrluInfoHost_t info, - double* max_diag_u_host, - double* min_diag_u_host, - double* max_l_host); - -cusolverStatus_t CUSOLVERAPI cusolverSpXcsrluNnzMHost(cusolverSpHandle_t handle, - int* nnz_m_ref_host, - csrluInfoHost_t info); - -cusolverStatus_t CUSOLVERAPI -cusolverSpDcsrluExtractMHost(cusolverSpHandle_t handle, - int* P_host, - int* Q_host, - const cusparseMatDescr_t M_descr, - double* M_values_host, - int* M_rowptr_host, - int* M_colind_host, - csrluInfoHost_t info, - void* work_host); - -struct csrgluInfo; -typedef struct csrgluInfo* csrgluInfo_t; - -cusolverStatus_t CUSOLVERAPI cusolverSpCreateGluInfo(csrgluInfo_t* info); - -cusolverStatus_t CUSOLVERAPI cusolverSpDestroyGluInfo(csrgluInfo_t info); - -cusolverStatus_t CUSOLVERAPI -cusolverSpDgluSetup(cusolverSpHandle_t handle, - int m, - int nnzA, - const cusparseMatDescr_t A_descr, - const int* A_rowptr_host, - const int* A_colind_host, - const int* P_host, - const int* Q_host, - int M_nnz, - const cusparseMatDescr_t M_descr, - const int* M_rowptr_host, - const int* M_colind_host, - csrgluInfo_t info); - -cusolverStatus_t CUSOLVERAPI cusolverSpDgluBufferSize( - cusolverSpHandle_t handle, csrgluInfo_t info, size_t* p_buffer_size_host); - -cusolverStatus_t CUSOLVERAPI cusolverSpDgluAnalysis(cusolverSpHandle_t handle, - csrgluInfo_t info, - void* work); - -cusolverStatus_t CUSOLVERAPI cusolverSpDgluReset(cusolverSpHandle_t handle, - int num_rows, - int A_nnz, - const cusparseMatDescr_t A_descr, - const double* A_values, - const int* A_rowptr, - const int* A_colind, - csrgluInfo_t info); - -cusolverStatus_t CUSOLVERAPI cusolverSpDgluFactor(cusolverSpHandle_t handle, - csrgluInfo_t info, - void* work); - -cusolverStatus_t CUSOLVERAPI cusolverSpDgluSolve(cusolverSpHandle_t handle, - int num_rows, - int A_nnz, - const cusparseMatDescr_t A_descr, - const double* A_values, - const int* A_rowptr, - const int* A_colind, - const double* b, /* right hand - side */ - double* x, /* left hand side - */ - int* ite_refine_succ_host, - double* r_nrminf_ptr_host, - csrgluInfo_t info, - void* work); - -cusolverStatus_t CUSOLVERAPI cusolverSpDnrminf(cusolverSpHandle_t handle, - int n, - const double* x, - double* result_host, /* |x|_inf, - * host - */ - void* work /* at least 8192 - bytes */ -); - -#if defined(__cplusplus) -} -#endif /* __cplusplus */ - -#endif // VERTEXCFD_LINEARSOLVERS_CUSOLVERNONPUBLIC_CUH diff --git a/src/linear_solvers/VertexCFD_LinearSolvers_LocalDirectSolver.hpp b/src/linear_solvers/VertexCFD_LinearSolvers_LocalDirectSolver.hpp deleted file mode 100644 index fb90db4..0000000 --- a/src/linear_solvers/VertexCFD_LinearSolvers_LocalDirectSolver.hpp +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef VERTEXCFD_LINEARSOLVERS_LOCALDIRECTSOLVER_HPP -#define VERTEXCFD_LINEARSOLVERS_LOCALDIRECTSOLVER_HPP - -#include -#include -#include -#include - -#include - -namespace VertexCFD -{ -namespace LinearSolvers -{ -//---------------------------------------------------------------------------// -// Base class for solvers performing local (non-MPI) sparse direct solves -//---------------------------------------------------------------------------// -class LocalDirectSolver -{ - public: - // Constructor - LocalDirectSolver() = default; - - // Set or change local matrix - virtual void setMatrix(Teuchos::RCP> A) = 0; - - // Perform one-time initialization (e.g., symbolic factorization) - virtual void initialize() = 0; - - // Compute factorization (every time matrix changes) - virtual void compute() = 0; - - // Given RHS vector b, solve for x - virtual void solve(const Tpetra::MultiVector<>& b, Tpetra::MultiVector<>& x) - = 0; -}; - -//---------------------------------------------------------------------------// - -} // namespace LinearSolvers -} // namespace VertexCFD - -#endif // VERTEXCFD_LINEARSOLVERS_LOCALDIRECTSOLVER_HPP diff --git a/src/linear_solvers/VertexCFD_LinearSolvers_LocalSolverFactory.cpp b/src/linear_solvers/VertexCFD_LinearSolvers_LocalSolverFactory.cpp deleted file mode 100644 index b2926e9..0000000 --- a/src/linear_solvers/VertexCFD_LinearSolvers_LocalSolverFactory.cpp +++ /dev/null @@ -1,54 +0,0 @@ - -#include "VertexCFD_LinearSolvers_LocalSolverFactory.hpp" - -#ifdef __CUDACC__ -#include "VertexCFD_LinearSolvers_CusolverGLU.hpp" -#endif -#ifdef HAVE_SUPERLUDIST -#include "VertexCFD_LinearSolvers_SuperLU.hpp" -#endif - -namespace VertexCFD -{ -namespace LinearSolvers -{ -//---------------------------------------------------------------------------// -// Constructor -//---------------------------------------------------------------------------// -std::shared_ptr -LocalSolverFactory::buildSolver(const Teuchos::ParameterList& params) -{ - // Get solver name, default to Cusolver GLU - std::string name = "Cusolver GLU"; - if (params.isType("Local Solver")) - name = params.get("Local Solver"); - - if (name == "Cusolver GLU") - { -#ifdef __CUDACC__ - return std::make_shared(params); -#else - throw std::runtime_error( - "Solver option `Cusolver GLU` is not available because CUDA is " - "not enabled."); -#endif - } - else if (name == "SuperLU") -#ifdef HAVE_SUPERLUDIST - return std::make_shared(); -#else - throw std::runtime_error( - "Solver option `SuperLU` is not available because SUPERLUDIST is" - "not enabled."); -#endif - else - { - std::string msg = "Unrecognized local solver " + name; - throw std::runtime_error(msg); - } -} - -//---------------------------------------------------------------------------// - -} // namespace LinearSolvers -} // namespace VertexCFD diff --git a/src/linear_solvers/VertexCFD_LinearSolvers_LocalSolverFactory.hpp b/src/linear_solvers/VertexCFD_LinearSolvers_LocalSolverFactory.hpp deleted file mode 100644 index 6fc9185..0000000 --- a/src/linear_solvers/VertexCFD_LinearSolvers_LocalSolverFactory.hpp +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef VERTEXCFD_LINEARSOLVERS_LOCALSOLVERFACTORY_HPP -#define VERTEXCFD_LINEARSOLVERS_LOCALSOLVERFACTORY_HPP - -#include "VertexCFD_LinearSolvers_LocalDirectSolver.hpp" - -#include - -namespace VertexCFD -{ -namespace LinearSolvers -{ -//---------------------------------------------------------------------------// -// Class for managing construction of LocalDirectSolver subclasses -//---------------------------------------------------------------------------// -class LocalSolverFactory -{ - public: - // Prevent construction - LocalSolverFactory() = delete; - - // Build solver from solver name - static std::shared_ptr - buildSolver(const Teuchos::ParameterList& params); -}; - -//---------------------------------------------------------------------------// - -} // namespace LinearSolvers -} // namespace VertexCFD - -#endif // VERTEXCFD_LINEARSOLVERS_LOCALSOLVERFACTORY_HPP diff --git a/src/linear_solvers/VertexCFD_LinearSolvers_Preconditioner.cpp b/src/linear_solvers/VertexCFD_LinearSolvers_Preconditioner.cpp deleted file mode 100644 index 8b4a989..0000000 --- a/src/linear_solvers/VertexCFD_LinearSolvers_Preconditioner.cpp +++ /dev/null @@ -1,138 +0,0 @@ -#include "VertexCFD_LinearSolvers_Preconditioner.hpp" -#include "VertexCFD_LinearSolvers_LocalSolverFactory.hpp" - -#include -#include -#include - -namespace VertexCFD -{ -namespace LinearSolvers -{ -//---------------------------------------------------------------------------// -// Constructor -//---------------------------------------------------------------------------// -Preconditioner::Preconditioner() - : _initialized(false) - , _computed(false) - , _num_initialize(0) - , _num_compute(0) - , _num_apply(0) - , _init_time(0.0) - , _compute_time(0.0) - , _apply_time(0.0) -{ -} - -//---------------------------------------------------------------------------// -// Set parameters governing solve and construct local solver -//---------------------------------------------------------------------------// -void Preconditioner::setParameters(const Teuchos::ParameterList& params) -{ - _local_solver = LocalSolverFactory::buildSolver(params); -} - -//---------------------------------------------------------------------------// -// Change matrix -//---------------------------------------------------------------------------// -void Preconditioner::setMatrix(const Teuchos::RCP>& A) -{ - auto timer = Teuchos::TimeMonitor::getNewTimer(_set_label); - Teuchos::TimeMonitor tm(*timer); - - // Depending on order of construction of AdditiveSchwarz, the matrix - // may be null on the first call to setMatrix. In this case, setMatrix - // will be called again later. - _A = A; - if (!_A) - return; - - _local_solver->setMatrix(_A); - _computed = false; -} - -//---------------------------------------------------------------------------// -// Initialize preconditioner (symbolic factorization) -//---------------------------------------------------------------------------// -void Preconditioner::initialize() -{ - auto timer = Teuchos::TimeMonitor::getNewTimer(_init_label); - Teuchos::TimeMonitor tm(*timer); - double start_time = Teuchos::Time::wallTime(); - - _local_solver->initialize(); - _initialized = true; - _num_initialize++; - _init_time += (Teuchos::Time::wallTime() - start_time); -} - -//---------------------------------------------------------------------------// -// Compute preconditioner (numeric factorization) -//---------------------------------------------------------------------------// -void Preconditioner::compute() -{ - auto timer = Teuchos::TimeMonitor::getNewTimer(_compute_label); - Teuchos::TimeMonitor tm(*timer); - double start_time = Teuchos::Time::wallTime(); - - _local_solver->compute(); - _computed = true; - _num_compute++; - _compute_time += (Teuchos::Time::wallTime() - start_time); -} - -//---------------------------------------------------------------------------// -// Apply preconditioner: y = alpha * P * x + beta * y -//---------------------------------------------------------------------------// -void Preconditioner::apply(const Tpetra::MultiVector<>& x, - Tpetra::MultiVector<>& y, - Teuchos::ETransp mode, - double alpha, - double beta) const -{ - auto timer = Teuchos::TimeMonitor::getNewTimer(_apply_label); - Teuchos::TimeMonitor tm(*timer); - double start_time = Teuchos::Time::wallTime(); - - _num_apply++; - - if (mode != Teuchos::NO_TRANS) - { - throw std::logic_error( - "VertexCFD preconditioner does not support apply with transpose"); - } - - // Use Belos class to perform common operations on multivectors - using MV_Traits = Belos::MultiVecTraits>; - - assert(MV_Traits::GetNumberVecs(x) == MV_Traits::GetNumberVecs(y)); - - // If alpha is zero, don't apply operator, just scale and return - if (alpha == Teuchos::ScalarTraits::zero()) - { - MV_Traits::MvScale(y, beta); - _apply_time += (Teuchos::Time::wallTime() - start_time); - return; - } - - // If beta is zero, do apply and scale - if (beta == Teuchos::ScalarTraits::zero()) - { - _local_solver->solve(x, y); - MV_Traits::MvScale(y, alpha); - } - else - { - // For nonzero beta, need temporary vector - Teuchos::RCP> z = MV_Traits::Clone(x, 1); - _local_solver->solve(x, *z); - - MV_Traits::MvAddMv(alpha, *z, beta, y, y); - } - _apply_time += (Teuchos::Time::wallTime() - start_time); -} - -//---------------------------------------------------------------------------// - -} // namespace LinearSolvers -} // namespace VertexCFD diff --git a/src/linear_solvers/VertexCFD_LinearSolvers_Preconditioner.hpp b/src/linear_solvers/VertexCFD_LinearSolvers_Preconditioner.hpp deleted file mode 100644 index 910e554..0000000 --- a/src/linear_solvers/VertexCFD_LinearSolvers_Preconditioner.hpp +++ /dev/null @@ -1,105 +0,0 @@ -#ifndef VERTEXCFD_LINEARSOLVERS_PRECONDITIONER_HPP -#define VERTEXCFD_LINEARSOLVERS_PRECONDITIONER_HPP - -#include "VertexCFD_LinearSolvers_LocalDirectSolver.hpp" - -#include -#include -#include -#include -#include -#include - -#include - -namespace VertexCFD -{ -namespace LinearSolvers -{ -//---------------------------------------------------------------------------// -/* - * This class is the Trilinos (Ifpack2) interface for local domain - * preconditioners as part of an additive Schwarz type scheme. It is assumed - * that the matrix provided via the setMatrix method will only contain the - * _local_ matrix elements with no off-processor components. - * It implements the Ifpack2::Preconditioner interface, which allows it to - * be used as the local solver within an Ifpack2::AdditiveSchwarz instance. - * This class is only an interface -- the local solve itself is handled by - * a subclass of LocalDirectSolver and built by the LocalSolverFactory. This - * design prevents every local solver class (e.g., CuSOLVER, SuperLU) from - * having to re-implement the full API inherited from Ifpack2::Preconditioner. - */ -//---------------------------------------------------------------------------// -class Preconditioner - : public Ifpack2::Preconditioner<>, - public Ifpack2::Details::CanChangeMatrix> -{ - private: - using MV = Tpetra::MultiVector<>; - - // Local matrix - Teuchos::RCP> _A; - - // Implementation of local solve - std::shared_ptr _local_solver; - - // Tracking of calls and time to init, compute, apply - bool _initialized; - bool _computed; - int _num_initialize; - int _num_compute; - mutable int _num_apply; // Must be updated from within const "apply" - double _init_time; - double _compute_time; - mutable double _apply_time; - - // Timer labels - const std::string _set_label = "VertexCFD::Preconditioner::setMatrix"; - const std::string _init_label = "VertexCFD::Preconditioner::initialize"; - const std::string _compute_label = "VertexCFD::Preconditioner::compute"; - const std::string _apply_label = "VertexCFD::Preconditioner::apply"; - - public: - // Constructor - Preconditioner(); - - // Inherited API from Ifpack2::CanChangeMatrix - void setMatrix(const Teuchos::RCP>& A) override; - - // Inherited API from Ifpack2::Preconditioner - Teuchos::RCP> getMatrix() const override - { - return _A; - } - bool isInitialized() const override { return _initialized; } - bool isComputed() const override { return _computed; } - int getNumInitialize() const override { return _num_initialize; } - int getNumCompute() const override { return _num_compute; } - int getNumApply() const override { return _num_apply; } - double getInitializeTime() const override { return _init_time; } - double getComputeTime() const override { return _compute_time; } - double getApplyTime() const override { return _apply_time; } - Teuchos::RCP> getDomainMap() const override - { - return _A->getDomainMap(); - } - Teuchos::RCP> getRangeMap() const override - { - return _A->getRangeMap(); - } - void setParameters(const Teuchos::ParameterList& pl) override; - void initialize() override; - void compute() override; - void apply(const Tpetra::MultiVector<>& x, - Tpetra::MultiVector<>& y, - Teuchos::ETransp mode, - double alpha, - double beta) const override; -}; - -//---------------------------------------------------------------------------// - -} // namespace LinearSolvers -} // namespace VertexCFD - -#endif // VERTEXCFD_LINEARSOLVERS_PRECONDITIONER_HPP diff --git a/src/linear_solvers/VertexCFD_LinearSolvers_PreconditionerFactory.cpp b/src/linear_solvers/VertexCFD_LinearSolvers_PreconditionerFactory.cpp deleted file mode 100644 index e8dd6ad..0000000 --- a/src/linear_solvers/VertexCFD_LinearSolvers_PreconditionerFactory.cpp +++ /dev/null @@ -1,178 +0,0 @@ -#include "VertexCFD_LinearSolvers_PreconditionerFactory.hpp" -#include "VertexCFD_LinearSolvers_Preconditioner.hpp" - -#include -#include -#include -#include - -namespace VertexCFD -{ -namespace LinearSolvers -{ -//---------------------------------------------------------------------------// -// Determine if preconditioner is compatible with specified operator -//---------------------------------------------------------------------------// -bool PreconditionerFactory::isCompatible( - const Thyra::LinearOpSourceBase& fwd_op_src) const -{ - auto fwd_op = fwd_op_src.getOp(); - - auto thyra_tpetra_op = Teuchos::rcp_dynamic_cast< - const Thyra::TpetraLinearOp>(fwd_op); - if (Teuchos::is_null(thyra_tpetra_op)) - return false; - - auto tpetra_op = thyra_tpetra_op->getConstTpetraOperator(); - auto tpetra_row_mat - = Teuchos::rcp_dynamic_cast>(tpetra_op); - - return Teuchos::nonnull(tpetra_row_mat); -} - -//---------------------------------------------------------------------------// -// Construct (but do not initialize) preconditioner -//---------------------------------------------------------------------------// -Teuchos::RCP> -PreconditionerFactory::createPrec() const -{ - return Teuchos::rcp(new Thyra::DefaultPreconditioner()); -} - -//---------------------------------------------------------------------------// -// Initialize preconditioner -//---------------------------------------------------------------------------// -void PreconditionerFactory::initializePrec( - const Teuchos::RCP>& fwd_op_src, - Thyra::PreconditionerBase* prec_op, - const Thyra::ESupportSolveUse /* not used */) const - -{ - // - // Extract raw Tpetra matrix - // - - using RowMatrix = Tpetra::RowMatrix<>; - - auto fwd_op = fwd_op_src->getOp(); - auto thyra_tpetra_op = Teuchos::rcp_dynamic_cast< - const Thyra::TpetraLinearOp>(fwd_op); - auto tpetra_op = thyra_tpetra_op->getConstTpetraOperator(); - auto tpetra_row_mat = Teuchos::rcp_dynamic_cast(tpetra_op); - - // Build Additive Schwarz preconditioner - if (!_schwarz) - { - // Build "outer" preconditiner - _schwarz = Teuchos::rcp( - new Ifpack2::AdditiveSchwarz(tpetra_row_mat)); - _schwarz->setParameters(*_params); - - // Build "inner" preconditioner and compute - auto inner_prec_params = Teuchos::sublist( - _params, "schwarz: inner preconditioner parameters"); - auto inner_prec = Teuchos::rcp(new Preconditioner()); - inner_prec->setParameters(*inner_prec_params); - _schwarz->setInnerPreconditioner(inner_prec); - _schwarz->initialize(); - _schwarz->compute(); - - // Wrap additive Schwarz into a Thyra::Preconditioner - auto thyra_schwarz - = Thyra::createLinearOp(_schwarz); - - // Cast input arg to Thyra::DefaultPreconditioner and set operator - auto* default_prec - = dynamic_cast*>(prec_op); - default_prec->initializeUnspecified(thyra_schwarz); - } - else - { - _schwarz->setMatrix(tpetra_row_mat); - _schwarz->initialize(); - _schwarz->compute(); - return; - } -} - -//---------------------------------------------------------------------------// -// Uninitialize preconditioner -//---------------------------------------------------------------------------// -void PreconditionerFactory::uninitializePrec( - Thyra::PreconditionerBase*, - Teuchos::RCP>*, - Thyra::ESupportSolveUse*) const -{ -} - -//---------------------------------------------------------------------------// -// Set parameters -//---------------------------------------------------------------------------// -void PreconditionerFactory::setParameterList( - const Teuchos::RCP& params) -{ - _params = params; -} - -//---------------------------------------------------------------------------// -// Return ParameterList -//---------------------------------------------------------------------------// -Teuchos::RCP -PreconditionerFactory::getNonconstParameterList() -{ - return _params; -} - -//---------------------------------------------------------------------------// -// Clear existing parameters -//---------------------------------------------------------------------------// -Teuchos::RCP PreconditionerFactory::unsetParameterList() -{ - auto old_params = _params; - _params = Teuchos::null; - return old_params; -} - -//---------------------------------------------------------------------------// -// Get valid parameters -//---------------------------------------------------------------------------// -Teuchos::RCP -PreconditionerFactory::getValidParameters() const -{ - // Get parameters for AdditiveSchwarz first - auto params = Teuchos::rcp(new Teuchos::ParameterList()); - if (_schwarz) - { - *params = *(_schwarz->getValidParameters()); - } - else - { - Teuchos::RCP> row_mat; - auto schwarz = Teuchos::rcp( - new Ifpack2::AdditiveSchwarz>(row_mat)); - *params = *(schwarz->getValidParameters()); - } - - // Add VertexCFD preconditioner parameters for inner solver - auto inner_params - = Teuchos::sublist(params, "schwarz: inner preconditioner parameters"); - inner_params->set("Local Solver", "Cusolver GLU"); - inner_params->set("Reorder", 1); - inner_params->set("Pivot Threshold", 1.0e-2); - - return params; -} - -//---------------------------------------------------------------------------// - -} // namespace LinearSolvers -} // namespace VertexCFD diff --git a/src/linear_solvers/VertexCFD_LinearSolvers_PreconditionerFactory.hpp b/src/linear_solvers/VertexCFD_LinearSolvers_PreconditionerFactory.hpp deleted file mode 100644 index 7c23f48..0000000 --- a/src/linear_solvers/VertexCFD_LinearSolvers_PreconditionerFactory.hpp +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef VERTEXCFD_LINEARSOLVERS_PRECONDITIONERFACTORY_HPP -#define VERTEXCFD_LINEARSOLVERS_PRECONDITIONERFACTORY_HPP - -#include -#include -#include - -#include - -namespace VertexCFD -{ -namespace LinearSolvers -{ -//---------------------------------------------------------------------------// -// Build a VertexCFD Preconditioner. -// This class allows for the construction of "custom" preconditioners that -// aren't supported through Trilinos. -//---------------------------------------------------------------------------// -class PreconditionerFactory : public Thyra::PreconditionerFactoryBase -{ - public: - // Determine if preconditioner is compatible with specified operator - bool isCompatible( - const Thyra::LinearOpSourceBase& fwdOpSrc) const override; - - // Construct (but do not initialize) preconditioner - Teuchos::RCP> createPrec() const override; - - // Initialize preconditioner - void initializePrec( - const Teuchos::RCP>& fwdOpSrc, - Thyra::PreconditionerBase* precOp, - const Thyra::ESupportSolveUse supportSolveUse - = Thyra::SUPPORT_SOLVE_UNSPECIFIED) const override; - - void uninitializePrec( - Thyra::PreconditionerBase* prec, - Teuchos::RCP>* fwdOpSrc = NULL, - Thyra::ESupportSolveUse* supportSolveUse = NULL) const override; - - // - // Teuchos::ParameterListAcceptor API - // - void setParameterList( - const Teuchos::RCP& params) override; - Teuchos::RCP getNonconstParameterList() override; - Teuchos::RCP unsetParameterList() override; - - Teuchos::RCP - getValidParameters() const override; - - private: - Teuchos::RCP _params; - - mutable Teuchos::RCP>> _schwarz; -}; - -//---------------------------------------------------------------------------// - -} // namespace LinearSolvers -} // namespace VertexCFD - -#endif // VERTEXCFD_LINEARSOLVERS_PRECONDITIONERFACTORY_HPP diff --git a/src/linear_solvers/VertexCFD_LinearSolvers_SuperLU.cpp b/src/linear_solvers/VertexCFD_LinearSolvers_SuperLU.cpp deleted file mode 100644 index 4026593..0000000 --- a/src/linear_solvers/VertexCFD_LinearSolvers_SuperLU.cpp +++ /dev/null @@ -1,236 +0,0 @@ -#include "VertexCFD_LinearSolvers_SuperLU.hpp" - -#include - -#include -#include - -namespace VertexCFD -{ -namespace LinearSolvers -{ -//---------------------------------------------------------------------------// -// Constructor -//---------------------------------------------------------------------------// -SuperLUSolver::SuperLUSolver() - : _matrix_set(false) - , _initialized(false) - , _computed(false) - , _factored(false) -{ - // setup grid 1 x 1 x 1 for single task MPI solve - superlu_gridinit(MPI_COMM_SELF, 1, 1, &_grid); - - // set SuperLU solver options - set_default_options_dist(&_options); - //_options.Algo3d = YES; - // 0: turn off row permutation - _options.RowPerm = (rowperm_t)0; - // 4: Use METIS ordering on A'+A - _options.ColPerm = (colperm_t)4; - - _options.IterRefine = NOREFINE; - _options.PrintStat = NO; - - // print out SuperLU version - int comm_rank; - MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank); - if (comm_rank == 0) - { - int v_major, v_minor, v_bugfix; - superlu_dist_GetVersionNumber(&v_major, &v_minor, &v_bugfix); - std::cout << "Uses SuperLU version " << v_major << "." << v_minor - << "." << v_bugfix << std::endl; - print_options_dist(&_options); - fflush(stdout); - } -} - -SuperLUSolver::~SuperLUSolver() -{ - Destroy_CompRowLoc_Matrix_dist(&_A); - dDestroy_LU(_num_rows, &_grid, &_LUstruct); - - dScalePermstructFree(&_ScalePermstruct); - dLUstructFree(&_LUstruct); - if (_options.SolveInitialized) - { - dSolveFinalize(&_options, &_SOLVEstruct); - } - - superlu_gridexit(&_grid); -} - -//---------------------------------------------------------------------------// -// Set matrix -//---------------------------------------------------------------------------// -void SuperLUSolver::setMatrix(Teuchos::RCP> A) -{ - if (_matrix_set) - { - // WARNING: - // destroying _A also destroys the vectors _A_rowptr_host, - // _A_colind_host and _A_values_host! - Destroy_CompRowLoc_Matrix_dist(&_A); - dDestroy_LU(_num_rows, &_grid, &_LUstruct); - } - - _num_rows = A->getNodeNumRows(); - - // Host-side allocation for CRS data - // Since SuperLU will free these arrays when destroying matrix using its - // own wrappers, let's use SuperLU wrappers to allocate that memory to - // ensure consistency - int nnz_loc = A->getNodeNumEntries(); - _A_rowptr_host = (int*)SUPERLU_MALLOC((_num_rows + 1) * sizeof(int)); - _A_colind_host = (int*)SUPERLU_MALLOC(nnz_loc * sizeof(int)); - _A_values_host = (double*)SUPERLU_MALLOC(nnz_loc * sizeof(double)); - - // Extract matrix data from A - std::size_t num_entries; - Teuchos::Array row_inds; - Teuchos::Array row_vals; - _A_rowptr_host[0] = 0; - int offset = 0; - for (int row = 0; row < _num_rows; ++row) - { - num_entries = A->getNumEntriesInLocalRow(row); - row_inds.resize(num_entries); - row_vals.resize(num_entries); - A->getLocalRowCopy(row, row_inds, row_vals, num_entries); - memcpy(_A_colind_host + offset, - row_inds.data(), - num_entries * sizeof(int)); - memcpy(_A_values_host + offset, - row_vals.data(), - num_entries * sizeof(double)); - _A_rowptr_host[1 + row] = _A_rowptr_host[row] + num_entries; - offset += num_entries; - } - - // create SuperLU matrix - dCreate_CompRowLoc_Matrix_dist(&_A, - _num_rows, - _num_rows, - nnz_loc, - _num_rows, - 0, - _A_values_host, - _A_colind_host, - _A_rowptr_host, - SLU_NR_loc, - SLU_D, - SLU_GE); - - if (_factored) - _options.Fact = SamePattern; // tell SuperLU new matrix has same nnz - // pattern - else - _options.Fact = DOFACT; - - _matrix_set = true; - _factored = false; -} - -//---------------------------------------------------------------------------// -// Initialize preconditioner -//---------------------------------------------------------------------------// -void SuperLUSolver::initialize() -{ - assert(_matrix_set); - - if (_initialized) - { - return; - } - - // Initialize SuperLU structs: ScalePermstruct and LUstruct - // Needs to be done only once since saprsity pattern will not change - dScalePermstructInit(_num_rows, _num_rows, &_ScalePermstruct); - dLUstructInit(_num_rows, &_LUstruct); - - _initialized = true; -} - -//---------------------------------------------------------------------------// -// Compute preconditioner -//---------------------------------------------------------------------------// -void SuperLUSolver::compute() -{ - _computed = true; -} - -//---------------------------------------------------------------------------// -// Compute and apply preconditioner -//---------------------------------------------------------------------------// -void SuperLUSolver::solve(const Tpetra::MultiVector<>& b, - Tpetra::MultiVector<>& x) -{ - assert(_matrix_set); - assert(_initialized); - - Kokkos::fence(); - - // copy b into x - Tpetra::deep_copy(x, b); - - // Get Kokkos Views - x.clear_sync_state(); - auto b_view = b.getLocalViewHost(Tpetra::Access::ReadOnly); - - auto xvec = x.getVectorNonConst(0); - auto x_view = xvec->getLocalViewHost(Tpetra::Access::OverwriteAllStruct()); - - int info; - - // Initialize SuperLU statistics variables - SuperLUStat_t stat; - PStatInit(&stat); - - double berr; - - // factorize and solve linear system - // by using Gaussian elimination with static pivoting - // Output: - // xv is overwritten with the solution - // A is overwritten by the scaled and permuted - // matrix diag(R)*A*diag(C)*Pc^T - // Solver expects and returns data on the CPU - // Detailed info in SuperLU_dist file: SRC/pdgssvx.c - double* xv = x_view.data(); - - if (_factored) - _options.Fact = FACTORED; // factored form of A is supplied - - pdgssvx(&_options, - &_A, - &_ScalePermstruct, - xv, - _num_rows, - 1, - &_grid, - &_LUstruct, - &_SOLVEstruct, - &berr, - &stat, - &info); - - x.modify_host(); - x.sync_device(); - if (info) - { // Something is wrong - std::stringstream ss; - ss << "ERROR: INFO = " << info << " returned from pdgssvx3d()"; - throw std::runtime_error(ss.str()); - } - - // Print statistics - // PStatPrint (&_options, &stat, &_grid); - - PStatFree(&stat); - - _factored = true; -} - -} // namespace LinearSolvers -} // namespace VertexCFD diff --git a/src/linear_solvers/VertexCFD_LinearSolvers_SuperLU.hpp b/src/linear_solvers/VertexCFD_LinearSolvers_SuperLU.hpp deleted file mode 100644 index 8c02edf..0000000 --- a/src/linear_solvers/VertexCFD_LinearSolvers_SuperLU.hpp +++ /dev/null @@ -1,73 +0,0 @@ -#ifndef VERTEXCFD_LINEARSOLVERS_SUPERLUSOLVER_HPP -#define VERTEXCFD_LINEARSOLVERS_SUPERLUSOLVER_HPP - -#include "VertexCFD_LinearSolvers_LocalDirectSolver.hpp" - -// superlu_ddefs.h includes C macro that conflicts with some -// cuda libraries include files. So let's include it after -// everything else -#define GPU_ACC -#include - -namespace VertexCFD -{ -namespace LinearSolvers -{ -//---------------------------------------------------------------------------// -// Local preconditioner/solver using SuperLU for on-GPU solves. -//---------------------------------------------------------------------------// -class SuperLUSolver : public LocalDirectSolver -{ - static_assert(std::is_same::value, - "SuperLU should be build with int_t=int"); - - private: - // >>> DATA - - // Matrix - SuperMatrix _A; - - // Host-side matrix data - int* _A_rowptr_host; - int* _A_colind_host; - double* _A_values_host; - - // Persistent SuperLU info - gridinfo_t _grid; - superlu_dist_options_t _options; - dLUstruct_t _LUstruct; - dScalePermstruct_t _ScalePermstruct; - dSOLVEstruct_t _SOLVEstruct; - - // Status flags - bool _matrix_set; - bool _initialized; - bool _computed; - bool _factored; - - int _num_rows; - - public: - // Constructor - SuperLUSolver(); - - ~SuperLUSolver(); - - // Update internal matrix - void setMatrix(Teuchos::RCP> A) override; - - // Inherited interface from LocalDirectSolver - void initialize() override; - void compute() override; - - // Inherited interface from LocalDirectSolver - void - solve(const Tpetra::MultiVector<>& b, Tpetra::MultiVector<>& x) override; -}; - -//---------------------------------------------------------------------------// - -} // namespace LinearSolvers -} // namespace VertexCFD - -#endif // VERTEXCFD_LINEARSOLVERS_SUPERLUSOLVER_HPP diff --git a/src/linear_solvers/unit_test/VertexCFD_SolverTester.hpp b/src/linear_solvers/unit_test/VertexCFD_SolverTester.hpp deleted file mode 100644 index 19b5b36..0000000 --- a/src/linear_solvers/unit_test/VertexCFD_SolverTester.hpp +++ /dev/null @@ -1,146 +0,0 @@ -#include - -#include -#include -#include -#include - -//---------------------------------------------------------------------------// -// TESTS -//---------------------------------------------------------------------------// -namespace VertexCFD -{ -namespace Test -{ -//---------------------------------------------------------------------------// -class SolverTester : public ::testing::Test -{ - protected: - void SetUp() - { - using GO = Tpetra::Details::DefaultTypes::global_ordinal_type; - using LO = Tpetra::Details::DefaultTypes::local_ordinal_type; - - auto comm = Teuchos::rcp(new Teuchos::MpiComm(MPI_COMM_WORLD)); - LO nx = 10; - LO ny = 10; - GO num_global_entries = nx * ny; - LO index_base = 0; - _map = Teuchos::rcp( - new Tpetra::Map<>(num_global_entries, index_base, comm)); - - LO entries_per_row = 5; - _matrix = Teuchos::rcp(new Tpetra::CrsMatrix<>(_map, entries_per_row)); - - // Build 2D Laplacian with Dirichlet BCs - Teuchos::ArrayRCP row_inds(entries_per_row); - Teuchos::ArrayRCP row_vals(entries_per_row); -#if TRILINOS_MAJOR_MINOR_VERSION >= 130400 - LO num_local_rows = _map->getLocalNumElements(); -#else - LO num_local_rows = _map->getNodeNumElements(); -#endif - for (LO local_row = 0; local_row < num_local_rows; ++local_row) - { - GO global_row = _map->getGlobalElement(local_row); - GO ix = global_row % nx; - GO iy = global_row / nx; - - // Diagonal entry - row_inds[0] = global_row; - row_vals[0] = 4.0; - int num_entries = 1; - - if (ix > 0) - { - row_inds[num_entries] = ix - 1 + iy * nx; - row_vals[num_entries] = -1.0; - num_entries++; - } - if (ix < (nx - 1)) - { - row_inds[num_entries] = ix + 1 + iy * nx; - row_vals[num_entries] = -1.0; - num_entries++; - } - if (iy > 0) - { - row_inds[num_entries] = ix + (iy - 1) * nx; - row_vals[num_entries] = -1.0; - num_entries++; - } - if (iy < (ny - 1)) - { - row_inds[num_entries] = ix + (iy + 1) * nx; - row_vals[num_entries] = -1.0; - num_entries++; - } - - _matrix->insertGlobalValues(global_row, - row_inds.view(0, num_entries), - row_vals.view(0, num_entries)); - } - _matrix->fillComplete(); - - // Build RHS and solution vector - _x = Teuchos::rcp(new Tpetra::MultiVector<>(_map, 1)); - _x->putScalar(1.0); - _y = Teuchos::rcp(new Tpetra::MultiVector<>(_map, 1)); - _y->putScalar(0.0); - - // Store reference solution -- this is result of solving a linear - // system with above matrix with a right hand side of all ones. - // Solution computed using numpy - _ref_soln - = {1.342423770482685, 2.18484754096537, 2.723654789583171, - 3.0479959507414374, 3.201077948227338, 3.201077948227339, - 3.047995950741439, 2.723654789583172, 2.1848475409653703, - 1.3424237704826851, 2.1848475409653694, 3.6733116037956237, - 4.6617756666258785, 5.267251065155242, 5.5552378939405775, - 5.555237893940578, 5.267251065155244, 4.661775666625878, - 3.6733116037956237, 2.1848475409653707, 2.723654789583172, - 4.661775666625879, 5.982885207969479, 6.803994749313078, - 7.19738466843915, 7.197384668439149, 6.803994749313074, - 5.982885207969476, 4.6617756666258785, 2.7236547895831706, - 3.0479959507414387, 5.267251065155243, 6.803994749313077, - 7.768458055688435, 8.232921362063793, 8.232921362063792, - 7.76845805568843, 6.803994749313073, 5.26725106515524, - 3.047995950741437, 3.2010779482273386, 5.555237893940577, - 7.19738466843915, 8.232921362063792, 8.732921362063793, - 8.732921362063792, 8.232921362063788, 7.197384668439146, - 5.555237893940573, 3.2010779482273364, 3.201077948227339, - 5.555237893940577, 7.197384668439149, 8.23292136206379, - 8.73292136206379, 8.732921362063788, 8.232921362063786, - 7.197384668439144, 5.555237893940571, 3.201077948227336, - 3.0479959507414396, 5.267251065155243, 6.803994749313074, - 7.76845805568843, 8.232921362063788, 8.232921362063786, - 7.768458055688429, 6.80399474931307, 5.267251065155238, - 3.0479959507414365, 2.723654789583173, 4.661775666625879, - 5.982885207969477, 6.803994749313072, 7.1973846684391445, - 7.197384668439141, 6.8039947493130715, 5.982885207969472, - 4.661775666625878, 2.72365478958317, 2.1848475409653707, - 3.6733116037956255, 4.661775666625879, 5.267251065155241, - 5.555237893940573, 5.555237893940573, 5.267251065155241, - 4.661775666625878, 3.673311603795623, 2.18484754096537, - 1.3424237704826854, 2.1848475409653703, 2.7236547895831715, - 3.047995950741438, 3.201077948227337, 3.2010779482273364, - 3.0479959507414374, 2.7236547895831706, 2.1848475409653694, - 1.342423770482685}; - } - - void TearDown() {} - - void solve() {} - - protected: - Teuchos::RCP> _map; - Teuchos::RCP> _matrix; - Teuchos::RCP> _x; - Teuchos::RCP> _y; - std::vector _ref_soln; -}; - -//---------------------------------------------------------------------------// - -} // end namespace Test -} // end namespace VertexCFD diff --git a/src/linear_solvers/unit_test/tstCusolverGLU.cpp b/src/linear_solvers/unit_test/tstCusolverGLU.cpp deleted file mode 100644 index 7119563..0000000 --- a/src/linear_solvers/unit_test/tstCusolverGLU.cpp +++ /dev/null @@ -1,52 +0,0 @@ -#include -#include -#include - -#include -#include -#include - -//---------------------------------------------------------------------------// -// TESTS -//---------------------------------------------------------------------------// -namespace VertexCFD -{ -namespace Test -{ -//---------------------------------------------------------------------------// -class CusolverGLUTester : public SolverTester -{ - protected: - void solve() const - { - // Build and compute preconditioner - Teuchos::ParameterList params; - VertexCFD::LinearSolvers::CusolverGLU solver(params); - solver.setMatrix(_matrix); - solver.initialize(); - solver.compute(); - - // In operator notation, the input vector "x" becomes the RHS for a - // linear solve and the output "y" is the result - solver.solve(*_x, *_y); - } -}; - -//---------------------------------------------------------------------------// -TEST_F(CusolverGLUTester, solve_test) -{ - this->solve(); - - auto y_data = _y->getData(0); - int num_local_rows = y_data.size(); - double tol = 1e-14; - for (int local_row = 0; local_row < num_local_rows; ++local_row) - { - EXPECT_NEAR(_ref_soln[local_row], y_data[local_row], tol); - } -} - -//---------------------------------------------------------------------------// - -} // end namespace Test -} // end namespace VertexCFD diff --git a/src/linear_solvers/unit_test/tstLocalSolverFactory.cpp b/src/linear_solvers/unit_test/tstLocalSolverFactory.cpp deleted file mode 100644 index 9619c1c..0000000 --- a/src/linear_solvers/unit_test/tstLocalSolverFactory.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#include -#include -#include - -//---------------------------------------------------------------------------// -// TESTS -//---------------------------------------------------------------------------// -namespace VertexCFD -{ -namespace Test -{ -//---------------------------------------------------------------------------// -TEST(LocalSolverFactoryTester, build_test) -{ - // Test with default parameters - Teuchos::ParameterList params; - auto solver - = VertexCFD::LinearSolvers::LocalSolverFactory::buildSolver(params); - auto cusolver - = std::dynamic_pointer_cast( - solver); - EXPECT_TRUE(cusolver != nullptr); - - // Test with solver name - params.set("Local Solver", "Cusolver GLU"); - solver = VertexCFD::LinearSolvers::LocalSolverFactory::buildSolver(params); - cusolver = std::dynamic_pointer_cast( - solver); - EXPECT_TRUE(cusolver != nullptr); - - // Test with invalid name - params.set("Local Solver", "Foo"); - EXPECT_THROW( - VertexCFD::LinearSolvers::LocalSolverFactory::buildSolver(params), - std::runtime_error); -} - -//---------------------------------------------------------------------------// - -} // end namespace Test -} // end namespace VertexCFD diff --git a/src/linear_solvers/unit_test/tstPreconditioner.cpp b/src/linear_solvers/unit_test/tstPreconditioner.cpp deleted file mode 100644 index 8f6a9fd..0000000 --- a/src/linear_solvers/unit_test/tstPreconditioner.cpp +++ /dev/null @@ -1,125 +0,0 @@ -#include -#include -#include - -#include -#include -#include - -//---------------------------------------------------------------------------// -// TESTS -//---------------------------------------------------------------------------// -namespace VertexCFD -{ -namespace Test -{ -//---------------------------------------------------------------------------// -class PreconditionerTester : public SolverTester -{ -}; - -//---------------------------------------------------------------------------// -TEST_F(PreconditionerTester, solve_test) -{ - // Build and compute preconditioner - Teuchos::ParameterList params; - VertexCFD::LinearSolvers::Preconditioner prec; - prec.setParameters(params); - EXPECT_FALSE(prec.isInitialized()); - EXPECT_FALSE(prec.isComputed()); - EXPECT_EQ(0, prec.getNumInitialize()); - EXPECT_EQ(0, prec.getNumCompute()); - EXPECT_EQ(0, prec.getNumApply()); - - // Set matrix - prec.setMatrix(_matrix); - EXPECT_FALSE(prec.isInitialized()); - EXPECT_FALSE(prec.isComputed()); - EXPECT_EQ(0, prec.getNumInitialize()); - EXPECT_EQ(0, prec.getNumCompute()); - EXPECT_EQ(0, prec.getNumApply()); - - // Initialize preconditioner - prec.initialize(); - EXPECT_TRUE(prec.isInitialized()); - EXPECT_FALSE(prec.isComputed()); - EXPECT_EQ(1, prec.getNumInitialize()); - EXPECT_EQ(0, prec.getNumCompute()); - EXPECT_EQ(0, prec.getNumApply()); - - // Compute preconditioner - prec.compute(); - EXPECT_TRUE(prec.isInitialized()); - EXPECT_TRUE(prec.isComputed()); - EXPECT_EQ(1, prec.getNumInitialize()); - EXPECT_EQ(1, prec.getNumCompute()); - EXPECT_EQ(0, prec.getNumApply()); - - // Apply preconditioner with beta = 0. - // Existing values in y should be ignored - _x->putScalar(1.0); - _y->putScalar(2.0); - prec.apply(*_x, *_y, Teuchos::NO_TRANS, 1.0, 0.0); - EXPECT_TRUE(prec.isInitialized()); - EXPECT_TRUE(prec.isComputed()); - EXPECT_EQ(1, prec.getNumInitialize()); - EXPECT_EQ(1, prec.getNumCompute()); - EXPECT_EQ(1, prec.getNumApply()); - - { - auto y_data = _y->getData(0); - int num_local_rows = y_data.size(); - double tol = 1e-14; - for (int local_row = 0; local_row < num_local_rows; ++local_row) - { - EXPECT_NEAR(_ref_soln[local_row], y_data[local_row], tol); - } - } - - // Apply preconditioner with alpha = 0. - // Values in x should be ignored. No solve is performed, just scaling on y. - _x->putScalar(1.0); - _y->putScalar(2.0); - prec.apply(*_x, *_y, Teuchos::NO_TRANS, 0.0, 1.5); - EXPECT_TRUE(prec.isInitialized()); - EXPECT_TRUE(prec.isComputed()); - EXPECT_EQ(1, prec.getNumInitialize()); - EXPECT_EQ(1, prec.getNumCompute()); - EXPECT_EQ(2, prec.getNumApply()); - - { - auto y_data = _y->getData(0); - int num_local_rows = y_data.size(); - for (int local_row = 0; local_row < num_local_rows; ++local_row) - { - EXPECT_DOUBLE_EQ(3.0, y_data[local_row]); - } - } - - // Apply preconditioner with nonzero alpha and beta. - // Values in both x and y are used. - _x->putScalar(1.0); - _y->putScalar(2.0); - prec.apply(*_x, *_y, Teuchos::NO_TRANS, 2.0, 3.0); - EXPECT_TRUE(prec.isInitialized()); - EXPECT_TRUE(prec.isComputed()); - EXPECT_EQ(1, prec.getNumInitialize()); - EXPECT_EQ(1, prec.getNumCompute()); - EXPECT_EQ(3, prec.getNumApply()); - - { - auto y_data = _y->getData(0); - int num_local_rows = y_data.size(); - double tol = 2e-14; - for (int local_row = 0; local_row < num_local_rows; ++local_row) - { - EXPECT_NEAR( - 2.0 * _ref_soln[local_row] + 6.0, y_data[local_row], tol); - } - } -} - -//---------------------------------------------------------------------------// - -} // end namespace Test -} // end namespace VertexCFD diff --git a/src/linear_solvers/unit_test/tstPreconditionerFactory.cpp b/src/linear_solvers/unit_test/tstPreconditionerFactory.cpp deleted file mode 100644 index 2bb5d56..0000000 --- a/src/linear_solvers/unit_test/tstPreconditionerFactory.cpp +++ /dev/null @@ -1,81 +0,0 @@ -#include -#include -#include - -#include -#include -#include -#include - -//---------------------------------------------------------------------------// -// TESTS -//---------------------------------------------------------------------------// -namespace VertexCFD -{ -namespace Test -{ -//---------------------------------------------------------------------------// -class PreconditionerFactoryTester : public SolverTester -{ -}; - -//---------------------------------------------------------------------------// -TEST_F(PreconditionerFactoryTester, build_test) -{ - using panzer::GlobalOrdinal; - using panzer::TpetraNodeType; - - // Wrap matrix into Thyra operator - auto thyra_op - = Thyra::createLinearOp( - _matrix); - auto thyra_op_src - = Teuchos::rcp(new Thyra::DefaultLinearOpSource(thyra_op)); - - // Create factory - VertexCFD::LinearSolvers::PreconditionerFactory factory; - auto params = Teuchos::rcp(new Teuchos::ParameterList()); - factory.setParameterList(params); - EXPECT_TRUE(factory.isCompatible(*thyra_op_src)); - - // Create preconditioner and initialize - auto prec = factory.createPrec(); - EXPECT_TRUE(prec != Teuchos::null); - factory.initializePrec(thyra_op_src, prec.get()); - - // Check that operator was initialized correctly within preconditioner - auto unspecified_prec_op = prec->getUnspecifiedPrecOp(); - EXPECT_TRUE(unspecified_prec_op != Teuchos::null); - - // Extract Thyra operator - auto thyra_tpetra_prec = Teuchos::rcp_dynamic_cast< - const Thyra::TpetraLinearOp>( - unspecified_prec_op); - EXPECT_TRUE(thyra_tpetra_prec != Teuchos::null); - auto tpetra_prec = thyra_tpetra_prec->getConstTpetraOperator(); - EXPECT_TRUE(tpetra_prec != Teuchos::null); - - // Check if operator is AdditiveSchwarz - auto schwarz = Teuchos::rcp_dynamic_cast< - const Ifpack2::AdditiveSchwarz>>(tpetra_prec); - EXPECT_TRUE(schwarz != Teuchos::null); - EXPECT_TRUE(schwarz->isInitialized()); - EXPECT_TRUE(schwarz->isComputed()); - - // Perform operator apply - schwarz->apply(*_x, *_y, Teuchos::NO_TRANS, 1.0, 0.0); - - // Compare against reference solution - auto y_data = _y->getData(0); - int num_local_rows = y_data.size(); - double tol = 1e-14; - for (int local_row = 0; local_row < num_local_rows; ++local_row) - { - EXPECT_NEAR(_ref_soln[local_row], y_data[local_row], tol); - } -} - -//---------------------------------------------------------------------------// - -} // end namespace Test -} // end namespace VertexCFD diff --git a/src/mesh/VertexCFD_Mesh_ExodusWriter.cpp b/src/mesh/VertexCFD_Mesh_ExodusWriter.cpp deleted file mode 100644 index abe92a3..0000000 --- a/src/mesh/VertexCFD_Mesh_ExodusWriter.cpp +++ /dev/null @@ -1,119 +0,0 @@ -#include "VertexCFD_Mesh_ExodusWriter.hpp" - -#include "utils/VertexCFD_Utils_VectorizeOutputFieldNames.hpp" - -#include - -namespace VertexCFD -{ -namespace Mesh -{ -//---------------------------------------------------------------------------// -void ExodusWriter::add_mesh_outputs(const Teuchos::ParameterList& params, - const OutputType output_type, - const OutputLocation output_location) -{ - for (const auto& param : params) - { - const auto& block_id = param.first; - const auto tokens = VectorizeOutputFieldNames::tokenizeParameter(param); - for (const auto& field : tokens) - { - if (output_location == OutputLocation::Node) - { - // nodal scalar - _mesh->addSolutionField(field, block_id); - } - else if (output_type == OutputType::Scalar) - { - // cell scalar - _mesh->addCellField(field, block_id); - } - else - { - // cell vector - constexpr char dim_name[3] = {'X', 'Y', 'Z'}; - for (std::size_t dim = 0; dim < _mesh->getDimension(); ++dim) - { - _mesh->addCellField(field + dim_name[dim], block_id); - } - } - } - } -} - -//---------------------------------------------------------------------------// -ExodusWriter::ExodusWriter( - const Teuchos::RCP& mesh, - const Teuchos::RCP& dof_manager, - const Teuchos::RCP>& lof, - const Teuchos::RCP>& response_library, - const Teuchos::ParameterList& output_params) - : _mesh(mesh) - , _dof_manager(dof_manager) - , _lof(lof) - , _response_library(response_library) -{ - add_mesh_outputs(output_params.sublist("Cell Average Quantities"), - OutputType::Scalar, - OutputLocation::Cell); - add_mesh_outputs(output_params.sublist("Cell Average Vectors"), - OutputType::Vector, - OutputLocation::Cell); - add_mesh_outputs(output_params.sublist("Cell Quantities"), - OutputType::Scalar, - OutputLocation::Cell); - add_mesh_outputs(output_params.sublist("Nodal Quantities"), - OutputType::Scalar, - OutputLocation::Node); - - _mesh->setupExodusFile( - output_params.template get("Exodus Output File")); - - std::vector element_blocks; - _mesh->getElementBlockNames(element_blocks); - panzer_stk::RespFactorySolnWriter_Builder response_builder; - response_builder.mesh = mesh; - - _response_library->addResponse( - "Main Field Output", element_blocks, response_builder); -} - -//---------------------------------------------------------------------------// -void ExodusWriter::writeSolution( - const Teuchos::RCP>& x, - const Teuchos::RCP>& x_dot, - const double time, - const double time_step) -{ - panzer::AssemblyEngineInArgs in_args; - in_args.container_ = _lof->buildLinearObjContainer(); - in_args.ghostedContainer_ = _lof->buildGhostedLinearObjContainer(); - in_args.alpha = 0.0; - in_args.beta = 1.0; - in_args.time = time; - in_args.step_size = time_step; - in_args.evaluate_transient_terms = true; - - _lof->initializeGhostedContainer( - panzer::LinearObjContainer::X | panzer::LinearObjContainer::DxDt, - *(in_args.ghostedContainer_)); - - auto thyra_container - = Teuchos::rcp_dynamic_cast>( - in_args.container_, true); - thyra_container->set_x_th( - Teuchos::rcp_const_cast>(x)); - thyra_container->set_dxdt_th( - Teuchos::rcp_const_cast>(x_dot)); - - _response_library->addResponsesToInArgs(in_args); - _response_library->evaluate(in_args); - - _mesh->writeToExodus(time); -} - -//---------------------------------------------------------------------------// - -} // end namespace Mesh -} // end namespace VertexCFD diff --git a/src/mesh/VertexCFD_Mesh_ExodusWriter.hpp b/src/mesh/VertexCFD_Mesh_ExodusWriter.hpp deleted file mode 100644 index a9fb942..0000000 --- a/src/mesh/VertexCFD_Mesh_ExodusWriter.hpp +++ /dev/null @@ -1,65 +0,0 @@ -#ifndef VERTEXCFD_MESH_EXODUSWRITER_HPP -#define VERTEXCFD_MESH_EXODUSWRITER_HPP - -#include -#include -#include -#include -#include - -#include - -#include -#include - -namespace VertexCFD -{ -namespace Mesh -{ -//---------------------------------------------------------------------------// -class ExodusWriter -{ - public: - ExodusWriter( - const Teuchos::RCP& mesh, - const Teuchos::RCP& dof_manager, - const Teuchos::RCP>& lof, - const Teuchos::RCP>& - response_library, - const Teuchos::ParameterList& output_params); - - void - writeSolution(const Teuchos::RCP>& x, - const Teuchos::RCP>& x_dot, - const double time = 0.0, - const double time_step = 0.0); - - private: - enum class OutputType - { - Scalar, - Vector - }; - - enum class OutputLocation - { - Node, - Cell - }; - - void add_mesh_outputs(const Teuchos::ParameterList& params, - const OutputType output_type, - const OutputLocation output_location); - - Teuchos::RCP _mesh; - Teuchos::RCP _dof_manager; - Teuchos::RCP> _lof; - Teuchos::RCP> _response_library; -}; - -//---------------------------------------------------------------------------// - -} // end namespace Mesh -} // end namespace VertexCFD - -#endif // end VERTEXCFD_MESH_EXODUSWRITER_HPP diff --git a/src/mesh/VertexCFD_Mesh_GeometryPrimitives.hpp b/src/mesh/VertexCFD_Mesh_GeometryPrimitives.hpp deleted file mode 100644 index 0f1ba22..0000000 --- a/src/mesh/VertexCFD_Mesh_GeometryPrimitives.hpp +++ /dev/null @@ -1,384 +0,0 @@ -/* - Function for calculating the wall distance from an arbitrary point - to an arbitrary (triangular) surface and/or (linear) edge -*/ -#include "utils/VertexCFD_Utils_SmoothMath.hpp" -#include -#include -#include -#include - -namespace VertexCFD -{ -namespace GeometryPrimitives -{ - -/* - Calculates the cross product of two 3x1 vectors -*/ -KOKKOS_INLINE_FUNCTION void -crossProduct(double arr1[3], double arr2[3], double arr_out[3]) -{ - arr_out[0] = arr1[1] * arr2[2] - arr1[2] * arr2[1]; - arr_out[1] = arr1[2] * arr2[0] - arr1[0] * arr2[2]; - arr_out[2] = arr1[0] * arr2[1] - arr1[1] * arr2[0]; -} - -/* - Checks if the intersection of a point, p, with a plane, defined ba * ca, lies - within the triangle abc, and if it is outside the triangle what edge it lies - closest to -*/ -template -KOKKOS_INLINE_FUNCTION int tetCheck(SideViewType& sides_view, - NormalViewType& normals_view, - int side, - PointViewType& ip_view, - int cell, - int point, - int index[3]) -{ - // calculate the intersection location of the point and plane along the - // normal vector - double t1 = normals_view(side, 0) * sides_view(side, index[0], 0) - + normals_view(side, 1) * sides_view(side, index[0], 1) - + normals_view(side, 2) * sides_view(side, index[0], 2); - double t2 = normals_view(side, 0) * ip_view(cell, point, 0) - + normals_view(side, 1) * ip_view(cell, point, 1) - + normals_view(side, 2) * ip_view(cell, point, 2); - double param = t1 - t2; - - double intersection_point[3]; - double line_a_int[3]; - double line_b_int[3]; - double line_c_int[3]; - double line_ba[3]; - double line_cb[3]; - double line_ac[3]; - - for (int dim = 0; dim < 3; ++dim) - { - // Intersection point with the plane the side lies in - intersection_point[dim] = ip_view(cell, point, dim) - + param * normals_view(side, dim); - // Line segment from intersection point to node A - line_a_int[dim] = intersection_point[dim] - - sides_view(side, index[0], dim); - // Line segment from node B to node A - line_ba[dim] = sides_view(side, index[1], dim) - - sides_view(side, index[0], dim); - // Line segment from intersection point to node B - line_b_int[dim] = intersection_point[dim] - - sides_view(side, index[1], dim); - // Line segment from node C to node B - line_cb[dim] = sides_view(side, index[2], dim) - - sides_view(side, index[1], dim); - // Line segment from intersection point to node C - line_c_int[dim] = intersection_point[dim] - - sides_view(side, index[2], dim); - // Line segment from node A to node C - line_ac[dim] = sides_view(side, index[0], dim) - - sides_view(side, index[2], dim); - } - - // calculate unit normal vector of triangle abp - double norm_abp[3]; - crossProduct(line_ba, line_b_int, norm_abp); - double n_abp_mag = sqrt(norm_abp[0] * norm_abp[0] - + norm_abp[1] * norm_abp[1] - + norm_abp[2] * norm_abp[2]); - if (n_abp_mag != 0) - { - for (int dim = 0; dim < 3; ++dim) - { - norm_abp[dim] /= n_abp_mag; - } - } - - // calculate unit normal vector of triangle bcp - double norm_bcp[3]; - crossProduct(line_cb, line_c_int, norm_bcp); - double n_bcp_mag = sqrt(norm_bcp[0] * norm_bcp[0] - + norm_bcp[1] * norm_bcp[1] - + norm_bcp[2] * norm_bcp[2]); - if (n_bcp_mag != 0) - { - for (int dim = 0; dim < 3; ++dim) - { - norm_bcp[dim] /= n_bcp_mag; - } - } - - // calculate unit normal vector of triangle cap - double norm_cap[3]; - crossProduct(line_ac, line_a_int, norm_cap); - double n_cap_mag = sqrt(norm_cap[0] * norm_cap[0] - + norm_cap[1] * norm_cap[1] - + norm_cap[2] * norm_cap[2]); - if (n_cap_mag != 0) - { - for (int dim = 0; dim < 3; ++dim) - { - norm_cap[dim] /= n_cap_mag; - } - } - - int tet_flag = -1; - - double abp = norm_abp[0] * normals_view(side, 0) - + norm_abp[1] * normals_view(side, 1) - + norm_abp[2] * normals_view(side, 2); - double bcp = norm_bcp[0] * normals_view(side, 0) - + norm_bcp[1] * normals_view(side, 1) - + norm_bcp[2] * normals_view(side, 2); - double cap = norm_cap[0] * normals_view(side, 0) - + norm_cap[1] * normals_view(side, 1) - + norm_cap[2] * normals_view(side, 2); - - if (abp > 0.01 && bcp > 0.01 && cap > 0.01) - { - tet_flag = 0; - } - else if (abp <= 0.01 && cap > 0.01 && bcp > 0.01) - { - tet_flag = 1; - } - else if (bcp <= 0.01 && cap > 0.01 && abp > 0.01) - { - tet_flag = 2; - } - else if (cap <= 0.01 && abp > 0.01 && bcp > 0.01) - { - tet_flag = 3; - } - else if (abp <= 0.01 && bcp <= 0.01) - { - tet_flag = 4; - } - else if (bcp <= 0.01 && cap <= 0.01) - { - tet_flag = 5; - } - else if (cap <= 0.01 && abp <= 0.01) - { - tet_flag = 6; - } - - return tet_flag; -} - -/* - Determines the distance between a point, p, and a plane defined by a point a - and a normal n -*/ -template -KOKKOS_INLINE_FUNCTION double planeIntersect(SideViewType& sides_view, - NormalViewType& normals_view, - int side, - PointViewType& ip_view, - int cell, - int point) -{ - // calculate n_hat * a - n_hat * p, which defines the distance to the - // interaction point - double t1 = normals_view(side, 0) * sides_view(side, 0, 0) - + normals_view(side, 1) * sides_view(side, 0, 1) - + normals_view(side, 2) * sides_view(side, 0, 2); - double t2 = normals_view(side, 0) * ip_view(cell, point, 0) - + normals_view(side, 1) * ip_view(cell, point, 1) - + normals_view(side, 2) * ip_view(cell, point, 2); - double param = t1 - t2; - double distance = std::abs(param); - - return distance; -} - -/* - Function that returns the distance to a specified edge from a specified point - p is the test point, p0 is one end of the linear edge given, and p1 is the - other end of the linear edge given -*/ -template -KOKKOS_INLINE_FUNCTION double distanceToLinearEdge(SideViewType& sides_view, - int side, - PointViewType& ip_view, - int cell, - int point, - int num_space_dim, - int index[2]) -{ - double line_ap[3]; - double line_ab[3]; - double num = 0.0; - double denom = 0.0; - - for (int dim = 0; dim < num_space_dim; ++dim) - { - // Line between point 0 and the test point - line_ap[dim] = ip_view(cell, point, dim) - - sides_view(side, index[0], dim); - // Line between point 0 and point 1 - line_ab[dim] = sides_view(side, index[1], dim) - - sides_view(side, index[0], dim); - num += line_ap[dim] * line_ab[dim]; - denom += line_ab[dim] * line_ab[dim]; - } - - double param = -1; - // don't test case where the line has 0 length - if (denom != 0) - param = num / denom; - - double intersection_point[3]; - - if (param < 0) - { - // the point is closest to end p0 - for (int dim = 0; dim < num_space_dim; ++dim) - { - intersection_point[dim] = sides_view(side, index[0], dim); - } - } - else if (param > 1) - { - // the point is closest to end p1 - for (int dim = 0; dim < num_space_dim; ++dim) - { - intersection_point[dim] = sides_view(side, index[1], dim); - } - } - else - { - // the point "p" is closest to a point "param" along line p0-p1 - for (int dim = 0; dim < num_space_dim; ++dim) - { - intersection_point[dim] = sides_view(side, index[0], dim) - + param * line_ab[dim]; - } - } - - double distance = 0.0; - for (int dim = 0; dim < num_space_dim; ++dim) - { - distance += pow(ip_view(cell, point, dim) - intersection_point[dim], 2); - } - return sqrt(distance); -} - -/* - Function that returns the nearest distance between a triangle and a point -*/ -template -KOKKOS_INLINE_FUNCTION double -distanceToTriangleFace(SideViewType& sides_view, - NormalViewType& normals_view, - int side, - PointViewType& ip_view, - int cell, - int point, - int index[3]) -{ - // Define vectors that store the line between the first point on the - // triangle and the other two - double line_ba[3]; - double line_ca[3]; - for (int dim = 0; dim < 3; ++dim) - { - line_ba[dim] = sides_view(side, index[1], dim) - - sides_view(side, index[0], dim); - line_ca[dim] = sides_view(side, index[2], dim) - - sides_view(side, index[0], dim); - } - - // Calculate the triangle unit normal vector - double normal_abc[3]; - crossProduct(line_ba, line_ca, normal_abc); - normals_view(side, 0) = normal_abc[0]; - normals_view(side, 1) = normal_abc[1]; - normals_view(side, 2) = normal_abc[2]; - double normal_mag - = std::sqrt(normals_view(side, 0) * normals_view(side, 0) - + normals_view(side, 1) * normals_view(side, 1) - + normals_view(side, 2) * normals_view(side, 2)); - normals_view(side, 0) /= normal_mag; - normals_view(side, 1) /= normal_mag; - normals_view(side, 2) /= normal_mag; - - // calculate if "p" is closest to the triangle face, or one of the sides - auto int_flag = tetCheck( - sides_view, normals_view, side, ip_view, cell, point, index); - - double distance = 1e8; - double d_ab, d_bc, d_ca; - int node[2]; - switch (int_flag) - { - case 0: - // point "p" is closest to a point on the triangle interior - distance = planeIntersect( - sides_view, normals_view, side, ip_view, cell, point); - break; - case 1: - // point "p" is closest to a point on the edge ab - node[0] = index[0]; - node[1] = index[1]; - distance = distanceToLinearEdge( - sides_view, side, ip_view, cell, point, 3, node); - break; - case 2: - // point "p" is closest to a point on the edge bc - node[0] = index[1]; - node[1] = index[2]; - distance = distanceToLinearEdge( - sides_view, side, ip_view, cell, point, 3, node); - break; - case 3: - // point "p" is closest to a point on the edge ca - node[0] = index[2]; - node[1] = index[0]; - distance = distanceToLinearEdge( - sides_view, side, ip_view, cell, point, 3, node); - break; - case 4: - // point "p" is closest to a point on the edge ab or bc - node[0] = index[0]; - node[1] = index[1]; - d_ab = distanceToLinearEdge( - sides_view, side, ip_view, cell, point, 3, node); - node[0] = index[1]; - node[1] = index[2]; - d_bc = distanceToLinearEdge( - sides_view, side, ip_view, cell, point, 3, node); - distance = std::fmin(d_ab, d_bc); - break; - case 5: - // point "p" is closest to a point on the edge bc or ca - node[0] = index[1]; - node[1] = index[2]; - d_bc = distanceToLinearEdge( - sides_view, side, ip_view, cell, point, 3, node); - node[0] = index[2]; - node[1] = index[0]; - d_ca = distanceToLinearEdge( - sides_view, side, ip_view, cell, point, 3, node); - distance = std::fmin(d_ca, d_bc); - break; - case 6: - // point "p" is closest to a point on the edge ab or ca - node[0] = index[0]; - node[1] = index[1]; - d_ab = distanceToLinearEdge( - sides_view, side, ip_view, cell, point, 3, node); - node[0] = index[2]; - node[1] = index[0]; - d_ca = distanceToLinearEdge( - sides_view, side, ip_view, cell, point, 3, node); - distance = std::fmin(d_ab, d_ca); - break; - } - - return distance; -} - -} // end namespace GeometryPrimitives -} // end namespace VertexCFD diff --git a/src/mesh/VertexCFD_Mesh_Restart.hpp b/src/mesh/VertexCFD_Mesh_Restart.hpp deleted file mode 100644 index 6c8670a..0000000 --- a/src/mesh/VertexCFD_Mesh_Restart.hpp +++ /dev/null @@ -1,91 +0,0 @@ -#ifndef VERTEXCFD_MESH_RESTART_HPP -#define VERTEXCFD_MESH_RESTART_HPP - -#include -#include - -#include - -#include -#include -#include - -#include -#include -#include - -namespace VertexCFD -{ -namespace Mesh -{ -//---------------------------------------------------------------------------// -class Restart -{ - public: - ~Restart() = default; - - MPI_Datatype - setupDofMapData(const Teuchos::RCP& mesh, - const Teuchos::RCP& dof_manager, - int& dofmap_offset, - int& local_num_own_elem, - std::vector& owned_element_lids); -}; - -//---------------------------------------------------------------------------// -class RestartWriter : public Restart -{ - public: - // NOTE: allow_dofmap_overwrite is false by default and should be provided - // only in unit tests. - RestartWriter(const Teuchos::RCP& mesh, - const Teuchos::RCP& dof_manager, - const Teuchos::ParameterList& output_params, - const bool allow_dofmap_overwrite = false); - - ~RestartWriter(); - - void - writeSolution(const Teuchos::RCP>& x, - const Teuchos::RCP>& x_dot, - const int index, - const double time = 0.0); - - private: - Teuchos::RCP _dof_manager; - std::string _file_prefix; - std::vector _displacements; - std::unordered_map _global_to_local; - MPI_Datatype _dof_type; -}; - -//---------------------------------------------------------------------------// -class RestartReader : public Restart -{ - public: - RestartReader(const Teuchos::RCP>& comm, - const Teuchos::ParameterList& input_params); - - void - readSolution(const Teuchos::RCP& mesh, - const Teuchos::RCP& dof_manager, - const Teuchos::RCP>& x, - const Teuchos::RCP>& x_dot); - - double initialStateTime() const { return _t_init; } - - private: - std::string _restart_file_name; - std::string _dofmap_file_name; - double _t_init; - - void update_vector(const Teuchos::RCP>& vec, - const std::vector& data) const; -}; - -//---------------------------------------------------------------------------// - -} // end namespace Mesh -} // end namespace VertexCFD - -#endif // end VERTEXCFD_MESH_RESTART_HPP diff --git a/src/mesh/VertexCFD_Mesh_StkReaderFactory.cpp b/src/mesh/VertexCFD_Mesh_StkReaderFactory.cpp deleted file mode 100644 index 1df3f55..0000000 --- a/src/mesh/VertexCFD_Mesh_StkReaderFactory.cpp +++ /dev/null @@ -1,505 +0,0 @@ -#include "VertexCFD_Mesh_StkReaderFactory.hpp" - -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include - -namespace VertexCFD -{ -namespace Mesh -{ -//---------------------------------------------------------------------------// -int getMeshDimension(const std::string& mesh_str, - stk::ParallelMachine parallel_mach, - const bool is_exodus) -{ - stk::io::StkMeshIoBroker mesh_data(parallel_mach); - mesh_data.property_add(Ioss::Property("LOWER_CASE_VARIABLE_NAMES", false)); - if (is_exodus) - mesh_data.add_mesh_database(mesh_str, "exodusII", stk::io::READ_MESH); - else - mesh_data.add_mesh_database(mesh_str, "cgns", stk::io::READ_MESH); - mesh_data.create_input_mesh(); - return Teuchos::as(mesh_data.meta_data().spatial_dimension()); -} - -//---------------------------------------------------------------------------// -StkReaderFactory::StkReaderFactory() - : file_name_("") - , decomp_method_("RIB") - , restart_index_(0) - , is_exodus_(true) - , user_mesh_scaling_(false) - , mesh_scale_factor_(0.0) - , levels_of_refinement_(0) -{ -} - -//---------------------------------------------------------------------------// -StkReaderFactory::StkReaderFactory(const std::string& file_name, - const int restart_index, - const bool is_exodus) - : file_name_(file_name) - , decomp_method_("RIB") - , restart_index_(restart_index) - , is_exodus_(is_exodus) - , user_mesh_scaling_(false) - , mesh_scale_factor_(0.0) - , levels_of_refinement_(0) -{ -} - -//---------------------------------------------------------------------------// -Teuchos::RCP -StkReaderFactory::buildMesh(stk::ParallelMachine parallel_mach) const -{ - auto mesh = buildUncommitedMesh(parallel_mach); - - const bool buildRefinementSupport = levels_of_refinement_ > 0 ? true - : false; - mesh->initialize(parallel_mach, false, buildRefinementSupport); - - completeMeshConstruction(*mesh, parallel_mach); - - return mesh; -} - -//---------------------------------------------------------------------------// -/** This builds all the meta data of the mesh. Does not call metaData->commit. - * Allows user to add solution fields and other pieces. The mesh can be - * "completed" by calling completeMeshConstruction. - */ -Teuchos::RCP -StkReaderFactory::buildUncommitedMesh(stk::ParallelMachine parallel_mach) const -{ - // read in meta data - stk::io::StkMeshIoBroker* mesh_data - = new stk::io::StkMeshIoBroker(parallel_mach); - -#if TRILINOS_MAJOR_MINOR_VERSION >= 140000 - mesh_data->use_simple_fields(); -#endif - - // Tell IOSS to keep variable names as is; do not convert to lower case. - mesh_data->property_add(Ioss::Property("LOWER_CASE_VARIABLE_NAMES", false)); - - // Tell IOSS not to combine scalar fields into vector or tensor fields - // based on suffix recognition. We need scalar fields in order to use them - // as initial conditions. - mesh_data->property_add(Ioss::Property("ENABLE_FIELD_RECOGNITION", false)); - - mesh_data->property_add( - Ioss::Property("DECOMPOSITION_METHOD", decomp_method_)); - - // add in "FAMILY_TREE" entity for doing refinement - std::vector entity_rank_names = stk::mesh::entity_rank_names(); - entity_rank_names.push_back("FAMILY_TREE"); - mesh_data->set_rank_name_vector(entity_rank_names); - - if (is_exodus_) - mesh_data->add_mesh_database( - file_name_, "exodusII", stk::io::READ_MESH); - else - mesh_data->add_mesh_database(file_name_, "cgns", stk::io::READ_MESH); - - mesh_data->create_input_mesh(); -#if TRILINOS_MAJOR_MINOR_VERSION >= 130500 - auto metaData = Teuchos::rcp(mesh_data->meta_data_ptr()); -#else - auto metaData = mesh_data->meta_data_rcp(); -#endif - - auto mesh = Teuchos::rcp(new panzer_stk::STK_Interface(metaData)); - mesh->initializeFromMetaData(); - mesh->instantiateBulkData(parallel_mach); -#if TRILINOS_MAJOR_MINOR_VERSION >= 130500 - mesh_data->set_bulk_data(Teuchos::get_shared_ptr(mesh->getBulkData())); -#else - mesh_data->set_bulk_data(mesh->getBulkData()); -#endif - - // read in other transient fields, these will be useful later when - // trying to read other fields for use in solve - mesh_data->add_all_mesh_fields_as_input_fields(); - - // store mesh data pointer for later use in initializing - // bulk data - mesh->getMetaData()->declare_attribute_with_delete(mesh_data); - - // build element blocks - registerElementBlocks(*mesh, *mesh_data); - registerSidesets(*mesh); - registerNodesets(*mesh); - - mesh->addPeriodicBCs(this->periodicBCVec_); - - return mesh; -} - -//---------------------------------------------------------------------------// -void StkReaderFactory::completeMeshConstruction( - panzer_stk::STK_Interface& mesh, stk::ParallelMachine parallel_mach) const -{ - if (not mesh.isInitialized()) - { - const bool buildRefinementSupport = levels_of_refinement_ > 0 ? true - : false; - mesh.initialize(parallel_mach, true, buildRefinementSupport); - } - - // grab mesh data pointer to build the bulk data - stk::mesh::MetaData& metaData = *mesh.getMetaData(); - stk::mesh::BulkData& bulkData = *mesh.getBulkData(); - stk::io::StkMeshIoBroker* mesh_data = const_cast( - metaData.get_attribute()); - - // remove the MeshData attribute - TEUCHOS_ASSERT(metaData.remove_attribute(mesh_data)); - - // build mesh bulk data - mesh_data->populate_bulk_data(); - - // Refine - const bool delete_parent_elements = true; - if (levels_of_refinement_ > 0) - mesh.refineMesh(levels_of_refinement_, delete_parent_elements); - - // The following section of code is applicable if mesh scaling is - // turned on from the input file. - if (user_mesh_scaling_) - { -#if TRILINOS_MAJOR_MINOR_VERSION >= 140000 - stk::mesh::Field* coord_field = metaData.get_field( - stk::topology::NODE_RANK, "coordinates"); -#else - stk::mesh::Field* coord_field - = metaData.get_field>( - stk::topology::NODE_RANK, "coordinates"); -#endif - - stk::mesh::Selector select_all_local - = metaData.locally_owned_part() | metaData.globally_shared_part(); - stk::mesh::BucketVector const& my_node_buckets - = bulkData.get_buckets(stk::topology::NODE_RANK, select_all_local); - - int mesh_dim = mesh.getDimension(); - - // Scale the mesh - const double inv_msf = 1.0 / mesh_scale_factor_; - for (size_t i = 0; i < my_node_buckets.size(); ++i) - { - stk::mesh::Bucket& b = *(my_node_buckets[i]); - double* coordinate_data = field_data(*coord_field, b); - - for (size_t j = 0; j < b.size(); ++j) - { - for (int k = 0; k < mesh_dim; ++k) - { - coordinate_data[mesh_dim * j + k] *= inv_msf; - } - } - } - } - - // put in a negative index and (like python) the restart will be from the - // back (-1 is the last time step) - int restart_index = restart_index_; - if (restart_index < 0) - { -#if TRILINOS_MAJOR_MINOR_VERSION >= 140500 - std::pair lastTimeStep - = mesh_data->get_input_ioss_region()->get_max_time(); -#else - std::pair lastTimeStep - = mesh_data->get_input_io_region()->get_max_time(); -#endif - restart_index = 1 + restart_index + lastTimeStep.first; - } - - // populate mesh fields with specific index - mesh_data->read_defined_input_fields(restart_index); - - mesh.buildSubcells(); - mesh.buildLocalElementIDs(); - - if (user_mesh_scaling_) - { -#if TRILINOS_MAJOR_MINOR_VERSION >= 140000 - stk::mesh::Field* coord_field = metaData.get_field( - stk::topology::NODE_RANK, "coordinates"); -#else - stk::mesh::Field* coord_field - = metaData.get_field>( - stk::topology::NODE_RANK, "coordinates"); -#endif - std::vector fields; - fields.push_back(coord_field); - - stk::mesh::communicate_field_data(bulkData, fields); - } - - // process_input_request is a no-op if restart_index <= 0 ... thus there - // would be no inital time - if (restart_index > 0) - { -#if TRILINOS_MAJOR_MINOR_VERSION >= 140500 - mesh.setInitialStateTime( - mesh_data->get_input_ioss_region()->get_state_time(restart_index)); -#else - mesh.setInitialStateTime( - mesh_data->get_input_io_region()->get_state_time(restart_index)); -#endif - } - else - { - mesh.setInitialStateTime(0.0); - } - - // clean up mesh data object - delete mesh_data; - - // calls Stk_MeshFactory::rebalance - this->rebalance(mesh); -} - -//---------------------------------------------------------------------------// -//! From ParameterListAcceptor -void StkReaderFactory::setParameterList( - const Teuchos::RCP& param_list) -{ - TEUCHOS_TEST_FOR_EXCEPTION_PURE_MSG( - !param_list->isParameter("File Name"), - Teuchos::Exceptions::InvalidParameterName, - "Error, the parameter {name=\"File Name\"," - "type=\"string\"" - "\nis required in parameter (sub)list \"" - << param_list->name() - << "\"." - "\n\nThe parsed parameter parameter list is: \n" - << param_list->currentParametersString()); - - // Set default values here. Not all the params should be set so this - // has to be done manually as opposed to using - // validateParametersAndSetDefaults(). - if (!param_list->isParameter("Decomp Method")) - param_list->set("Decomp Method", "RIB"); - - if (!param_list->isParameter("Restart Index")) - param_list->set("Restart Index", -1); - - if (!param_list->isParameter("File Type")) - param_list->set("File Type", "Exodus"); - - if (!param_list->isSublist("Periodic BCs")) - param_list->sublist("Periodic BCs"); - - Teuchos::ParameterList& p_bcs = param_list->sublist("Periodic BCs"); - if (!p_bcs.isParameter("Count")) - p_bcs.set("Count", 0); - - if (!param_list->isParameter("Levels of Uniform Refinement")) - param_list->set("Levels of Uniform Refinement", 0); - - param_list->validateParameters(*getValidParameters(), 0); - - setMyParamList(param_list); - - file_name_ = param_list->get("File Name"); - - decomp_method_ = param_list->get("Decomp Method"); - - restart_index_ = param_list->get("Restart Index"); - - const auto file_type = param_list->get("File Type"); - is_exodus_ = (file_type == "Exodus"); - - // get any mesh scale factor - if (param_list->isParameter("Scale Factor")) - { - mesh_scale_factor_ = param_list->get("Scale Factor"); - user_mesh_scaling_ = true; - } - - // read in periodic boundary conditions -#if TRILINOS_MAJOR_MINOR_VERSION >= 130500 - parsePeriodicBCList(Teuchos::rcpFromRef(param_list->sublist("Periodic " - "BCs")), - this->periodicBCVec_, - this->useBBoxSearch_); -#else - parsePeriodicBCList(Teuchos::rcpFromRef(param_list->sublist("Periodic " - "BCs")), - this->periodicBCVec_); -#endif - - levels_of_refinement_ - = param_list->get("Levels of Uniform Refinement"); -} - -//---------------------------------------------------------------------------// -//! From ParameterListAcceptor -Teuchos::RCP -StkReaderFactory::getValidParameters() const -{ - static Teuchos::RCP validParams; - - if (validParams == Teuchos::null) - { - validParams = Teuchos::rcp(new Teuchos::ParameterList); - validParams->set( - "File Name", - "", - "Name of mesh file to be read", - Teuchos::rcp(new Teuchos::FileNameValidator)); - - validParams->set("Decomp Method", - "RIB", - "Parallel mesh decomposition method", - Teuchos::rcp(new Teuchos::StringValidator( - Ioss::valid_decomp_methods()))); - - validParams->set( - "Restart Index", - -1, - "Index of solution to read in", - Teuchos::rcp(new Teuchos::AnyNumberParameterEntryValidator( - Teuchos::AnyNumberParameterEntryValidator::PREFER_INT, - Teuchos::AnyNumberParameterEntryValidator::AcceptedTypes( - true)))); - - Teuchos::setStringToIntegralParameter( - "File Type", - "Exodus", - "Choose input file type - either \"Exodus\" or \"CGNS\"", - Teuchos::tuple("Exodus", "CGNS"), - validParams.get()); - - validParams->set( - "Scale Factor", - 1.0, - "Scale factor to apply to mesh after read", - Teuchos::rcp(new Teuchos::AnyNumberParameterEntryValidator( - Teuchos::AnyNumberParameterEntryValidator::PREFER_DOUBLE, - Teuchos::AnyNumberParameterEntryValidator::AcceptedTypes( - true)))); - - Teuchos::ParameterList& bcs = validParams->sublist("Periodic BCs"); - bcs.set("Count", 0); // no default periodic boundary conditions - - validParams->set("Levels of Uniform Refinement", - 0, - "Number of levels of inline uniform mesh refinement"); - } - - return validParams.getConst(); -} - -//---------------------------------------------------------------------------// -void StkReaderFactory::registerElementBlocks( - panzer_stk::STK_Interface& mesh, stk::io::StkMeshIoBroker& mesh_data) const -{ - auto femMetaData = mesh.getMetaData(); - - // here we use the Ioss interface because they don't add - // "bonus" element blocks and its easier to determine - // "real" element blocks versus STK-only blocks -#if TRILINOS_MAJOR_MINOR_VERSION >= 140500 - const Ioss::ElementBlockContainer& elem_blocks - = mesh_data.get_input_ioss_region()->get_element_blocks(); -#else - const Ioss::ElementBlockContainer& elem_blocks - = mesh_data.get_input_io_region()->get_element_blocks(); -#endif - for (const auto& entity : elem_blocks) - { - // Ioss::GroupingEntity* entity = *itr; - const std::string& name = entity->name(); - - const stk::mesh::Part* part = femMetaData->get_part(name); - shards::CellTopology cellTopo - = stk::mesh::get_cell_topology(femMetaData->get_topology(*part)); - const CellTopologyData* ct = cellTopo.getCellTopologyData(); - - TEUCHOS_ASSERT(ct != 0); - mesh.addElementBlock(part->name(), ct); - } -} - -//---------------------------------------------------------------------------// -void StkReaderFactory::registerSidesets(panzer_stk::STK_Interface& mesh) const -{ - Teuchos::RCP metaData = mesh.getMetaData(); - const stk::mesh::PartVector& parts = metaData->get_parts(); - - for (const auto& part : parts) - { - const stk::mesh::PartVector& subsets = part->subsets(); - shards::CellTopology cellTopo - = stk::mesh::get_cell_topology(metaData->get_topology(*part)); - const CellTopologyData* ct = cellTopo.getCellTopologyData(); - - // if a side part ==> this is a sideset: now storage is recursive - // on part contains all sub parts with consistent topology - if (part->primary_entity_rank() == mesh.getSideRank() && ct == 0 - && subsets.size() > 0) - { - TEUCHOS_TEST_FOR_EXCEPTION( - subsets.size() != 1, - std::runtime_error, - "StkReaderFactory::registerSidesets error - part \"" - << part->name() << "\" has more than one subset"); - - // grab cell topology and name of subset part - const stk::mesh::Part* ss_part = subsets[0]; - shards::CellTopology ss_cellTopo = stk::mesh::get_cell_topology( - metaData->get_topology(*ss_part)); - const CellTopologyData* ss_ct = ss_cellTopo.getCellTopologyData(); - - // only add subset parts that have no topology - if (ss_ct != 0) - mesh.addSideset(part->name(), ss_ct); - } - } -} - -//---------------------------------------------------------------------------// -void StkReaderFactory::registerNodesets(panzer_stk::STK_Interface& mesh) const -{ - Teuchos::RCP metaData = mesh.getMetaData(); - const stk::mesh::PartVector& parts = metaData->get_parts(); - - stk::mesh::PartVector::const_iterator partItr; - for (partItr = parts.begin(); partItr != parts.end(); ++partItr) - { - const stk::mesh::Part* part = *partItr; - shards::CellTopology cellTopo - = stk::mesh::get_cell_topology(metaData->get_topology(*part)); - const CellTopologyData* ct = cellTopo.getCellTopologyData(); - - // if a side part ==> this is a sideset: now storage is recursive - // on part contains all sub parts with consistent topology - if (part->primary_entity_rank() == mesh.getNodeRank() && ct == 0) - { - // only add subset parts that have no topology - if (part->name() != panzer_stk::STK_Interface::nodesString) - mesh.addNodeset(part->name()); - } - } -} - -//---------------------------------------------------------------------------// - -} // end namespace Mesh -} // end namespace VertexCFD diff --git a/src/mesh/VertexCFD_Mesh_StkReaderFactory.hpp b/src/mesh/VertexCFD_Mesh_StkReaderFactory.hpp deleted file mode 100644 index f3fd522..0000000 --- a/src/mesh/VertexCFD_Mesh_StkReaderFactory.hpp +++ /dev/null @@ -1,128 +0,0 @@ -#ifndef VERTEXCFD_MESH_STKREADERFACTORY_HPP -#define VERTEXCFD_MESH_STKREADERFACTORY_HPP - -#include - -#include -#include - -#include - -namespace VertexCFD -{ -namespace Mesh -{ -//---------------------------------------------------------------------------// -/** External function to return the dimension of an Exodus or CGNS - * mesh. This uses a quick temporary read of the meta data from input - * file/mesh and is intended if you need the mesh dimension before the - * MeshFactory is used to build the uncommitted mesh. Once - * buildUncommittedMesh() is called, you can query the dimension from - * the MetaData in the STK_Interface object (will be faster than - * creating mesh metadata done in this function). - * - * \param[in] mesh_str Filename containing the mesh string, or the mesh string - * itself. - * \param[in] parallel_mach Descriptor for machine to build this mesh on. - * \param[in] is_exodus Set to true for Exodus mesh, set to false for CGNS - * mesh. - * - * \returns Integer indicating the spatial dimension of the mesh. - */ -int getMeshDimension(const std::string& mesh_str, - stk::ParallelMachine parallel_mach, - const bool is_exodus = true); - -//---------------------------------------------------------------------------// -/** Concrete mesh factory instantiation. This reads - * a mesh from an exodus file and builds a STK_Interface object. - * - * Also, if a nonzero restart index (the Exodus indices are 1 based) is - * specified then this will set the initial state time in the STK_Interface. - * However, as prescribed by that interface the currentStateTime is only - * set by the writeToExodus call, thus the currentStateTime of the created - * STK_Interface object will be zero. It is up to the user to rectify this - * when calling writeToExodus. - */ -class StkReaderFactory : public panzer_stk::STK_MeshFactory -{ - public: - StkReaderFactory(); - - /** \brief Ctor - * - * \param[in] file_name Name of the input file. - * \param[in] restart_index Index used for restarts. - * \param[in] is_exodus If true, the input file is in exodus format. If - * false, it assumes CGNS format. - */ - StkReaderFactory(const std::string& file_name, - const int restart_index = 0, - const bool is_exodus = true); - - /** Construct a STK_Inteface object described by this factory. - * - * \param[in] parallel_mach Descriptor for machine to build this mesh on. - * - * \returns Pointer to STK_Interface object with - * isModifiable()==false. - */ - virtual Teuchos::RCP - buildMesh(stk::ParallelMachine parallel_mach) const override; - - /** This builds all the meta data of the mesh. Does not call - * metaData->commit. Allows user to add solution fields and other pieces. - * The mesh can be "completed" by calling - * completeMeshConstruction. - */ - virtual Teuchos::RCP - buildUncommitedMesh(stk::ParallelMachine parallel_mach) const override; - - /** Finishes building a mesh object started by - * buildUncommitedMesh. - */ - virtual void - completeMeshConstruction(panzer_stk::STK_Interface& mesh, - stk::ParallelMachine parallel_mach) const override; - - //! From ParameterListAcceptor. Must be called if the empty ctor is used to - //! construct this object. - void setParameterList( - const Teuchos::RCP& param_list) override; - - //! From ParameterListAcceptor - Teuchos::RCP - getValidParameters() const override; - - //! Get file name mean is read from. - const std::string& getFileName() const { return file_name_; } - - protected: - void registerElementBlocks(panzer_stk::STK_Interface& mesh, - stk::io::StkMeshIoBroker& mesh_data) const; - void registerSidesets(panzer_stk::STK_Interface& mesh) const; - void registerNodesets(panzer_stk::STK_Interface& mesh) const; - - std::string file_name_; - std::string decomp_method_; - int restart_index_; - bool is_exodus_; - - private: - //! Did the user request mesh scaling - bool user_mesh_scaling_; - - //! If requested, scale the input mesh by this factor - double mesh_scale_factor_; - - //! Number of levels of inline uniform mesh refinement to be applied to - //! exodus mesh - int levels_of_refinement_; -}; - -//---------------------------------------------------------------------------// - -} // end namespace Mesh -} // end namespace VertexCFD - -#endif // VERTEXCFD_STKREADERFACTORY_HPP diff --git a/src/mesh/unit_test/CMakeLists.txt b/src/mesh/unit_test/CMakeLists.txt deleted file mode 100644 index 7fe1991..0000000 --- a/src/mesh/unit_test/CMakeLists.txt +++ /dev/null @@ -1,28 +0,0 @@ -set(TEST_HARNESS_DIR ${CMAKE_SOURCE_DIR}/src/test_harness) -include(${TEST_HARNESS_DIR}/TestHarness.cmake) - -configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/test_data/read_only_test.restart.data - ${CMAKE_CURRENT_BINARY_DIR}/read_only_test.restart.data - COPYONLY) - -configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/test_data/read_only_test.restart.dofmap - ${CMAKE_CURRENT_BINARY_DIR}/read_only_test.restart.dofmap - COPYONLY) - -configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/test_data/read_only_test_periodic.restart.data - ${CMAKE_CURRENT_BINARY_DIR}/read_only_test_periodic.restart.data - COPYONLY) - -configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/test_data/read_only_test_periodic.restart.dofmap - ${CMAKE_CURRENT_BINARY_DIR}/read_only_test_periodic.restart.dofmap - COPYONLY) - -VertexCFD_add_tests( - MPI - LIBS VertexCFD - NAMES Restart GeometryPrimitives - ) diff --git a/src/mesh/unit_test/test_data/.gitattributes b/src/mesh/unit_test/test_data/.gitattributes deleted file mode 100644 index 3107f4c..0000000 --- a/src/mesh/unit_test/test_data/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -* !filter !diff !merge !text diff --git a/src/mesh/unit_test/test_data/read_only_test.restart.data b/src/mesh/unit_test/test_data/read_only_test.restart.data deleted file mode 100644 index c97c67f..0000000 Binary files a/src/mesh/unit_test/test_data/read_only_test.restart.data and /dev/null differ diff --git a/src/mesh/unit_test/test_data/read_only_test.restart.dofmap b/src/mesh/unit_test/test_data/read_only_test.restart.dofmap deleted file mode 100644 index f2cc02b..0000000 Binary files a/src/mesh/unit_test/test_data/read_only_test.restart.dofmap and /dev/null differ diff --git a/src/mesh/unit_test/test_data/read_only_test_periodic.restart.data b/src/mesh/unit_test/test_data/read_only_test_periodic.restart.data deleted file mode 100644 index d5eabf1..0000000 Binary files a/src/mesh/unit_test/test_data/read_only_test_periodic.restart.data and /dev/null differ diff --git a/src/mesh/unit_test/test_data/read_only_test_periodic.restart.dofmap b/src/mesh/unit_test/test_data/read_only_test_periodic.restart.dofmap deleted file mode 100644 index c9b5a46..0000000 Binary files a/src/mesh/unit_test/test_data/read_only_test_periodic.restart.dofmap and /dev/null differ diff --git a/src/mesh/unit_test/tstGeometryPrimitives.cpp b/src/mesh/unit_test/tstGeometryPrimitives.cpp deleted file mode 100644 index 2b9aea1..0000000 --- a/src/mesh/unit_test/tstGeometryPrimitives.cpp +++ /dev/null @@ -1,316 +0,0 @@ -#include - -#include - -#include -#include - -#include - -#include - -//---------------------------------------------------------------------------// -// TESTS -//---------------------------------------------------------------------------// -namespace VertexCFD -{ -namespace Test -{ -//---------------------------------------------------------------------------// -template -KOKKOS_INLINE_FUNCTION void faceDistanceFunc(SideViewType sides, - PointViewType point, - ResultViewType result, - NormalViewType normal, - int index) -{ - int orient[3] = {0, 1, 2}; - result(index, 0) = VertexCFD::GeometryPrimitives::tetCheck( - sides, normal, 0, point, 0, 0, orient); - result(index, 1) = VertexCFD::GeometryPrimitives::planeIntersect( - sides, normal, 0, point, 0, 0); - result(index, 2) = VertexCFD::GeometryPrimitives::distanceToTriangleFace( - sides, normal, 0, point, 0, 0, orient); -} - -template -void testEval() -{ - double tol = 1e-6; - - // Define kokkos views needed for all tests - Kokkos::View point( - Kokkos::ViewAllocateWithoutInitializing("pointView"), 1, 1, 3); - Kokkos::View sides( - Kokkos::ViewAllocateWithoutInitializing("sidesView"), 1, 3, 3); - Kokkos::View normal( - Kokkos::ViewAllocateWithoutInitializing("normalView"), 1, 3); - Kokkos::View dist( - Kokkos::ViewAllocateWithoutInitializing("distanceView")); - - // Test of linearEdge function - Kokkos::parallel_for( - "linearEdgeTest", - Kokkos::RangePolicy(0, 1), - KOKKOS_LAMBDA(const int) { - // Define the line segment to test against - for (int dim = 0; dim < 3; ++dim) - { - sides(0, 0, dim) = 0.0; - sides(0, 1, dim) = 1.0; - } - sides(0, 1, 2) = 0.0; - - // Test for 3d test_point that is closest to some point on the line - // segment - point(0, 0, 0) = 0.1; - point(0, 0, 1) = 0.1; - point(0, 0, 2) = 1.0; - int index[2] = {0, 1}; - dist(0) = VertexCFD::GeometryPrimitives::distanceToLinearEdge( - sides, 0, point, 0, 0, 3, index); - - // Test for 3d test_point that is closest to the end of the line - point(0, 0, 0) = 2.5; - point(0, 0, 1) = 1.0; - point(0, 0, 2) = 2.0; - dist(1) = VertexCFD::GeometryPrimitives::distanceToLinearEdge( - sides, 0, point, 0, 0, 3, index); - - // Test for 3d test_point that is closest to the start of the line - point(0, 0, 0) = -1.0; - point(0, 0, 1) = -2.4; - point(0, 0, 2) = 0.0; - dist(2) = VertexCFD::GeometryPrimitives::distanceToLinearEdge( - sides, 0, point, 0, 0, 3, index); - - // Test for 2d test_point that is closest to the end of the line - point(0, 0, 0) = 1.0; - point(0, 0, 1) = 3.0; - dist(3) = VertexCFD::GeometryPrimitives::distanceToLinearEdge( - sides, 0, point, 0, 0, 2, index); - - // Test for 2d test_point that is closest to the some point on the - // line - point(0, 0, 0) = 0.2; - point(0, 0, 1) = 0.8; - dist(4) = VertexCFD::GeometryPrimitives::distanceToLinearEdge( - sides, 0, point, 0, 0, 2, index); - - // Test for 2d test_point that is closest to the start of the line - point(0, 0, 0) = -0.8; - point(0, 0, 1) = 0.6; - dist(5) = VertexCFD::GeometryPrimitives::distanceToLinearEdge( - sides, 0, point, 0, 0, 2, index); - }); - - auto dist_mirror - = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), dist); - EXPECT_DOUBLE_EQ(1.0, dist_mirror(0)); - EXPECT_DOUBLE_EQ(2.5, dist_mirror(1)); - EXPECT_DOUBLE_EQ(2.6, dist_mirror(2)); - EXPECT_DOUBLE_EQ(2.0, dist_mirror(3)); - EXPECT_NEAR(0.424264, dist_mirror(4), tol); - EXPECT_DOUBLE_EQ(1.0, dist_mirror(5)); - - Kokkos::View result( - Kokkos::ViewAllocateWithoutInitializing("ResultView")); - - // Test of distanceToTriangleFace, tetCheck and planeIntersect functions - Kokkos::parallel_for( - "tetIntersectTest", - Kokkos::RangePolicy(0, 1), - KOKKOS_LAMBDA(const int) { - // Define the unit triangle to test against - for (int dim = 0; dim < 3; ++dim) - { - sides(0, 0, dim) = 0.0; - sides(0, 1, dim) = 0.0; - sides(0, 2, dim) = 0.0; - normal(0, dim) = 0.0; - } - sides(0, 1, 0) = 1.0; - sides(0, 2, 1) = 1.0; - normal(0, 2) = 1.0; - - // Test for a point that intersects the triangle - int index = 0; - point(0, 0, 0) = 0.1; - point(0, 0, 1) = 0.1; - point(0, 0, 2) = 1.0; - faceDistanceFunc(sides, point, result, normal, index); - - // Test for a point that is closest to edge ab - ++index; - point(0, 0, 0) = 0.5; - point(0, 0, 1) = -0.5; - point(0, 0, 2) = 1.0; - faceDistanceFunc(sides, point, result, normal, index); - - // Test for a point that is closest to edge bc - ++index; - point(0, 0, 0) = 1.0; - point(0, 0, 1) = 1.0; - point(0, 0, 2) = 1.0; - faceDistanceFunc(sides, point, result, normal, index); - - // Test for a point that is closest to edge ca - ++index; - point(0, 0, 0) = -0.5; - point(0, 0, 1) = 0.5; - point(0, 0, 2) = 1.0; - faceDistanceFunc(sides, point, result, normal, index); - - // Test for a point that is closest to edge ab or bc - ++index; - point(0, 0, 0) = 2.0; - point(0, 0, 1) = -1.0; - point(0, 0, 2) = 1.0; - faceDistanceFunc(sides, point, result, normal, index); - - // Test for a point that is closest to edge bc or ca - ++index; - point(0, 0, 0) = -1.0; - point(0, 0, 1) = 4.0; - point(0, 0, 2) = 1.0; - faceDistanceFunc(sides, point, result, normal, index); - - // Test for a point that is closest to edge ca or ab - ++index; - point(0, 0, 0) = -2.0; - point(0, 0, 1) = -1.0; - point(0, 0, 2) = 1.0; - faceDistanceFunc(sides, point, result, normal, index); - }); - - auto result_mirror - = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), result); - - EXPECT_EQ(0, result_mirror(0, 0)); - EXPECT_DOUBLE_EQ(1.0, result_mirror(0, 1)); - EXPECT_NEAR(1.0, result_mirror(0, 2), tol); - - EXPECT_EQ(1, result_mirror(1, 0)); - EXPECT_DOUBLE_EQ(1.0, result_mirror(1, 1)); - EXPECT_NEAR(1.118034, result_mirror(1, 2), tol); - - EXPECT_EQ(2, result_mirror(2, 0)); - EXPECT_DOUBLE_EQ(1.0, result_mirror(2, 1)); - EXPECT_NEAR(1.22474487, result_mirror(2, 2), tol); - - EXPECT_EQ(3, result_mirror(3, 0)); - EXPECT_DOUBLE_EQ(1.0, result_mirror(3, 1)); - EXPECT_NEAR(1.118034, result_mirror(3, 2), tol); - - EXPECT_EQ(4, result_mirror(4, 0)); - EXPECT_DOUBLE_EQ(1.0, result_mirror(4, 1)); - EXPECT_NEAR(1.732050807, result_mirror(4, 2), tol); - - EXPECT_EQ(5, result_mirror(5, 0)); - EXPECT_DOUBLE_EQ(1.0, result_mirror(5, 1)); - EXPECT_NEAR(3.31662479, result_mirror(5, 2), tol); - - EXPECT_EQ(6, result_mirror(6, 0)); - EXPECT_DOUBLE_EQ(1.0, result_mirror(6, 1)); - EXPECT_NEAR(2.44948974, result_mirror(6, 2), tol); - - // Test the crossProduct function - Kokkos::View cross_product( - Kokkos::ViewAllocateWithoutInitializing("CrossProductView")); - - Kokkos::parallel_for( - "CrossProductTest", - Kokkos::RangePolicy(0, 1), - KOKKOS_LAMBDA(const int) { - double array1[3]; - double array2[3]; - double array_out[3]; - array1[0] = 1.0; - array1[1] = 0.0; - array1[2] = 0.0; - - array2[0] = 0.0; - array2[1] = 1.0; - array2[2] = 0.0; - VertexCFD::GeometryPrimitives::crossProduct( - array1, array2, array_out); - cross_product(0, 0) = array_out[0]; - cross_product(0, 1) = array_out[1]; - cross_product(0, 2) = array_out[2]; - - array2[0] = 0.0; - array2[1] = 0.0; - array2[2] = 1.0; - VertexCFD::GeometryPrimitives::crossProduct( - array1, array2, array_out); - cross_product(1, 0) = array_out[0]; - cross_product(1, 1) = array_out[1]; - cross_product(1, 2) = array_out[2]; - - array2[0] = 1.0; - array2[1] = 0.0; - array2[2] = 0.0; - VertexCFD::GeometryPrimitives::crossProduct( - array1, array2, array_out); - cross_product(2, 0) = array_out[0]; - cross_product(2, 1) = array_out[1]; - cross_product(2, 2) = array_out[2]; - - array2[0] = 1.0; - array2[1] = 1.0; - array2[2] = 1.0; - VertexCFD::GeometryPrimitives::crossProduct( - array1, array2, array_out); - cross_product(3, 0) = array_out[0]; - cross_product(3, 1) = array_out[1]; - cross_product(3, 2) = array_out[2]; - - array2[0] = 0.0; - array2[1] = 0.0; - array2[2] = 0.0; - VertexCFD::GeometryPrimitives::crossProduct( - array1, array2, array_out); - cross_product(4, 0) = array_out[0]; - cross_product(4, 1) = array_out[1]; - cross_product(4, 2) = array_out[2]; - }); - - auto cross_product_mirror = Kokkos::create_mirror_view_and_copy( - Kokkos::HostSpace(), cross_product); - EXPECT_EQ(0, cross_product_mirror(0, 0)); - EXPECT_EQ(0, cross_product_mirror(0, 1)); - EXPECT_EQ(1, cross_product_mirror(0, 2)); - - EXPECT_EQ(0, cross_product_mirror(1, 0)); - EXPECT_EQ(-1, cross_product_mirror(1, 1)); - EXPECT_EQ(0, cross_product_mirror(1, 2)); - - EXPECT_EQ(0, cross_product_mirror(2, 0)); - EXPECT_EQ(0, cross_product_mirror(2, 1)); - EXPECT_EQ(0, cross_product_mirror(2, 2)); - - EXPECT_EQ(0, cross_product_mirror(3, 0)); - EXPECT_EQ(-1, cross_product_mirror(3, 1)); - EXPECT_EQ(1, cross_product_mirror(3, 2)); - - EXPECT_EQ(0, cross_product_mirror(4, 0)); - EXPECT_EQ(0, cross_product_mirror(4, 1)); - EXPECT_EQ(0, cross_product_mirror(4, 2)); -} - -//---------------------------------------------------------------------------// -TEST(GeometryPrimitives, residual_test) -{ - testEval(); -} - -//---------------------------------------------------------------------------// -TEST(GeometryPrimitives, jacobian_test) -{ - testEval(); -} - -//---------------------------------------------------------------------------// - -} // end namespace Test -} // end namespace VertexCFD diff --git a/src/observers/VertexCFD_Compute_ErrorNorms.hpp b/src/observers/VertexCFD_Compute_ErrorNorms.hpp deleted file mode 100644 index 9d76dec..0000000 --- a/src/observers/VertexCFD_Compute_ErrorNorms.hpp +++ /dev/null @@ -1,100 +0,0 @@ -#ifndef VERTEXCFD_COMPUTE_ERRORNORMS_HPP -#define VERTEXCFD_COMPUTE_ERRORNORMS_HPP - -#include "boundary_conditions/VertexCFD_BCStrategy_Factory.hpp" -#include "equation_sets/VertexCFD_EquationSet_Factory.hpp" - -#include -#include -#include -#include -#include - -#include - -#include -#include - -#include - -#include - -namespace VertexCFD -{ -namespace ComputeErrorNorms -{ -//---------------------------------------------------------------------------// -template -class ErrorNorms -{ - public: - ErrorNorms( - const Teuchos::RCP& mesh, - const Teuchos::RCP>& lof, - const Teuchos::RCP>& - response_library, - const std::vector>& physics_blocks, - const panzer::ClosureModelFactory_TemplateManager& - cm_factory, - const Teuchos::ParameterList& closure_params, - const Teuchos::ParameterList& user_params, - const Teuchos::RCP& eq_set_factory, - const double volume, - const int integration_order); - - void ComputeNorms( - const Teuchos::RCP>& working_state); - - struct DofErrorNorm - { - std::string name{}; - double error_norm = 0.0; - - explicit DofErrorNorm(const std::string& dof_name) - : name(dof_name) - { - } - ~DofErrorNorm() = default; - DofErrorNorm(const DofErrorNorm&) = default; - DofErrorNorm& operator=(const DofErrorNorm&) = default; - DofErrorNorm(DofErrorNorm&&) = default; - DofErrorNorm& operator=(DofErrorNorm&&) = default; - }; - - private: - Teuchos::RCP> _lof; - Teuchos::RCP> _response_library; - std::vector> _physics_blocks; - panzer::ClosureModelFactory_TemplateManager _cm_factory; - Teuchos::ParameterList _closure_params; - Teuchos::ParameterList _user_params; - - Teuchos::RCP _eq_set_factory; - - double _volume; - std::vector _L1_error_norms; - std::vector _L2_error_norms; - int _L1_error_norm_order; - int _L2_error_norm_order; - int _num_mom_eq; - - public: - const std::vector& L1_errorNorms() const - { - return _L1_error_norms; - } - - const std::vector& L2_errorNorms() const - { - return _L2_error_norms; - } -}; - -//---------------------------------------------------------------------------// - -} // end namespace ComputeErrorNorms -} // end namespace VertexCFD - -#include "VertexCFD_Compute_ErrorNorms_impl.hpp" - -#endif // end VERTEXCFD_COMPUTE_ERRORNORMS_HPP diff --git a/src/observers/VertexCFD_Compute_ErrorNorms_impl.hpp b/src/observers/VertexCFD_Compute_ErrorNorms_impl.hpp deleted file mode 100644 index 1fb0ac7..0000000 --- a/src/observers/VertexCFD_Compute_ErrorNorms_impl.hpp +++ /dev/null @@ -1,174 +0,0 @@ -#ifndef VERTEXCFD_COMPUTE_ERRORNORMS_IMPL_HPP -#define VERTEXCFD_COMPUTE_ERRORNORMS_IMPL_HPP - -#include - -#include - -#include -#include - -namespace VertexCFD -{ -namespace ComputeErrorNorms -{ -//---------------------------------------------------------------------------// -template -ErrorNorms::ErrorNorms( - const Teuchos::RCP& mesh, - const Teuchos::RCP>& lof, - const Teuchos::RCP>& response_library, - const std::vector>& physics_blocks, - const panzer::ClosureModelFactory_TemplateManager& cm_factory, - const Teuchos::ParameterList& closure_params, - const Teuchos::ParameterList& user_params, - const Teuchos::RCP& eq_set_factory, - const double volume, - const int integration_order) - : _lof(lof) - , _response_library(response_library) - , _physics_blocks(physics_blocks) - , _cm_factory(cm_factory) - , _closure_params(closure_params) - , _user_params(user_params) - , _eq_set_factory(eq_set_factory) - , _volume(volume) -{ - // Initialize names of equation based on the equation set name - std::vector eq_name; - _num_mom_eq = mesh->getDimension(); - // Continuity equation - eq_name.push_back("continuity"); - // Temperature equation - if (_user_params.isType("Build Temperature Equation")) - { - if (_user_params.get("Build Temperature Equation")) - eq_name.push_back("energy"); - } - // Full induction equation - if (_user_params.isSublist("Full Induction MHD Properties")) - { - for (int i = 0; i < _num_mom_eq; ++i) - { - eq_name.push_back("induction_" + std::to_string(i)); - } - } - // Momentum equation - for (int i = 0; i < _num_mom_eq; ++i) - eq_name.push_back("momentum_" + std::to_string(i)); - - // Add response library - std::vector element_blocks; - mesh->getElementBlockNames(element_blocks); - - panzer::FunctionalResponse_Builder response_builder; - response_builder.comm = Teuchos::getRawMpiComm(*(mesh->getComm())); - response_builder.cubatureDegree = integration_order; - response_builder.requiresCellIntegral = true; - - // L1 error norm - auto add_dof_L1 = [&](const std::string& dof) { - response_builder.quadPointField = "L1_Error_" + dof; - _response_library->addResponse( - dof + "_L1_error_norms", element_blocks, response_builder); - - _L1_error_norms.emplace_back(dof); - }; - - // L2 error norm - auto add_dof_L2 = [&](const std::string& dof) { - response_builder.quadPointField = "L2_Error_" + dof; - _response_library->addResponse( - dof + "_L2_error_norms", element_blocks, response_builder); - - _L2_error_norms.emplace_back(dof); - }; - - // Add L1 and L2 error norms - for (auto& element : eq_name) - { - add_dof_L1(element); - add_dof_L2(element); - } - - // Finalize construction of response library - _response_library->buildResponseEvaluators( - _physics_blocks, _cm_factory, _closure_params, _user_params); -} - -//---------------------------------------------------------------------------// -template -void ErrorNorms::ComputeNorms( - const Teuchos::RCP>& working_state) -{ - // Get the working X - auto x = working_state->getX(); - - // Assemble linear system - panzer::AssemblyEngineInArgs in_args; - in_args.container_ = _lof->buildLinearObjContainer(); - in_args.ghostedContainer_ = _lof->buildGhostedLinearObjContainer(); - in_args.evaluate_transient_terms = false; - in_args.time = working_state->getTime(); - - _lof->initializeGhostedContainer(panzer::LinearObjContainer::X, - *(in_args.ghostedContainer_)); - - auto thyra_container - = Teuchos::rcp_dynamic_cast>( - in_args.container_); - thyra_container->set_x_th( - Teuchos::rcp_const_cast>(x)); - - // Set up resp, resp_func, resp_vec for L1_error_norms - for (auto& dof : _L1_error_norms) - { - auto resp = _response_library->getResponse( - dof.name + "_L1_error_norms"); - auto resp_func = Teuchos::rcp_dynamic_cast< - panzer::Response_Functional>(resp); - auto resp_vec = Thyra::createMember(resp_func->getVectorSpace()); - resp_func->setVector(resp_vec); - } - - // Set up resp, resp_func, resp_vec for L2_error_norms - for (auto& dof : _L2_error_norms) - { - auto resp = _response_library->getResponse( - dof.name + "_L2_error_norms"); - auto resp_func = Teuchos::rcp_dynamic_cast< - panzer::Response_Functional>(resp); - auto resp_vec = Thyra::createMember(resp_func->getVectorSpace()); - resp_func->setVector(resp_vec); - } - - _response_library->addResponsesToInArgs(in_args); - _response_library->evaluate(in_args); - - // Compute L1 error norm - for (auto& dof : _L1_error_norms) - { - auto resp = _response_library->getResponse( - dof.name + "_L1_error_norms"); - auto resp_func = Teuchos::rcp_dynamic_cast< - panzer::Response_Functional>(resp); - dof.error_norm = (resp_func->value) / _volume; - } - - // Compute L2 error norm - for (auto& dof : _L2_error_norms) - { - auto resp = _response_library->getResponse( - dof.name + "_L2_error_norms"); - auto resp_func = Teuchos::rcp_dynamic_cast< - panzer::Response_Functional>(resp); - dof.error_norm = std::sqrt(resp_func->value) / _volume; - } -} - -//---------------------------------------------------------------------------// - -} // end namespace ComputeErrorNorms -} // end namespace VertexCFD - -#endif // end VERTEXCFD_COMPUTE_ERRORNORMS_IMPL_HPP diff --git a/src/observers/VertexCFD_Compute_Volume.hpp b/src/observers/VertexCFD_Compute_Volume.hpp deleted file mode 100644 index 5ca2d2d..0000000 --- a/src/observers/VertexCFD_Compute_Volume.hpp +++ /dev/null @@ -1,71 +0,0 @@ -#ifndef VERTEXCFD_COMPUTE_VOLUME_HPP -#define VERTEXCFD_COMPUTE_VOLUME_HPP - -#include "equation_sets/VertexCFD_EquationSet_Factory.hpp" - -#include -#include -#include -#include -#include -#include - -#include - -#include -#include - -#include - -namespace VertexCFD -{ -namespace ComputeVolume -{ -//---------------------------------------------------------------------------// -template -class Volume -{ - public: - Volume( - const Teuchos::RCP& mesh, - const Teuchos::RCP>& lof, - const Teuchos::RCP>& - response_library, - const std::vector>& physics_blocks, - const panzer::ClosureModelFactory_TemplateManager& - cm_factory, - const Teuchos::ParameterList& closure_params, - const Teuchos::ParameterList& user_params, - const Teuchos::RCP& workset_container, - const std::vector& bcs, - const Teuchos::RCP& bc_factory, - const Teuchos::RCP& eq_set_factory, - const int integration_order); - - void ComputeVol(); - double volume() const; - - private: - Teuchos::RCP> _lof; - Teuchos::RCP> _response_library; - std::vector> _physics_blocks; - panzer::ClosureModelFactory_TemplateManager _cm_factory; - Teuchos::ParameterList _closure_params; - Teuchos::ParameterList _user_params; - Teuchos::RCP _workset_container; - - std::vector _bcs; - Teuchos::RCP _bc_factory; - Teuchos::RCP _eq_set_factory; - - double _volume; -}; - -//---------------------------------------------------------------------------// - -} // end namespace ComputeVolume -} // end namespace VertexCFD - -#include "VertexCFD_Compute_Volume_impl.hpp" - -#endif // end VERTEXCFD_COMPUTE_VOLUME_HPP diff --git a/src/observers/VertexCFD_Compute_Volume_impl.hpp b/src/observers/VertexCFD_Compute_Volume_impl.hpp deleted file mode 100644 index dac281a..0000000 --- a/src/observers/VertexCFD_Compute_Volume_impl.hpp +++ /dev/null @@ -1,100 +0,0 @@ -#ifndef VERTEXCFD_COMPUTE_VOLUME_IMPL_HPP -#define VERTEXCFD_COMPUTE_VOLUME_IMPL_HPP - -#include - -#include - -#include -#include - -namespace VertexCFD -{ -namespace ComputeVolume -{ -//---------------------------------------------------------------------------// -template -Volume::Volume( - const Teuchos::RCP& mesh, - const Teuchos::RCP>& lof, - const Teuchos::RCP>& response_library, - const std::vector>& physics_blocks, - const panzer::ClosureModelFactory_TemplateManager& cm_factory, - const Teuchos::ParameterList& closure_params, - const Teuchos::ParameterList& user_params, - const Teuchos::RCP& workset_container, - const std::vector& bcs, - const Teuchos::RCP& bc_factory, - const Teuchos::RCP& eq_set_factory, - const int integration_order) - : _lof(lof) - , _response_library(response_library) - , _physics_blocks(physics_blocks) - , _cm_factory(cm_factory) - , _closure_params(closure_params) - , _user_params(user_params) - , _workset_container(workset_container) - , _bcs(bcs) - , _bc_factory(bc_factory) - , _eq_set_factory(eq_set_factory) -{ - // Add response library - std::vector element_blocks; - mesh->getElementBlockNames(element_blocks); - - panzer::FunctionalResponse_Builder response_builder_vol; - response_builder_vol.comm = Teuchos::getRawMpiComm(*(mesh->getComm())); - response_builder_vol.cubatureDegree = integration_order; - response_builder_vol.requiresCellIntegral = true; - - response_builder_vol.quadPointField = "volume"; - - _response_library->addResponse( - "compute volume", element_blocks, response_builder_vol); - - // Finalize construction of response library - _response_library->buildResponseEvaluators( - _physics_blocks, _cm_factory, _closure_params, _user_params); -} - -//---------------------------------------------------------------------------// -template -void Volume::ComputeVol() -{ - // Assemble linear system - panzer::AssemblyEngineInArgs in_args; - in_args.container_ = _lof->buildLinearObjContainer(); - in_args.ghostedContainer_ = _lof->buildGhostedLinearObjContainer(); - in_args.evaluate_transient_terms = false; - - _lof->initializeGhostedContainer(panzer::LinearObjContainer::X - | panzer::LinearObjContainer::F - | panzer::LinearObjContainer::Mat, - *(in_args.ghostedContainer_)); - - // Set up resp, resp_func, resp_vec for volume - auto resp_vol = _response_library->getResponse( - "compute volume"); - auto resp_func_vol = Teuchos::rcp_dynamic_cast< - panzer::Response_Functional>(resp_vol); - auto resp_vec_vol = Thyra::createMember(resp_func_vol->getVectorSpace()); - resp_func_vol->setVector(resp_vec_vol); - - _response_library->addResponsesToInArgs(in_args); - _response_library->evaluate(in_args); - - _volume = resp_func_vol->value; -} - -//---------------------------------------------------------------------------// -template -double Volume::volume() const -{ - return _volume; -} -//---------------------------------------------------------------------------// - -} // end namespace ComputeVolume -} // end namespace VertexCFD - -#endif // end VERTEXCFD_COMPUTE_VOLUME_IMPL_HPP diff --git a/src/observers/VertexCFD_NOXObserver_IterationOutput.cpp b/src/observers/VertexCFD_NOXObserver_IterationOutput.cpp deleted file mode 100644 index bfc9cc9..0000000 --- a/src/observers/VertexCFD_NOXObserver_IterationOutput.cpp +++ /dev/null @@ -1,86 +0,0 @@ -#include "VertexCFD_NOXObserver_IterationOutput.hpp" - -#include - -#include - -namespace VertexCFD -{ -namespace NOXObserver -{ -//---------------------------------------------------------------------------// -IterationOutput::IterationOutput() - : _ostream(Teuchos::rcp(&std::cout, false)) -{ - _ostream.setShowProcRank(false); - _ostream.setOutputToRootOnly(0); -} - -//---------------------------------------------------------------------------// -void IterationOutput::runPreIterate(const NOX::Solver::Generic&) {} - -//---------------------------------------------------------------------------// -void IterationOutput::runPostIterate(const NOX::Solver::Generic& solver) -{ - // Output nonlinear solver results after nonlinear iteration. - auto stats = solver.getSolverStatistics(); - const auto& group = solver.getSolutionGroup(); - const SolveDataExtractor& data_extractor - = dynamic_cast(group); - _ostream << " " << std::setw(9) << std::right << std::fixed - << stats->numNonlinearIterations; - _ostream << " " << std::setw(8) << std::left << std::setprecision(2) - << std::scientific << group.getNormF(); - _ostream << " " << std::setw(8) << std::right << std::fixed - << data_extractor.lastLinearSolveNumIters(); - _ostream << " " << std::setw(8) << std::left << std::setprecision(2) - << std::scientific << data_extractor.lastLinearSolveAchievedTol(); - _ostream << " \n"; -} - -//---------------------------------------------------------------------------// -void IterationOutput::runPreSolve(const NOX::Solver::Generic& solver) -{ - _ostream << " | "; - _ostream << std::setw(9) << std::right << "Nonlinear"; - _ostream << " | " << std::setw(8) << std::left << "F 2-Norm"; - _ostream << " | "; - _ostream << std::setw(8) << std::right << "# Linear"; - _ostream << " | " << std::setw(8) << std::left << "R 2-Norm"; - _ostream << " | \n"; - - const auto& group = solver.getSolutionGroup(); - if (!group.isF()) - { - const_cast(group).computeF(); - } - _ostream << " " << std::setw(9) << std::right << std::fixed << 0; - _ostream << " " << std::setw(8) << std::left << std::setprecision(2) - << std::scientific << group.getNormF() << "\n"; -} - -//---------------------------------------------------------------------------// -void IterationOutput::runPostSolve(const NOX::Solver::Generic&) {} - -//---------------------------------------------------------------------------// -SolveDataExtractor::SolveDataExtractor(const NOX::Thyra::Group& group) - : NOX::Thyra::Group(group, NOX::ShapeCopy) -{ -} - -//---------------------------------------------------------------------------// -int SolveDataExtractor::lastLinearSolveNumIters() const -{ - return this->last_linear_solve_num_iters_; -} - -//---------------------------------------------------------------------------// -double SolveDataExtractor::lastLinearSolveAchievedTol() const -{ - return this->last_linear_solve_achieved_tol_; -} - -//---------------------------------------------------------------------------// - -} // end namespace NOXObserver -} // end namespace VertexCFD diff --git a/src/observers/VertexCFD_NOXObserver_IterationOutput.hpp b/src/observers/VertexCFD_NOXObserver_IterationOutput.hpp deleted file mode 100644 index 83d8c06..0000000 --- a/src/observers/VertexCFD_NOXObserver_IterationOutput.hpp +++ /dev/null @@ -1,58 +0,0 @@ -#ifndef VERTEXCFD_NOXOBSERVER_ITERATIONOUTPUT_HPP -#define VERTEXCFD_NOXOBSERVER_ITERATIONOUTPUT_HPP - -#include -#include -#include - -#include -#include -#include - -namespace VertexCFD -{ -namespace NOXObserver -{ -//---------------------------------------------------------------------------// -class IterationOutput : public NOX::Observer -{ - public: - IterationOutput(); - - //! User defined method that will be executed at the start of a call to - //! NOX::Solver::Generic::step(). - void runPreIterate(const NOX::Solver::Generic& solver) override; - - //! User defined method that will be executed at the end of a call to - //! NOX::Solver::Generic::step(). - void runPostIterate(const NOX::Solver::Generic& solver) override; - - //! User defined method that will be executed at the start of a call to - //! NOX::Solver::Generic::solve(). - void runPreSolve(const NOX::Solver::Generic& solver) override; - - //! User defined method that will be executed at the end of a call to - //! NOX::Solver::Generic::solve(). - void runPostSolve(const NOX::Solver::Generic& solver) override; - - private: - Teuchos::FancyOStream _ostream; -}; - -//---------------------------------------------------------------------------// -// This class is a workaround for the unused lineaer solver status in -// NOX::SolverStats::LinearSolveStats::LogLinearSolve() -class SolveDataExtractor : public NOX::Thyra::Group -{ - public: - SolveDataExtractor(const NOX::Thyra::Group& group); - int lastLinearSolveNumIters() const; - double lastLinearSolveAchievedTol() const; -}; - -//---------------------------------------------------------------------------// - -} // end namespace NOXObserver -} // end namespace VertexCFD - -#endif // end VERTEXCFD_NOXOBSERVER_ITERATIONOUTPUT_HPP diff --git a/src/observers/VertexCFD_TempusObserver_ErrorNormOutput.hpp b/src/observers/VertexCFD_TempusObserver_ErrorNormOutput.hpp deleted file mode 100644 index 485fbda..0000000 --- a/src/observers/VertexCFD_TempusObserver_ErrorNormOutput.hpp +++ /dev/null @@ -1,89 +0,0 @@ -#ifndef VERTEXCFD_TEMPUSOBSERVER_ERRORNORMOUTPUT_HPP -#define VERTEXCFD_TEMPUSOBSERVER_ERRORNORMOUTPUT_HPP - -#include - -#include -#include - -#include -#include -#include - -#include -#include - -namespace VertexCFD -{ -namespace TempusObserver -{ -//---------------------------------------------------------------------------// -template -class ErrorNormOutput : virtual public Tempus::IntegratorObserver -{ - public: - ErrorNormOutput( - const Teuchos::ParameterList& error_norm_list, - Teuchos::RCP> error_norm); - - /// Observe the beginning of the time integrator. - void observeStartIntegrator( - const Tempus::Integrator& integrator) override; - - /// Observe the beginning of the time step loop. - void - observeStartTimeStep(const Tempus::Integrator& integrator) override; - - /// Observe after the next time step size is selected. The - /// observer can choose to change the current integratorStatus. - void - observeNextTimeStep(const Tempus::Integrator& integrator) override; - - /// Observe before Stepper takes step. - void - observeBeforeTakeStep(const Tempus::Integrator& integrator) override; - - /// Observe after Stepper takes step. - void - observeAfterTakeStep(const Tempus::Integrator& integrator) override; - - /// Observe after checking time step. Observer can still fail the time step - /// here. - void observeAfterCheckTimeStep( - const Tempus::Integrator& integrator) override; - - /// Observe the end of the time step loop. - void - observeEndTimeStep(const Tempus::Integrator& integrator) override; - - /// Observe the end of the time integrator. - void - observeEndIntegrator(const Tempus::Integrator& integrator) override; - - private: - /// Print error norms with heading - void - print_error_norms(const std::string& heading, - const std::vector::DofErrorNorm>& error_norm, - const double scaling = 1.0); - - int _output_freq; - bool _compute_time_error; - Teuchos::FancyOStream _ostream; - Teuchos::RCP> _error_norm; - static constexpr int prec = std::numeric_limits::digits10 + 1; - std::vector::DofErrorNorm> - _L1_time_error_norms; - std::vector::DofErrorNorm> - _L2_time_error_norms; -}; - -//---------------------------------------------------------------------------// - -} // end namespace TempusObserver -} // end namespace VertexCFD - -#include "VertexCFD_TempusObserver_ErrorNormOutput_impl.hpp" - -#endif // end VERTEXCFD_TEMPUSOBSERVER_ERRORNORMOUTPUT_HPP diff --git a/src/observers/VertexCFD_TempusObserver_ErrorNormOutput_impl.hpp b/src/observers/VertexCFD_TempusObserver_ErrorNormOutput_impl.hpp deleted file mode 100644 index 3912133..0000000 --- a/src/observers/VertexCFD_TempusObserver_ErrorNormOutput_impl.hpp +++ /dev/null @@ -1,202 +0,0 @@ -#ifndef VERTEXCFD_TEMPUSOBSERVER_ERRORNORMOUTPUT_IMPL_HPP -#define VERTEXCFD_TEMPUSOBSERVER_ERRORNORMOUTPUT_IMPL_HPP - -#include -#include -#include - -namespace VertexCFD -{ -namespace TempusObserver -{ -//---------------------------------------------------------------------------// -template -ErrorNormOutput::ErrorNormOutput( - const Teuchos::ParameterList& error_norm_list, - Teuchos::RCP> error_norm) - : _output_freq(std::numeric_limits::max()) - , _compute_time_error(true) - , _ostream(Teuchos::rcp(&std::cout, false)) - , _error_norm(error_norm) -{ - // Get output frequency - if (error_norm_list.isType("Output Frequency")) - { - _output_freq = error_norm_list.get("Output Frequency"); - } - - // Time integrated error norm - if (error_norm_list.isType("Compute Time Integral")) - { - _compute_time_error - = error_norm_list.get("Compute Time Integral"); - } - - // Initialize L1/L2 error norms objects - if (_compute_time_error) - { - _L1_time_error_norms = _error_norm->L1_errorNorms(); - _L2_time_error_norms = _error_norm->L2_errorNorms(); - } - - // Initialize output variable - _ostream.setShowProcRank(false); - _ostream.setOutputToRootOnly(0); -} - -//---------------------------------------------------------------------------// -template -void ErrorNormOutput::observeStartIntegrator( - const Tempus::Integrator& integrator) -{ - // Compute Initial Error Norms - const auto state = integrator.getSolutionHistory()->getCurrentState(); - _error_norm->ComputeNorms(state); - - // Print initial L1/L2 error norms - print_error_norms("Initial Spatial Integrated L1 Error Norms:", - _error_norm->L1_errorNorms()); - print_error_norms("Initial Spatial Integrated L2 Error Norms:", - _error_norm->L2_errorNorms()); -} - -//---------------------------------------------------------------------------// -template -void ErrorNormOutput::observeStartTimeStep( - const Tempus::Integrator& /*integrator*/) -{ -} - -//---------------------------------------------------------------------------// -template -void ErrorNormOutput::observeNextTimeStep( - const Tempus::Integrator& /*integrator*/) -{ -} - -//---------------------------------------------------------------------------// -template -void ErrorNormOutput::observeBeforeTakeStep( - const Tempus::Integrator& /*integrator*/) -{ -} - -//---------------------------------------------------------------------------// -template -void ErrorNormOutput::observeAfterTakeStep( - const Tempus::Integrator& /*integrator*/) -{ -} - -//---------------------------------------------------------------------------// -template -void ErrorNormOutput::observeAfterCheckTimeStep( - const Tempus::Integrator& /*integrator*/) -{ -} - -//---------------------------------------------------------------------------// -template -void ErrorNormOutput::observeEndTimeStep( - const Tempus::Integrator& integrator) -{ - // Compute Error Norms - const auto state = integrator.getSolutionHistory()->getCurrentState(); - _error_norm->ComputeNorms(state); - const auto dt = state->getTimeStep(); - const auto current_index = state->getIndex(); - - // Compute integrated L1/L2 error norms - if (_compute_time_error) - { - for (std::size_t i = 0; i < _L1_time_error_norms.size(); ++i) - { - _L1_time_error_norms[i].error_norm - += _error_norm->L1_errorNorms()[i].error_norm * dt; - } - - for (std::size_t i = 0; i < _L2_time_error_norms.size(); ++i) - { - _L2_time_error_norms[i].error_norm - += _error_norm->L2_errorNorms()[i].error_norm * dt; - } - } - - // Print L1/L2 error norms - if (0 == current_index % _output_freq) - { - print_error_norms("Spatial Integrated L1 Error Norms:", - _error_norm->L1_errorNorms()); - print_error_norms("Spatial Integrated L2 Error Norms:", - _error_norm->L2_errorNorms()); - - if (_compute_time_error) - { - const double current_time = integrator.getTime(); - - print_error_norms("Temporal/Spatial Integrated L1 Error Norms:", - _L1_time_error_norms, - current_time); - - print_error_norms("Temporal/Spatial Integrated L2 Error Norms:", - _L2_time_error_norms, - current_time); - } - } -} - -//---------------------------------------------------------------------------// -template -void ErrorNormOutput::observeEndIntegrator( - const Tempus::Integrator& integrator) -{ - if (_compute_time_error) - { - // Get final time - const double final_time = integrator.getTime(); - - // L1 error norms - print_error_norms("Final Temporal/Spatial Integrated L1 Error Norms:", - _L1_time_error_norms, - final_time); - - // L2 error norms - print_error_norms("Final Temporal/Spatial Integrated L2 Error Norms:", - _L2_time_error_norms, - final_time); - } - else - { - // Print L1/L2 error norms - print_error_norms("Final Spatial Integrated L1 Error Norms:", - _error_norm->L1_errorNorms()); - print_error_norms("Final Spatial Integrated L2 Error Norms:", - _error_norm->L2_errorNorms()); - } -} - -//---------------------------------------------------------------------------// -template -void ErrorNormOutput::print_error_norms( - const std::string& heading, - const std::vector< - typename ComputeErrorNorms::ErrorNorms::DofErrorNorm>& error_norm, - const double scaling) -{ - _ostream << '\n' - << heading << '\n' - << std::setprecision(prec) << std::scientific; - for (auto& dof : error_norm) - { - _ostream << " " << dof.name << " = " << dof.error_norm / scaling - << '\n'; - } - _ostream << '\n'; -} - -//---------------------------------------------------------------------------// - -} // end namespace TempusObserver -} // end namespace VertexCFD - -#endif // end VERTEXCFD_TEMPUSOBSERVER_ERRORNORMOUTPUT_IMPL_HPP diff --git a/src/observers/VertexCFD_TempusObserver_IterationOutput.hpp b/src/observers/VertexCFD_TempusObserver_IterationOutput.hpp deleted file mode 100644 index ae9f513..0000000 --- a/src/observers/VertexCFD_TempusObserver_IterationOutput.hpp +++ /dev/null @@ -1,76 +0,0 @@ -#ifndef VERTEXCFD_TEMPUSOBSERVER_ITERATIONOUTPUT_HPP -#define VERTEXCFD_TEMPUSOBSERVER_ITERATIONOUTPUT_HPP - -#include "observers/VertexCFD_TempusTimeStepControl_Strategy.hpp" - -#include - -#include -#include -#include -#include -#include - -#include -#include - -namespace VertexCFD -{ -namespace TempusObserver -{ -//---------------------------------------------------------------------------// -template -class IterationOutput : virtual public Tempus::IntegratorObserver -{ - public: - IterationOutput( - Teuchos::RCP> dt_strategy); - - /// Observe the beginning of the time integrator. - void observeStartIntegrator( - const Tempus::Integrator& integrator) override; - - /// Observe the beginning of the time step loop. - void - observeStartTimeStep(const Tempus::Integrator& integrator) override; - - /// Observe after the next time step size is selected. The - /// observer can choose to change the current integratorStatus. - void - observeNextTimeStep(const Tempus::Integrator& integrator) override; - - /// Observe before Stepper takes step. - void - observeBeforeTakeStep(const Tempus::Integrator& integrator) override; - - /// Observe after Stepper takes step. - void - observeAfterTakeStep(const Tempus::Integrator& integrator) override; - - /// Observe after checking time step. Observer can still fail the time step - /// here. - void observeAfterCheckTimeStep( - const Tempus::Integrator& integrator) override; - - /// Observe the end of the time step loop. - void - observeEndTimeStep(const Tempus::Integrator& integrator) override; - - /// Observe the end of the time integrator. - void - observeEndIntegrator(const Tempus::Integrator& integrator) override; - - private: - Teuchos::FancyOStream _ostream; - Teuchos::RCP> _dt_strategy; - int _time_precision = 3; -}; - -//---------------------------------------------------------------------------// - -} // end namespace TempusObserver -} // end namespace VertexCFD - -#include "VertexCFD_TempusObserver_IterationOutput_impl.hpp" - -#endif // end VERTEXCFD_TEMPUSOBSERVER_ITERATIONOUTPUT_HPP diff --git a/src/observers/VertexCFD_TempusObserver_IterationOutput_impl.hpp b/src/observers/VertexCFD_TempusObserver_IterationOutput_impl.hpp deleted file mode 100644 index ee668b6..0000000 --- a/src/observers/VertexCFD_TempusObserver_IterationOutput_impl.hpp +++ /dev/null @@ -1,153 +0,0 @@ -#ifndef VERTEXCFD_TEMPUSOBSERVER_ITERATIONOUTPUT_IMPL_HPP -#define VERTEXCFD_TEMPUSOBSERVER_ITERATIONOUTPUT_IMPL_HPP - -#include -#include -#include - -namespace VertexCFD -{ -namespace TempusObserver -{ -//---------------------------------------------------------------------------// -template -IterationOutput::IterationOutput( - Teuchos::RCP> dt_strategy) - : _ostream(Teuchos::rcp(&std::cout, false)) - , _dt_strategy(dt_strategy) -{ - _ostream.setShowProcRank(false); - _ostream.setOutputToRootOnly(0); -} - -//---------------------------------------------------------------------------// -template -void IterationOutput::observeStartIntegrator( - const Tempus::Integrator& integrator) -{ - std::time_t begin = std::time(nullptr); - _ostream << "\n===========================================================" - "=================\n" - << "Time Integration Begin\n" - << std::asctime(std::localtime(&begin)) - << "\n Stepper = " << integrator.getStepper()->description() - << "\n Simulation Time Range [" - << integrator.getTimeStepControl()->getInitTime() << ", " - << integrator.getTimeStepControl()->getFinalTime() << "]" - << "\n-----------------------------------------------------------" - "-----------------\n"; - - auto tsc = integrator.getTimeStepControl(); - const auto final_time = tsc->getFinalTime(); - const auto dt_min = tsc->getMinTimeStep(); - - // Get location of first significant digit of a double - auto get_digit = [](double t) -> int { - return t > 0.0 ? std::floor(std::log10(t)) : 0; - }; - - const int t_digit = get_digit(final_time); - const int dt_digit = get_digit(dt_min); - - // Make sure we always get meaningful time precision - _time_precision = t_digit - dt_digit + 2; -} - -//---------------------------------------------------------------------------// -template -void IterationOutput::observeStartTimeStep( - const Tempus::Integrator& /*integrator*/) -{ -} - -//---------------------------------------------------------------------------// -template -void IterationOutput::observeNextTimeStep( - const Tempus::Integrator& /*integrator*/) -{ -} - -//---------------------------------------------------------------------------// -template -void IterationOutput::observeBeforeTakeStep( - const Tempus::Integrator& integrator) -{ - const auto current_time = integrator.getTime(); - const auto state = integrator.getSolutionHistory()->getWorkingState(); - _ostream << "\nTime Step = " << state->getIndex(); - _ostream << "; Order = " << state->getOrder(); - _ostream << "\nCFL = " << std::setprecision(3) << std::scientific - << _dt_strategy->currentCFL(); - _ostream << "; dt = " << std::setprecision(3) << std::scientific - << state->getTimeStep(); - _ostream << "; Time = " << std::setprecision(_time_precision) - << std::scientific << current_time << "\n"; -} - -//---------------------------------------------------------------------------// -template -void IterationOutput::observeAfterTakeStep( - const Tempus::Integrator& /*integrator*/) -{ -} - -//---------------------------------------------------------------------------// -template -void IterationOutput::observeAfterCheckTimeStep( - const Tempus::Integrator& /*integrator*/) -{ -} - -//---------------------------------------------------------------------------// -template -void IterationOutput::observeEndTimeStep( - const Tempus::Integrator& integrator) -{ - const auto stepper_time = integrator.getStepperTimer()->totalElapsedTime(); - integrator.getStepperTimer()->reset(); - _ostream << "Time step time to completion (s): " << std::setprecision(2) - << std::scientific << stepper_time; - _ostream << "\n"; -} - -//---------------------------------------------------------------------------// -template -void IterationOutput::observeEndIntegrator( - const Tempus::Integrator& integrator) -{ - std::string exit_status; - if (integrator.getSolutionHistory()->getCurrentState()->getSolutionStatus() - == Tempus::Status::FAILED - or integrator.getStatus() == Tempus::Status::FAILED) - { - exit_status = "Time integration FAILURE!"; - } - else - { - exit_status = "Time integration complete."; - } - std::time_t end = std::time(nullptr); - const auto runtime_sec - = integrator.getIntegratorTimer()->totalElapsedTime(); - const auto runtime_min = runtime_sec / 60; - const auto runtime_hr = runtime_min / 60; - _ostream << "\n-----------------------------------------------------------" - "-----------------\n" - << "Total runtime = " << std::setprecision(2) << std::scientific - << runtime_sec << " sec\n" - << " = " << std::setprecision(2) << std::scientific - << runtime_min << " min\n" - << " = " << std::setprecision(2) << std::fixed - << runtime_hr << " hr\n" - << std::asctime(std::localtime(&end)) << exit_status - << "\n===========================================================" - "=================\n" - << "\n"; -} - -//---------------------------------------------------------------------------// - -} // end namespace TempusObserver -} // end namespace VertexCFD - -#endif // end VERTEXCFD_TEMPUSOBSERVER_ITERATIONOUTPUT_IMPL_HPP diff --git a/src/observers/VertexCFD_TempusObserver_ResponseOutput.hpp b/src/observers/VertexCFD_TempusObserver_ResponseOutput.hpp deleted file mode 100644 index 5bff03d..0000000 --- a/src/observers/VertexCFD_TempusObserver_ResponseOutput.hpp +++ /dev/null @@ -1,76 +0,0 @@ -#ifndef VERTEXCFD_TEMPUSOBSERVER_RESPONSEOUTPUT_HPP -#define VERTEXCFD_TEMPUSOBSERVER_RESPONSEOUTPUT_HPP - -#include "responses/VertexCFD_ResponseManager.hpp" - -#include -#include - -#include -#include - -#include - -namespace VertexCFD -{ -namespace TempusObserver -{ -//---------------------------------------------------------------------------// -template -class ResponseOutput : virtual public Tempus::IntegratorObserver -{ - public: - ResponseOutput(Teuchos::RCP response_manager, - std::vector output_freq); - - /// Observe the beginning of the time integrator. - void observeStartIntegrator( - const Tempus::Integrator& integrator) override; - - /// Observe the beginning of the time step loop. - void - observeStartTimeStep(const Tempus::Integrator& integrator) override; - - /// Observe after the next time step size is selected. The - /// observer can choose to change the current integratorStatus. - void - observeNextTimeStep(const Tempus::Integrator& integrator) override; - - /// Observe before Stepper takes step. - void - observeBeforeTakeStep(const Tempus::Integrator& integrator) override; - - /// Observe after Stepper takes step. - void - observeAfterTakeStep(const Tempus::Integrator& integrator) override; - - /// Observe after checking time step. Observer can still fail the time step - /// here. - void observeAfterCheckTimeStep( - const Tempus::Integrator& integrator) override; - - /// Observe the end of the time step loop. - void - observeEndTimeStep(const Tempus::Integrator& integrator) override; - - /// Observe the end of the time integrator. - void - observeEndIntegrator(const Tempus::Integrator& integrator) override; - - private: - Teuchos::FancyOStream _ostream; - Teuchos::RCP _response_manager; - std::vector _output_freq; - - void outputResponses(const Tempus::Integrator& integrator, - const int current_index = 0); -}; - -//---------------------------------------------------------------------------// - -} // namespace TempusObserver -} // namespace VertexCFD - -#include "VertexCFD_TempusObserver_ResponseOutput_impl.hpp" - -#endif // VERTEXCFD_TEMPUSOBSERVER_RESPONSEOUTPUT_HPP diff --git a/src/observers/VertexCFD_TempusObserver_ResponseOutput_impl.hpp b/src/observers/VertexCFD_TempusObserver_ResponseOutput_impl.hpp deleted file mode 100644 index 81053a9..0000000 --- a/src/observers/VertexCFD_TempusObserver_ResponseOutput_impl.hpp +++ /dev/null @@ -1,141 +0,0 @@ -#ifndef VERTEXCFD_TEMPUSOBSERVER_RESPONSEOUTPUT_IMPL_HPP -#define VERTEXCFD_TEMPUSOBSERVER_RESPONSEOUTPUT_IMPL_HPP - -#include -#include -#include - -namespace VertexCFD -{ -namespace TempusObserver -{ -//---------------------------------------------------------------------------// -template -ResponseOutput::ResponseOutput( - Teuchos::RCP response_manager, - std::vector output_freq) - : _ostream(Teuchos::rcp(&std::cout, false)) - , _response_manager(response_manager) - , _output_freq(std::move(output_freq)) -{ - _ostream.setShowProcRank(false); - _ostream.setOutputToRootOnly(0); -} - -//---------------------------------------------------------------------------// -template -void ResponseOutput::observeStartIntegrator( - const Tempus::Integrator& integrator) -{ - // When the initial time index is zero, this will output all responses. - // Otherwise, output will depend on specified frequencies. - outputResponses(integrator, integrator.getIndex()); -} - -//---------------------------------------------------------------------------// -template -void ResponseOutput::observeStartTimeStep( - const Tempus::Integrator& /*integrator*/) -{ -} - -//---------------------------------------------------------------------------// -template -void ResponseOutput::observeNextTimeStep( - const Tempus::Integrator& /*integrator*/) -{ -} - -//---------------------------------------------------------------------------// -template -void ResponseOutput::observeBeforeTakeStep( - const Tempus::Integrator& /*integrator*/) -{ -} - -//---------------------------------------------------------------------------// -template -void ResponseOutput::observeAfterTakeStep( - const Tempus::Integrator& /*integrator*/) -{ -} - -//---------------------------------------------------------------------------// -template -void ResponseOutput::observeAfterCheckTimeStep( - const Tempus::Integrator& /*integrator*/) -{ -} - -//---------------------------------------------------------------------------// -template -void ResponseOutput::observeEndTimeStep( - const Tempus::Integrator& integrator) -{ - // Output responses at specified frequencies based on time step index. - outputResponses(integrator, integrator.getIndex()); -} - -//---------------------------------------------------------------------------// -template -void ResponseOutput::observeEndIntegrator( - const Tempus::Integrator& integrator) -{ - // Output all responses unconditionally. - outputResponses(integrator); -} - -//---------------------------------------------------------------------------// -template -void ResponseOutput::outputResponses( - const Tempus::Integrator& integrator, const int current_index) -{ - const int num_resp = _response_manager->numResponses(); - - // Just return if there are no responses to output. - if (num_resp == 0) - return; - - _response_manager->deactivateAll(); - - // Activate desired responses. - int num_outputs = 0; - for (int i = 0; i < num_resp; ++i) - { - if (0 == current_index % _output_freq[i]) - { - _response_manager->activateResponse(i); - ++num_outputs; - } - } - - // Just return if there are no respones to output for this time step. - if (num_outputs == 0) - return; - - // Evaluate responses. - const auto state = integrator.getSolutionHistory()->getCurrentState(); - _response_manager->evaluateResponses(state->getX(), state->getXDot()); - - // Outupt the integrated values. - _ostream << "Scalar Responses:\n"; - for (int i = 0; i < num_resp; ++i) - { - if (0 == current_index % _output_freq[i]) - { - const auto& name = _response_manager->name(i); - const auto value = _response_manager->value(i); - - constexpr int prec = std::numeric_limits::digits10 + 1; - - _ostream << " " << name << " = " << std::setprecision(prec) - << value << '\n'; - } - } -} -//---------------------------------------------------------------------------// - -} // namespace TempusObserver -} // namespace VertexCFD - -#endif // VERTEXCFD_TEMPUSOBSERVER_RESPONSEOUTPUT_IMPL_HPP diff --git a/src/observers/VertexCFD_TempusObserver_WriteMatrix.hpp b/src/observers/VertexCFD_TempusObserver_WriteMatrix.hpp deleted file mode 100644 index 64fc3c8..0000000 --- a/src/observers/VertexCFD_TempusObserver_WriteMatrix.hpp +++ /dev/null @@ -1,92 +0,0 @@ -#ifndef VERTEXCFD_TEMPUSOBSERVER_WRITEMATRIX_HPP -#define VERTEXCFD_TEMPUSOBSERVER_WRITEMATRIX_HPP - -#include -#include - -#include -#include - -namespace VertexCFD -{ -namespace TempusObserver -{ -//---------------------------------------------------------------------------// -template -class WriteMatrix : virtual public Tempus::IntegratorObserver -{ - public: - WriteMatrix(const Teuchos::ParameterList& output_params); - - /// Observe the beginning of the time integrator. - void observeStartIntegrator( - const Tempus::Integrator& integrator) override; - - /// Observe the beginning of the time step loop. - void - observeStartTimeStep(const Tempus::Integrator& integrator) override; - - /// Observe after the next time step size is selected. The - /// observer can choose to change the current integratorStatus. - void - observeNextTimeStep(const Tempus::Integrator& integrator) override; - - /// Observe before Stepper takes step. - void - observeBeforeTakeStep(const Tempus::Integrator& integrator) override; - - /// Observe after Stepper takes step. - void - observeAfterTakeStep(const Tempus::Integrator& integrator) override; - - /// Observe after checking time step. Observer can still fail the time step - /// here. - void observeAfterCheckTimeStep( - const Tempus::Integrator& integrator) override; - - /// Observe the end of the time step loop. - void - observeEndTimeStep(const Tempus::Integrator& integrator) override; - - /// Observe the end of the time integrator. - void - observeEndIntegrator(const Tempus::Integrator& integrator) override; - - private: - Teuchos::Array _write_steps; - std::string _jacobian_prefix; - std::string _residual_prefix; - bool _write_residual; - - // Extract Thyra linear operator from linear solver - Teuchos::RCP> extractLinearOp( - const Teuchos::RCP>& - linear_solver) const; - - // Extract forward op src (the Jacobian) from a linear op with solve - template - Teuchos::RCP> tryExtractForwardOp( - const Teuchos::RCP>& - linear_solver) const; - - // Write Jacobian matrix to file, toggling on Epetra vs. Tpetra - void - write_jacobian(const Teuchos::RCP>& matrix, - const std::string& filename, - const std::string& description) const; - - // Write residual to file, toggling on Epetra vs. Tpetra - void - write_residual(const Teuchos::RCP>& vec, - const std::string& filename, - const std::string& description) const; -}; - -//---------------------------------------------------------------------------// - -} // end namespace TempusObserver -} // end namespace VertexCFD - -#include "VertexCFD_TempusObserver_WriteMatrix_impl.hpp" - -#endif // end VERTEXCFD_TEMPUSOBSERVER_WRITEMATRIX_HPP diff --git a/src/observers/VertexCFD_TempusObserver_WriteMatrix_impl.hpp b/src/observers/VertexCFD_TempusObserver_WriteMatrix_impl.hpp deleted file mode 100644 index 21abc15..0000000 --- a/src/observers/VertexCFD_TempusObserver_WriteMatrix_impl.hpp +++ /dev/null @@ -1,345 +0,0 @@ -#ifndef VERTEXCFD_TEMPUSOBSERVER_WRITEMATRIX_IMPL_HPP -#define VERTEXCFD_TEMPUSOBSERVER_WRITEMATRIX_IMPL_HPP - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace VertexCFD -{ -namespace TempusObserver -{ -//---------------------------------------------------------------------------// -template -WriteMatrix::WriteMatrix(const Teuchos::ParameterList& write_params) -{ - // Determine which time steps will write out matrix files - if (write_params.isType>("Write Steps")) - { - _write_steps - = write_params.template get>("Write Steps"); - } - else - { - throw std::runtime_error( - "Requested matrix output but 'Write Steps' was not provided'"); - } - - // Determine if we want the residual in addition to matrix - _write_residual = false; - if (write_params.isType("Write Residual")) - { - _write_residual = write_params.template get("Write Residual"); - } - - // Set base filename for files. If not specified, use generic - // "jacobian" and "residual" - if (write_params.isType("Matrix File Prefix")) - { - auto base_prefix - = write_params.template get("Matrix File Prefix"); - _jacobian_prefix = base_prefix + "-jacobian"; - _residual_prefix = base_prefix + "-residual"; - } - else - { - _jacobian_prefix = "jacobian"; - _residual_prefix = "residual"; - } -} - -//---------------------------------------------------------------------------// -template -void WriteMatrix::observeStartIntegrator( - const Tempus::Integrator&) -{ -} - -//---------------------------------------------------------------------------// -template -void WriteMatrix::observeStartTimeStep(const Tempus::Integrator&) -{ -} - -//---------------------------------------------------------------------------// -template -void WriteMatrix::observeNextTimeStep(const Tempus::Integrator&) -{ -} - -//---------------------------------------------------------------------------// -template -void WriteMatrix::observeBeforeTakeStep(const Tempus::Integrator&) -{ -} - -//---------------------------------------------------------------------------// -template -void WriteMatrix::observeAfterTakeStep(const Tempus::Integrator&) -{ -} - -//---------------------------------------------------------------------------// -template -void WriteMatrix::observeAfterCheckTimeStep( - const Tempus::Integrator&) -{ -} - -//---------------------------------------------------------------------------// -template -void WriteMatrix::observeEndTimeStep( - const Tempus::Integrator& integrator) -{ - auto step_index = integrator.getIndex(); - - // Only write solution at specified time steps - if (std::find(_write_steps.begin(), _write_steps.end(), step_index) - != _write_steps.end()) - { - // Determine filename for this step - std::string filename = _jacobian_prefix + "-" - + std::to_string(step_index) + ".mtx"; - - // Message to put into comments of file - std::string descr = "VertexCFD Jacobian matrix at time step " - + std::to_string(step_index); - - // Get nonlinear solver from time integrator - auto stepper = integrator.getStepper(); - auto nonlinear_solver = stepper->getSolver(); - if (!nonlinear_solver) - { - throw std::runtime_error("Nonlinear solver not available"); - } - - // Extract linear solver operator - auto linear_solver = nonlinear_solver->get_W(); - if (!linear_solver) - { - throw std::runtime_error("Linear solver is not available"); - } - - // Extra linear operator (Jacobian), toggling on Belos vs. AztecOO - auto jacobian_op = this->extractLinearOp(linear_solver); - - // Process matrix output, toggling on Epetra vs. Tpetra - this->write_jacobian(jacobian_op, filename, descr); - - if (_write_residual) - { - filename = _residual_prefix + "-" + std::to_string(step_index) - + ".mtx"; - descr = "Residual vector at time step " - + std::to_string(step_index); - - // Extract NOX solver - auto thyranox_solver - = Teuchos::rcp_dynamic_cast( - nonlinear_solver); - auto nox_solver = thyranox_solver->getNOXSolver(); - - // Get residual vector from the solver - // Use the _previous_ solution group so that the residual - // is the RHS from the last nonlinear iteration rather than - // the converged residual after the solve is complete. - const auto& group = nox_solver->getPreviousSolutionGroup(); - const auto& nox_resid = group.getF(); - const NOX::Thyra::Vector& noxthyra_resid - = dynamic_cast(nox_resid); - auto thyra_resid = noxthyra_resid.getThyraRCPVector(); - - // Process vector output, toggling on Epetra vs. Tpetra - this->write_residual(thyra_resid, filename, descr); - } - } -} - -//---------------------------------------------------------------------------// -template -void WriteMatrix::observeEndIntegrator(const Tempus::Integrator&) -{ -} - -//---------------------------------------------------------------------------// -template -Teuchos::RCP> -WriteMatrix::extractLinearOp( - const Teuchos::RCP>& - linear_solver) const -{ - Teuchos::RCP> jacobian_op; - - // Currently support Belos, AztecOO, Amesos, Amesos2 solvers. - // These all implement the same "getOp" interface, but that method is - // NOT a member of the LinearOpWithSolve base class. - // Try casting to each of these in turn to extract the Jacobian - jacobian_op - = this->tryExtractForwardOp>( - linear_solver); - if (jacobian_op) - return jacobian_op; - - jacobian_op = this->tryExtractForwardOp( - linear_solver); - if (jacobian_op) - return jacobian_op; - - jacobian_op = this->tryExtractForwardOp( - linear_solver); - if (jacobian_op) - return jacobian_op; - - jacobian_op - = this->tryExtractForwardOp>( - linear_solver); - if (jacobian_op) - return jacobian_op; - - throw std::runtime_error( - "Unrecognized linear solver type in matrix output"); -} - -//---------------------------------------------------------------------------// -// Attempt to extract the Jacobian from a solver of the type specified by -// the SolverType template parameter. If the concrete solver is not of the -// specified type, a null RCP will be returned. -//---------------------------------------------------------------------------// -template -template -Teuchos::RCP> -WriteMatrix::tryExtractForwardOp( - const Teuchos::RCP>& - linear_solver) const -{ - Teuchos::RCP> jacobian_op; - - auto derived_solver - = Teuchos::rcp_dynamic_cast(linear_solver); - if (derived_solver) - { - // Const-cast and extract forward source operator (which is the - // Jacobian) - auto nonconst_derived_solver - = Teuchos::rcp_const_cast(derived_solver); - auto fwd_opsrc = nonconst_derived_solver->extract_fwdOpSrc(); - jacobian_op = fwd_opsrc->getOp(); - } - - return jacobian_op; -} - -//---------------------------------------------------------------------------// -template -void WriteMatrix::write_jacobian( - const Teuchos::RCP>& jacobian_op, - const std::string& filename, - const std::string& description) const -{ - // Toggle on Epetra vs. Tpetra - auto jacobian_epetra - = Teuchos::rcp_dynamic_cast(jacobian_op); - if (jacobian_epetra) - { - auto epetra_op = jacobian_epetra->epetra_op(); - auto epetra_mat - = Teuchos::rcp_dynamic_cast(epetra_op); - if (!epetra_mat) - { - throw std::runtime_error("Epetra operator is not a RowMatrix"); - } - - EpetraExt::RowMatrixToMatrixMarketFile( - filename.c_str(), *epetra_mat, description.c_str()); - } - else - { - // If not Epetra, must be Tpetra - auto jacobian_tpetra = Teuchos::rcp_dynamic_cast< - const Thyra::TpetraLinearOp>(jacobian_op); - if (!jacobian_tpetra) - { - throw std::runtime_error("Unexpected matrix type"); - } - - // Tpetra matrix output requires concrete type (CrsMatrix, not - // RowMatrix) - using TpetraMatrix = Tpetra:: - CrsMatrix; - auto tpetra_op = jacobian_tpetra->getConstTpetraOperator(); - auto tpetra_mat - = Teuchos::rcp_dynamic_cast(tpetra_op); - if (!tpetra_mat) - { - throw std::runtime_error("Tpetra operator is not a CrsMatrix"); - } - - Tpetra::MatrixMarket::Writer::writeSparseFile( - filename, *tpetra_mat, "", description); - } -} - -//---------------------------------------------------------------------------// -template -void WriteMatrix::write_residual( - const Teuchos::RCP>& vec, - const std::string& filename, - const std::string& description) const -{ - // Vector should be a DefaultSpmdVector (Epetra) or a TpetraVector. - auto spmd_vec - = Teuchos::rcp_dynamic_cast>( - vec); - if (spmd_vec) - { - auto space = vec->space(); - auto epetra_map = Thyra::get_Epetra_Map(space); - auto epetra_vec = Thyra::get_Epetra_Vector(vec, epetra_map); - - EpetraExt::MultiVectorToMatrixMarketFile( - filename.c_str(), *epetra_vec, "", description.c_str()); - } - - auto thyratpetra_vec = Teuchos::rcp_dynamic_cast< - const Thyra:: - TpetraVector>( - vec); - if (thyratpetra_vec) - { - auto tpetra_vec = thyratpetra_vec->getConstTpetraVector(); - - using TpetraMatrix = Tpetra:: - CrsMatrix; - Tpetra::MatrixMarket::Writer::writeDenseFile( - filename, *tpetra_vec, "", description); - } -} - -//---------------------------------------------------------------------------// - -} // end namespace TempusObserver -} // end namespace VertexCFD - -#endif // end VERTEXCFD_TEMPUSOBSERVER_WRITEMATRIX_IMPL_HPP diff --git a/src/observers/VertexCFD_TempusObserver_WriteRestart.hpp b/src/observers/VertexCFD_TempusObserver_WriteRestart.hpp deleted file mode 100644 index 2498160..0000000 --- a/src/observers/VertexCFD_TempusObserver_WriteRestart.hpp +++ /dev/null @@ -1,79 +0,0 @@ -#ifndef VERTEXCFD_TEMPUSOBSERVER_WRITERESTART_HPP -#define VERTEXCFD_TEMPUSOBSERVER_WRITERESTART_HPP - -#include "mesh/VertexCFD_Mesh_Restart.hpp" - -#include -#include - -#include -#include -#include -#include -#include - -#include - -namespace VertexCFD -{ -namespace TempusObserver -{ -//---------------------------------------------------------------------------// -template -class WriteRestart : virtual public Tempus::IntegratorObserver -{ - public: - WriteRestart(const Teuchos::RCP& restart_writer, - const Teuchos::ParameterList& output_params); - - /// Observe the beginning of the time integrator. - void observeStartIntegrator( - const Tempus::Integrator& integrator) override; - - /// Observe the beginning of the time step loop. - void - observeStartTimeStep(const Tempus::Integrator& integrator) override; - - /// Observe after the next time step size is selected. The - /// observer can choose to change the current integratorStatus. - void - observeNextTimeStep(const Tempus::Integrator& integrator) override; - - /// Observe before Stepper takes step. - void - observeBeforeTakeStep(const Tempus::Integrator& integrator) override; - - /// Observe after Stepper takes step. - void - observeAfterTakeStep(const Tempus::Integrator& integrator) override; - - /// Observe after checking time step. Observer can still fail the time step - /// here. - void observeAfterCheckTimeStep( - const Tempus::Integrator& integrator) override; - - /// Observe the end of the time step loop. - void - observeEndTimeStep(const Tempus::Integrator& integrator) override; - - /// Observe the end of the time integrator. - void - observeEndIntegrator(const Tempus::Integrator& integrator) override; - - private: - void writeSolution(const Tempus::Integrator& integrator); - - private: - Teuchos::RCP _restart_writer; - int _write_frequency = 1; - int _last_index = -1; -}; - -//---------------------------------------------------------------------------// - -} // end namespace TempusObserver -} // end namespace VertexCFD - -#include "VertexCFD_TempusObserver_WriteRestart_impl.hpp" - -#endif // end VERTEXCFD_TEMPUSOBSERVER_WRITERESTART_HPP diff --git a/src/observers/VertexCFD_TempusObserver_WriteRestart_impl.hpp b/src/observers/VertexCFD_TempusObserver_WriteRestart_impl.hpp deleted file mode 100644 index 90d3518..0000000 --- a/src/observers/VertexCFD_TempusObserver_WriteRestart_impl.hpp +++ /dev/null @@ -1,107 +0,0 @@ -#ifndef VERTEXCFD_TEMPUSOBSERVER_WRITERESTART_IMPL_HPP -#define VERTEXCFD_TEMPUSOBSERVER_WRITERESTART_IMPL_HPP - -#include -#include - -namespace VertexCFD -{ -namespace TempusObserver -{ -//---------------------------------------------------------------------------// -template -WriteRestart::WriteRestart( - const Teuchos::RCP& restart_writer, - const Teuchos::ParameterList& output_params) - : _restart_writer(restart_writer) -{ - if (output_params.isType("Restart Write Frequency")) - { - _write_frequency - = output_params.template get("Restart Write Frequency"); - } -} - -//---------------------------------------------------------------------------// -template -void WriteRestart::observeStartIntegrator( - const Tempus::Integrator&) -{ -} - -//---------------------------------------------------------------------------// -template -void WriteRestart::observeStartTimeStep(const Tempus::Integrator&) -{ -} - -//---------------------------------------------------------------------------// -template -void WriteRestart::observeNextTimeStep(const Tempus::Integrator&) -{ -} - -//---------------------------------------------------------------------------// -template -void WriteRestart::observeBeforeTakeStep( - const Tempus::Integrator&) -{ -} - -//---------------------------------------------------------------------------// -template -void WriteRestart::observeAfterTakeStep(const Tempus::Integrator&) -{ -} - -//---------------------------------------------------------------------------// -template -void WriteRestart::observeAfterCheckTimeStep( - const Tempus::Integrator&) -{ -} - -//---------------------------------------------------------------------------// -template -void WriteRestart::observeEndTimeStep( - const Tempus::Integrator& integrator) -{ - // Only write solution at specified time step intervals. - if (0 == integrator.getIndex() % _write_frequency) - { - writeSolution(integrator); - } -} - -//---------------------------------------------------------------------------// -template -void WriteRestart::observeEndIntegrator( - const Tempus::Integrator& integrator) -{ - // Write out final solution, but only if this time step has not been - // written already. - if (integrator.getIndex() > _last_index) - { - writeSolution(integrator); - } -} - -//---------------------------------------------------------------------------// -template -void WriteRestart::writeSolution( - const Tempus::Integrator& integrator) -{ - auto time = integrator.getTime(); - auto solution = integrator.getSolutionHistory()->findState(time)->getX(); - auto solution_dot - = integrator.getSolutionHistory()->findState(time)->getXDot(); - _last_index = integrator.getIndex(); - _restart_writer->writeSolution(solution, solution_dot, _last_index, time); -} - -//---------------------------------------------------------------------------// - -} // end namespace TempusObserver -} // end namespace VertexCFD - -#endif // end VERTEXCFD_TEMPUSOBSERVER_WRITERESTART_IMPL_HPP diff --git a/src/observers/VertexCFD_TempusObserver_WriteToExodus.hpp b/src/observers/VertexCFD_TempusObserver_WriteToExodus.hpp deleted file mode 100644 index 8524f42..0000000 --- a/src/observers/VertexCFD_TempusObserver_WriteToExodus.hpp +++ /dev/null @@ -1,79 +0,0 @@ -#ifndef VERTEXCFD_TEMPUSOBSERVER_WRITETOEXODUS_HPP -#define VERTEXCFD_TEMPUSOBSERVER_WRITETOEXODUS_HPP - -#include "mesh/VertexCFD_Mesh_ExodusWriter.hpp" - -#include -#include - -#include -#include -#include -#include -#include - -#include - -namespace VertexCFD -{ -namespace TempusObserver -{ -//---------------------------------------------------------------------------// -template -class WriteToExodus : virtual public Tempus::IntegratorObserver -{ - public: - WriteToExodus(const Teuchos::RCP& exodus_writer, - const Teuchos::ParameterList& output_params); - - /// Observe the beginning of the time integrator. - void observeStartIntegrator( - const Tempus::Integrator& integrator) override; - - /// Observe the beginning of the time step loop. - void - observeStartTimeStep(const Tempus::Integrator& integrator) override; - - /// Observe after the next time step size is selected. The - /// observer can choose to change the current integratorStatus. - void - observeNextTimeStep(const Tempus::Integrator& integrator) override; - - /// Observe before Stepper takes step. - void - observeBeforeTakeStep(const Tempus::Integrator& integrator) override; - - /// Observe after Stepper takes step. - void - observeAfterTakeStep(const Tempus::Integrator& integrator) override; - - /// Observe after checking time step. Observer can still fail the time step - /// here. - void observeAfterCheckTimeStep( - const Tempus::Integrator& integrator) override; - - /// Observe the end of the time step loop. - void - observeEndTimeStep(const Tempus::Integrator& integrator) override; - - /// Observe the end of the time integrator. - void - observeEndIntegrator(const Tempus::Integrator& integrator) override; - - private: - void writeSolution(const Tempus::Integrator& integrator); - - private: - Teuchos::RCP _exodus_writer; - int _write_frequency; - int _last_index = -1; -}; - -//---------------------------------------------------------------------------// - -} // end namespace TempusObserver -} // end namespace VertexCFD - -#include "VertexCFD_TempusObserver_WriteToExodus_impl.hpp" - -#endif // end VERTEXCFD_TEMPUSOBSERVER_WRITETOEXODUS_HPP diff --git a/src/observers/VertexCFD_TempusObserver_WriteToExodus_impl.hpp b/src/observers/VertexCFD_TempusObserver_WriteToExodus_impl.hpp deleted file mode 100644 index e1331a0..0000000 --- a/src/observers/VertexCFD_TempusObserver_WriteToExodus_impl.hpp +++ /dev/null @@ -1,110 +0,0 @@ -#ifndef VERTEXCFD_TEMPUSOBSERVER_WRITETOEXODUS_IMPL_HPP -#define VERTEXCFD_TEMPUSOBSERVER_WRITETOEXODUS_IMPL_HPP - -#include -#include - -namespace VertexCFD -{ -namespace TempusObserver -{ -//---------------------------------------------------------------------------// -template -WriteToExodus::WriteToExodus( - const Teuchos::RCP& exodus_writer, - const Teuchos::ParameterList& output_params) - : _exodus_writer(exodus_writer) - , _write_frequency(1) -{ - _write_frequency - = output_params.template get("Exodus Write Frequency"); -} - -//---------------------------------------------------------------------------// -template -void WriteToExodus::observeStartIntegrator( - const Tempus::Integrator& integrator) -{ - // Write out initial conditions. - writeSolution(integrator); -} - -//---------------------------------------------------------------------------// -template -void WriteToExodus::observeStartTimeStep( - const Tempus::Integrator&) -{ -} - -//---------------------------------------------------------------------------// -template -void WriteToExodus::observeNextTimeStep(const Tempus::Integrator&) -{ -} - -//---------------------------------------------------------------------------// -template -void WriteToExodus::observeBeforeTakeStep( - const Tempus::Integrator&) -{ -} - -//---------------------------------------------------------------------------// -template -void WriteToExodus::observeAfterTakeStep( - const Tempus::Integrator&) -{ -} - -//---------------------------------------------------------------------------// -template -void WriteToExodus::observeAfterCheckTimeStep( - const Tempus::Integrator&) -{ -} - -//---------------------------------------------------------------------------// -template -void WriteToExodus::observeEndTimeStep( - const Tempus::Integrator& integrator) -{ - // Only write solution at specified time step intervals. - if (0 == integrator.getIndex() % _write_frequency) - { - writeSolution(integrator); - } -} - -//---------------------------------------------------------------------------// -template -void WriteToExodus::observeEndIntegrator( - const Tempus::Integrator& integrator) -{ - // Write out final solution, but only if this time step has not been - // written already. - if (integrator.getIndex() > _last_index) - { - writeSolution(integrator); - } -} - -//---------------------------------------------------------------------------// -template -void WriteToExodus::writeSolution( - const Tempus::Integrator& integrator) -{ - const auto state = integrator.getSolutionHistory()->getCurrentState(); - const auto time = state->getTime(); - const auto time_step = state->getTimeStep(); - const auto solution = state->getX(); - const auto solution_dot = state->getXDot(); - _exodus_writer->writeSolution(solution, solution_dot, time, time_step); - _last_index = integrator.getIndex(); -} - -//---------------------------------------------------------------------------// - -} // end namespace TempusObserver -} // end namespace VertexCFD - -#endif // end VERTEXCFD_TEMPUSOBSERVER_WRITETOEXODUS_IMPL_HPP diff --git a/src/observers/VertexCFD_TempusTimeStepControl_GlobalTimeStep.hpp b/src/observers/VertexCFD_TempusTimeStepControl_GlobalTimeStep.hpp deleted file mode 100644 index 04164b1..0000000 --- a/src/observers/VertexCFD_TempusTimeStepControl_GlobalTimeStep.hpp +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef VERTEXCFD_TEMPUSTIMESTEPCONTROL_GLOBALTIMESTEP_HPP -#define VERTEXCFD_TEMPUSTIMESTEPCONTROL_GLOBALTIMESTEP_HPP - -#include "observers/VertexCFD_TempusTimeStepControl_Strategy.hpp" - -#include "drivers/VertexCFD_PhysicsManager.hpp" -#include "responses/VertexCFD_ResponseManager.hpp" - -#include -#include -#include -#include -#include - -#include - -#include -#include - -namespace VertexCFD -{ -namespace TempusTimeStepControl -{ -//---------------------------------------------------------------------------// -template -class GlobalTimeStep : virtual public Strategy -{ - public: - GlobalTimeStep(const Teuchos::ParameterList& user_params, - Teuchos::RCP physics_manager); - - // Determine the time step size. - void setNextTimeStep( - const Tempus::TimeStepControl& tsc, - Teuchos::RCP> solution_history, - Tempus::Status& integrator_status) override; - - private: - int _dt_transition_steps; - Response::ResponseManager _response_manager; -}; - -//---------------------------------------------------------------------------// - -} // namespace TempusTimeStepControl -} // namespace VertexCFD - -#include "VertexCFD_TempusTimeStepControl_GlobalTimeStep_impl.hpp" - -#endif // VERTEXCFD_TEMPUSTIMESTEPCONTROL_GLOBALTIMESTEP_HPP diff --git a/src/observers/VertexCFD_TempusTimeStepControl_GlobalTimeStep_impl.hpp b/src/observers/VertexCFD_TempusTimeStepControl_GlobalTimeStep_impl.hpp deleted file mode 100644 index 0751a79..0000000 --- a/src/observers/VertexCFD_TempusTimeStepControl_GlobalTimeStep_impl.hpp +++ /dev/null @@ -1,74 +0,0 @@ -#ifndef VERTEXCFD_TEMPUSTIMESTEPCONTROL_GLOBALTIMESTEP_IMPL_HPP -#define VERTEXCFD_TEMPUSTIMESTEPCONTROL_GLOBALTIMESTEP_IMPL_HPP - -#include "VertexCFD_TempusTimeStepControl_GlobalTimeStep.hpp" -#include - -namespace VertexCFD -{ -namespace TempusTimeStepControl -{ -//---------------------------------------------------------------------------// -template -GlobalTimeStep::GlobalTimeStep( - const Teuchos::ParameterList& user_params, - Teuchos::RCP physics_manager) - : _dt_transition_steps(user_params.isType("Time step transition " - "steps") - ? user_params.get("Time step transition " - "steps") - : 0) - , _response_manager(physics_manager) -{ - _response_manager.addMinValueResponse("global_cfl_time_step", "local_dt"); - - // For the new Tempus::TimeStepControlStrategy interface, we need to - // set a few base class member variables. In particular, incorrect - // behavior may result if "stepType_" is not set to "Variable". - this->stepType_ = "Variable"; - this->strategyType_ = "Global Time Step Strategy"; - this->name_ = "Global Time Step Strategy"; -} - -//---------------------------------------------------------------------------// -// Determine the time step size. -template -void GlobalTimeStep::setNextTimeStep( - const Tempus::TimeStepControl& tsc, - Teuchos::RCP> solution_history, - Tempus::Status&) -{ - // Get the working state. - auto working_state = solution_history->getWorkingState(); - - // Get minimum time step that ensures CFL <= 1 - _response_manager.evaluateResponses(working_state->getX(), - working_state->getXDot()); - const double dt_cfl1 = _response_manager.value(); - - // Get time step index (1-based) and compute linear weight - const auto dt_index = working_state->getIndex() - 1; - const auto wt - = _dt_transition_steps > 0 - ? std::min(static_cast(dt_index) / _dt_transition_steps, - 1.0) - : 1.0; - - const double dt_init - = std::max(tsc.getMinTimeStep(), tsc.getInitTimeStep()); - const double dt_final = tsc.getMaxTimeStep(); - const double dt = (1.0 - wt) * dt_init + wt * dt_final; - - working_state->setTimeStep(dt); - working_state->setTime(solution_history->getCurrentState()->getTime() + dt); - - // Save current CFL so it may be accessed elsewhere - this->setCurrentCFL(dt / dt_cfl1); -} - -//---------------------------------------------------------------------------// - -} // namespace TempusTimeStepControl -} // namespace VertexCFD - -#endif // VERTEXCFD_TEMPUSTIMESTEPCONTROL_GLOBALTIMESTEP_IMPL_HPP diff --git a/src/observers/VertexCFD_TempusTimeStepControl_Strategy.hpp b/src/observers/VertexCFD_TempusTimeStepControl_Strategy.hpp deleted file mode 100644 index 284fd90..0000000 --- a/src/observers/VertexCFD_TempusTimeStepControl_Strategy.hpp +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef VERTEXCFD_TEMPUSTIMESTEPCONTROL_STRATEGY_HPP -#define VERTEXCFD_TEMPUSTIMESTEPCONTROL_STRATEGY_HPP - -#include - -#include -#include - -namespace VertexCFD -{ -namespace TempusTimeStepControl -{ -//---------------------------------------------------------------------------// -template -class Strategy : virtual public Tempus::TimeStepControlStrategy -{ - public: - virtual ~Strategy() = default; - double currentCFL() const { return _cfl_current; } - - protected: - void setCurrentCFL(const double cfl) { _cfl_current = cfl; } - - private: - double _cfl_current = 0.0; -}; - -//---------------------------------------------------------------------------// - -} // namespace TempusTimeStepControl -} // namespace VertexCFD - -#endif // VERTEXCFD_TEMPUSTIMESTEPCONTROL_STRATEGY_HPP diff --git a/src/observers/unit_test/CDR_Model.hpp b/src/observers/unit_test/CDR_Model.hpp deleted file mode 100644 index 62bd5be..0000000 --- a/src/observers/unit_test/CDR_Model.hpp +++ /dev/null @@ -1,175 +0,0 @@ -// @HEADER -// **************************************************************************** -// Tempus: Copyright (2017) Sandia Corporation -// -// Distributed under BSD 3-clause license (See accompanying file Copyright.txt) -// **************************************************************************** -// @HEADER - -// **************************************************************************** -// Adapted for use in VertexCFD from Trilinos/packages/tempus/test/TestModels -// **************************************************************************** - -#ifndef VERTEXCFD_CDR_MODEL_HPP -#define VERTEXCFD_CDR_MODEL_HPP - -#include "Thyra_StateFuncModelEvaluatorBase.hpp" - -class Epetra_Comm; -class Epetra_Map; -class Epetra_Vector; -class Epetra_CrsGraph; -class Epetra_Import; - -namespace VertexCFD -{ -namespace Test -{ -template -class ModelEvaluator1DFEM; - -/** \brief 1D CGFEM model for convection/diffusion/reaction - * - * The equation modeled is: - - \verbatim - -dT dT d^2(T) --- + a -- + ------ - K * T**2 = 0 -dt dz dz^2 - - subject to: - T = 1.0 @ z = z_min - - \endverbatim - - * The Matrix W = d(f)/d(x) is implemented as a - * Thyra::MultiVectorBase object and the class - * Thyra::DefaultSerialDenseLinearOpWithSolveFactory is used to - * create the linear solver. - */ -template -class CDR_Model final : public ::Thyra::StateFuncModelEvaluatorBase -{ - public: - CDR_Model(const Teuchos::RCP& comm, - const int num_global_elements, - const Scalar z_min, - const Scalar z_max, - const Scalar a, // convection - const Scalar k); // source - - /** \name Initializers/Accessors */ - //@{ - - void set_x0(const Teuchos::ArrayView& x0); - - void setShowGetInvalidArgs(bool showGetInvalidArg); - - void set_W_factory( - const Teuchos::RCP>& - W_factory); - - //@} - - /** \name Public functions overridden from ModelEvaluator. */ - //@{ - - Teuchos::RCP> - get_x_space() const override; - Teuchos::RCP> - get_f_space() const override; - ::Thyra::ModelEvaluatorBase::InArgs - getNominalValues() const override; - Teuchos::RCP> - create_W() const override; - Teuchos::RCP<::Thyra::LinearOpBase> create_W_op() const override; - Teuchos::RCP> - get_W_factory() const override; - ::Thyra::ModelEvaluatorBase::InArgs createInArgs() const override; - Teuchos::RCP<::Thyra::PreconditionerBase> - create_W_prec() const override; - //@} - - private: - /** Allocates and returns the Jacobian matrix graph */ - Teuchos::RCP createGraph(); - - /** \name Private functions overridden from ModelEvaluatorDefaultBase. */ - //@{ - - ::Thyra::ModelEvaluatorBase::OutArgs - createOutArgsImpl() const override; - void - evalModelImpl(const ::Thyra::ModelEvaluatorBase::InArgs& inArgs, - const ::Thyra::ModelEvaluatorBase::OutArgs& outArgs) - const override; - - //@} - - private: // data members - const Teuchos::RCP comm_; - const int num_global_elements_; - const Scalar z_min_; - const Scalar z_max_; - const Scalar a_; - const Scalar k_; - - Teuchos::RCP> x_space_; - Teuchos::RCP x_owned_map_; - Teuchos::RCP x_ghosted_map_; - Teuchos::RCP importer_; - - Teuchos::RCP> f_space_; - Teuchos::RCP f_owned_map_; - - Teuchos::RCP W_graph_; - - Teuchos::RCP> W_factory_; - - Teuchos::RCP node_coordinates_; - Teuchos::RCP ghosted_node_coordinates_; - - mutable Teuchos::RCP u_ptr; - mutable Teuchos::RCP u_dot_ptr; - mutable Teuchos::RCP x_ptr; - - mutable Teuchos::RCP J_diagonal_; - - ::Thyra::ModelEvaluatorBase::InArgs nominalValues_; - Teuchos::RCP<::Thyra::VectorBase> x0_; - Teuchos::Array p_; - bool showGetInvalidArg_; - ::Thyra::ModelEvaluatorBase::InArgs prototypeInArgs_; - ::Thyra::ModelEvaluatorBase::OutArgs prototypeOutArgs_; -}; - -//================================================================== -// Finite Element Basis Object -class Basis -{ - public: - // Constructor - Basis(); - - // Destructor - ~Basis(); - - // Calculates the values of u and x at the specified gauss point - void computeBasis(int gp, double* z, double* u, double* u_dot = nullptr); - - public: - // Variables that are calculated at the gauss point - double *phi, *dphide; - double uu, zz, duu, eta, wt; - double dz; - // These are only needed for transient - double uu_dot, duu_dot; -}; - -} // namespace Test -} // namespace VertexCFD - -#include "CDR_Model_impl.hpp" - -#endif diff --git a/src/observers/unit_test/CDR_Model_impl.hpp b/src/observers/unit_test/CDR_Model_impl.hpp deleted file mode 100644 index 7700070..0000000 --- a/src/observers/unit_test/CDR_Model_impl.hpp +++ /dev/null @@ -1,637 +0,0 @@ -// @HEADER -// **************************************************************************** -// Tempus: Copyright (2017) Sandia Corporation -// -// Distributed under BSD 3-clause license (See accompanying file Copyright.txt) -// **************************************************************************** -// @HEADER - -#ifndef VERTEXCFD_CDR_MODEL_IMPL_HPP -#define VERTEXCFD_CDR_MODEL_IMPL_HPP - -// Thyra support -#include "Thyra_DefaultSerialDenseLinearOpWithSolveFactory.hpp" -#include "Thyra_DefaultSpmdVectorSpace.hpp" -#include "Thyra_DetachedMultiVectorView.hpp" -#include "Thyra_DetachedVectorView.hpp" -#include "Thyra_MultiVectorStdOps.hpp" -#include "Thyra_PreconditionerBase.hpp" -#include "Thyra_VectorStdOps.hpp" - -// Epetra support -#include "Epetra_Comm.h" -#include "Epetra_CrsGraph.h" -#include "Epetra_CrsMatrix.h" -#include "Epetra_Import.h" -#include "Epetra_Map.h" -#include "Epetra_Vector.h" -#include "Thyra_EpetraLinearOp.hpp" -#include "Thyra_EpetraThyraWrappers.hpp" -#include "Thyra_get_Epetra_Operator.hpp" - -namespace VertexCFD -{ -namespace Test -{ -// Constructor - -template -CDR_Model::CDR_Model(const Teuchos::RCP& comm, - const int num_global_elements, - const Scalar z_min, - const Scalar z_max, - const Scalar a, - const Scalar k) - : comm_(comm) - , num_global_elements_(num_global_elements) - , z_min_(z_min) - , z_max_(z_max) - , a_(a) - , k_(k) - , showGetInvalidArg_(false) -{ - using Teuchos::RCP; - using Teuchos::rcp; - using ::Thyra::VectorBase; - typedef ::Thyra::ModelEvaluatorBase MEB; - typedef Teuchos::ScalarTraits ST; - - TEUCHOS_ASSERT(nonnull(comm_)); - - const int num_nodes = num_global_elements_ + 1; - - // owned space - x_owned_map_ = rcp(new Epetra_Map(num_nodes, 0, *comm_)); - x_space_ = ::Thyra::create_VectorSpace(x_owned_map_); - - // ghosted space - if (comm_->NumProc() == 1) - { - x_ghosted_map_ = x_owned_map_; - } - else - { - int OverlapNumMyElements; - int OverlapMinMyGID; - OverlapNumMyElements = x_owned_map_->NumMyElements() + 2; - if ((comm_->MyPID() == 0) || (comm_->MyPID() == (comm_->NumProc() - 1))) - OverlapNumMyElements--; - - if (comm_->MyPID() == 0) - OverlapMinMyGID = x_owned_map_->MinMyGID(); - else - OverlapMinMyGID = x_owned_map_->MinMyGID() - 1; - - int* OverlapMyGlobalElements = new int[OverlapNumMyElements]; - - for (int i = 0; i < OverlapNumMyElements; i++) - OverlapMyGlobalElements[i] = OverlapMinMyGID + i; - - x_ghosted_map_ = Teuchos::rcp(new Epetra_Map( - -1, OverlapNumMyElements, OverlapMyGlobalElements, 0, *comm_)); - - delete[] OverlapMyGlobalElements; - } - - importer_ = Teuchos::rcp(new Epetra_Import(*x_ghosted_map_, *x_owned_map_)); - - // residual space - f_owned_map_ = x_owned_map_; - f_space_ = x_space_; - - x0_ = ::Thyra::createMember(x_space_); - V_S(x0_.ptr(), ST::zero()); - - // set_p(Teuchos::tuple(p0, p1)()); - // set_x0(Teuchos::tuple(x0, x1)()); - - // Initialize the graph for W CrsMatrix object - W_graph_ = createGraph(); - - // Create the nodal coordinates - { - node_coordinates_ = Teuchos::rcp(new Epetra_Vector(*x_owned_map_)); - Scalar length = z_max_ - z_min_; - Scalar dx = length / ((double)num_global_elements_ - 1); - for (int i = 0; i < x_owned_map_->NumMyElements(); i++) - { - (*node_coordinates_)[i] - = z_min_ + dx * ((double)x_owned_map_->MinMyGID() + i); - } - } - - MEB::InArgsSetup inArgs; - inArgs.setModelEvalDescription(this->description()); - inArgs.setSupports(MEB::IN_ARG_t); - inArgs.setSupports(MEB::IN_ARG_x); - inArgs.setSupports(MEB::IN_ARG_beta); - inArgs.setSupports(MEB::IN_ARG_x_dot); - inArgs.setSupports(MEB::IN_ARG_alpha); - prototypeInArgs_ = inArgs; - - MEB::OutArgsSetup outArgs; - outArgs.setModelEvalDescription(this->description()); - outArgs.setSupports(MEB::OUT_ARG_f); - outArgs.setSupports(MEB::OUT_ARG_W); - outArgs.setSupports(MEB::OUT_ARG_W_op); - outArgs.setSupports(MEB::OUT_ARG_W_prec); - // outArgs.set_W_properties(DerivativeProperties( - // DERIV_LINEARITY_NONCONST - // ,DERIV_RANK_FULL - // ,true // supportsAdjoint - // )); - prototypeOutArgs_ = outArgs; - - // Setup nominal values - nominalValues_ = inArgs; - nominalValues_.set_x(x0_); - auto x_dot_init = Thyra::createMember(this->get_x_space()); - Thyra::put_scalar(Scalar(0.0), x_dot_init.ptr()); - nominalValues_.set_x_dot(x_dot_init); -} - -// Initializers/Accessors - -template -Teuchos::RCP CDR_Model::createGraph() -{ - Teuchos::RCP W_graph; - - // Create the shell for the - W_graph = Teuchos::rcp(new Epetra_CrsGraph(Copy, *x_owned_map_, 5)); - - // Declare required variables - int row; - int column; - int OverlapNumMyElements = x_ghosted_map_->NumMyElements(); - - // Loop Over # of Finite Elements on Processor - for (int ne = 0; ne < OverlapNumMyElements - 1; ne++) - { - // Loop over Nodes in Element - for (int i = 0; i < 2; i++) - { - row = x_ghosted_map_->GID(ne + i); - - // Loop over Trial Functions - for (int j = 0; j < 2; j++) - { - // If this row is owned by current processor, add the index - if (x_owned_map_->MyGID(row)) - { - column = x_ghosted_map_->GID(ne + j); - W_graph->InsertGlobalIndices(row, 1, &column); - } - } - } - } - W_graph->FillComplete(); - return W_graph; -} - -template -void CDR_Model::set_x0(const Teuchos::ArrayView& x0_in) -{ -#ifdef TEUCHOS_DEBUG - TEUCHOS_ASSERT_EQUALITY(x_space_->dim(), x0_in.size()); -#endif - Thyra::DetachedVectorView x0(x0_); - x0.sv().values()().assign(x0_in); -} - -template -void CDR_Model::setShowGetInvalidArgs(bool showGetInvalidArg) -{ - showGetInvalidArg_ = showGetInvalidArg; -} - -template -void CDR_Model::set_W_factory( - const Teuchos::RCP>& - W_factory) -{ - W_factory_ = W_factory; -} - -// Public functions overridden from ModelEvaluator - -template -Teuchos::RCP> -CDR_Model::get_x_space() const -{ - return x_space_; -} - -template -Teuchos::RCP> -CDR_Model::get_f_space() const -{ - return f_space_; -} - -template -Thyra::ModelEvaluatorBase::InArgs -CDR_Model::getNominalValues() const -{ - return nominalValues_; -} - -template -Teuchos::RCP> -CDR_Model::create_W() const -{ - Teuchos::RCP> W_factory - = this->get_W_factory(); - - TEUCHOS_TEST_FOR_EXCEPTION(is_null(W_factory), - std::runtime_error, - "W_factory in CDR_Model has a null W_factory!"); - - Teuchos::RCP> matrix = this->create_W_op(); - - Teuchos::RCP> W - = Thyra::linearOpWithSolve(*W_factory, matrix); - - return W; -} - -template -Teuchos::RCP> CDR_Model::create_W_op() const -{ - Teuchos::RCP W_epetra - = Teuchos::rcp(new Epetra_CrsMatrix(::Copy, *W_graph_)); - - return Thyra::nonconstEpetraLinearOp(W_epetra); -} - -template -Teuchos::RCP<::Thyra::PreconditionerBase> -CDR_Model::create_W_prec() const -{ - Teuchos::RCP W_epetra - = Teuchos::rcp(new Epetra_CrsMatrix(::Copy, *W_graph_)); - - const Teuchos::RCP> W_op - = Thyra::nonconstEpetraLinearOp(W_epetra); - - Teuchos::RCP> prec - = Teuchos::rcp(new Thyra::DefaultPreconditioner); - - prec->initializeRight(W_op); - - return prec; -} - -template -Teuchos::RCP> -CDR_Model::get_W_factory() const -{ - return W_factory_; -} - -template -Thyra::ModelEvaluatorBase::InArgs -CDR_Model::createInArgs() const -{ - return prototypeInArgs_; -} - -// Private functions overridden from ModelEvaluatorDefaultBase - -template -Thyra::ModelEvaluatorBase::OutArgs -CDR_Model::createOutArgsImpl() const -{ - return prototypeOutArgs_; -} - -template -void CDR_Model::evalModelImpl( - const Thyra::ModelEvaluatorBase::InArgs& inArgs, - const Thyra::ModelEvaluatorBase::OutArgs& outArgs) const -{ - using Teuchos::RCP; - using Teuchos::rcp; - using Teuchos::rcp_dynamic_cast; - - TEUCHOS_ASSERT(nonnull(inArgs.get_x())); - TEUCHOS_ASSERT(nonnull(inArgs.get_x_dot())); - - // const Thyra::ConstDetachedVectorView x(inArgs.get_x()); - - const RCP> f_out = outArgs.get_f(); - const RCP> W_out = outArgs.get_W_op(); - const RCP> W_prec_out - = outArgs.get_W_prec(); - - if (nonnull(f_out) || nonnull(W_out) || nonnull(W_prec_out)) - { - // **************** - // Get the underlying epetra objects - // **************** - - RCP f; - if (nonnull(f_out)) - { - f = Thyra::get_Epetra_Vector(*f_owned_map_, outArgs.get_f()); - } - - RCP J; - if (nonnull(W_out)) - { - RCP W_epetra = Thyra::get_Epetra_Operator(*W_out); - J = rcp_dynamic_cast(W_epetra); - TEUCHOS_ASSERT(nonnull(J)); - } - - RCP M_inv; - if (nonnull(W_prec_out)) - { - RCP M_epetra = Thyra::get_Epetra_Operator( - *(W_prec_out->getNonconstRightPrecOp())); - M_inv = rcp_dynamic_cast(M_epetra); - TEUCHOS_ASSERT(nonnull(M_inv)); - J_diagonal_ = Teuchos::rcp(new Epetra_Vector(*x_owned_map_)); - } - - // **************** - // Create ghosted objects - // **************** - - // Set the boundary condition directly. Works for both x and xDot - // solves. - if (comm_->MyPID() == 0) - { - RCP> x - = Teuchos::rcp_const_cast>( - inArgs.get_x()); - (*Thyra::get_Epetra_Vector(*x_owned_map_, x))[0] = 1.0; - } - - if (is_null(u_ptr)) - u_ptr = Teuchos::rcp(new Epetra_Vector(*x_ghosted_map_)); - - u_ptr->Import( - *(Thyra::get_Epetra_Vector(*x_owned_map_, inArgs.get_x())), - *importer_, - Insert); - - if (is_null(u_dot_ptr)) - u_dot_ptr = Teuchos::rcp(new Epetra_Vector(*x_ghosted_map_)); - - u_dot_ptr->Import( - *(Thyra::get_Epetra_Vector(*x_owned_map_, inArgs.get_x_dot())), - *importer_, - Insert); - - if (is_null(x_ptr)) - { - x_ptr = Teuchos::rcp(new Epetra_Vector(*x_ghosted_map_)); - x_ptr->Import(*node_coordinates_, *importer_, Insert); - } - - Epetra_Vector& u = *u_ptr; - Epetra_Vector& u_dot = *u_dot_ptr; - Epetra_Vector& x = *x_ptr; - - int ierr = 0; - int OverlapNumMyElements = x_ghosted_map_->NumMyElements(); - - double xx[2]; - double uu[2]; - double uu_dot[2]; - Basis basis; - const auto alpha = inArgs.get_alpha(); - const auto beta = inArgs.get_beta(); - - // Zero out the objects that will be filled - if (nonnull(f)) - f->PutScalar(0.0); - if (nonnull(J)) - J->PutScalar(0.0); - if (nonnull(M_inv)) - M_inv->PutScalar(0.0); - - // Loop Over # of Finite Elements on Processor - for (int ne = 0; ne < OverlapNumMyElements - 1; ne++) - { - // Loop Over Gauss Points - for (int gp = 0; gp < 2; gp++) - { - // Get the solution and coordinates at the nodes - xx[0] = x[ne]; - xx[1] = x[ne + 1]; - uu[0] = u[ne]; - uu[1] = u[ne + 1]; - uu_dot[0] = u_dot[ne]; - uu_dot[1] = u_dot[ne + 1]; - // Calculate the basis function at the gauss point - basis.computeBasis(gp, xx, uu, uu_dot); - - // Loop over Nodes in Element - for (int i = 0; i < 2; i++) - { - int row = x_ghosted_map_->GID(ne + i); - // printf("Proc=%d GlobalRow=%d LocalRow=%d Owned=%d\n", - // MyPID, row, ne+i,x_owned_map_.MyGID(row)); - if (x_owned_map_->MyGID(row)) - { - if (nonnull(f)) - { - (*f)[x_owned_map_->LID(x_ghosted_map_->GID(ne + i))] - += +basis.wt * basis.dz - * (basis.uu_dot * basis.phi[i] // transient - + (a_ / basis.dz * basis.duu - * basis.phi[i] // convection - + 1.0 / (basis.dz * basis.dz)) - * basis.duu - * basis.dphide[i] // diffusion - + k_ * basis.uu * basis.uu - * basis.phi[i]); // source - } - } - // Loop over Trial Functions - if (nonnull(J)) - { - for (int j = 0; j < 2; j++) - { - if (x_owned_map_->MyGID(row)) - { - int column = x_ghosted_map_->GID(ne + j); - double jac - = basis.wt * basis.dz - * (alpha * basis.phi[i] - * basis.phi[j] // transient - + beta - * (+a_ / basis.dz - * basis.dphide[j] - * basis.phi[i] // convection - + (1.0 / (basis.dz * basis.dz)) - * basis.dphide[j] - * basis.dphide[i] // diffusion - + 2.0 * k_ * basis.uu - * basis.phi[j] - * basis.phi[i] // source - )); - ierr = J->SumIntoGlobalValues( - row, 1, &jac, &column); - } - } - } - if (nonnull(M_inv)) - { - for (int j = 0; j < 2; j++) - { - if (x_owned_map_->MyGID(row)) - { - int column = x_ghosted_map_->GID(ne + j); - // The prec will be the diagonal of J. No need - // to assemble the other entries - if (row == column) - { - double jac - = basis.wt * basis.dz - * (alpha * basis.phi[i] - * basis.phi[j] // transient - + beta - * (+a_ / basis.dz - * basis.dphide[j] - * basis.phi[i] // convection - + (1.0 - / (basis.dz * basis.dz)) - * basis.dphide[j] - * basis.dphide[i] // diffusion - + 2.0 * k_ * basis.uu - * basis.phi[j] - * basis.phi[i] // source - )); - ierr = M_inv->SumIntoGlobalValues( - row, 1, &jac, &column); - } - } - } - } - } - } - } - - // Insert Boundary Conditions and modify Jacobian and function (F) - // U(0)=1 - if (comm_->MyPID() == 0) - { - if (nonnull(f)) - (*f)[0] = 0.0; // Setting BC above and zero residual here works - // for x and xDot solves. - //(*f)[0]= u[0] - 1.0; // BC equation works for x solves. - if (nonnull(J)) - { - int column = 0; - double jac = 1.0; - ierr = J->ReplaceGlobalValues(0, 1, &jac, &column); - column = 1; - jac = 0.0; - ierr = J->ReplaceGlobalValues(0, 1, &jac, &column); - } - if (nonnull(M_inv)) - { - int column = 0; - double jac = 1.0; - ierr = M_inv->ReplaceGlobalValues(0, 1, &jac, &column); - column = 1; - jac = 0.0; - ierr = M_inv->ReplaceGlobalValues(0, 1, &jac, &column); - } - } - - if (nonnull(J)) - J->FillComplete(); - - if (nonnull(M_inv)) - { - // invert the Jacobian diagonal for the preconditioner - M_inv->ExtractDiagonalCopy(*J_diagonal_); - - for (int i = 0; i < J_diagonal_->MyLength(); ++i) - (*J_diagonal_)[i] = 1.0 / ((*J_diagonal_)[i]); - - M_inv->PutScalar(0.0); - M_inv->ReplaceDiagonalValues(*J_diagonal_); - M_inv->FillComplete(); - } - - TEUCHOS_ASSERT(ierr > -1); - } -} - -//==================================================================== -// Basis vector - -// Constructor -Basis::Basis() - : uu(0.0) - , zz(0.0) - , duu(0.0) - , eta(0.0) - , wt(0.0) - , dz(0.0) - , uu_dot(0.0) - , duu_dot(0.0) -{ - phi = new double[2]; - dphide = new double[2]; -} - -// Destructor -Basis::~Basis() -{ - delete[] phi; - delete[] dphide; -} - -// Calculates a linear 1D basis -void Basis::computeBasis(int gp, double* z, double* u, double* u_dot) -{ - int N = 2; - if (gp == 0) - { - eta = -1.0 / sqrt(3.0); - wt = 1.0; - } - if (gp == 1) - { - eta = 1.0 / sqrt(3.0); - wt = 1.0; - } - - // Calculate basis function and derivatives at nodel pts - phi[0] = (1.0 - eta) / 2.0; - phi[1] = (1.0 + eta) / 2.0; - dphide[0] = -0.5; - dphide[1] = 0.5; - - // Caculate basis function and derivative at GP. - dz = 0.5 * (z[1] - z[0]); - zz = 0.0; - uu = 0.0; - duu = 0.0; - uu_dot = 0.0; - duu_dot = 0.0; - for (int i = 0; i < N; i++) - { - zz += z[i] * phi[i]; - uu += u[i] * phi[i]; - duu += u[i] * dphide[i]; - if (u_dot) - { - uu_dot += u_dot[i] * phi[i]; - duu_dot += u_dot[i] * dphide[i]; - } - } - - return; -} - -} // namespace Test -} // namespace VertexCFD - -#endif diff --git a/src/observers/unit_test/CMakeLists.txt b/src/observers/unit_test/CMakeLists.txt deleted file mode 100644 index ae533f8..0000000 --- a/src/observers/unit_test/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -set(TEST_HARNESS_DIR ${CMAKE_SOURCE_DIR}/src/test_harness) -include(${TEST_HARNESS_DIR}/TestHarness.cmake) - -VertexCFD_add_tests( - MPI - LIBS VertexCFD - NAMES - WriteMatrix - ) diff --git a/src/parameters/VertexCFD_GeneralScalarParameter.cpp b/src/parameters/VertexCFD_GeneralScalarParameter.cpp deleted file mode 100644 index ea98265..0000000 --- a/src/parameters/VertexCFD_GeneralScalarParameter.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_GeneralScalarParameter.hpp" -#include "VertexCFD_GeneralScalarParameter_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL( - VertexCFD::Parameter::GeneralScalarParameter) diff --git a/src/parameters/VertexCFD_GeneralScalarParameter.hpp b/src/parameters/VertexCFD_GeneralScalarParameter.hpp deleted file mode 100644 index a1ad8bc..0000000 --- a/src/parameters/VertexCFD_GeneralScalarParameter.hpp +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef VERTEXCFD_GENERALSCALARPARAMETER_HPP -#define VERTEXCFD_GENERALSCALARPARAMETER_HPP - -#include "VertexCFD_GeneralScalarParameterInput.hpp" - -#include - -#include - -#include -#include - -namespace VertexCFD -{ -namespace Parameter -{ -//---------------------------------------------------------------------------// -template -class GeneralScalarParameter -{ - public: - using scalar_type = typename EvalType::ScalarT; - - GeneralScalarParameter(const std::string& name, - scalar_type& ref_to_parameter); - - const std::string& name() const; - - void - update(const panzer::Workset& workset, - const std::unordered_map>& - general_scalar_params); - - private: - std::string _name; - scalar_type& _ref_to_parameter; -}; - -//---------------------------------------------------------------------------// - -} // end namespace Parameter -} // end namespace VertexCFD - -#endif // end VERTEXCFD_GENERALSCALARPARAMETER_HPP diff --git a/src/parameters/VertexCFD_GeneralScalarParameterInput.cpp b/src/parameters/VertexCFD_GeneralScalarParameterInput.cpp deleted file mode 100644 index 6876f47..0000000 --- a/src/parameters/VertexCFD_GeneralScalarParameterInput.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#include "VertexCFD_GeneralScalarParameterInput.hpp" - -namespace VertexCFD -{ -namespace Parameter -{ -//---------------------------------------------------------------------------// -bool GeneralScalarParameterInput::operator==( - const GeneralScalarParameterInput& rhs) const -{ - return parameter_name == rhs.parameter_name; -} - -//---------------------------------------------------------------------------// -std::ostream& -operator<<(std::ostream& out, const GeneralScalarParameterInput& input) -{ - out << input.parameter_name; - return out; -} - -//---------------------------------------------------------------------------// -std::istream& operator>>(std::istream& in, GeneralScalarParameterInput& input) -{ - std::getline(in, input.parameter_name); - return in; -} - -//---------------------------------------------------------------------------// - -} // end namespace Parameter -} // end namespace VertexCFD diff --git a/src/parameters/VertexCFD_GeneralScalarParameterInput.hpp b/src/parameters/VertexCFD_GeneralScalarParameterInput.hpp deleted file mode 100644 index 4c1eefe..0000000 --- a/src/parameters/VertexCFD_GeneralScalarParameterInput.hpp +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef VERTEXCFD_GENERALSCALARPARAMTERINPUT_HPP -#define VERTEXCFD_GENERALSCALARPARAMTERINPUT_HPP - -#include - -#include - -namespace VertexCFD -{ -namespace Parameter -{ -//---------------------------------------------------------------------------// -struct GeneralScalarParameterInput -{ - std::string parameter_name; - - bool operator==(const GeneralScalarParameterInput& rhs) const; -}; - -//---------------------------------------------------------------------------// -std::ostream& -operator<<(std::ostream& out, const GeneralScalarParameterInput& input); - -std::istream& operator>>(std::istream& in, GeneralScalarParameterInput& input); - -//---------------------------------------------------------------------------// - -} // end namespace Parameter -} // end namespace VertexCFD - -//---------------------------------------------------------------------------// -namespace Teuchos -{ -template<> -class TypeNameTraits -{ - public: - static std::string name() { return "GeneralScalarParameter"; } -}; - -} // end namespace Teuchos - -//---------------------------------------------------------------------------// - -#endif // end VERTEXCFD_GENERALSCALARPARAMTERINPUT_HPP diff --git a/src/parameters/VertexCFD_GeneralScalarParameter_impl.hpp b/src/parameters/VertexCFD_GeneralScalarParameter_impl.hpp deleted file mode 100644 index 97c2f80..0000000 --- a/src/parameters/VertexCFD_GeneralScalarParameter_impl.hpp +++ /dev/null @@ -1,73 +0,0 @@ -#ifndef VERTEXCFD_GENERALSCALARPARAMETER_IMPL_HPP -#define VERTEXCFD_GENERALSCALARPARAMETER_IMPL_HPP - -namespace VertexCFD -{ -namespace Parameter -{ -//---------------------------------------------------------------------------// -template -GeneralScalarParameter::GeneralScalarParameter( - const std::string& name, scalar_type& ref_to_parameter) - : _name(name) - , _ref_to_parameter(ref_to_parameter) -{ -} - -//---------------------------------------------------------------------------// -template -const std::string& GeneralScalarParameter::name() const -{ - return _name; -} - -//---------------------------------------------------------------------------// -template -void GeneralScalarParameter::update( - const panzer::Workset& workset, - const std::unordered_map>& - general_scalar_params) -{ - // Lookup parameter values. - auto param_values = general_scalar_params.find(_name); - if (param_values == general_scalar_params.end()) - { - std::string msg = "GeneralScalar parameter " + _name + " not found"; - throw std::runtime_error(msg); - } - - // Check to see if this is an element block we have a value for. - auto block_name = workset.getElementBlock(); - auto block_value = param_values->second.find(block_name); - - // If the block is in the parameter list assign the value. - if (block_value != param_values->second.end()) - { - _ref_to_parameter = block_value->second; - } - - // Othwerwise just assign the default as this block wasn't given a - // specific value. - else - { - auto default_value = param_values->second.find("Default Value"); - if (default_value != param_values->second.end()) - { - _ref_to_parameter = default_value->second; - } - else - { - std::string msg = "GeneralScalar parameter " + _name - + " does not have a value for block " + block_name - + " and is also missing a default value"; - throw std::runtime_error(msg); - } - } -} - -//---------------------------------------------------------------------------// - -} // end namespace Parameter -} // end namespace VertexCFD - -#endif // end VERTEXCFD_GENERALSCALARPARAMETER_IMPL_HPP diff --git a/src/parameters/VertexCFD_ParameterDatabase.cpp b/src/parameters/VertexCFD_ParameterDatabase.cpp deleted file mode 100644 index f1672ce..0000000 --- a/src/parameters/VertexCFD_ParameterDatabase.cpp +++ /dev/null @@ -1,357 +0,0 @@ -#include "VertexCFD_ParameterDatabase.hpp" -#include "VertexCFD_GeneralScalarParameterInput.hpp" -#include "VertexCFD_ScalarParameterInput.hpp" - -#include -#include -#include - -namespace VertexCFD -{ -namespace Parameter -{ -//---------------------------------------------------------------------------// -ParameterDatabase::ParameterDatabase( - const Teuchos::RCP>& comm) - : _comm(comm) -{ - // Create sublists. - _mesh_params = Teuchos::parameterList(); - _physics_params = Teuchos::parameterList(); - _scalar_params = Teuchos::parameterList(); - _general_scalar_params = Teuchos::parameterList(); - _block_mapping_params = Teuchos::parameterList(); - _bc_params = Teuchos::parameterList(); - _ic_params = Teuchos::parameterList(); - _closure_params = Teuchos::parameterList(); - _response_output_params = Teuchos::parameterList(); - _user_params = Teuchos::parameterList(); - _output_params = Teuchos::parameterList(); - _read_restart_params = Teuchos::parameterList(); - _write_restart_params = Teuchos::parameterList(); - _write_matrix_params = Teuchos::parameterList(); - _transient_solver_params = Teuchos::parameterList(); - _linear_solver_params = Teuchos::parameterList(); - - // Store the MPI communicator in the "User Data" ParameterList. - _user_params->set>>("Comm", _comm); -} - -//---------------------------------------------------------------------------// -ParameterDatabase::ParameterDatabase( - const Teuchos::RCP>& comm, - const Teuchos::RCP& parameters) - : _comm(comm) - , _input_params(parameters) -{ - // Get the sublists. - extractSublists(); -} - -//---------------------------------------------------------------------------// -ParameterDatabase::ParameterDatabase( - const Teuchos::RCP>& comm, - const std::string& xml_file) - : _comm(comm) -{ - // Parse file. - readParameterFile(xml_file); -} - -//---------------------------------------------------------------------------// -ParameterDatabase::ParameterDatabase( - const Teuchos::RCP>& comm, - int argc, - char* argv[]) - : _comm(comm) -{ - // Get the input file from the command line arguments. - Teuchos::CommandLineProcessor clp; - std::string input_file = "input.xml"; - clp.setOption("i", &input_file, "XML Input File"); - clp.parse(argc, argv, &std::cerr); - - // Parse file. - readParameterFile(input_file); -} - -//---------------------------------------------------------------------------// -void ParameterDatabase::readParameterFile(const std::string& xml_file) -{ - // Add custom input types. - TEUCHOS_ADD_TYPE_CONVERTER(ScalarParameterInput); - TEUCHOS_ADD_TYPE_CONVERTER(GeneralScalarParameterInput); - - // Build a parameter list from the inputs - _input_params = Teuchos::parameterList("Input Parameters"); - Teuchos::updateParametersFromXmlFileAndBroadcast( - xml_file, _input_params.ptr(), *_comm); - - // Get the sublists. - extractSublists(); -} - -//---------------------------------------------------------------------------// -Teuchos::RCP -ParameterDatabase::requiredSublist(const std::string& name) -{ - if (!_input_params->isSublist(name)) - { - std::string msg = "Sublist " + name + " missing from input"; - throw std::logic_error(msg); - } - return Teuchos::parameterList(_input_params->sublist(name)); -} - -//---------------------------------------------------------------------------// -Teuchos::RCP -ParameterDatabase::optionalSublist(const std::string& name) -{ - if (_input_params->isSublist(name)) - { - return Teuchos::parameterList(_input_params->sublist(name)); - } - else - { - return Teuchos::null; - } -} - -//---------------------------------------------------------------------------// -void ParameterDatabase::extractSublists() -{ - // Check if we are using new input format. This will be removed once - // the transition to the new format is complete. - if (_input_params->isParameter("Use New Input Format")) - { - _use_new_input = _input_params->get("Use New Input Format"); - } - - // Create sublists from new format - if (_use_new_input) - { - extractSublistsNew(); - } - - // Get sublists directly in old format. - else - { - extractSublistsOld(); - } - - // Store the MPI communicator in the "User Data" ParameterList. - _user_params->set>>("Comm", _comm); -} - -//---------------------------------------------------------------------------// -void ParameterDatabase::extractSublistsOld() -{ - // Get required sublists. - _mesh_params = requiredSublist("Mesh"); - _physics_params = requiredSublist("Physics Blocks"); - _block_mapping_params = requiredSublist("Block ID to Physics ID Mapping"); - _bc_params = requiredSublist("Boundary Conditions"); - _ic_params = requiredSublist("Initial Conditions"); - _closure_params = requiredSublist("Closure Models"); - _user_params = requiredSublist("User Data"); - _transient_solver_params = requiredSublist("Tempus"); - _linear_solver_params = requiredSublist("Linear Solver"); - - // Get optional sublists. - _profiling_params = optionalSublist("Profiling"); - _scalar_params = optionalSublist("Scalar Parameters"); - _general_scalar_params = optionalSublist("General Scalar Parameters"); - _output_params = optionalSublist("Solution Output"); - _response_output_params = optionalSublist("Scalar Response Output"); - if (Teuchos::is_null(_response_output_params)) - { - // Check old name for backward compatibility - _response_output_params = optionalSublist("Volume Integral Output"); - } - _read_restart_params = optionalSublist("Read Restart"); - _write_restart_params = optionalSublist("Write Restart"); - _write_matrix_params = optionalSublist("Write Matrix"); -} - -//---------------------------------------------------------------------------// -void ParameterDatabase::extractSublistsNew() -{ - // Get required sublists. - _mesh_params = requiredSublist("Mesh"); - _assembly_params = requiredSublist("Equation Assembly"); - _bc_params = requiredSublist("Boundary Conditions"); - _ic_params = requiredSublist("Initial Conditions"); - _closure_params = requiredSublist("Closure Models"); - _user_params = requiredSublist("User Data"); - _transient_solver_params = requiredSublist("Tempus"); - _linear_solver_params = requiredSublist("Linear Solver"); - - // Get optional sublists. - _profiling_params = optionalSublist("Profiling"); - _scalar_params = optionalSublist("Scalar Parameters"); - _general_scalar_params = optionalSublist("General Scalar Parameters"); - _output_params = optionalSublist("Solution Output"); - _response_output_params = optionalSublist("Scalar Response Output"); - if (Teuchos::is_null(_response_output_params)) - { - // Check old name for backward compatibility - _response_output_params = optionalSublist("Volume Integral Output"); - } - _read_restart_params = optionalSublist("Read Restart"); - _write_restart_params = optionalSublist("Write Restart"); - _write_matrix_params = optionalSublist("Write Matrix"); - - // Make auxiliary parameter lists. - _physics_params - = Teuchos::parameterList(_input_params->sublist("Physics Blocks")); - _block_mapping_params = Teuchos::parameterList( - _input_params->sublist("Block ID to Physics ID Mapping")); -} - -//---------------------------------------------------------------------------// -Teuchos::RCP> ParameterDatabase::comm() const -{ - return _comm; -} - -//---------------------------------------------------------------------------// -// Main list accessor. -Teuchos::RCP ParameterDatabase::allParameters() const -{ - return _input_params; -} - -//---------------------------------------------------------------------------// -Teuchos::RCP ParameterDatabase::meshParameters() const -{ - return _mesh_params; -} - -//---------------------------------------------------------------------------// -Teuchos::RCP -ParameterDatabase::assemblyParameters() const -{ - return _assembly_params; -} - -//---------------------------------------------------------------------------// -Teuchos::RCP -ParameterDatabase::physicsParameters() const -{ - return _physics_params; -} - -//---------------------------------------------------------------------------// -Teuchos::RCP ParameterDatabase::scalarParameters() const -{ - return _scalar_params; -} - -//---------------------------------------------------------------------------// -Teuchos::RCP -ParameterDatabase::generalScalarParameters() const -{ - return _general_scalar_params; -} - -//---------------------------------------------------------------------------// -Teuchos::RCP -ParameterDatabase::blockMappingParameters() const -{ - return _block_mapping_params; -} - -//---------------------------------------------------------------------------// -Teuchos::RCP -ParameterDatabase::boundaryConditionParameters() const -{ - return _bc_params; -} - -//---------------------------------------------------------------------------// -Teuchos::RCP -ParameterDatabase::initialConditionParameters() const -{ - return _ic_params; -} - -//---------------------------------------------------------------------------// -Teuchos::RCP -ParameterDatabase::closureModelParameters() const -{ - return _closure_params; -} - -//---------------------------------------------------------------------------// -Teuchos::RCP -ParameterDatabase::responseOutputParameters() const -{ - return _response_output_params; -} - -//---------------------------------------------------------------------------// -Teuchos::RCP ParameterDatabase::userParameters() const -{ - return _user_params; -} - -//---------------------------------------------------------------------------// -Teuchos::RCP ParameterDatabase::outputParameters() const -{ - return _output_params; -} - -//---------------------------------------------------------------------------// -Teuchos::RCP -ParameterDatabase::readRestartParameters() const -{ - return _read_restart_params; -} - -//---------------------------------------------------------------------------// -Teuchos::RCP -ParameterDatabase::writeRestartParameters() const -{ - return _write_restart_params; -} - -//---------------------------------------------------------------------------// -Teuchos::RCP -ParameterDatabase::writeMatrixParameters() const -{ - return _write_matrix_params; -} - -//---------------------------------------------------------------------------// -Teuchos::RCP -ParameterDatabase::profilingParameters() const -{ - return _profiling_params; -} - -//---------------------------------------------------------------------------// -Teuchos::RCP -ParameterDatabase::transientSolverParameters() const -{ - return _transient_solver_params; -} - -//---------------------------------------------------------------------------// -Teuchos::RCP -ParameterDatabase::linearSolverParameters() const -{ - return _linear_solver_params; -} - -//---------------------------------------------------------------------------// -bool ParameterDatabase::useNewInputFormat() const -{ - return _use_new_input; -} - -//---------------------------------------------------------------------------// - -} // end namespace Parameter -} // end namespace VertexCFD - -//---------------------------------------------------------------------------// diff --git a/src/parameters/VertexCFD_ParameterDatabase.hpp b/src/parameters/VertexCFD_ParameterDatabase.hpp deleted file mode 100644 index 969958e..0000000 --- a/src/parameters/VertexCFD_ParameterDatabase.hpp +++ /dev/null @@ -1,118 +0,0 @@ -#ifndef VERTEXCFD_PARAMETERDATABASE_HPP -#define VERTEXCFD_PARAMETERDATABASE_HPP - -#include -#include -#include - -#include - -namespace VertexCFD -{ -namespace Parameter -{ -//---------------------------------------------------------------------------// -class ParameterDatabase -{ - public: - // Default constructor. - ParameterDatabase(const Teuchos::RCP>& comm); - - // Parameter list constructor. - ParameterDatabase(const Teuchos::RCP>& comm, - const Teuchos::RCP& parameters); - - // XML file constructor. - ParameterDatabase(const Teuchos::RCP>& comm, - const std::string& xml_file); - - // Main argument constructor. - ParameterDatabase(const Teuchos::RCP>& comm, - int argc, - char* argv[]); - - // Communicator. - Teuchos::RCP> comm() const; - - // Main list accessor. - Teuchos::RCP allParameters() const; - - // Sublist accessors. - Teuchos::RCP meshParameters() const; - Teuchos::RCP assemblyParameters() const; - Teuchos::RCP scalarParameters() const; - Teuchos::RCP generalScalarParameters() const; - Teuchos::RCP boundaryConditionParameters() const; - Teuchos::RCP initialConditionParameters() const; - Teuchos::RCP closureModelParameters() const; - Teuchos::RCP responseOutputParameters() const; - Teuchos::RCP userParameters() const; - Teuchos::RCP outputParameters() const; - Teuchos::RCP readRestartParameters() const; - Teuchos::RCP writeRestartParameters() const; - Teuchos::RCP writeMatrixParameters() const; - Teuchos::RCP profilingParameters() const; - Teuchos::RCP transientSolverParameters() const; - Teuchos::RCP linearSolverParameters() const; - - // Deprecated sublist accessors. - Teuchos::RCP physicsParameters() const; - Teuchos::RCP blockMappingParameters() const; - - // New format boolean. This will be removed once the transition to the new - // format is complete. - bool useNewInputFormat() const; - - private: - // Read an xml file with parameters and extract sublists. - void readParameterFile(const std::string& xml_file); - - // Get the sublists from the input parameters. - void extractSublists(); - - // Get the sublists from the input parameters - old variant. (Deprecated) - void extractSublistsOld(); - - // Get the sublists from the input parameters - new variant. - void extractSublistsNew(); - - // Get a required sublist from the main input list. - Teuchos::RCP - requiredSublist(const std::string& name); - - // Get an optional sublist from the main input list. - Teuchos::RCP - optionalSublist(const std::string& name); - - private: - Teuchos::RCP> _comm; - Teuchos::RCP _input_params; - Teuchos::RCP _mesh_params; - Teuchos::RCP _assembly_params; - Teuchos::RCP _scalar_params; - Teuchos::RCP _general_scalar_params; - Teuchos::RCP _bc_params; - Teuchos::RCP _ic_params; - Teuchos::RCP _closure_params; - Teuchos::RCP _response_output_params; - Teuchos::RCP _user_params; - Teuchos::RCP _output_params; - Teuchos::RCP _read_restart_params; - Teuchos::RCP _write_restart_params; - Teuchos::RCP _write_matrix_params; - Teuchos::RCP _profiling_params; - Teuchos::RCP _transient_solver_params; - Teuchos::RCP _linear_solver_params; - bool _use_new_input = false; - - // Deprecated lists. - Teuchos::RCP _physics_params; - Teuchos::RCP _block_mapping_params; -}; - -//---------------------------------------------------------------------------// - -} // namespace Parameter -} // namespace VertexCFD - -#endif // end VERTEXCFD_PARAMETERDATABASE_HPP diff --git a/src/parameters/VertexCFD_ScalarParameter.cpp b/src/parameters/VertexCFD_ScalarParameter.cpp deleted file mode 100644 index 04e12ba..0000000 --- a/src/parameters/VertexCFD_ScalarParameter.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_ScalarParameter.hpp" -#include "VertexCFD_ScalarParameter_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL(VertexCFD::Parameter::ScalarParameter) diff --git a/src/parameters/VertexCFD_ScalarParameter.hpp b/src/parameters/VertexCFD_ScalarParameter.hpp deleted file mode 100644 index 895aca9..0000000 --- a/src/parameters/VertexCFD_ScalarParameter.hpp +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef VERTEXCFD_SCALARPARAMETER_HPP -#define VERTEXCFD_SCALARPARAMETER_HPP - -#include - -#include - -namespace VertexCFD -{ -namespace Parameter -{ -//---------------------------------------------------------------------------// -// Global scalar parameter. Parameters managed by this class will be -// updated from the parameter library. -//---------------------------------------------------------------------------// -template -class ScalarParameter -{ - public: - using scalar_type = typename EvalType::ScalarT; - - ScalarParameter(const std::string& name, scalar_type& ref_to_parameter); - - const std::string& name() const; - - void update(const panzer::GlobalData& global_data); - - private: - std::string _name; - scalar_type& _ref_to_parameter; -}; - -//---------------------------------------------------------------------------// - -} // namespace Parameter -} // namespace VertexCFD - -#endif // end VERTEXCFD_SCALARPARAMETER_HPP diff --git a/src/parameters/VertexCFD_ScalarParameterEvaluator.cpp b/src/parameters/VertexCFD_ScalarParameterEvaluator.cpp deleted file mode 100644 index bf0d169..0000000 --- a/src/parameters/VertexCFD_ScalarParameterEvaluator.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_ScalarParameterEvaluator.hpp" -#include "VertexCFD_ScalarParameterEvaluator_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS( - VertexCFD::Parameter::ScalarParameterEvaluator) diff --git a/src/parameters/VertexCFD_ScalarParameterEvaluator.hpp b/src/parameters/VertexCFD_ScalarParameterEvaluator.hpp deleted file mode 100644 index 5ff2174..0000000 --- a/src/parameters/VertexCFD_ScalarParameterEvaluator.hpp +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef VERTEXCFD_SCALARPARAMETEREVALUATOR_HPP -#define VERTEXCFD_SCALARPARAMETEREVALUATOR_HPP - -#include "VertexCFD_ScalarParameterManager.hpp" - -#include -#include - -#include -#include - -#include - -#include - -namespace VertexCFD -{ -namespace Parameter -{ -//---------------------------------------------------------------------------// -template -class ScalarParameterEvaluator : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - - ScalarParameterEvaluator( - const Teuchos::RCP>& param_manager, - const Teuchos::RCP& global_data); - - void evaluateFields(typename Traits::EvalData workset) override; - - private: - Teuchos::RCP _param_update_trigger; - Teuchos::RCP> _param_manager; - Teuchos::RCP _global_data; -}; - -//---------------------------------------------------------------------------// - -} // end namespace Parameter -} // end namespace VertexCFD - -#endif // end VERTEXCFD_SCALARPARAMETEREVALUATOR_HPP diff --git a/src/parameters/VertexCFD_ScalarParameterEvaluator_impl.hpp b/src/parameters/VertexCFD_ScalarParameterEvaluator_impl.hpp deleted file mode 100644 index 23e99d1..0000000 --- a/src/parameters/VertexCFD_ScalarParameterEvaluator_impl.hpp +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef VERTEXCFD_SCALARPARAMETEREVALUATOR_IMPL_HPP -#define VERTEXCFD_SCALARPARAMETEREVALUATOR_IMPL_HPP - -#include - -#include -#include - -namespace VertexCFD -{ -namespace Parameter -{ -//---------------------------------------------------------------------------// -template -ScalarParameterEvaluator::ScalarParameterEvaluator( - const Teuchos::RCP>& param_manager, - const Teuchos::RCP& global_data) - : _param_manager(param_manager) - , _global_data(global_data) -{ - auto dummy_layout = Teuchos::rcp(new PHX::MDALayout(0)); - _param_update_trigger = Teuchos::rcp( - new PHX::Tag("scalar_parameter_eval", dummy_layout)); - this->addEvaluatedField(*_param_update_trigger); - this->setName("Scalar Parameter Evaluation"); -} - -//---------------------------------------------------------------------------// -template -void ScalarParameterEvaluator::evaluateFields( - typename Traits::EvalData workset) -{ - _param_manager->update(*_global_data, workset); -} - -//---------------------------------------------------------------------------// - -} // end namespace Parameter -} // end namespace VertexCFD - -#endif // end VERTEXCFD_SCALARPARAMETEREVALUATOR_IMPL_HPP diff --git a/src/parameters/VertexCFD_ScalarParameterInput.cpp b/src/parameters/VertexCFD_ScalarParameterInput.cpp deleted file mode 100644 index 1507b40..0000000 --- a/src/parameters/VertexCFD_ScalarParameterInput.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include "VertexCFD_ScalarParameterInput.hpp" - -namespace VertexCFD -{ -namespace Parameter -{ -//---------------------------------------------------------------------------// -bool ScalarParameterInput::operator==(const ScalarParameterInput& rhs) const -{ - return parameter_name == rhs.parameter_name; -} - -//---------------------------------------------------------------------------// -std::ostream& operator<<(std::ostream& out, const ScalarParameterInput& input) -{ - out << input.parameter_name; - return out; -} - -//---------------------------------------------------------------------------// -std::istream& operator>>(std::istream& in, ScalarParameterInput& input) -{ - std::getline(in, input.parameter_name); - return in; -} - -//---------------------------------------------------------------------------// - -} // end namespace Parameter -} // end namespace VertexCFD diff --git a/src/parameters/VertexCFD_ScalarParameterInput.hpp b/src/parameters/VertexCFD_ScalarParameterInput.hpp deleted file mode 100644 index c93970a..0000000 --- a/src/parameters/VertexCFD_ScalarParameterInput.hpp +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef VERTEXCFD_SCALARPARAMETERINPUT_HPP -#define VERTEXCFD_SCALARPARAMETERINPUT_HPP - -#include - -#include - -namespace VertexCFD -{ -namespace Parameter -{ -//---------------------------------------------------------------------------// -struct ScalarParameterInput -{ - std::string parameter_name; - - bool operator==(const ScalarParameterInput& rhs) const; -}; - -//---------------------------------------------------------------------------// -std::ostream& operator<<(std::ostream& out, const ScalarParameterInput& input); - -std::istream& operator>>(std::istream& in, ScalarParameterInput& input); - -//---------------------------------------------------------------------------// - -} // end namespace Parameter -} // end namespace VertexCFD - -//---------------------------------------------------------------------------// -namespace Teuchos -{ -template<> -class TypeNameTraits -{ - public: - static std::string name() { return "ScalarParameter"; } -}; - -} // end namespace Teuchos - -//---------------------------------------------------------------------------// - -#endif // end VERTEXCFD_SCALARPARAMETERINPUT_HPP diff --git a/src/parameters/VertexCFD_ScalarParameterManager.cpp b/src/parameters/VertexCFD_ScalarParameterManager.cpp deleted file mode 100644 index defacde..0000000 --- a/src/parameters/VertexCFD_ScalarParameterManager.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_ScalarParameterManager.hpp" -#include "VertexCFD_ScalarParameterManager_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL( - VertexCFD::Parameter::ScalarParameterManager) diff --git a/src/parameters/VertexCFD_ScalarParameterManager.hpp b/src/parameters/VertexCFD_ScalarParameterManager.hpp deleted file mode 100644 index ba84b6a..0000000 --- a/src/parameters/VertexCFD_ScalarParameterManager.hpp +++ /dev/null @@ -1,48 +0,0 @@ -#ifndef VERTEXCFD_SCALARPARAMETERMANAGER_HPP -#define VERTEXCFD_SCALARPARAMETERMANAGER_HPP - -#include "VertexCFD_ParameterDatabase.hpp" -#include "VertexCFD_ScalarParameterObserver.hpp" - -#include - -#include - -#include -#include -#include - -namespace VertexCFD -{ -namespace Parameter -{ -//---------------------------------------------------------------------------// -template -class ScalarParameterManager -{ - public: - // Construct a manager from the parameter database. - ScalarParameterManager(const ParameterDatabase& parameter_db); - - // Assign a new observer to be managed by this manager. - void - addObserver(const Teuchos::RCP>& observer); - - // Update the parameters in all observers owned by this manager with the - // given global data. Also update the state of all observers with the new - // parameter values. - void update(const panzer::GlobalData& global_data, - const panzer::Workset& workset); - - private: - std::vector>> _observers; - std::unordered_map> - _general_parameter_data; -}; - -//---------------------------------------------------------------------------// - -} // namespace Parameter -} // namespace VertexCFD - -#endif // end VERTEXCFD_SCALARPARAMETERMANAGER_HPP diff --git a/src/parameters/VertexCFD_ScalarParameterManager_impl.hpp b/src/parameters/VertexCFD_ScalarParameterManager_impl.hpp deleted file mode 100644 index 71e9c3b..0000000 --- a/src/parameters/VertexCFD_ScalarParameterManager_impl.hpp +++ /dev/null @@ -1,61 +0,0 @@ -#ifndef VERTEXCFD_SCALARPARAMETERMANAGER_IMPL_HPP -#define VERTEXCFD_SCALARPARAMETERMANAGER_IMPL_HPP - -#include - -namespace VertexCFD -{ -namespace Parameter -{ -//---------------------------------------------------------------------------// -template -ScalarParameterManager::ScalarParameterManager( - const ParameterDatabase& parameter_db) -{ - // Extract the general_scalar parameters from the input. - auto general_scalar_params = parameter_db.generalScalarParameters(); - if (Teuchos::nonnull(general_scalar_params)) - { - // Loop through parameters - for (const auto& gp : *general_scalar_params) - { - // Loop through block values - std::unordered_map block_values; - auto param_values = general_scalar_params->sublist(gp.first); - for (const auto& bv : param_values) - { - // Insert block name and value. - block_values.emplace(bv.first, bv.second.getValue(0)); - } - - // Insert parameter name and block values. - _general_parameter_data.emplace(gp.first, std::move(block_values)); - } - } -} - -//---------------------------------------------------------------------------// -template -void ScalarParameterManager::addObserver( - const Teuchos::RCP>& observer) -{ - _observers.emplace_back(observer); -} - -//---------------------------------------------------------------------------// -template -void ScalarParameterManager::update( - const panzer::GlobalData& global_data, const panzer::Workset& workset) -{ - for (auto& o : _observers) - { - o->update(global_data, workset, _general_parameter_data); - } -} - -//---------------------------------------------------------------------------// - -} // namespace Parameter -} // namespace VertexCFD - -#endif // end VERTEXCFD_SCALARPARAMETERMANAGER_IMPL_HPP diff --git a/src/parameters/VertexCFD_ScalarParameterObserver.cpp b/src/parameters/VertexCFD_ScalarParameterObserver.cpp deleted file mode 100644 index 6df41db..0000000 --- a/src/parameters/VertexCFD_ScalarParameterObserver.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_ScalarParameterObserver.hpp" -#include "VertexCFD_ScalarParameterObserver_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL( - VertexCFD::Parameter::ScalarParameterObserver) diff --git a/src/parameters/VertexCFD_ScalarParameterObserver.hpp b/src/parameters/VertexCFD_ScalarParameterObserver.hpp deleted file mode 100644 index db6bca0..0000000 --- a/src/parameters/VertexCFD_ScalarParameterObserver.hpp +++ /dev/null @@ -1,60 +0,0 @@ -#ifndef VERTEXCFD_SCALARPARAMETEROBSERVER_HPP -#define VERTEXCFD_SCALARPARAMETEROBSERVER_HPP - -#include "VertexCFD_GeneralScalarParameter.hpp" -#include "VertexCFD_ScalarParameter.hpp" - -#include - -#include - -#include -#include - -namespace VertexCFD -{ -namespace Parameter -{ -//---------------------------------------------------------------------------// -template -class ScalarParameterObserver -{ - public: - using scalar_type = typename EvalType::ScalarT; - - // Register a parameter with the observer. The parameter will be extracted - // from the parameter list and assigned to the reference (note that this - // reference is stored by the underlying parameter). If the parameter is - // not in the list the provided default value will be used. - void registerParameter(const std::string& name, - const double default_value, - const Teuchos::ParameterList& plist, - scalar_type& ref_to_parameter); - - // Update the value of all parameters owned by the observer with the - // current state of the global data and the current workset. - void - update(const panzer::GlobalData& global_data, - const panzer::Workset& workset, - const std::unordered_map>& - general_parameter_data); - - protected: - // After the parameters have been updated, update the state of the - // observer as necessary to be consistent with the new parameter - // values. This will always be called inside of update() and therefore the - // parameter state is guaranteed to be up-to-date. - virtual void updateStateWithNewParameters() = 0; - - private: - std::vector> _scalar_parameters; - std::vector> _general_parameters; -}; - -//---------------------------------------------------------------------------// - -} // namespace Parameter -} // namespace VertexCFD - -#endif // end VERTEXCFD_SCALARPARAMETEROBSERVER_HPP diff --git a/src/parameters/VertexCFD_ScalarParameterObserver_impl.hpp b/src/parameters/VertexCFD_ScalarParameterObserver_impl.hpp deleted file mode 100644 index dc76d28..0000000 --- a/src/parameters/VertexCFD_ScalarParameterObserver_impl.hpp +++ /dev/null @@ -1,97 +0,0 @@ -#ifndef VERTEXCFD_SCALARPARAMETEROBSERVER_IMPL_HPP -#define VERTEXCFD_SCALARPARAMETEROBSERVER_IMPL_HPP - -#include "VertexCFD_GeneralScalarParameterInput.hpp" -#include "VertexCFD_ScalarParameterInput.hpp" - -namespace VertexCFD -{ -namespace Parameter -{ -//---------------------------------------------------------------------------// -template -void ScalarParameterObserver::registerParameter( - const std::string& name, - const double default_value, - const Teuchos::ParameterList& plist, - scalar_type& ref_to_parameter) -{ - // Sensitivity Parameter - // General Parameter - - // Sensitivity scalar parameter. Initially assign the default - // value. Parameterized values will get assigned during update(), - // including those nominal values set in the input file. Sensitivity - // scalar parameters have: - // - // nominal value: provided by user, applied when model is not being - // parameterized w.r.t. given parameter - // - // default value: provided by developer, applied when the user - // doesn't specify the parameter in any way - if (plist.isType(name)) - { - auto param_input = plist.get(name); - _scalar_parameters.emplace_back(param_input.parameter_name, - ref_to_parameter); - ref_to_parameter = default_value; - } - - // General scalar parameter. A default value is provided to use for all - // blocks that aren't given their own parameter value. Block parameter - // values will get assigned during update(), including those default - // values set in the input file. General scalar parameters have: - // - // block value: provided by user, applied on the given block - // - // default value; provided by user, applied when no block value is - // given for a block - // - // default value: provided by developer, applied when the user - // doesn't specify the parameter in any way - else if (plist.isType(name)) - { - auto param_input = plist.get(name); - _general_parameters.emplace_back(param_input.parameter_name, - ref_to_parameter); - ref_to_parameter = default_value; - } - - // Check for local parameter. - else if (plist.isType(name)) - { - ref_to_parameter = plist.get(name); - } - - // Otherwise treat as local parameter and set default. - else - { - ref_to_parameter = default_value; - } -} - -//---------------------------------------------------------------------------// -template -void ScalarParameterObserver::update( - const panzer::GlobalData& global_data, - const panzer::Workset& workset, - const std::unordered_map>& - general_parameter_data) -{ - for (auto& p : _scalar_parameters) - { - p.update(global_data); - } - for (auto& p : _general_parameters) - { - p.update(workset, general_parameter_data); - } - this->updateStateWithNewParameters(); -} - -//---------------------------------------------------------------------------// - -} // namespace Parameter -} // namespace VertexCFD - -#endif // end VERTEXCFD_SCALARPARAMETEROBSERVER_IMPL_HPP diff --git a/src/parameters/VertexCFD_ScalarParameter_impl.hpp b/src/parameters/VertexCFD_ScalarParameter_impl.hpp deleted file mode 100644 index 295eaf9..0000000 --- a/src/parameters/VertexCFD_ScalarParameter_impl.hpp +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef VERTEXCFD_SCALARPARAMETER_IMPL_HPP -#define VERTEXCFD_SCALARPARAMETER_IMPL_HPP - -namespace VertexCFD -{ -namespace Parameter -{ -//---------------------------------------------------------------------------// -template -ScalarParameter::ScalarParameter(const std::string& name, - scalar_type& ref_to_parameter) - : _name(name) - , _ref_to_parameter(ref_to_parameter) -{ -} - -//---------------------------------------------------------------------------// -template -const std::string& ScalarParameter::name() const -{ - return _name; -} - -//---------------------------------------------------------------------------// -template -void ScalarParameter::update(const panzer::GlobalData& global_data) -{ - _ref_to_parameter = global_data.pl->getValue(_name); -} - -//---------------------------------------------------------------------------// - -} // namespace Parameter -} // namespace VertexCFD - -#endif // end VERTEXCFD_SCALARPARAMETER_IMPL_HPP diff --git a/src/parameters/unit_test/CMakeLists.txt b/src/parameters/unit_test/CMakeLists.txt deleted file mode 100644 index 512529e..0000000 --- a/src/parameters/unit_test/CMakeLists.txt +++ /dev/null @@ -1,18 +0,0 @@ -configure_file( - VertexCFD_ParameterUnitTestConfig.hpp.cmakein - VertexCFD_ParameterUnitTestConfig.hpp ) - -set(TEST_HARNESS_DIR ${CMAKE_SOURCE_DIR}/src/test_harness) -include(${TEST_HARNESS_DIR}/TestHarness.cmake) - -VertexCFD_add_tests( - LIBS VertexCFD - NAMES - ParameterDatabase - GeneralScalarParameterInput - GeneralScalarParameter - ScalarParameter - ScalarParameterInput - ScalarParameterObserver - ScalarParameterEvaluator - ) diff --git a/src/parameters/unit_test/VertexCFD_ParameterUnitTestConfig.hpp.cmakein b/src/parameters/unit_test/VertexCFD_ParameterUnitTestConfig.hpp.cmakein deleted file mode 100644 index e1ad226..0000000 --- a/src/parameters/unit_test/VertexCFD_ParameterUnitTestConfig.hpp.cmakein +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef VERTEXCFD_PARAMETERUNITTESTCONFIG_HPP -#define VERTEXCFD_PARAMETERUNITTESTCONFIG_HPP - -constexpr char VERTEXCFD_PARAMETER_TEST_DATA_DIR[] = R"(@CMAKE_CURRENT_SOURCE_DIR@/data/)"; -constexpr char VERTEXCFD_RESPONSE_TEST_DATA_DIR[] = R"(@CMAKE_SOURCE_DIR@/src/responses/unit_test/data/)"; - -#endif // end VERTEXCFD_PARAMETERUNITTESTCONFIG_HPP diff --git a/src/parameters/unit_test/data/input_parser_test.xml b/src/parameters/unit_test/data/input_parser_test.xml deleted file mode 100644 index 18b5924..0000000 --- a/src/parameters/unit_test/data/input_parser_test.xml +++ /dev/null @@ -1,71 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/parameters/unit_test/data/scalar_parameter_evaluator_test.xml b/src/parameters/unit_test/data/scalar_parameter_evaluator_test.xml deleted file mode 100644 index ba85dc2..0000000 --- a/src/parameters/unit_test/data/scalar_parameter_evaluator_test.xml +++ /dev/null @@ -1,111 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/parameters/unit_test/tstGeneralScalarParameter.cpp b/src/parameters/unit_test/tstGeneralScalarParameter.cpp deleted file mode 100644 index be904ce..0000000 --- a/src/parameters/unit_test/tstGeneralScalarParameter.cpp +++ /dev/null @@ -1,111 +0,0 @@ -#include "VertexCFD_ParameterUnitTestConfig.hpp" - -#include "parameters/VertexCFD_GeneralScalarParameter.hpp" - -#include -#include - -#include - -#include -#include -#include - -//---------------------------------------------------------------------------// -// TESTS -//---------------------------------------------------------------------------// -namespace VertexCFD -{ -namespace Test -{ -//---------------------------------------------------------------------------// -double getValue(const panzer::Traits::Residual::ScalarT& observed) -{ - return observed; -} - -//---------------------------------------------------------------------------// -double getValue(const panzer::Traits::Jacobian::ScalarT& observed) -{ - return observed.val(); -} - -//---------------------------------------------------------------------------// -template -void testGeneralScalarParameter() -{ - // Create input structure. - std::unordered_map> - general_parameter_data; - { - std::unordered_map param_values; - param_values.emplace("Default Value", 1.2345); - param_values.emplace("Block 1", 2.3456); - general_parameter_data.emplace("Foo", std::move(param_values)); - } - { - general_parameter_data.emplace( - "Bar", std::unordered_map{}); - } - - // Create worksets. - panzer::Workset w1; - w1.block_id = "Block 1"; - panzer::Workset w2; - w2.block_id = "Block 2"; - - // Create a parameter. - typename EvalType::ScalarT result = -1.0; - Parameter::GeneralScalarParameter gsp("Foo", result); - EXPECT_EQ("Foo", gsp.name()); - - // Test evaluation. - gsp.update(w1, general_parameter_data); - EXPECT_EQ(2.3456, getValue(result)); - gsp.update(w2, general_parameter_data); - EXPECT_EQ(1.2345, getValue(result)); - - // Try a parameter not in the list. - Parameter::GeneralScalarParameter bad_param("Biz", result); - const std::string biz_msg = "GeneralScalar parameter Biz not found"; - EXPECT_THROW( - try { - bad_param.update(w1, general_parameter_data); - } catch (const std::runtime_error& e) { - EXPECT_EQ(biz_msg, e.what()); - throw; - }, - std::runtime_error); - - // Try a parameter without a default for a block that doesn't exist. - Parameter::GeneralScalarParameter no_default("Bar", result); - const std::string bar_msg - = "GeneralScalar parameter Bar" - " does not have a value for block Block 2" - " and is also missing a default value"; - EXPECT_THROW( - try { - no_default.update(w2, general_parameter_data); - } catch (const std::runtime_error& e) { - EXPECT_EQ(bar_msg, e.what()); - throw; - }, - std::runtime_error); -} - -//---------------------------------------------------------------------------// -TEST(GeneralScalarParameter, residual) -{ - testGeneralScalarParameter(); -} - -//---------------------------------------------------------------------------// -TEST(GeneralScalarParameter, jacobian) -{ - testGeneralScalarParameter(); -} - -//---------------------------------------------------------------------------// - -} // namespace Test -} // namespace VertexCFD diff --git a/src/parameters/unit_test/tstGeneralScalarParameterInput.cpp b/src/parameters/unit_test/tstGeneralScalarParameterInput.cpp deleted file mode 100644 index 8a8be38..0000000 --- a/src/parameters/unit_test/tstGeneralScalarParameterInput.cpp +++ /dev/null @@ -1,54 +0,0 @@ -#include "parameters/VertexCFD_GeneralScalarParameterInput.hpp" - -#include -#include -#include - -#include - -#include -#include - -//---------------------------------------------------------------------------// -// TESTS -//---------------------------------------------------------------------------// -namespace VertexCFD -{ -namespace Test -{ -//---------------------------------------------------------------------------// -TEST(GeneralScalarParameterInput, xml_write_read) -{ - // Inject custom type for parameter input. - TEUCHOS_ADD_TYPE_CONVERTER(Parameter::GeneralScalarParameterInput); - - // Make a parameter list with a general_scalar parameter input. - Teuchos::ParameterList write_list; - Parameter::GeneralScalarParameterInput write_input = {"Parameter Name"}; - write_list.set("Object Parameter", write_input); - - // Write a parameter list to XML. Write it to cout too so we can see it. - Teuchos::writeParameterListToXmlFile( - write_list, "general_scalar_parameter_input_test.xml"); - Teuchos::writeParameterListToXmlOStream(write_list, std::cout); - - // Read the parameter list back in. Also write it to cout so we can see - // it. - auto read_list = Teuchos::getParametersFromXmlFile( - "general_scalar_parameter_input_test.xml"); - std::cout << *read_list; - - // Check result. - auto read_input = read_list->get( - "Object Parameter"); - EXPECT_EQ("Parameter Name", read_input.parameter_name); - - // Check equality operator. - Parameter::GeneralScalarParameterInput eq_check = {"Parameter Name"}; - EXPECT_EQ(eq_check, write_input); -} - -//---------------------------------------------------------------------------// - -} // namespace Test -} // namespace VertexCFD diff --git a/src/parameters/unit_test/tstParameterDatabase.cpp b/src/parameters/unit_test/tstParameterDatabase.cpp deleted file mode 100644 index d8faf95..0000000 --- a/src/parameters/unit_test/tstParameterDatabase.cpp +++ /dev/null @@ -1,175 +0,0 @@ -#include - -#include - -#include -#include -#include - -#include - -#include - -//---------------------------------------------------------------------------// -// TESTS -//---------------------------------------------------------------------------// -namespace VertexCFD -{ -namespace Test -{ -//---------------------------------------------------------------------------// -void testDefaultDatabase() -{ - // Get the MPI communicator. - auto comm = Teuchos::rcp_dynamic_cast>( - Teuchos::DefaultComm::getComm()); - - // Create database. - VertexCFD::Parameter::ParameterDatabase parameter_db(comm); - - // Check that all parameter lists got populated. - EXPECT_TRUE(Teuchos::nonnull(parameter_db.meshParameters())); - EXPECT_TRUE(Teuchos::nonnull(parameter_db.physicsParameters())); - EXPECT_TRUE(Teuchos::nonnull(parameter_db.blockMappingParameters())); - EXPECT_TRUE(Teuchos::nonnull(parameter_db.scalarParameters())); - EXPECT_TRUE(Teuchos::nonnull(parameter_db.generalScalarParameters())); - EXPECT_TRUE(Teuchos::nonnull(parameter_db.boundaryConditionParameters())); - EXPECT_TRUE(Teuchos::nonnull(parameter_db.initialConditionParameters())); - EXPECT_TRUE(Teuchos::nonnull(parameter_db.closureModelParameters())); - EXPECT_TRUE(Teuchos::nonnull(parameter_db.responseOutputParameters())); - EXPECT_TRUE(Teuchos::nonnull(parameter_db.userParameters())); - EXPECT_TRUE(Teuchos::nonnull(parameter_db.outputParameters())); - EXPECT_TRUE(Teuchos::nonnull(parameter_db.readRestartParameters())); - EXPECT_TRUE(Teuchos::nonnull(parameter_db.writeRestartParameters())); - EXPECT_TRUE(Teuchos::nonnull(parameter_db.writeMatrixParameters())); - EXPECT_TRUE(Teuchos::is_null(parameter_db.profilingParameters())); - EXPECT_TRUE(Teuchos::nonnull(parameter_db.transientSolverParameters())); - EXPECT_TRUE(Teuchos::nonnull(parameter_db.linearSolverParameters())); - - // Check that we added the communicator to the user data. - auto param_comm - = parameter_db.userParameters() - ->get>>("Comm"); - EXPECT_EQ(comm->getRank(), param_comm->getRank()); - EXPECT_EQ(comm->getSize(), param_comm->getSize()); -} - -//---------------------------------------------------------------------------// -TEST(ParameterDatabase, default_test) -{ - testDefaultDatabase(); -} - -//---------------------------------------------------------------------------// -void testInputParser(const Teuchos::RCP>& comm, - const VertexCFD::Parameter::ParameterDatabase& parameter_db) -{ - // Check that all parameter lists got populated. - EXPECT_DOUBLE_EQ(1.0, parameter_db.meshParameters()->get("value")); - EXPECT_DOUBLE_EQ(1.4, - parameter_db.physicsParameters()->get("value")); - EXPECT_DOUBLE_EQ( - 1.3, parameter_db.blockMappingParameters()->get("value")); - EXPECT_DOUBLE_EQ( - 1.6, parameter_db.boundaryConditionParameters()->get("value")); - EXPECT_DOUBLE_EQ( - 1.7, parameter_db.initialConditionParameters()->get("value")); - EXPECT_DOUBLE_EQ( - 1.8, parameter_db.closureModelParameters()->get("value")); - EXPECT_DOUBLE_EQ( - 2.4, parameter_db.responseOutputParameters()->get("value")); - EXPECT_DOUBLE_EQ(1.5, parameter_db.userParameters()->get("value")); - EXPECT_DOUBLE_EQ(1.1, - parameter_db.outputParameters()->get("value")); - EXPECT_DOUBLE_EQ( - 2.3, parameter_db.readRestartParameters()->get("value")); - EXPECT_DOUBLE_EQ( - 2.2, parameter_db.writeRestartParameters()->get("value")); - EXPECT_DOUBLE_EQ( - 2.1, parameter_db.writeMatrixParameters()->get("value")); - EXPECT_DOUBLE_EQ(1.2, - parameter_db.profilingParameters()->get("value")); - EXPECT_DOUBLE_EQ( - 2.0, parameter_db.transientSolverParameters()->get("value")); - EXPECT_DOUBLE_EQ( - 1.9, parameter_db.linearSolverParameters()->get("value")); - EXPECT_DOUBLE_EQ(2.5, - parameter_db.scalarParameters()->get("value")); - EXPECT_DOUBLE_EQ( - 2.6, parameter_db.generalScalarParameters()->get("value")); - - // Check the parameter communicator. - EXPECT_EQ(comm->getRank(), parameter_db.comm()->getRank()); - EXPECT_EQ(comm->getSize(), parameter_db.comm()->getSize()); - - // Check that we added the communicator to the user data. - auto param_comm - = parameter_db.userParameters() - ->get>>("Comm"); - EXPECT_EQ(comm->getRank(), param_comm->getRank()); - EXPECT_EQ(comm->getSize(), param_comm->getSize()); -} - -//---------------------------------------------------------------------------// -TEST(ParameterDatabase, argv_test) -{ - // Get the MPI communicator. - auto comm = Teuchos::rcp_dynamic_cast>( - Teuchos::DefaultComm::getComm()); - - // Parse input. - int argc = 2; - std::string option = "--i="; - std::string location = VERTEXCFD_PARAMETER_TEST_DATA_DIR; - std::string file = "input_parser_test.xml"; - std::string argv_str = option + location + file; - char* argv[2]; - argv[1] = &argv_str[0]; - VertexCFD::Parameter::ParameterDatabase parameter_db(comm, argc, argv); - - // Test - testInputParser(comm, parameter_db); -} - -//---------------------------------------------------------------------------// -TEST(ParameterDatabase, file_test) -{ - // Get the MPI communicator. - auto comm = Teuchos::rcp_dynamic_cast>( - Teuchos::DefaultComm::getComm()); - - // Parse input. - std::string location = VERTEXCFD_PARAMETER_TEST_DATA_DIR; - std::string file = "input_parser_test.xml"; - std::string filename = location + file; - VertexCFD::Parameter::ParameterDatabase parameter_db(comm, filename); - - // Test - testInputParser(comm, parameter_db); -} - -//---------------------------------------------------------------------------// -TEST(ParameterDatabase, list_test) -{ - // Get the MPI communicator. - auto comm = Teuchos::rcp_dynamic_cast>( - Teuchos::DefaultComm::getComm()); - - // Parse input. - std::string location = VERTEXCFD_PARAMETER_TEST_DATA_DIR; - std::string file = "input_parser_test.xml"; - std::string filename = location + file; - VertexCFD::Parameter::ParameterDatabase file_db(comm, filename); - - // Create a new parameter database from the input list. - VertexCFD::Parameter::ParameterDatabase parameter_db( - comm, file_db.allParameters()); - - // Test - testInputParser(comm, parameter_db); -} - -//---------------------------------------------------------------------------// - -} // end namespace Test -} // end namespace VertexCFD diff --git a/src/parameters/unit_test/tstScalarParameter.cpp b/src/parameters/unit_test/tstScalarParameter.cpp deleted file mode 100644 index a00e3ee..0000000 --- a/src/parameters/unit_test/tstScalarParameter.cpp +++ /dev/null @@ -1,83 +0,0 @@ -#include "VertexCFD_ParameterUnitTestConfig.hpp" - -#include "parameters/VertexCFD_ParameterDatabase.hpp" -#include "parameters/VertexCFD_ScalarParameter.hpp" - -#include "drivers/VertexCFD_InitialConditionManager.hpp" -#include "drivers/VertexCFD_MeshManager.hpp" -#include "drivers/VertexCFD_PhysicsManager.hpp" - -#include - -#include - -//---------------------------------------------------------------------------// -// TESTS -//---------------------------------------------------------------------------// -namespace VertexCFD -{ -namespace Test -{ -//---------------------------------------------------------------------------// -double getValue(const panzer::Traits::Residual::ScalarT& observed) -{ - return observed; -} - -//---------------------------------------------------------------------------// -double getValue(const panzer::Traits::Jacobian::ScalarT& observed) -{ - return observed.val(); -} - -//---------------------------------------------------------------------------// -template -void testScalarParameter() -{ - // Setup base data structures to make a parameter library. - auto comm = Teuchos::rcp_dynamic_cast>( - Teuchos::DefaultComm::getComm()); - const std::string location = VERTEXCFD_RESPONSE_TEST_DATA_DIR; - const std::string file = "response_manager_test.xml"; - auto parameter_db = Teuchos::rcp( - new Parameter::ParameterDatabase(comm, location + file)); - parameter_db->physicsParameters() - ->sublist("FluidPhysicsBlock", true) - .sublist("Data", true) - .set("Basis Order", 1); - auto mesh_manager = Teuchos::rcp(new MeshManager(*parameter_db, comm)); - auto physics_manager = Teuchos::rcp(new PhysicsManager( - std::integral_constant{}, parameter_db, mesh_manager)); - physics_manager->setupModel(); - - // Add a global parameter - physics_manager->addScalarParameter("Global Parameter", 1.234); - - // Make a parameter to change. - typename EvalType::ScalarT param_value = 2.345; - - // Make global parameter. - auto global_param = Teuchos::rcp(new Parameter::ScalarParameter( - "Global Parameter", param_value)); - EXPECT_EQ("Global Parameter", global_param->name()); - EXPECT_EQ(2.345, getValue(param_value)); - global_param->update(*(physics_manager->globalData())); - EXPECT_EQ(1.234, getValue(param_value)); -} - -//---------------------------------------------------------------------------// -TEST(ScalarParameter, residual) -{ - testScalarParameter(); -} - -//---------------------------------------------------------------------------// -TEST(ScalarParameter, jacobian) -{ - testScalarParameter(); -} - -//---------------------------------------------------------------------------// - -} // namespace Test -} // namespace VertexCFD diff --git a/src/parameters/unit_test/tstScalarParameterEvaluator.cpp b/src/parameters/unit_test/tstScalarParameterEvaluator.cpp deleted file mode 100644 index e9cdd7f..0000000 --- a/src/parameters/unit_test/tstScalarParameterEvaluator.cpp +++ /dev/null @@ -1,223 +0,0 @@ -#include "VertexCFD_ParameterUnitTestConfig.hpp" - -#include "parameters/VertexCFD_ParameterDatabase.hpp" -#include "parameters/VertexCFD_ScalarParameterEvaluator.hpp" -#include "parameters/VertexCFD_ScalarParameterInput.hpp" -#include "parameters/VertexCFD_ScalarParameterManager.hpp" -#include "parameters/VertexCFD_ScalarParameterObserver.hpp" - -#include "drivers/VertexCFD_InitialConditionManager.hpp" -#include "drivers/VertexCFD_MeshManager.hpp" -#include "drivers/VertexCFD_PhysicsManager.hpp" - -#include "utils/VertexCFD_EvaluatorBase.hpp" - -#include - -#include -#include - -#include - -#include - -//---------------------------------------------------------------------------// -// TESTS -//---------------------------------------------------------------------------// -namespace VertexCFD -{ -namespace Test -{ -//---------------------------------------------------------------------------// -template -class EvaluatorWithParameter - : public EvaluatorBase, - public Parameter::ScalarParameterObserver -{ - public: - using scalar_type = typename EvalType::ScalarT; - - EvaluatorWithParameter(const panzer::IntegrationRule& ir, - const Teuchos::ParameterList& params) - : _f1("f1", ir.dl_scalar) - , _f2("f2", ir.dl_scalar) - , _f3("f3", ir.dl_scalar) - , _f4("f4", ir.dl_scalar) - , _f5("f5", ir.dl_scalar) - { - this->addEvaluatedField(_f1); - this->addEvaluatedField(_f2); - this->addEvaluatedField(_f3); - this->addEvaluatedField(_f4); - this->addEvaluatedField(_f5); - this->registerParameter("p1", 2.0, params, _p1); - this->registerParameter("p2", 3.0, params, _p2); - this->registerParameter("p3", 4.0, params, _p3); - this->registerParameter("p4", 5.0, params, _p4); - this->registerParameter("p5", 6.0, params, _p5); - this->setName("EvaluatorWithParameter"); - } - - scalar_type _p1; - scalar_type _p2; - scalar_type _p3; - scalar_type _p4; - scalar_type _p5; - scalar_type _cp1; - scalar_type _cp2; - scalar_type _cp3; - scalar_type _cp4; - scalar_type _cp5; - PHX::MDField _f1; - PHX::MDField _f2; - PHX::MDField _f3; - PHX::MDField _f4; - PHX::MDField _f5; - - protected: - void updateStateWithNewParameters() override - { - // Do a copy here to make sure this function gets called. - _cp1 = _p1; - _cp2 = _p2; - _cp3 = _p3; - _cp4 = _p4; - _cp5 = _p5; - } - - void evaluateFieldsImpl(typename Traits::EvalData) override - { - _f1.deep_copy(_cp1); - _f2.deep_copy(_cp2); - _f3.deep_copy(_cp3); - _f4.deep_copy(_cp4); - _f5.deep_copy(_cp5); - } -}; - -//---------------------------------------------------------------------------// -template -void testScalarParameterEvaluator() -{ - // Setup base data structures to make a parameter library. - auto comm = Teuchos::rcp_dynamic_cast>( - Teuchos::DefaultComm::getComm()); - const std::string location = VERTEXCFD_PARAMETER_TEST_DATA_DIR; - const std::string file = "scalar_parameter_evaluator_test.xml"; - auto parameter_db = Teuchos::rcp( - new Parameter::ParameterDatabase(comm, location + file)); - parameter_db->physicsParameters() - ->sublist("FluidPhysicsBlock", true) - .sublist("Data", true) - .set("Basis Order", 1); - auto mesh_manager = Teuchos::rcp(new MeshManager(*parameter_db, comm)); - auto physics_manager = Teuchos::rcp(new PhysicsManager( - std::integral_constant{}, parameter_db, mesh_manager)); - physics_manager->setupModel(); - - // Setup test fixture. - const int num_space_dim = 2; - const int integration_order = 1; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - - // Inject custom type for parameter input. - TEUCHOS_ADD_TYPE_CONVERTER(Parameter::ScalarParameterInput); - - // Setup parameterized evaluator. The parameter list below in XML would - // be: - // - // - // - // - // - // - // - // Note that p1 is not included to trigger the default evaluation. - Teuchos::ParameterList plist; - Parameter::ScalarParameterInput input_2 = {"Parameter2"}; - plist.set("p2", input_2); - plist.set("p3", 9.2); - Parameter::GeneralScalarParameterInput input_4 = {"GeneralParam1"}; - plist.set("p4", input_4); - Parameter::GeneralScalarParameterInput input_5 = {"GeneralParam2"}; - plist.set("p5", input_5); - auto param_eval - = Teuchos::rcp(new EvaluatorWithParameter( - *test_fixture.ir, plist)); - test_fixture.registerEvaluator(param_eval); - - // Create a parameter observer manager and register the evaluator with it. - auto param_manager = Teuchos::rcp( - new Parameter::ScalarParameterManager(*parameter_db)); - param_manager->addObserver(param_eval); - - // Setup scalar parameter evaluator. This will trigger the parameter - // update first in the graph. - auto global_data = physics_manager->globalData(); - auto sp_eval = Teuchos::rcp( - new Parameter::ScalarParameterEvaluator( - param_manager, global_data)); - test_fixture.registerEvaluator(sp_eval); - - // Add required test fields. - test_fixture.registerTestField(param_eval->_f1); - test_fixture.registerTestField(param_eval->_f2); - test_fixture.registerTestField(param_eval->_f3); - test_fixture.registerTestField(param_eval->_f4); - test_fixture.registerTestField(param_eval->_f5); - - // Set the test fixture block. - test_fixture.workset->block_id = "eblock-0_0"; - - // Evaluate test fields. - test_fixture.evaluate(); - - // Check the test fields during evaluate. - // - // Field 1 should have the default in the evaluator because it is not - // defined in the evaluator list. - // - // Field 2 should have the nominal value from the global scalar parameter - // list because it is set as a scalar parameter for the object. - // - // Field 3 should have the value from the evaluator parameter list because - // it is set as a local parameter in the evaluator list. - // - // Field 4 should have the value of the first general parameter in the - // given element block. - // - // Field 5 should have the default value of the second general - // parameter in the given element block because no block-specific values - // are given for the second parameter in the input. - auto f1_result = test_fixture.getTestFieldData(param_eval->_f1); - auto f2_result = test_fixture.getTestFieldData(param_eval->_f2); - auto f3_result = test_fixture.getTestFieldData(param_eval->_f3); - auto f4_result = test_fixture.getTestFieldData(param_eval->_f4); - auto f5_result = test_fixture.getTestFieldData(param_eval->_f5); - EXPECT_DOUBLE_EQ(2.0, fieldValue(f1_result, 0, 0)); - EXPECT_DOUBLE_EQ(5.5, fieldValue(f2_result, 0, 0)); - EXPECT_DOUBLE_EQ(9.2, fieldValue(f3_result, 0, 0)); - EXPECT_DOUBLE_EQ(2.34, fieldValue(f4_result, 0, 0)); - EXPECT_DOUBLE_EQ(3.45, fieldValue(f5_result, 0, 0)); -} - -//---------------------------------------------------------------------------// -TEST(ScalarParameter, residual) -{ - testScalarParameterEvaluator(); -} - -//---------------------------------------------------------------------------// -TEST(ScalarParameter, jacobian) -{ - testScalarParameterEvaluator(); -} - -//---------------------------------------------------------------------------// - -} // namespace Test -} // namespace VertexCFD diff --git a/src/parameters/unit_test/tstScalarParameterInput.cpp b/src/parameters/unit_test/tstScalarParameterInput.cpp deleted file mode 100644 index 913fc49..0000000 --- a/src/parameters/unit_test/tstScalarParameterInput.cpp +++ /dev/null @@ -1,55 +0,0 @@ -#include "parameters/VertexCFD_ParameterDatabase.hpp" -#include "parameters/VertexCFD_ScalarParameterInput.hpp" - -#include -#include -#include - -#include - -#include -#include - -//---------------------------------------------------------------------------// -// TESTS -//---------------------------------------------------------------------------// -namespace VertexCFD -{ -namespace Test -{ -//---------------------------------------------------------------------------// -TEST(ScalarParameterInput, xml_write_read) -{ - // Inject custom type for parameter input. - TEUCHOS_ADD_TYPE_CONVERTER(Parameter::ScalarParameterInput); - - // Make a parameter list with a scalar parameter input. - Teuchos::ParameterList write_list; - Parameter::ScalarParameterInput write_input = {"Parameter Name"}; - write_list.set("Object Parameter", write_input); - - // Write a parameter list to XML. Write it to cout too so we can see it. - Teuchos::writeParameterListToXmlFile(write_list, - "scalar_parameter_input_test.xml"); - Teuchos::writeParameterListToXmlOStream(write_list, std::cout); - - // Read the parameter list back in. Also write it to cout so we can see - // it. - auto read_list - = Teuchos::getParametersFromXmlFile("scalar_parameter_input_test.xml"); - std::cout << *read_list; - - // Check result. - auto read_input - = read_list->get("Object Parameter"); - EXPECT_EQ("Parameter Name", read_input.parameter_name); - - // Check equality operator. - Parameter::ScalarParameterInput eq_check = {"Parameter Name"}; - EXPECT_EQ(eq_check, write_input); -} - -//---------------------------------------------------------------------------// - -} // namespace Test -} // namespace VertexCFD diff --git a/src/parameters/unit_test/tstScalarParameterObserver.cpp b/src/parameters/unit_test/tstScalarParameterObserver.cpp deleted file mode 100644 index 2670279..0000000 --- a/src/parameters/unit_test/tstScalarParameterObserver.cpp +++ /dev/null @@ -1,155 +0,0 @@ -#include "VertexCFD_ParameterUnitTestConfig.hpp" - -#include "parameters/VertexCFD_GeneralScalarParameterInput.hpp" -#include "parameters/VertexCFD_ParameterDatabase.hpp" -#include "parameters/VertexCFD_ScalarParameterInput.hpp" -#include "parameters/VertexCFD_ScalarParameterObserver.hpp" - -#include "drivers/VertexCFD_InitialConditionManager.hpp" -#include "drivers/VertexCFD_MeshManager.hpp" -#include "drivers/VertexCFD_PhysicsManager.hpp" - -#include - -#include - -#include - -//---------------------------------------------------------------------------// -// TESTS -//---------------------------------------------------------------------------// -namespace VertexCFD -{ -namespace Test -{ -//---------------------------------------------------------------------------// -template -class TestObserver : public Parameter::ScalarParameterObserver -{ - public: - void updateStateWithNewParameters() override { _state_updated = true; } - bool _state_updated = false; -}; - -//---------------------------------------------------------------------------// -double getValue(const panzer::Traits::Residual::ScalarT& observed) -{ - return observed; -} - -//---------------------------------------------------------------------------// -double getValue(const panzer::Traits::Jacobian::ScalarT& observed) -{ - return observed.val(); -} - -//---------------------------------------------------------------------------// -template -void testScalarParameterObserver() -{ - // Setup base data structures to make a parameter library. - auto comm = Teuchos::rcp_dynamic_cast>( - Teuchos::DefaultComm::getComm()); - const std::string location = VERTEXCFD_RESPONSE_TEST_DATA_DIR; - const std::string file = "response_manager_test.xml"; - auto parameter_db = Teuchos::rcp( - new Parameter::ParameterDatabase(comm, location + file)); - parameter_db->physicsParameters() - ->sublist("FluidPhysicsBlock", true) - .sublist("Data", true) - .set("Basis Order", 1); - auto mesh_manager = Teuchos::rcp(new MeshManager(*parameter_db, comm)); - auto physics_manager = Teuchos::rcp(new PhysicsManager( - std::integral_constant{}, parameter_db, mesh_manager)); - physics_manager->setupModel(); - - // Add a global parameter - physics_manager->addScalarParameter("Global Parameter", 1.234); - - // Make worksets to get block info. First workset has a real block, second - // does not so we can check default assignment. - panzer::Workset workset_1; - workset_1.block_id = "eblock-0_0"; - panzer::Workset workset_2; - workset_2.block_id = "undefined"; - - // Make general parameter data. - std::unordered_map> - general_parameter_data; - std::unordered_map param_values; - param_values.emplace("Default Value", 5.678); - param_values.emplace("eblock-0_0", 6.789); - general_parameter_data.emplace("General Parameter", param_values); - - // Make parameter list. - Teuchos::ParameterList plist; - - // Add a global parameter. - Parameter::ScalarParameterInput global_input = {"Global Parameter"}; - plist.set("global_param", global_input); - - // Add a general parameter. - Parameter::GeneralScalarParameterInput general_input - = {"General Parameter"}; - plist.set("general_param", general_input); - - // Add a regular parameter. - plist.set("local_param_1", 3.456); - - // Make parameters. - typename EvalType::ScalarT global_param; - typename EvalType::ScalarT general_param; - typename EvalType::ScalarT local_param_1; - typename EvalType::ScalarT local_param_2; - - // Make a parameter observer. - TestObserver observer; - observer.registerParameter("global_param", 2.345, plist, global_param); - observer.registerParameter("general_param", 0.123, plist, general_param); - observer.registerParameter("local_param_1", 4.567, plist, local_param_1); - observer.registerParameter("local_param_2", 4.567, plist, local_param_2); - - // Check pre-update values. - EXPECT_EQ(2.345, getValue(global_param)); - EXPECT_EQ(0.123, getValue(general_param)); - EXPECT_EQ(3.456, getValue(local_param_1)); - EXPECT_EQ(4.567, getValue(local_param_2)); - - // Update with the first workset. - EXPECT_FALSE(observer._state_updated); - observer.update( - *(physics_manager->globalData()), workset_1, general_parameter_data); - EXPECT_TRUE(observer._state_updated); - - // Check post-update values. - EXPECT_EQ(1.234, getValue(global_param)); - EXPECT_EQ(6.789, getValue(general_param)); - EXPECT_EQ(3.456, getValue(local_param_1)); - EXPECT_EQ(4.567, getValue(local_param_2)); - - // Update with the second workset and make sure the block default was - // given. The general param should be the only one that changes. - observer.update( - *(physics_manager->globalData()), workset_2, general_parameter_data); - EXPECT_EQ(1.234, getValue(global_param)); - EXPECT_EQ(5.678, getValue(general_param)); - EXPECT_EQ(3.456, getValue(local_param_1)); - EXPECT_EQ(4.567, getValue(local_param_2)); -} - -//---------------------------------------------------------------------------// -TEST(ScalarParameterObserver, residual) -{ - testScalarParameterObserver(); -} - -//---------------------------------------------------------------------------// -TEST(ScalarParameterObserver, jacobian) -{ - testScalarParameterObserver(); -} - -//---------------------------------------------------------------------------// - -} // namespace Test -} // namespace VertexCFD diff --git a/src/responses/VertexCFD_ResponseManager.cpp b/src/responses/VertexCFD_ResponseManager.cpp deleted file mode 100644 index 14669ca..0000000 --- a/src/responses/VertexCFD_ResponseManager.cpp +++ /dev/null @@ -1,285 +0,0 @@ -// Due to a conflict with FAD types and Kokkos views, this file needs to be -// included before other VertexCFD includes -#include "utils/VertexCFD_Utils_KokkosFadFixup.hpp" - -#include "VertexCFD_ResponseManager.hpp" - -#include -#include -#include -#include -#include - -#include -#include - -#include - -#include - -namespace VertexCFD -{ -namespace Response -{ -//---------------------------------------------------------------------------// -ResponseManager::ResponseManager(Teuchos::RCP physics_manager) - : _num_responses(0) - , _physics_manager(physics_manager) -{ - std::vector element_blocks; - _physics_manager->meshManager()->mesh()->getElementBlockNames( - element_blocks); - - _default_workset_descriptors.reserve(element_blocks.size()); - for (const auto& block : element_blocks) - _default_workset_descriptors.emplace_back(block); -} - -//---------------------------------------------------------------------------// -int ResponseManager::numResponses() const -{ - return _num_responses; -} - -//---------------------------------------------------------------------------// -void ResponseManager::addFunctionalResponse(const std::string& name, - const std::string& field_name) -{ - addFunctionalResponse(name, field_name, _default_workset_descriptors); -} - -//---------------------------------------------------------------------------// -void ResponseManager::addFunctionalResponse( - const std::string& name, - const std::string& field_name, - const std::vector& workset_descriptors) -{ - // Setup the response builder. - auto builder = Teuchos::rcp( - new panzer::FunctionalResponse_Builder); - builder->comm - = Teuchos::getRawMpiComm(*_physics_manager->meshManager()->comm()); - builder->cubatureDegree = _physics_manager->integrationOrder(); - builder->requiresCellIntegral = true; - builder->quadPointField = field_name; - builder->applyDirichletToDerivative = false; - - addResponseFromBuilder(name, workset_descriptors, builder); -} - -//---------------------------------------------------------------------------// -void ResponseManager::addMinValueResponse(const std::string& name, - const std::string& field_name) -{ - addMinValueResponse(name, field_name, _default_workset_descriptors); -} - -//---------------------------------------------------------------------------// -void ResponseManager::addMinValueResponse( - const std::string& name, - const std::string& field_name, - const std::vector& workset_descriptors) -{ - constexpr int use_max = false; - addExtremeValueResponse(use_max, name, field_name, workset_descriptors); -} - -//---------------------------------------------------------------------------// -void ResponseManager::addMaxValueResponse(const std::string& name, - const std::string& field_name) -{ - addMaxValueResponse(name, field_name, _default_workset_descriptors); -} - -//---------------------------------------------------------------------------// -void ResponseManager::addMaxValueResponse( - const std::string& name, - const std::string& field_name, - const std::vector& workset_descriptors) -{ - constexpr int use_max = true; - addExtremeValueResponse(use_max, name, field_name, workset_descriptors); -} - -//---------------------------------------------------------------------------// -void ResponseManager::addExtremeValueResponse( - const bool use_max, - const std::string& name, - const std::string& field_name, - const std::vector& workset_descriptors) -{ - // Setup the response builder. - auto builder = Teuchos::rcp( - new panzer::ExtremeValueResponse_Builder); - builder->comm - = Teuchos::getRawMpiComm(*_physics_manager->meshManager()->comm()); - builder->cubatureDegree = _physics_manager->integrationOrder(); - builder->requiresCellExtreme = true; - builder->useMax = use_max; - builder->quadPointField = field_name; - builder->applyDirichletToDerivative = false; - builder->prefix = use_max ? "Max " : "Min "; - - addResponseFromBuilder(name, workset_descriptors, builder); -} - -//---------------------------------------------------------------------------// -void ResponseManager::addProbeResponse(const std::string& name, - const std::string& field_name, - const Teuchos::Array& point) -{ - addProbeResponse(name, field_name, point, _default_workset_descriptors); -} - -//---------------------------------------------------------------------------// -void ResponseManager::addProbeResponse( - const std::string& name, - const std::string& field_name, - const Teuchos::Array& point, - const std::vector& workset_descriptors) -{ - // Setup the response builder. - auto builder = Teuchos::rcp( - new panzer::ProbeResponse_Builder); - builder->comm - = Teuchos::getRawMpiComm(*_physics_manager->meshManager()->comm()); - builder->cubatureDegree = _physics_manager->integrationOrder(); - builder->fieldName = field_name; - builder->fieldComponent = 0; - builder->point = point; - builder->applyDirichletToDerivative = false; - - addResponseFromBuilder(name, workset_descriptors, builder); -} - -//---------------------------------------------------------------------------// -template -void ResponseManager::addResponseFromBuilder( - const std::string& name, - const std::vector& workset_descriptors, - const Builder& builder) -{ - auto model_evaluator = _physics_manager->modelEvaluator(); - - // If no workset descriptors were provided, use the default - // (all element blocks). - const auto& workset_desc = workset_descriptors.empty() - ? _default_workset_descriptors - : workset_descriptors; - - const int response_index - = model_evaluator->addFlexibleResponse(name, workset_desc, builder); - - _resp_vectors.emplace_back( - Thyra::createMember(model_evaluator->get_g_space(response_index))); - - _index_map.emplace_back(response_index); - _name_map.emplace(name, _num_responses); - _is_active.emplace_back(true); - - // Add a scalar parameter to store the result of the response. Default - // value is zero. - panzer::registerScalarParameter( - name, *(_physics_manager->globalData()->pl), 0.0); - - ++_num_responses; -} - -//---------------------------------------------------------------------------// -void ResponseManager::activateResponse(const int index) -{ - _is_active.at(index) = true; -} - -//---------------------------------------------------------------------------// -void ResponseManager::activateResponse(const std::string& name) -{ - const int index = _name_map.at(name); - activateResponse(index); -} - -//---------------------------------------------------------------------------// -void ResponseManager::deactivateAll() -{ - std::fill(_is_active.begin(), _is_active.end(), false); -} - -//---------------------------------------------------------------------------// -void ResponseManager::evaluateResponses( - const Teuchos::RCP>& x, - const Teuchos::RCP>& x_dot) -{ - const int num_active - = std::count(_is_active.begin(), _is_active.end(), true); - - // Just return if there are no active responses. - if (num_active == 0) - return; - - auto model_evaluator = _physics_manager->modelEvaluator(); - - auto in_args = model_evaluator->createInArgs(); - auto out_args = model_evaluator->createOutArgs(); - - in_args.set_x(x); - in_args.set_x_dot(x_dot); - - // Set output vector for each active response. - for (int i = 0; i < _num_responses; ++i) - { - if (_is_active[i]) - { - out_args.set_g(_index_map[i], _resp_vectors[i]); - } - } - - // Evaluate the response. - model_evaluator->evalModel(in_args, out_args); - - // Extract the value and insert it into the parameter library. - for (int i = 0; i < _num_responses; ++i) - { - panzer::registerScalarParameter( - name(i), *(_physics_manager->globalData()->pl), value(i)); - } -} - -//---------------------------------------------------------------------------// -int ResponseManager::globalIndex(const int index) const -{ - return _index_map.at(index); -} - -//---------------------------------------------------------------------------// -int ResponseManager::globalIndex(const std::string& name) const -{ - const int index = _name_map.at(name); - return globalIndex(index); -} - -//---------------------------------------------------------------------------// -const std::string& ResponseManager::name(const int index) const -{ - return _physics_manager->modelEvaluator()->get_g_name(globalIndex(index)); -} - -//---------------------------------------------------------------------------// -double ResponseManager::value(const int index) const -{ - return Thyra::get_ele(*_resp_vectors.at(index), 0); -} - -//---------------------------------------------------------------------------// -double ResponseManager::value(const std::string& name) const -{ - const int index = _name_map.at(name); - return value(index); -} - -//---------------------------------------------------------------------------// - -} // namespace Response -} // namespace VertexCFD diff --git a/src/responses/VertexCFD_ResponseManager.hpp b/src/responses/VertexCFD_ResponseManager.hpp deleted file mode 100644 index 81ca66d..0000000 --- a/src/responses/VertexCFD_ResponseManager.hpp +++ /dev/null @@ -1,91 +0,0 @@ -#ifndef VERTEXCFD_RESPONSEMANAGER_HPP -#define VERTEXCFD_RESPONSEMANAGER_HPP - -#include "drivers/VertexCFD_PhysicsManager.hpp" - -#include - -#include - -#include -#include - -#include -#include -#include - -namespace VertexCFD -{ -namespace Response -{ -class ResponseManager -{ - public: - explicit ResponseManager(Teuchos::RCP physics_manager); - - void addFunctionalResponse( - const std::string& name, - const std::string& field_name, - const std::vector& workset_descriptors); - void addFunctionalResponse(const std::string& name, - const std::string& field_name); - void addMinValueResponse(const std::string& name, - const std::string& field_name); - void addMinValueResponse( - const std::string& name, - const std::string& field_name, - const std::vector& workset_descriptors); - void addMaxValueResponse( - const std::string& name, - const std::string& field_name, - const std::vector& workset_descriptors); - void addMaxValueResponse(const std::string& name, - const std::string& field_name); - void addProbeResponse( - const std::string& name, - const std::string& field_name, - const Teuchos::Array& point, - const std::vector& workset_descriptors); - void addProbeResponse(const std::string& name, - const std::string& field_name, - const Teuchos::Array& point); - void activateResponse(const int index = 0); - void activateResponse(const std::string& name); - void deactivateAll(); - void - evaluateResponses(const Teuchos::RCP>& x, - const Teuchos::RCP>& x_dot); - - int numResponses() const; - int globalIndex(const int index = 0) const; - int globalIndex(const std::string& name) const; - const std::string& name(const int index = 0) const; - double value(const int index = 0) const; - double value(const std::string& name) const; - - private: - int _num_responses; - Teuchos::RCP _physics_manager; - std::vector _default_workset_descriptors; - std::vector _index_map; - std::unordered_map _name_map; - std::vector>> _resp_vectors; - std::vector _is_active; - - void addExtremeValueResponse( - const bool use_max, - const std::string& name, - const std::string& field_name, - const std::vector& workset_descriptors); - - template - void addResponseFromBuilder( - const std::string& name, - const std::vector& workset_descriptors, - const Builder& builder); -}; - -} // namespace Response -} // namespace VertexCFD - -#endif // VERTEXCFD_RESPONSEMANAGER_HPP diff --git a/src/responses/VertexCFD_Response_Utils.cpp b/src/responses/VertexCFD_Response_Utils.cpp deleted file mode 100644 index 897846e..0000000 --- a/src/responses/VertexCFD_Response_Utils.cpp +++ /dev/null @@ -1,52 +0,0 @@ -#include "VertexCFD_Response_Utils.hpp" - -#include - -namespace VertexCFD -{ -namespace Response -{ - -//---------------------------------------------------------------------------// -std::vector -buildWorksetDescriptors(const Teuchos::ParameterList& plist) -{ - std::vector workset_descriptors; - - // Let user set specific element blocks for volume integrals. - if (plist.isType("Element Blocks")) - { - std::vector element_blocks; - panzer::StringTokenizer( - element_blocks, plist.get("Element Blocks"), ",", true); - - workset_descriptors.reserve(element_blocks.size()); - for (const auto& block : element_blocks) - workset_descriptors.emplace_back(block); - } - // Let user set specific sidesets for surface integrals. - else if (plist.isSublist("Sidesets")) - { - const auto& sideset_plist = plist.sublist("Sidesets"); - std::vector sidesets; - - for (auto sideset_itr = sideset_plist.begin(); - sideset_itr != sideset_plist.end(); - ++sideset_itr) - { - const auto& block = sideset_itr->first; - - sidesets.clear(); - panzer::StringTokenizer( - sidesets, sideset_plist.get(block), ",", true); - - for (const auto& side : sidesets) - workset_descriptors.emplace_back(block, side); - } - } - - return workset_descriptors; -} - -} // namespace Response -} // namespace VertexCFD diff --git a/src/responses/VertexCFD_Response_Utils.hpp b/src/responses/VertexCFD_Response_Utils.hpp deleted file mode 100644 index 0136b47..0000000 --- a/src/responses/VertexCFD_Response_Utils.hpp +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef VERTEXCFD_RESPONSE_UTILS_HPP -#define VERTEXCFD_RESPONSE_UTILS_HPP - -// Need to make TEUCHOS_TEST_FOR_EXCEPTION available to Panzer. -#include - -// This uses TEUCHOS_TEST_FOR_EXCEPTION, but doesn't inlude the required -// header. -#include - -#include - -#include - -namespace VertexCFD -{ -namespace Response -{ - -std::vector -buildWorksetDescriptors(const Teuchos::ParameterList& sideset_plist); - -} // namespace Response -} // namespace VertexCFD - -#endif // VERTEXCFD_RESPONSE_UTILS_HPP diff --git a/src/responses/unit_test/CMakeLists.txt b/src/responses/unit_test/CMakeLists.txt deleted file mode 100644 index 84c6b9e..0000000 --- a/src/responses/unit_test/CMakeLists.txt +++ /dev/null @@ -1,18 +0,0 @@ -configure_file( VertexCFD_ResponseUnitTestConfig.hpp.cmakein VertexCFD_ResponseUnitTestConfig.hpp ) - -set(TEST_HARNESS_DIR ${CMAKE_SOURCE_DIR}/src/test_harness) -include(${TEST_HARNESS_DIR}/TestHarness.cmake) - -VertexCFD_add_tests( - LIBS VertexCFD - NAMES - ResponseManager - ResponseUtils - ) - -# The ResponseManager test relies on Panzer capability that uses CUDA UVM. -# This must be launched with CUDA_LAUNCH_BLOCKING to work correctly. -if(${VERTEXCFD_KOKKOS_DEVICE_TYPE} STREQUAL "CUDA") - message("Setting ResponseManager launch env") - set_property(TEST VertexCFD_ResponseManager_test_CUDA PROPERTY ENVIRONMENT "CUDA_LAUNCH_BLOCKING=1") -endif() diff --git a/src/responses/unit_test/VertexCFD_ResponseUnitTestConfig.hpp.cmakein b/src/responses/unit_test/VertexCFD_ResponseUnitTestConfig.hpp.cmakein deleted file mode 100644 index e924f9a..0000000 --- a/src/responses/unit_test/VertexCFD_ResponseUnitTestConfig.hpp.cmakein +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef VERTEXCFD_RESPONSEUNITTESTCONFIG_HPP -#define VERTEXCFD_RESPONSEUNITTESTCONFIG_HPP - -constexpr char VERTEXCFD_RESPONSE_TEST_DATA_DIR[] = R"(@CMAKE_SOURCE_DIR@/src/responses/unit_test/data/)"; -constexpr char VERTEXCFD_RESPONSE_TEST_INPUT_DIR[] = R"(@CMAKE_SOURCE_DIR@/examples/inputs/)"; -constexpr char VERTEXCFD_RESPONSE_TEST_MESH_DIR[] = R"(@CMAKE_SOURCE_DIR@/examples/mesh/)"; - -#endif // end VERTEXCFD_RESPONSEUNITTESTCONFIG_HPP diff --git a/src/responses/unit_test/data/response_manager_test.xml b/src/responses/unit_test/data/response_manager_test.xml deleted file mode 100644 index 55e9e68..0000000 --- a/src/responses/unit_test/data/response_manager_test.xml +++ /dev/null @@ -1,86 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/responses/unit_test/tstResponseUtils.cpp b/src/responses/unit_test/tstResponseUtils.cpp deleted file mode 100644 index 613ee04..0000000 --- a/src/responses/unit_test/tstResponseUtils.cpp +++ /dev/null @@ -1,59 +0,0 @@ -#include "responses/VertexCFD_Response_Utils.hpp" - -#include - -#include - -//---------------------------------------------------------------------------// -// TESTS -//---------------------------------------------------------------------------// -namespace VertexCFD -{ -namespace Test -{ - -//---------------------------------------------------------------------------// -TEST(BuildWorksetDescriptors, FromElementBlocks) -{ - const auto params = Teuchos::ParameterList("Volume Response") - .set("Element Blocks", "block1,block2"); - auto workset_descriptors = Response::buildWorksetDescriptors(params); - - ASSERT_EQ(2, workset_descriptors.size()); - - EXPECT_EQ("block1", workset_descriptors[0].getElementBlock()); - EXPECT_FALSE(workset_descriptors[0].useSideset()); - - EXPECT_EQ("block2", workset_descriptors[1].getElementBlock()); - EXPECT_FALSE(workset_descriptors[1].useSideset()); -} - -//---------------------------------------------------------------------------// -TEST(BuildWorksetDescriptors, FromSidesets) -{ - const auto params = Teuchos::ParameterList("Surface Response") - .set("Sidesets", - Teuchos::ParameterList() - .set("block1", "side1,side2") - .set("block2", "side2")); - auto workset_descriptors = Response::buildWorksetDescriptors(params); - - ASSERT_EQ(3, workset_descriptors.size()); - - EXPECT_EQ("block1", workset_descriptors[0].getElementBlock()); - EXPECT_TRUE(workset_descriptors[0].useSideset()); - EXPECT_EQ("side1", workset_descriptors[0].getSideset()); - - EXPECT_EQ("block1", workset_descriptors[1].getElementBlock()); - EXPECT_TRUE(workset_descriptors[1].useSideset()); - EXPECT_EQ("side2", workset_descriptors[1].getSideset()); - - EXPECT_EQ("block2", workset_descriptors[2].getElementBlock()); - EXPECT_TRUE(workset_descriptors[2].useSideset()); - EXPECT_EQ("side2", workset_descriptors[2].getSideset()); -} - -//---------------------------------------------------------------------------// - -} // namespace Test -} // namespace VertexCFD diff --git a/src/test_harness/CMakeLists.txt b/src/test_harness/CMakeLists.txt deleted file mode 100644 index 3263f4b..0000000 --- a/src/test_harness/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -set(gtest_args --gtest_color=yes PARENT_SCOPE) -add_subdirectory(unit_test) diff --git a/src/test_harness/VertexCFD_EvaluatorTestHarness.hpp b/src/test_harness/VertexCFD_EvaluatorTestHarness.hpp deleted file mode 100644 index 08ca391..0000000 --- a/src/test_harness/VertexCFD_EvaluatorTestHarness.hpp +++ /dev/null @@ -1,367 +0,0 @@ -#ifndef VERTEXCFD_EVALUATORTESTHARNESS_HPP -#define VERTEXCFD_EVALUATORTESTHARNESS_HPP - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include - -#include - -#include - -#include -#include -#include -#include - -namespace VertexCFD -{ -namespace Test -{ -//---------------------------------------------------------------------------// -// Evaluator cell test fixture. -struct EvaluatorTestFixture -{ - Teuchos::RCP> fm; - Teuchos::RCP cell_topo; - Teuchos::RCP workset; - Teuchos::RCP cell_data; - Teuchos::RCP ir; - Teuchos::RCP> int_values; - Teuchos::RCP basis_ir_layout; - Teuchos::RCP> basis_values; - - using host_coords_view = Kokkos::View::type, - PHX::Device>::HostMirror; - - // Create an evaluator test fixture object. If a side id is not specified - // then integration rules will be setup over the volume of the cell - // instead of the side. - EvaluatorTestFixture(const CellTopologyData* cell_topo_data, - const host_coords_view host_coords, - const int integration_order, - const int basis_order, - const int side_id = -1) - { - initialize(cell_topo_data, - host_coords, - integration_order, - basis_order, - side_id); - } - - // Use a default cell topology. - EvaluatorTestFixture(const int num_space_dim, - const int integration_order, - const int basis_order, - const int side_id = -1) - { - // Single cell. - const int num_cell = 1; - - const CellTopologyData* cell_topo_data = nullptr; - host_coords_view host_coords; - - // Build a line, quad, or hex as the test cell. - if (1 == num_space_dim) - { - cell_topo_data = shards::getCellTopologyData>(); - - host_coords = host_coords_view("coords", num_cell, 2, 1); - - host_coords(0, 0, 0) = 0.0; - host_coords(0, 1, 0) = 1.0; - } - else if (2 == num_space_dim) - { - cell_topo_data - = shards::getCellTopologyData>(); - - host_coords = host_coords_view("coords", num_cell, 4, 2); - - host_coords(0, 0, 0) = 0.0; - host_coords(0, 0, 1) = 0.0; - - host_coords(0, 1, 0) = 1.0; - host_coords(0, 1, 1) = 0.0; - - host_coords(0, 2, 0) = 1.0; - host_coords(0, 2, 1) = 1.0; - - host_coords(0, 3, 0) = 0.0; - host_coords(0, 3, 1) = 1.0; - } - else if (3 == num_space_dim) - { - cell_topo_data - = shards::getCellTopologyData>(); - - host_coords = host_coords_view("coords", num_cell, 8, 3); - - host_coords(0, 0, 0) = 0.0; - host_coords(0, 0, 1) = 0.0; - host_coords(0, 0, 2) = 0.0; - - host_coords(0, 1, 0) = 1.0; - host_coords(0, 1, 1) = 0.0; - host_coords(0, 1, 2) = 0.0; - - host_coords(0, 2, 0) = 1.0; - host_coords(0, 2, 1) = 1.0; - host_coords(0, 2, 2) = 0.0; - - host_coords(0, 3, 0) = 0.0; - host_coords(0, 3, 1) = 1.0; - host_coords(0, 3, 2) = 0.0; - - host_coords(0, 4, 0) = 0.0; - host_coords(0, 4, 1) = 0.0; - host_coords(0, 4, 2) = 1.0; - - host_coords(0, 5, 0) = 1.0; - host_coords(0, 5, 1) = 0.0; - host_coords(0, 5, 2) = 1.0; - - host_coords(0, 6, 0) = 1.0; - host_coords(0, 6, 1) = 1.0; - host_coords(0, 6, 2) = 1.0; - - host_coords(0, 7, 0) = 0.0; - host_coords(0, 7, 1) = 1.0; - host_coords(0, 7, 2) = 1.0; - } - else - { - std::ostringstream msg; - msg << "Invalid spatial dimensions (" << num_space_dim - << "): must be 1, 2, or 3."; - throw std::logic_error(msg.str()); - } - - initialize(cell_topo_data, - host_coords, - integration_order, - basis_order, - side_id); - } - - // Add an evaluator to the manager. - template - void - registerEvaluator(const Teuchos::RCP>& eval) - { - fm->registerEvaluator(eval); - } - - // Register fields that will be checked in the test. - template - void registerTestField(const Field& field) - { - fm->requireField(field.fieldTag()); - } - - // Set time. - void setTime(const double& time) { workset->time = time; } - - // Set time step size. - void setStepSize(const double& step_size) - { - workset->step_size = step_size; - } - - // Evaluate. - template - void evaluate() - { - panzer::Traits::SD setup_data; - auto worksets = Teuchos::rcp(new std::vector); - worksets->push_back(*workset); - setup_data.worksets_ = worksets; - std::vector derivative_dimensions; - derivative_dimensions.push_back(4); - fm->setKokkosExtendedDataTypeDimensions( - derivative_dimensions); - fm->postRegistrationSetup(setup_data); - panzer::Traits::PED ped; - fm->preEvaluate(ped); - fm->evaluateFields(*workset); - fm->postEvaluate(0); - } - - // Get a test field on the host to test after evaluation. - template - auto getTestFieldData(const Field& field) const - { - auto field_view = field.get_static_view(); - auto field_mirror = Kokkos::create_mirror(field_view); - Kokkos::deep_copy(field_mirror, field_view); - return field_mirror; - } - - // Get the number of quadrature points. - int numPoint() const { return ir->num_points; } - - // Get the number of basis points. - int cardinality() const { return basis_ir_layout->cardinality(); } - - private: - void initialize(const CellTopologyData* cell_topo_data, - const host_coords_view host_coords, - const int integration_order, - const int basis_order, - const int side_id) - { - cell_topo = Teuchos::rcp(new shards::CellTopology(cell_topo_data)); - - const int num_space_dim = cell_topo->getDimension(); - - if (num_space_dim != host_coords.extent_int(2)) - { - std::ostringstream msg; - msg << "Unexpected spatial dimensions in provided coordinates: " - << cell_topo->getName() << " expects " << num_space_dim - << " dimensions, but " << host_coords.extent(2) - << " were provided."; - throw std::logic_error(msg.str()); - } - - const int nodes_per_cell = cell_topo->getNodeCount(); - - if (nodes_per_cell != host_coords.extent_int(1)) - { - std::ostringstream msg; - msg << "Unexpected node count in provided coordinates: " - << cell_topo->getName() << " expects " << nodes_per_cell - << " nodes, but " << host_coords.extent(1) - << " were provided."; - throw std::logic_error(msg.str()); - } - - const int num_cell = host_coords.extent(0); - - // Create field manager. - fm = Teuchos::rcp(new PHX::FieldManager); - - // Create the workset. - workset = Teuchos::rcp(new panzer::Workset); - workset->num_cells = num_cell; - - // Fill cell local IDs - { - Kokkos::View cell_local_ids_k( - "cell_local_ids_k", num_cell); - auto cell_local_ids_k_host - = Kokkos::create_mirror_view(cell_local_ids_k); - - workset->cell_local_ids.resize(num_cell); - - for (int i = 0; i < num_cell; ++i) - { - cell_local_ids_k_host(i) = i; - workset->cell_local_ids[i] = i; - } - - Kokkos::deep_copy(cell_local_ids_k, cell_local_ids_k_host); - workset->cell_local_ids_k = cell_local_ids_k; - } - - workset->block_id = "block_0"; - workset->ir_degrees = Teuchos::rcp(new std::vector); - workset->basis_names = Teuchos::rcp(new std::vector); - workset->time = 0.0; - workset->step_size = 0.0; - - panzer::MDFieldArrayFactory array_factory("", true); -#if TRILINOS_MAJOR_MINOR_VERSION >= 140500 - auto& node_coords = workset->cell_node_coordinates; -#else - auto& node_coords = workset->cell_vertex_coordinates; -#endif - - node_coords - = array_factory - .buildStaticArray( - "coords", num_cell, nodes_per_cell, num_space_dim); - - Kokkos::deep_copy(node_coords.get_static_view(), host_coords); - - // Setup a cell. - cell_data - = Teuchos::rcp(new panzer::CellData(num_cell, side_id, cell_topo)); - - // Create integration rule and populate integration values. - ir = Teuchos::rcp( - new panzer::IntegrationRule(integration_order, *cell_data)); - int_values - = Teuchos::rcp(new panzer::IntegrationValues2("", true)); - int_values->setupArrays(ir); - int_values->evaluateValues(node_coords); - workset->ir_degrees->push_back(ir->cubature_degree); - workset->int_rules.push_back(int_values); - - // Create basis and populate basis values. - basis_ir_layout = panzer::basisIRLayout("HGrad", basis_order, *ir); - basis_values - = Teuchos::rcp(new panzer::BasisValues2("", true, true)); - basis_values->setupArrays(basis_ir_layout); - basis_values->evaluateValues(int_values->cub_points, - int_values->jac, - int_values->jac_det, - int_values->jac_inv, - int_values->weighted_measure, - int_values->node_coordinates); - workset->bases.push_back(basis_values); - workset->basis_names->push_back(basis_ir_layout->getBasis()->name()); - } -}; - -//---------------------------------------------------------------------------// -// For a residual evaluation, the field value is a double and returned as-is. -double accessValue(double v) -{ - return v; -} - -//---------------------------------------------------------------------------// -// For a Jacobian evaluation, the field value is Sacado FAD type, so return its -// value. -template -double accessValue(Value&& v) -{ - return accessValue(v.val()); -} - -//---------------------------------------------------------------------------// -// Access a field value at the given indices. -template -double fieldValue(Field f, const Indices... i) -{ - return accessValue(f(i...)); -} - -//---------------------------------------------------------------------------// - -} // end namespace Test -} // end namespace VertexCFD - -#endif // end VERTEXCFD_EVALUATORTESTHARNESS_HPP diff --git a/src/test_harness/test_main.cpp b/src/test_harness/test_main.cpp deleted file mode 100644 index a633a63..0000000 --- a/src/test_harness/test_main.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include - -#include - -#include - -int main(int argc, char* argv[]) -{ - MPI_Init(&argc, &argv); - Kokkos::initialize(argc, argv); - ::testing::InitGoogleTest(&argc, argv); - int return_val = RUN_ALL_TESTS(); - Kokkos::finalize(); - MPI_Finalize(); - return return_val; -} diff --git a/src/test_harness/unit_test/CMakeLists.txt b/src/test_harness/unit_test/CMakeLists.txt deleted file mode 100644 index 30ec326..0000000 --- a/src/test_harness/unit_test/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -set(TEST_HARNESS_DIR ${CMAKE_SOURCE_DIR}/src/test_harness) -include(${TEST_HARNESS_DIR}/TestHarness.cmake) - -include_directories(${Trilinos_INCLUDE_DIRS} ${Trilinos_TPL_INCLUDE_DIRS}) -link_directories(${Trilinos_LIBRARY_DIRS} ${Trilinos_TPL_LIBRARY_DIRS}) - -VertexCFD_add_tests( - MPI - LIBS ${Trilinos_LIBRARIES} ${Trilinos_TPL_LIBRARIES} - NAMES KokkosMPI EvaluatorTestHarness ) \ No newline at end of file diff --git a/src/test_harness/unit_test/tstEvaluatorTestHarness.cpp b/src/test_harness/unit_test/tstEvaluatorTestHarness.cpp deleted file mode 100644 index 1639b7b..0000000 --- a/src/test_harness/unit_test/tstEvaluatorTestHarness.cpp +++ /dev/null @@ -1,495 +0,0 @@ -#include - -#include -#include -#include -#include -#include - -#include -#include - -#include - -#include - -#include -#include - -//---------------------------------------------------------------------------// -// TESTS -//---------------------------------------------------------------------------// -namespace VertexCFD -{ -namespace Test -{ -//---------------------------------------------------------------------------// -// Workset Data -template -struct TestData : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - PHX::MDField _node_coords; - PHX::MDField _ip_coords; - PHX::MDField _basis; - PHX::MDField - _grad_basis; - - TestData(const panzer::IntegrationRule& ir, - const panzer::BasisIRLayout& layout) - : _node_coords("node_coords", layout.functional_grad) - , _ip_coords("ip_coords", ir.dl_vector) - , _basis("basis", layout.basis) - , _grad_basis("grad_basis", layout.basis_grad) - { - this->addEvaluatedField(_node_coords); - this->addEvaluatedField(_ip_coords); - this->addEvaluatedField(_basis); - this->addEvaluatedField(_grad_basis); - this->setName("TestData"); - } - - void evaluateFields(typename panzer::Traits::EvalData workset) override - { - _node_coords.deep_copy(workset.int_rules[0]->node_coordinates); - _ip_coords.deep_copy(workset.int_rules[0]->ip_coordinates); - _basis.deep_copy(this->wda(workset).bases[0]->basis_scalar); - _grad_basis.deep_copy(this->wda(workset).bases[0]->grad_basis); - } -}; - -//---------------------------------------------------------------------------// -template -void test2D_default_cell() -{ - // Setup test fixture. - const int num_space_dim = 2; - const int integration_order = 1; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - - EXPECT_STREQ("Quadrilateral_4", test_fixture.cell_topo->getName()); - - // Create data. - auto test_eval = Teuchos::rcp(new TestData( - *test_fixture.ir, *test_fixture.basis_ir_layout)); - test_fixture.registerEvaluator(test_eval); - - // Set the time. - EXPECT_EQ(0.0, test_fixture.workset->time); - const double time = 1.3; - test_fixture.setTime(time); - EXPECT_EQ(time, test_fixture.workset->time); - - // Add required test fields. Check that some integration values were made - // as well as some basis values. - test_fixture.registerTestField(test_eval->_node_coords); - test_fixture.registerTestField(test_eval->_ip_coords); - test_fixture.registerTestField(test_eval->_basis); - test_fixture.registerTestField(test_eval->_grad_basis); - - // Evaluate fields. - test_fixture.evaluate(); - - // Get fields. - auto node_coords_result - = test_fixture.getTestFieldData(test_eval->_node_coords); - auto ip_coords_result - = test_fixture.getTestFieldData(test_eval->_ip_coords); - auto basis_result - = test_fixture.getTestFieldData(test_eval->_basis); - auto grad_basis_result - = test_fixture.getTestFieldData(test_eval->_grad_basis); - - // Check fields. - EXPECT_EQ(1, node_coords_result.extent(0)); - EXPECT_EQ(4, node_coords_result.extent(1)); - EXPECT_EQ(2, node_coords_result.extent(2)); - EXPECT_EQ(0.0, node_coords_result(0, 0, 0)); - EXPECT_EQ(0.0, node_coords_result(0, 0, 1)); - EXPECT_EQ(1.0, node_coords_result(0, 1, 0)); - EXPECT_EQ(0.0, node_coords_result(0, 1, 1)); - EXPECT_EQ(1.0, node_coords_result(0, 2, 0)); - EXPECT_EQ(1.0, node_coords_result(0, 2, 1)); - EXPECT_EQ(0.0, node_coords_result(0, 3, 0)); - EXPECT_EQ(1.0, node_coords_result(0, 3, 1)); - - EXPECT_EQ(1, test_fixture.numPoint()); - EXPECT_EQ(1, ip_coords_result.extent(0)); - EXPECT_EQ(1, ip_coords_result.extent(1)); - EXPECT_EQ(2, ip_coords_result.extent(2)); - EXPECT_EQ(0.5, ip_coords_result(0, 0, 0)); - EXPECT_EQ(0.5, ip_coords_result(0, 0, 1)); - - EXPECT_EQ(4, test_fixture.cardinality()); - EXPECT_EQ(1, basis_result.extent(0)); - EXPECT_EQ(4, basis_result.extent(1)); - EXPECT_EQ(1, basis_result.extent(2)); - EXPECT_EQ(0.25, basis_result(0, 0, 0)); - EXPECT_EQ(0.25, basis_result(0, 1, 0)); - EXPECT_EQ(0.25, basis_result(0, 2, 0)); - EXPECT_EQ(0.25, basis_result(0, 3, 0)); - - EXPECT_EQ(1, grad_basis_result.extent(0)); - EXPECT_EQ(4, grad_basis_result.extent(1)); - EXPECT_EQ(1, grad_basis_result.extent(2)); - EXPECT_EQ(2, grad_basis_result.extent(3)); - EXPECT_EQ(-0.5, grad_basis_result(0, 0, 0, 0)); - EXPECT_EQ(-0.5, grad_basis_result(0, 0, 0, 1)); - EXPECT_EQ(0.5, grad_basis_result(0, 1, 0, 0)); - EXPECT_EQ(-0.5, grad_basis_result(0, 1, 0, 1)); - EXPECT_EQ(0.5, grad_basis_result(0, 2, 0, 0)); - EXPECT_EQ(0.5, grad_basis_result(0, 2, 0, 1)); - EXPECT_EQ(-0.5, grad_basis_result(0, 3, 0, 0)); - EXPECT_EQ(0.5, grad_basis_result(0, 3, 0, 1)); -} - -//---------------------------------------------------------------------------// -template -void test3D_default_cell() -{ - // Setup test fixture. - const int num_space_dim = 3; - const int integration_order = 1; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - - EXPECT_STREQ("Hexahedron_8", test_fixture.cell_topo->getName()); - - // Create data. - auto test_eval = Teuchos::rcp(new TestData( - *test_fixture.ir, *test_fixture.basis_ir_layout)); - test_fixture.registerEvaluator(test_eval); - - // Set the time. - EXPECT_EQ(0.0, test_fixture.workset->time); - const double time = 1.3; - test_fixture.setTime(time); - EXPECT_EQ(time, test_fixture.workset->time); - - // Add required test fields. Check that some integration values were made - // as well as some basis values. - test_fixture.registerTestField(test_eval->_node_coords); - test_fixture.registerTestField(test_eval->_ip_coords); - test_fixture.registerTestField(test_eval->_basis); - test_fixture.registerTestField(test_eval->_grad_basis); - - // Evaluate fields. - test_fixture.evaluate(); - - // Get fields. - auto node_coords_result - = test_fixture.getTestFieldData(test_eval->_node_coords); - auto ip_coords_result - = test_fixture.getTestFieldData(test_eval->_ip_coords); - auto basis_result - = test_fixture.getTestFieldData(test_eval->_basis); - auto grad_basis_result - = test_fixture.getTestFieldData(test_eval->_grad_basis); - - // Check fields. - EXPECT_EQ(1, node_coords_result.extent(0)); - EXPECT_EQ(8, node_coords_result.extent(1)); - EXPECT_EQ(3, node_coords_result.extent(2)); - EXPECT_EQ(0.0, node_coords_result(0, 0, 0)); - EXPECT_EQ(0.0, node_coords_result(0, 0, 1)); - EXPECT_EQ(0.0, node_coords_result(0, 0, 2)); - EXPECT_EQ(1.0, node_coords_result(0, 1, 0)); - EXPECT_EQ(0.0, node_coords_result(0, 1, 1)); - EXPECT_EQ(0.0, node_coords_result(0, 1, 2)); - EXPECT_EQ(1.0, node_coords_result(0, 2, 0)); - EXPECT_EQ(1.0, node_coords_result(0, 2, 1)); - EXPECT_EQ(0.0, node_coords_result(0, 2, 2)); - EXPECT_EQ(0.0, node_coords_result(0, 3, 0)); - EXPECT_EQ(1.0, node_coords_result(0, 3, 1)); - EXPECT_EQ(0.0, node_coords_result(0, 3, 2)); - EXPECT_EQ(0.0, node_coords_result(0, 4, 0)); - EXPECT_EQ(0.0, node_coords_result(0, 4, 1)); - EXPECT_EQ(1.0, node_coords_result(0, 4, 2)); - EXPECT_EQ(1.0, node_coords_result(0, 5, 0)); - EXPECT_EQ(0.0, node_coords_result(0, 5, 1)); - EXPECT_EQ(1.0, node_coords_result(0, 5, 2)); - EXPECT_EQ(1.0, node_coords_result(0, 6, 0)); - EXPECT_EQ(1.0, node_coords_result(0, 6, 1)); - EXPECT_EQ(1.0, node_coords_result(0, 6, 2)); - EXPECT_EQ(0.0, node_coords_result(0, 7, 0)); - EXPECT_EQ(1.0, node_coords_result(0, 7, 1)); - EXPECT_EQ(1.0, node_coords_result(0, 7, 2)); - - EXPECT_EQ(1, test_fixture.numPoint()); - EXPECT_EQ(1, ip_coords_result.extent(0)); - EXPECT_EQ(1, ip_coords_result.extent(1)); - EXPECT_EQ(3, ip_coords_result.extent(2)); - EXPECT_EQ(0.5, ip_coords_result(0, 0, 0)); - EXPECT_EQ(0.5, ip_coords_result(0, 0, 1)); - EXPECT_EQ(0.5, ip_coords_result(0, 0, 2)); - - EXPECT_EQ(8, test_fixture.cardinality()); - EXPECT_EQ(1, basis_result.extent(0)); - EXPECT_EQ(8, basis_result.extent(1)); - EXPECT_EQ(1, basis_result.extent(2)); - EXPECT_EQ(0.125, basis_result(0, 0, 0)); - EXPECT_EQ(0.125, basis_result(0, 1, 0)); - EXPECT_EQ(0.125, basis_result(0, 2, 0)); - EXPECT_EQ(0.125, basis_result(0, 3, 0)); - EXPECT_EQ(0.125, basis_result(0, 4, 0)); - EXPECT_EQ(0.125, basis_result(0, 5, 0)); - EXPECT_EQ(0.125, basis_result(0, 6, 0)); - EXPECT_EQ(0.125, basis_result(0, 7, 0)); - - EXPECT_EQ(1, grad_basis_result.extent(0)); - EXPECT_EQ(8, grad_basis_result.extent(1)); - EXPECT_EQ(1, grad_basis_result.extent(2)); - EXPECT_EQ(3, grad_basis_result.extent(3)); - EXPECT_EQ(-0.25, grad_basis_result(0, 0, 0, 0)); - EXPECT_EQ(-0.25, grad_basis_result(0, 0, 0, 1)); - EXPECT_EQ(-0.25, grad_basis_result(0, 0, 0, 2)); - EXPECT_EQ(0.25, grad_basis_result(0, 1, 0, 0)); - EXPECT_EQ(-0.25, grad_basis_result(0, 1, 0, 1)); - EXPECT_EQ(-0.25, grad_basis_result(0, 1, 0, 2)); - EXPECT_EQ(0.25, grad_basis_result(0, 2, 0, 0)); - EXPECT_EQ(0.25, grad_basis_result(0, 2, 0, 1)); - EXPECT_EQ(-0.25, grad_basis_result(0, 2, 0, 2)); - EXPECT_EQ(-0.25, grad_basis_result(0, 3, 0, 0)); - EXPECT_EQ(0.25, grad_basis_result(0, 3, 0, 1)); - EXPECT_EQ(-0.25, grad_basis_result(0, 3, 0, 2)); - EXPECT_EQ(-0.25, grad_basis_result(0, 4, 0, 0)); - EXPECT_EQ(-0.25, grad_basis_result(0, 4, 0, 1)); - EXPECT_EQ(0.25, grad_basis_result(0, 4, 0, 2)); - EXPECT_EQ(0.25, grad_basis_result(0, 5, 0, 0)); - EXPECT_EQ(-0.25, grad_basis_result(0, 5, 0, 1)); - EXPECT_EQ(0.25, grad_basis_result(0, 5, 0, 2)); - EXPECT_EQ(0.25, grad_basis_result(0, 6, 0, 0)); - EXPECT_EQ(0.25, grad_basis_result(0, 6, 0, 1)); - EXPECT_EQ(0.25, grad_basis_result(0, 6, 0, 2)); - EXPECT_EQ(-0.25, grad_basis_result(0, 7, 0, 0)); - EXPECT_EQ(0.25, grad_basis_result(0, 7, 0, 1)); - EXPECT_EQ(0.25, grad_basis_result(0, 7, 0, 2)); -} - -//---------------------------------------------------------------------------// -template -void test_custom_cell() -{ - // Setup test fixture. - const int num_cell = 1; - const int nodes_per_cell = 3; - const int num_space_dim = 2; - - EvaluatorTestFixture::host_coords_view coords( - "coords", num_cell, nodes_per_cell, num_space_dim); - coords(0, 0, 0) = 0.0; - coords(0, 0, 1) = 0.0; - - coords(0, 1, 0) = 1.0; - coords(0, 1, 1) = 0.0; - - coords(0, 2, 0) = 0.0; - coords(0, 2, 1) = 1.0; - - const int integration_order = 1; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - shards::getCellTopologyData>(), - coords, - integration_order, - basis_order); - - EXPECT_STREQ("Triangle_3", test_fixture.cell_topo->getName()); - - // Create data. - auto test_eval = Teuchos::rcp(new TestData( - *test_fixture.ir, *test_fixture.basis_ir_layout)); - test_fixture.registerEvaluator(test_eval); - - // Set the time. - EXPECT_EQ(0.0, test_fixture.workset->time); - const double time = 1.3; - test_fixture.setTime(time); - EXPECT_EQ(time, test_fixture.workset->time); - - // Add required test fields. Check that some integration values were made - // as well as some basis values. - test_fixture.registerTestField(test_eval->_node_coords); - test_fixture.registerTestField(test_eval->_ip_coords); - test_fixture.registerTestField(test_eval->_basis); - test_fixture.registerTestField(test_eval->_grad_basis); - - // Evaluate fields. - test_fixture.evaluate(); - - // Get fields. - auto node_coords_result - = test_fixture.getTestFieldData(test_eval->_node_coords); - auto ip_coords_result - = test_fixture.getTestFieldData(test_eval->_ip_coords); - auto basis_result - = test_fixture.getTestFieldData(test_eval->_basis); - auto grad_basis_result - = test_fixture.getTestFieldData(test_eval->_grad_basis); - - // Check fields. - EXPECT_EQ(num_cell, node_coords_result.extent(0)); - EXPECT_EQ(nodes_per_cell, node_coords_result.extent(1)); - EXPECT_EQ(num_space_dim, node_coords_result.extent(2)); - for (int cell = 0; cell < num_cell; ++cell) - { - for (int node = 0; node < nodes_per_cell; ++node) - { - for (int dim = 0; dim < num_space_dim; ++dim) - { - EXPECT_EQ(coords(cell, node, dim), - node_coords_result(cell, node, dim)); - } - } - } - - EXPECT_EQ(1, test_fixture.numPoint()); - - EXPECT_EQ(1, ip_coords_result.extent(0)); - EXPECT_EQ(1, ip_coords_result.extent(1)); - EXPECT_EQ(2, ip_coords_result.extent(2)); - EXPECT_DOUBLE_EQ(1.0 / 3.0, ip_coords_result(0, 0, 0)); - EXPECT_DOUBLE_EQ(1.0 / 3.0, ip_coords_result(0, 0, 1)); - - EXPECT_EQ(3, test_fixture.cardinality()); - EXPECT_EQ(1, basis_result.extent(0)); - EXPECT_EQ(3, basis_result.extent(1)); - EXPECT_EQ(1, basis_result.extent(2)); - EXPECT_DOUBLE_EQ(1.0 / 3.0, basis_result(0, 0, 0)); - EXPECT_DOUBLE_EQ(1.0 / 3.0, basis_result(0, 1, 0)); - EXPECT_DOUBLE_EQ(1.0 / 3.0, basis_result(0, 2, 0)); - - EXPECT_EQ(1, grad_basis_result.extent(0)); - EXPECT_EQ(3, grad_basis_result.extent(1)); - EXPECT_EQ(1, grad_basis_result.extent(2)); - EXPECT_EQ(2, grad_basis_result.extent(3)); - EXPECT_EQ(-1.0, grad_basis_result(0, 0, 0, 0)); - EXPECT_EQ(-1.0, grad_basis_result(0, 0, 0, 1)); - EXPECT_EQ(1.0, grad_basis_result(0, 1, 0, 0)); - EXPECT_EQ(0.0, grad_basis_result(0, 1, 0, 1)); - EXPECT_EQ(0.0, grad_basis_result(0, 2, 0, 0)); - EXPECT_EQ(1.0, grad_basis_result(0, 2, 0, 1)); -} - -//---------------------------------------------------------------------------// -TEST(EvaluatorTestHarness, residual_test_2d_default_cell) -{ - test2D_default_cell(); -} - -//---------------------------------------------------------------------------// -TEST(EvaluatorTestHarness, jacobian_test_2d_default_cell) -{ - test2D_default_cell(); -} - -//---------------------------------------------------------------------------// -TEST(EvaluatorTestHarness, residual_test_3d_default_cell) -{ - test3D_default_cell(); -} - -//---------------------------------------------------------------------------// -TEST(EvaluatorTestHarness, jacobian_test_3d_default_cell) -{ - test3D_default_cell(); -} - -//---------------------------------------------------------------------------// -TEST(EvaluatorTestHarness, residual_test_custom_cell) -{ - test_custom_cell(); -} - -//---------------------------------------------------------------------------// -TEST(EvaluatorTestHarness, jacobian_test_custom_cell) -{ - test_custom_cell(); -} - -//---------------------------------------------------------------------------// -TEST(EvaluatorTestHarness, default_cell_bad_space_dim) -{ - // Setup test fixture. - const int num_space_dim = 4; - const int integration_order = 1; - const int basis_order = 1; - - const std::string msg - = "Invalid spatial dimensions (4): must be 1, 2, or 3."; - EXPECT_THROW( - try { - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - } catch (const std::logic_error& e) { - EXPECT_EQ(msg, e.what()); - throw; - }, - std::logic_error); -} - -//---------------------------------------------------------------------------// -TEST(EvaluatorTestHarness, custom_cell_bad_space_dim) -{ - // Setup test fixture. - const int num_cell = 1; - const int nodes_per_cell = 3; - const int num_space_dim = 3; - EvaluatorTestFixture::host_coords_view coords( - "coords", num_cell, nodes_per_cell, num_space_dim); - const int integration_order = 1; - const int basis_order = 1; - - const std::string msg - = "Unexpected spatial dimensions in provided coordinates: " - "Triangle_3 expects 2 dimensions, but 3 were provided."; - EXPECT_THROW( - try { - EvaluatorTestFixture test_fixture( - shards::getCellTopologyData>(), - coords, - integration_order, - basis_order); - } catch (const std::logic_error& e) { - EXPECT_EQ(msg, e.what()); - throw; - }, - std::logic_error); -} - -//---------------------------------------------------------------------------// -TEST(EvaluatorTestHarness, custom_cell_bad_node_count) -{ - // Setup test fixture. - const int num_cell = 1; - const int nodes_per_cell = 4; - const int num_space_dim = 2; - EvaluatorTestFixture::host_coords_view coords( - "coords", num_cell, nodes_per_cell, num_space_dim); - const int integration_order = 1; - const int basis_order = 1; - - const std::string msg - = "Unexpected node count in provided coordinates: " - "Triangle_3 expects 3 nodes, but 4 were provided."; - EXPECT_THROW( - try { - EvaluatorTestFixture test_fixture( - shards::getCellTopologyData>(), - coords, - integration_order, - basis_order); - } catch (const std::logic_error& e) { - EXPECT_EQ(msg, e.what()); - throw; - }, - std::logic_error); -} - -//---------------------------------------------------------------------------// - -} // end namespace Test -} // end namespace VertexCFD diff --git a/src/test_harness/unit_test/tstKokkosMPI.cpp b/src/test_harness/unit_test/tstKokkosMPI.cpp deleted file mode 100644 index f092437..0000000 --- a/src/test_harness/unit_test/tstKokkosMPI.cpp +++ /dev/null @@ -1,47 +0,0 @@ -#include - -#include - -#include - -#include - -#include - -namespace Test -{ -//---------------------------------------------------------------------------// -void kokkosTest() -{ - int size = 10; - Kokkos::View data("data", size); - Kokkos::parallel_for( - "fill_data", - Kokkos::RangePolicy(0, size), - KOKKOS_LAMBDA(const int i) { data(i) = 1.0; }); - - auto data_host - = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), data); - int sum = 0; - for (int i = 0; i < size; ++i) - sum += data_host(i); - - MPI_Allreduce(MPI_IN_PLACE, &sum, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD); - - int comm_size; - MPI_Comm_size(MPI_COMM_WORLD, &comm_size); - - EXPECT_EQ(comm_size * size, sum); -} - -//---------------------------------------------------------------------------// -// RUN TESTS -//---------------------------------------------------------------------------// -TEST(kokkos_mpi, kokkos_mpi_test) -{ - kokkosTest(); -} - -//---------------------------------------------------------------------------// - -} // end namespace Test diff --git a/src/turbulence_models/boundary_conditions/VertexCFD_BoundaryState_TurbulenceBoundaryEddyViscosity.cpp b/src/turbulence_models/boundary_conditions/VertexCFD_BoundaryState_TurbulenceBoundaryEddyViscosity.cpp deleted file mode 100644 index 30a566a..0000000 --- a/src/turbulence_models/boundary_conditions/VertexCFD_BoundaryState_TurbulenceBoundaryEddyViscosity.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_BoundaryState_TurbulenceBoundaryEddyViscosity.hpp" -#include "VertexCFD_BoundaryState_TurbulenceBoundaryEddyViscosity_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS( - VertexCFD::BoundaryCondition::TurbulenceBoundaryEddyViscosity) diff --git a/src/turbulence_models/boundary_conditions/VertexCFD_BoundaryState_TurbulenceBoundaryEddyViscosity.hpp b/src/turbulence_models/boundary_conditions/VertexCFD_BoundaryState_TurbulenceBoundaryEddyViscosity.hpp deleted file mode 100644 index c3c8540..0000000 --- a/src/turbulence_models/boundary_conditions/VertexCFD_BoundaryState_TurbulenceBoundaryEddyViscosity.hpp +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef VERTEXCFD_BOUNDARYSTATE_TURBULENCEBOUNDARYEDDYVISCOSITY_HPP -#define VERTEXCFD_BOUNDARYSTATE_TURBULENCEBOUNDARYEDDYVISCOSITY_HPP - -#include -#include - -#include -#include -#include -#include - -#include - -namespace VertexCFD -{ -namespace BoundaryCondition -{ -//---------------------------------------------------------------------------// -// Populates boundary eddy viscosity fields according to boundary condition -// type -//---------------------------------------------------------------------------// -template -class TurbulenceBoundaryEddyViscosity - : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - - TurbulenceBoundaryEddyViscosity(const panzer::IntegrationRule& ir, - const Teuchos::ParameterList& bc_params, - const std::string& flux_prefix); - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - public: - PHX::MDField _boundary_nu_t; - - private: - PHX::MDField _interior_nu_t; - PHX::MDField _wall_func_nu_t; - - bool _wall_func; -}; - -//---------------------------------------------------------------------------// - -} // end namespace BoundaryCondition -} // end namespace VertexCFD - -#endif // VERTEXCFD_BOUNDARYSTATE_TURBULENCEBOUNDARYEDDYVISCOSITY_HPP diff --git a/src/turbulence_models/boundary_conditions/VertexCFD_BoundaryState_TurbulenceExtrapolate.cpp b/src/turbulence_models/boundary_conditions/VertexCFD_BoundaryState_TurbulenceExtrapolate.cpp deleted file mode 100644 index d798e68..0000000 --- a/src/turbulence_models/boundary_conditions/VertexCFD_BoundaryState_TurbulenceExtrapolate.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_BoundaryState_TurbulenceExtrapolate.hpp" -#include "VertexCFD_BoundaryState_TurbulenceExtrapolate_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS( - VertexCFD::BoundaryCondition::TurbulenceExtrapolate) diff --git a/src/turbulence_models/boundary_conditions/VertexCFD_BoundaryState_TurbulenceExtrapolate.hpp b/src/turbulence_models/boundary_conditions/VertexCFD_BoundaryState_TurbulenceExtrapolate.hpp deleted file mode 100644 index fda293e..0000000 --- a/src/turbulence_models/boundary_conditions/VertexCFD_BoundaryState_TurbulenceExtrapolate.hpp +++ /dev/null @@ -1,54 +0,0 @@ -#ifndef VERTEXCFD_BOUNDARYSTATE_TURBULENCEEXTRAPOLATE_HPP -#define VERTEXCFD_BOUNDARYSTATE_TURBULENCEEXTRAPOLATE_HPP - -#include -#include - -#include -#include -#include -#include - -#include - -namespace VertexCFD -{ -namespace BoundaryCondition -{ -//---------------------------------------------------------------------------// -template -class TurbulenceExtrapolate : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - - TurbulenceExtrapolate(const panzer::IntegrationRule& ir, - const std::string variable_name); - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - public: - PHX::MDField _boundary_variable; - - PHX::MDField - _boundary_grad_variable; - - private: - PHX::MDField _variable; - PHX::MDField - _grad_variable; - - int _num_grad_dim; -}; - -//---------------------------------------------------------------------------// - -} // end namespace BoundaryCondition -} // end namespace VertexCFD - -#endif // VERTEXCFD_BOUNDARYSTATE_TURBULENCEEXTRAPOLATE_HPP diff --git a/src/turbulence_models/boundary_conditions/VertexCFD_BoundaryState_TurbulenceFixed.cpp b/src/turbulence_models/boundary_conditions/VertexCFD_BoundaryState_TurbulenceFixed.cpp deleted file mode 100644 index ad3e1b1..0000000 --- a/src/turbulence_models/boundary_conditions/VertexCFD_BoundaryState_TurbulenceFixed.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_BoundaryState_TurbulenceFixed.hpp" -#include "VertexCFD_BoundaryState_TurbulenceFixed_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS( - VertexCFD::BoundaryCondition::TurbulenceFixed) diff --git a/src/turbulence_models/boundary_conditions/VertexCFD_BoundaryState_TurbulenceFixed.hpp b/src/turbulence_models/boundary_conditions/VertexCFD_BoundaryState_TurbulenceFixed.hpp deleted file mode 100644 index f3d8522..0000000 --- a/src/turbulence_models/boundary_conditions/VertexCFD_BoundaryState_TurbulenceFixed.hpp +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef VERTEXCFD_BOUNDARYSTATE_TURBULENCEFIXED_HPP -#define VERTEXCFD_BOUNDARYSTATE_TURBULENCEFIXED_HPP - -#include -#include - -#include -#include -#include -#include - -#include - -namespace VertexCFD -{ -namespace BoundaryCondition -{ -//---------------------------------------------------------------------------// -template -class TurbulenceFixed : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - - TurbulenceFixed(const panzer::IntegrationRule& ir, - const Teuchos::ParameterList& bc_params, - const std::string variable_name); - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - public: - PHX::MDField _boundary_variable; - - PHX::MDField - _boundary_grad_variable; - - private: - PHX::MDField - _grad_variable; - - double _fixed_value; - int _num_grad_dim; -}; - -//---------------------------------------------------------------------------// - -} // end namespace BoundaryCondition -} // end namespace VertexCFD - -#endif // VERTEXCFD_BOUNDARYSTATE_TURBULENCEFIXED_HPP diff --git a/src/turbulence_models/boundary_conditions/VertexCFD_BoundaryState_TurbulenceInletOutlet.cpp b/src/turbulence_models/boundary_conditions/VertexCFD_BoundaryState_TurbulenceInletOutlet.cpp deleted file mode 100644 index 2fcbc58..0000000 --- a/src/turbulence_models/boundary_conditions/VertexCFD_BoundaryState_TurbulenceInletOutlet.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_BoundaryState_TurbulenceInletOutlet.hpp" -#include "VertexCFD_BoundaryState_TurbulenceInletOutlet_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS_NUMSPACEDIM( - VertexCFD::BoundaryCondition::TurbulenceInletOutlet) diff --git a/src/turbulence_models/boundary_conditions/VertexCFD_BoundaryState_TurbulenceInletOutlet.hpp b/src/turbulence_models/boundary_conditions/VertexCFD_BoundaryState_TurbulenceInletOutlet.hpp deleted file mode 100644 index c387c67..0000000 --- a/src/turbulence_models/boundary_conditions/VertexCFD_BoundaryState_TurbulenceInletOutlet.hpp +++ /dev/null @@ -1,61 +0,0 @@ -#ifndef VERTEXCFD_BOUNDARYSTATE_TURBULENCEINLETOUTLET_HPP -#define VERTEXCFD_BOUNDARYSTATE_TURBULENCEINLETOUTLET_HPP - -#include -#include - -#include -#include -#include -#include - -#include - -namespace VertexCFD -{ -namespace BoundaryCondition -{ -//---------------------------------------------------------------------------// -template -class TurbulenceInletOutlet : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - static constexpr int num_space_dim = NumSpaceDim; - - TurbulenceInletOutlet(const panzer::IntegrationRule& ir, - const Teuchos::ParameterList& bc_params, - const std::string variable_name); - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - public: - PHX::MDField _boundary_variable; - - PHX::MDField - _boundary_grad_variable; - - private: - PHX::MDField _variable; - PHX::MDField - _grad_variable; - PHX::MDField - _normals; - Kokkos::Array, - num_space_dim> - _velocity; - - double _inlet_value; -}; - -//---------------------------------------------------------------------------// - -} // end namespace BoundaryCondition -} // end namespace VertexCFD - -#endif // VERTEXCFD_BOUNDARYSTATE_TURBULENCEINLETOUTLET_HPP diff --git a/src/turbulence_models/boundary_conditions/VertexCFD_BoundaryState_TurbulenceKEpsilonWallFunction.cpp b/src/turbulence_models/boundary_conditions/VertexCFD_BoundaryState_TurbulenceKEpsilonWallFunction.cpp deleted file mode 100644 index 1dee5bf..0000000 --- a/src/turbulence_models/boundary_conditions/VertexCFD_BoundaryState_TurbulenceKEpsilonWallFunction.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_BoundaryState_TurbulenceKEpsilonWallFunction.hpp" -#include "VertexCFD_BoundaryState_TurbulenceKEpsilonWallFunction_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS_NUMSPACEDIM( - VertexCFD::BoundaryCondition::TurbulenceKEpsilonWallFunction) diff --git a/src/turbulence_models/boundary_conditions/VertexCFD_BoundaryState_TurbulenceKEpsilonWallFunction.hpp b/src/turbulence_models/boundary_conditions/VertexCFD_BoundaryState_TurbulenceKEpsilonWallFunction.hpp deleted file mode 100644 index 51f95d3..0000000 --- a/src/turbulence_models/boundary_conditions/VertexCFD_BoundaryState_TurbulenceKEpsilonWallFunction.hpp +++ /dev/null @@ -1,84 +0,0 @@ -#ifndef VERTEXCFD_BOUNDARYSTATE_TURBULENCEKEPSILONWALLFUNCTION_HPP -#define VERTEXCFD_BOUNDARYSTATE_TURBULENCEKEPSILONWALLFUNCTION_HPP - -#include "incompressible_solver/fluid_properties/VertexCFD_ConstantFluidProperties.hpp" - -#include -#include - -#include -#include -#include -#include - -#include - -namespace VertexCFD -{ -namespace BoundaryCondition -{ -//---------------------------------------------------------------------------// -// Wall function boundary conditions for K-Epsilon family of turbulence -// models as outlined by Kuzmin et al. (2007) -//---------------------------------------------------------------------------// -template -class TurbulenceKEpsilonWallFunction - : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - static constexpr int num_space_dim = NumSpaceDim; - - TurbulenceKEpsilonWallFunction( - const panzer::IntegrationRule& ir, - const Teuchos::ParameterList& bc_params, - const FluidProperties::ConstantFluidProperties& fluid_prop); - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - public: - PHX::MDField _boundary_k; - PHX::MDField _boundary_e; - - PHX::MDField - _boundary_grad_k; - - PHX::MDField - _boundary_grad_e; - - PHX::MDField _boundary_u_tau; - PHX::MDField _boundary_y_plus; - PHX::MDField _wall_func_nu_t; - - private: - PHX::MDField _k; - PHX::MDField _e; - Kokkos::Array, - num_space_dim> - _velocity; - PHX::MDField - _grad_k; - PHX::MDField - _grad_e; - PHX::MDField - _normals; - - int _num_grad_dim; - double _C_mu; - double _nu; - double _kappa; - double _yp_tr; - bool _neumann; -}; - -//---------------------------------------------------------------------------// - -} // end namespace BoundaryCondition -} // end namespace VertexCFD - -#endif // VERTEXCFD_BOUNDARYSTATE_TURBULENCEKEPSILONWALLFUNCTION_HPP diff --git a/src/turbulence_models/boundary_conditions/VertexCFD_BoundaryState_TurbulenceSymmetry.cpp b/src/turbulence_models/boundary_conditions/VertexCFD_BoundaryState_TurbulenceSymmetry.cpp deleted file mode 100644 index 61a91d9..0000000 --- a/src/turbulence_models/boundary_conditions/VertexCFD_BoundaryState_TurbulenceSymmetry.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_BoundaryState_TurbulenceSymmetry.hpp" -#include "VertexCFD_BoundaryState_TurbulenceSymmetry_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS( - VertexCFD::BoundaryCondition::TurbulenceSymmetry) diff --git a/src/turbulence_models/boundary_conditions/VertexCFD_BoundaryState_TurbulenceSymmetry.hpp b/src/turbulence_models/boundary_conditions/VertexCFD_BoundaryState_TurbulenceSymmetry.hpp deleted file mode 100644 index 9770aa8..0000000 --- a/src/turbulence_models/boundary_conditions/VertexCFD_BoundaryState_TurbulenceSymmetry.hpp +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef VERTEXCFD_BOUNDARYSTATE_TURBULENCESYMMETRY_HPP -#define VERTEXCFD_BOUNDARYSTATE_TURBULENCESYMMETRY_HPP - -#include -#include - -#include -#include -#include -#include - -#include - -namespace VertexCFD -{ -namespace BoundaryCondition -{ -//---------------------------------------------------------------------------// -template -class TurbulenceSymmetry : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - - TurbulenceSymmetry(const panzer::IntegrationRule& ir, - const std::string variable_name); - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - public: - PHX::MDField _boundary_variable; - - PHX::MDField - _boundary_grad_variable; - - private: - PHX::MDField _variable; - PHX::MDField - _grad_variable; - PHX::MDField - _normals; - - int _num_grad_dim; -}; - -//---------------------------------------------------------------------------// - -} // end namespace BoundaryCondition -} // end namespace VertexCFD - -#endif // VERTEXCFD_BOUNDARYSTATE_TURBULENCESYMMETRY_HPP diff --git a/src/turbulence_models/boundary_conditions/VertexCFD_TurbulenceBoundaryState_Factory.cpp b/src/turbulence_models/boundary_conditions/VertexCFD_TurbulenceBoundaryState_Factory.cpp deleted file mode 100644 index 2b1108a..0000000 --- a/src/turbulence_models/boundary_conditions/VertexCFD_TurbulenceBoundaryState_Factory.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "turbulence_models/boundary_conditions/VertexCFD_TurbulenceBoundaryState_Factory.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS_NUMSPACEDIM( - VertexCFD::BoundaryCondition::TurbulenceBoundaryStateFactory) diff --git a/src/turbulence_models/boundary_conditions/unit_test/doc/KEpsilon_Wall_Function_reference.py b/src/turbulence_models/boundary_conditions/unit_test/doc/KEpsilon_Wall_Function_reference.py deleted file mode 100644 index 94b1622..0000000 --- a/src/turbulence_models/boundary_conditions/unit_test/doc/KEpsilon_Wall_Function_reference.py +++ /dev/null @@ -1,62 +0,0 @@ -import numpy as np - -vel = [1.5, -3.0, 4.5] -grad_k = [0.02, 0.04, 0.06] -grad_e = [0.03, 0.06, 0.09] -normals = [0.33, 0.66, 0.99] - -tke_list = [0.25, 2.5] -eps = 3.1 - -yplus = 11.06 -C_mu = 0.09 -nu = 1e-4 -kappa = 0.41 - -dim_list = [2, 3] - -for dim in dim_list: - print("Computing K-Epsilon wall function BCs in ", dim, "D\n") - - vel_dim = vel[:dim] - normals_dim = normals[:dim] - grad_k_dim = grad_k[:dim] - grad_e_dim = grad_e[:dim] - - mag_u = np.linalg.norm(np.array(vel_dim)) - - print("\tVelocity magnitude: ", mag_u, "\n") - - print("\tLimiting tke = ", pow(mag_u / yplus / pow(C_mu, 0.25), 2.0), "\n") - - for tke in tke_list: - print("\tTesting tke value = ", tke, "\n") - - u_tau = max(pow(C_mu, 0.25) * pow(tke, 0.5), mag_u / yplus) - - print("\t\tu_tau = ", u_tau, "\n") - - nu_t = kappa * yplus * nu - - print("\t\tNeumann nu_t = ", nu_t, "\n") - - nu_t = C_mu * pow(tke, 2.0) / eps - - print("\t\tDirichlet nu_t = ", nu_t, "\n") - - e_bnd = pow(u_tau, 4.0) / nu_t - - print("\t\tboundary e for dirichlet condition: ", e_bnd) - - boundary_grad_k = grad_k_dim - np.array(np.dot( - grad_k_dim, normals_dim)) * normals_dim - boundary_grad_e = grad_e_dim + np.array(kappa * pow(u_tau, 5.0) / pow( - nu_t, 2.0) - np.dot(grad_e_dim, normals_dim)) * normals_dim - - for d in range(dim): - print("\t\tk boundary gradient component ", d, " = ", - boundary_grad_k[d], "\n") - print("\t\te boundary gradient component ", d, " = ", - boundary_grad_e[d], "\n") - - print("\n") diff --git a/src/turbulence_models/boundary_conditions/unit_test/doc/turbulence_symmetry_reference.py b/src/turbulence_models/boundary_conditions/unit_test/doc/turbulence_symmetry_reference.py deleted file mode 100644 index 8039bef..0000000 --- a/src/turbulence_models/boundary_conditions/unit_test/doc/turbulence_symmetry_reference.py +++ /dev/null @@ -1,21 +0,0 @@ -import numpy as np - -grad_var = [0.02, 0.04, 0.06] -normals = [0.33, 0.66, 0.99] - -dim_list = [2, 3] - -for dim in dim_list: - print("Computing boundary variable gradient in ", dim, "D\n") - - normals_dim = normals[:dim] - grad_var_dim = grad_var[:dim] - - boundary_grad_var = grad_var_dim - np.array( - np.dot(grad_var_dim, normals_dim)) * normals_dim - - for d in range(dim): - print("Boundary gradient component ", d, " = ", boundary_grad_var[d], - "\n") - - print("\n") diff --git a/src/turbulence_models/boundary_conditions/unit_test/tstTurbulenceBoundaryEddyViscosity.cpp b/src/turbulence_models/boundary_conditions/unit_test/tstTurbulenceBoundaryEddyViscosity.cpp deleted file mode 100644 index ffb41e3..0000000 --- a/src/turbulence_models/boundary_conditions/unit_test/tstTurbulenceBoundaryEddyViscosity.cpp +++ /dev/null @@ -1,161 +0,0 @@ -#include "VertexCFD_EvaluatorTestHarness.hpp" -#include "turbulence_models/boundary_conditions/VertexCFD_BoundaryState_TurbulenceBoundaryEddyViscosity.hpp" - -#include -#include -#include - -#include - -//---------------------------------------------------------------------------// -// TESTS -//---------------------------------------------------------------------------// -namespace VertexCFD -{ -namespace Test -{ -//---------------------------------------------------------------------------// -// Test data dependencies. -template -struct Dependencies : public PHX::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - using scalar_type = typename EvalType::ScalarT; - - PHX::MDField _nu_t_int; - PHX::MDField _nu_t_wf; - - Dependencies(const panzer::IntegrationRule& ir) - : _nu_t_int("turbulent_eddy_viscosity", ir.dl_scalar) - , _nu_t_wf("wall_func_turbulent_eddy_viscosity", ir.dl_scalar) - { - this->addEvaluatedField(_nu_t_int); - this->addEvaluatedField(_nu_t_wf); - this->setName( - "Turbulence Model Boundary Eddy Viscosity Unit Test Dependencies"); - } - - void evaluateFields(typename panzer::Traits::EvalData /**d**/) override - { - _nu_t_int.deep_copy(2.5); - _nu_t_wf.deep_copy(3.5); - } -}; - -//---------------------------------------------------------------------------// -// Inlet/outlet cases -enum class EddyViscosity -{ - wall_func, - wall_modeled -}; - -//---------------------------------------------------------------------------// -template -void testEval(const EddyViscosity bc_type) -{ - // Test fixture - const int num_space_dim = 2; - const int integration_order = 2; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - - // Set BC type - std::string type = ""; - - switch (bc_type) - { - case (EddyViscosity::wall_func): - type = "Wall Function Condition"; - break; - case (EddyViscosity::wall_modeled): - type = "Wall Modeled Condition"; - break; - } - - // Create dependencies - const auto dep_eval - = Teuchos::rcp(new Dependencies(*test_fixture.ir)); - test_fixture.registerEvaluator(dep_eval); - - // Create boundary eddy viscosity evaluator. - Teuchos::ParameterList bc_params; - bc_params.set("Type", type); - const auto eddy_visc_eval = Teuchos::rcp( - new BoundaryCondition::TurbulenceBoundaryEddyViscosity( - *test_fixture.ir, bc_params, "BOUNDARY_")); - test_fixture.registerEvaluator(eddy_visc_eval); - - // Add required test fields. - test_fixture.registerTestField(eddy_visc_eval->_boundary_nu_t); - - // Evaluate values - test_fixture.evaluate(); - - // Check values - const auto boundary_nu_t_result = test_fixture.getTestFieldData( - eddy_visc_eval->_boundary_nu_t); - - const int num_point = boundary_nu_t_result.extent(1); - - const double exp_value = type == "Wall Function Condition" ? 3.5 : 2.5; - - for (int qp = 0; qp < num_point; ++qp) - { - EXPECT_DOUBLE_EQ(exp_value, fieldValue(boundary_nu_t_result, 0, qp)); - } -} -//---------------------------------------------------------------------------// -// Value parameterized test fixture -struct EvaluationTest : public testing::TestWithParam -{ - // Case generator for parameterized test - struct ParamNameGenerator - { - std::string - operator()(const testing::TestParamInfo& info) const - { - const auto bc_type = info.param; - switch (bc_type) - { - case (EddyViscosity::wall_func): - return "wall_func"; - case (EddyViscosity::wall_modeled): - return "wall_modeled"; - default: - return "INVALID_NAME"; - } - } - }; -}; - -//---------------------------------------------------------------------------// -// Residual evaluation -TEST_P(EvaluationTest, residual) -{ - EddyViscosity bc_type; - bc_type = GetParam(); - testEval(bc_type); -} - -// Jacobian evaluation -TEST_P(EvaluationTest, jacobian) -{ - EddyViscosity bc_type; - bc_type = GetParam(); - testEval(bc_type); -} - -//---------------------------------------------------------------------------// -// Generate test suite with wall function and wall modeled options -INSTANTIATE_TEST_SUITE_P(EddyViscosityBC, - EvaluationTest, - testing::Values(EddyViscosity::wall_func, - EddyViscosity::wall_modeled), - EvaluationTest::ParamNameGenerator{}); - -//---------------------------------------------------------------------------// -} // end namespace Test -} // namespace VertexCFD diff --git a/src/turbulence_models/boundary_conditions/unit_test/tstTurbulenceExtrapolate.cpp b/src/turbulence_models/boundary_conditions/unit_test/tstTurbulenceExtrapolate.cpp deleted file mode 100644 index 6f43228..0000000 --- a/src/turbulence_models/boundary_conditions/unit_test/tstTurbulenceExtrapolate.cpp +++ /dev/null @@ -1,123 +0,0 @@ -#include "turbulence_models/boundary_conditions/VertexCFD_BoundaryState_TurbulenceExtrapolate.hpp" -#include - -#include -#include -#include - -#include - -//---------------------------------------------------------------------------// -// TESTS -//---------------------------------------------------------------------------// -namespace VertexCFD -{ -namespace Test -{ -//---------------------------------------------------------------------------// -// Test data dependencies. -template -struct Dependencies : public PHX::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - using scalar_type = typename EvalType::ScalarT; - - PHX::MDField _variable; - - PHX::MDField - _grad_variable; - - Dependencies(const panzer::IntegrationRule& ir) - : _variable("variable", ir.dl_scalar) - , _grad_variable("GRAD_variable", ir.dl_vector) - { - this->addEvaluatedField(_variable); - this->addEvaluatedField(_grad_variable); - this->setName("Turbulence Model Extrapolate Unit Test Dependencies"); - } - - void evaluateFields(typename panzer::Traits::EvalData /**d**/) override - { - _variable.deep_copy(1.5); - _grad_variable.deep_copy(2.0); - } -}; - -//---------------------------------------------------------------------------// -template -void testEval(const int num_grad_dim) -{ - // Test fixture - const int integration_order = 2; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_grad_dim, integration_order, basis_order); - - // Create dependencies - const auto dep_eval - = Teuchos::rcp(new Dependencies(*test_fixture.ir)); - test_fixture.registerEvaluator(dep_eval); - - // Create extrapolate evaluator. - const std::string variable_name = "variable"; - const auto extr_eval = Teuchos::rcp( - new BoundaryCondition::TurbulenceExtrapolate( - *test_fixture.ir, variable_name)); - test_fixture.registerEvaluator(extr_eval); - - // Add required test fields. - test_fixture.registerTestField(extr_eval->_boundary_variable); - test_fixture.registerTestField( - extr_eval->_boundary_grad_variable); - - // Evaluate values - test_fixture.evaluate(); - - // Check values - const auto boundary_var_result = test_fixture.getTestFieldData( - extr_eval->_boundary_variable); - const auto boundary_grad_var_result - = test_fixture.getTestFieldData( - extr_eval->_boundary_grad_variable); - - const int num_point = boundary_var_result.extent(1); - - for (int qp = 0; qp < num_point; ++qp) - { - EXPECT_DOUBLE_EQ(1.5, fieldValue(boundary_var_result, 0, qp)); - - for (int d = 0; d < num_grad_dim; ++d) - { - EXPECT_DOUBLE_EQ(2.0, - fieldValue(boundary_grad_var_result, 0, qp, d)); - } - } -} - -//---------------------------------------------------------------------------// -// 2-D case -TEST(Test2DTurbulenceExtrapolate, residual) -{ - testEval(2); -} - -TEST(Test2DTurbulenceExtrapolate, jacobian) -{ - testEval(2); -} - -//---------------------------------------------------------------------------// -// 3-D case -TEST(Test3DTurbulenceExtrapolate, residual) -{ - testEval(3); -} - -TEST(Test3DTurbulenceExtrapolate, jacobian) -{ - testEval(3); -} - -//---------------------------------------------------------------------------// -} // end namespace Test -} // end namespace VertexCFD diff --git a/src/turbulence_models/boundary_conditions/unit_test/tstTurbulenceFixed.cpp b/src/turbulence_models/boundary_conditions/unit_test/tstTurbulenceFixed.cpp deleted file mode 100644 index 823312f..0000000 --- a/src/turbulence_models/boundary_conditions/unit_test/tstTurbulenceFixed.cpp +++ /dev/null @@ -1,122 +0,0 @@ -#include "turbulence_models/boundary_conditions/VertexCFD_BoundaryState_TurbulenceFixed.hpp" -#include - -#include -#include -#include - -#include - -#include - -//---------------------------------------------------------------------------// -// TESTS -//---------------------------------------------------------------------------// -namespace VertexCFD -{ -namespace Test -{ -//---------------------------------------------------------------------------// -// Test data dependencies. -template -struct Dependencies : public PHX::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - using scalar_type = typename EvalType::ScalarT; - - PHX::MDField - _grad_variable; - - Dependencies(const panzer::IntegrationRule& ir) - : _grad_variable("GRAD_variable", ir.dl_vector) - { - this->addEvaluatedField(_grad_variable); - this->setName("Turbulence Model Fixed Unit Test Dependencies"); - } - - void evaluateFields(typename panzer::Traits::EvalData /**d**/) override - { - _grad_variable.deep_copy(2.0); - } -}; - -//---------------------------------------------------------------------------// -template -void testEval(const int num_grad_dim) -{ - // Test fixture - const int integration_order = 2; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_grad_dim, integration_order, basis_order); - - // Create dependencies - const auto dep_eval - = Teuchos::rcp(new Dependencies(*test_fixture.ir)); - test_fixture.registerEvaluator(dep_eval); - - // Create dirichlet evaluator. - const std::string variable_name = "variable"; - Teuchos::ParameterList bc_params; - bc_params.set("variable Value", 3.0); - const auto fixed_eval = Teuchos::rcp( - new BoundaryCondition::TurbulenceFixed( - *test_fixture.ir, bc_params, variable_name)); - test_fixture.registerEvaluator(fixed_eval); - - // Add required test fields. - test_fixture.registerTestField(fixed_eval->_boundary_variable); - test_fixture.registerTestField( - fixed_eval->_boundary_grad_variable); - - // Evaluate values - test_fixture.evaluate(); - - // Check values - const auto boundary_var_result = test_fixture.getTestFieldData( - fixed_eval->_boundary_variable); - const auto boundary_grad_var_result - = test_fixture.getTestFieldData( - fixed_eval->_boundary_grad_variable); - - const int num_point = boundary_var_result.extent(1); - const double exp_value = 2.0; - for (int qp = 0; qp < num_point; ++qp) - { - EXPECT_DOUBLE_EQ(3.0, fieldValue(boundary_var_result, 0, qp)); - - for (int d = 0; d < num_grad_dim; ++d) - { - EXPECT_DOUBLE_EQ(exp_value, - fieldValue(boundary_grad_var_result, 0, qp, d)); - } - } -} - -//---------------------------------------------------------------------------// -// 2-D case -TEST(Test2D, residual) -{ - testEval(2); -} - -TEST(Test2D, jacobian) -{ - testEval(2); -} - -//---------------------------------------------------------------------------// -// 3-D case -TEST(Test3D, residual) -{ - testEval(3); -} - -TEST(Test3D, jacobian) -{ - testEval(3); -} - -//---------------------------------------------------------------------------// -} // end namespace Test -} // end namespace VertexCFD diff --git a/src/turbulence_models/boundary_conditions/unit_test/tstTurbulenceInletOutlet.cpp b/src/turbulence_models/boundary_conditions/unit_test/tstTurbulenceInletOutlet.cpp deleted file mode 100644 index 9e41f5c..0000000 --- a/src/turbulence_models/boundary_conditions/unit_test/tstTurbulenceInletOutlet.cpp +++ /dev/null @@ -1,221 +0,0 @@ -#include "turbulence_models/boundary_conditions/VertexCFD_BoundaryState_TurbulenceInletOutlet.hpp" -#include - -#include - -#include -#include -#include - -#include - -//---------------------------------------------------------------------------// -// TESTS -//---------------------------------------------------------------------------// -namespace VertexCFD -{ -namespace Test -{ -//---------------------------------------------------------------------------// -// Test data dependencies. -template -struct Dependencies : public PHX::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - using scalar_type = typename EvalType::ScalarT; - - double _u0, _u1, _u2; - - PHX::MDField _variable; - PHX::MDField - _grad_variable; - PHX::MDField _velocity_0; - PHX::MDField _velocity_1; - PHX::MDField _velocity_2; - PHX::MDField _normals; - - Dependencies(const panzer::IntegrationRule& ir, - const double u0, - const double u1, - const double u2) - : _u0(u0) - , _u1(u1) - , _u2(u2) - , _variable("variable", ir.dl_scalar) - , _grad_variable("GRAD_variable", ir.dl_vector) - , _velocity_0("velocity_0", ir.dl_scalar) - , _velocity_1("velocity_1", ir.dl_scalar) - , _velocity_2("velocity_2", ir.dl_scalar) - , _normals("Side Normal", ir.dl_vector) - { - this->addEvaluatedField(_variable); - this->addEvaluatedField(_grad_variable); - this->addEvaluatedField(_velocity_0); - this->addEvaluatedField(_velocity_1); - this->addEvaluatedField(_velocity_2); - this->addEvaluatedField(_normals); - this->setName("Turbulence Model Inlet/Outlet Unit Test Dependencies"); - } - - void evaluateFields(typename panzer::Traits::EvalData /**d**/) override - { - _variable.deep_copy(2.0); - _grad_variable.deep_copy(3.0); - _normals.deep_copy(4.0); - _velocity_0.deep_copy(_u0); - _velocity_1.deep_copy(_u1); - _velocity_2.deep_copy(_u2); - } -}; - -//---------------------------------------------------------------------------// -// Inlet/outlet cases -enum class InletOutlet -{ - inlet, - outlet -}; - -//---------------------------------------------------------------------------// -template -void testEval(const InletOutlet inlet_outlet) -{ - // Test fixture - constexpr int num_space_dim = NumSpaceDim; - const int integration_order = 2; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - - // Set sign for inlet or outlet flow - double sign = 0.0; - - switch (inlet_outlet) - { - case (InletOutlet::inlet): - sign = -1.0; - break; - case (InletOutlet::outlet): - sign = 1.0; - break; - } - - // Create dependencies - const double _nanval = std::numeric_limits::quiet_NaN(); - const double u0 = 5.0 * sign; - const double u1 = 6.0 * sign; - const double u2 = num_space_dim == 3 ? 7.0 * sign : _nanval; - - const auto dep_eval = Teuchos::rcp( - new Dependencies(*test_fixture.ir, u0, u1, u2)); - test_fixture.registerEvaluator(dep_eval); - - // Create inlet/outlet evaluator. - const std::string variable_name = "variable"; - Teuchos::ParameterList bc_params; - bc_params.set("variable Inlet Value", 2.75); - const auto fixed_eval = Teuchos::rcp( - new BoundaryCondition:: - TurbulenceInletOutlet( - *test_fixture.ir, bc_params, variable_name)); - test_fixture.registerEvaluator(fixed_eval); - - // Add required test fields. - test_fixture.registerTestField(fixed_eval->_boundary_variable); - test_fixture.registerTestField( - fixed_eval->_boundary_grad_variable); - - // Evaluate values - test_fixture.evaluate(); - - // Check values - const auto boundary_var_result = test_fixture.getTestFieldData( - fixed_eval->_boundary_variable); - const auto boundary_grad_var_result - = test_fixture.getTestFieldData( - fixed_eval->_boundary_grad_variable); - - const int num_point = boundary_var_result.extent(1); - const double exp_value = sign > 0 ? 2.0 : 2.75; - for (int qp = 0; qp < num_point; ++qp) - { - EXPECT_DOUBLE_EQ(exp_value, fieldValue(boundary_var_result, 0, qp)); - - for (int d = 0; d < num_space_dim; ++d) - { - EXPECT_DOUBLE_EQ(3.0, - fieldValue(boundary_grad_var_result, 0, qp, d)); - } - } -} -//---------------------------------------------------------------------------// -// Value parameterized test fixture -struct EvaluationTest : public testing::TestWithParam -{ - // Case generator for parameterized test - struct ParamNameGenerator - { - std::string - operator()(const testing::TestParamInfo& info) const - { - const auto inlet_outlet = info.param; - switch (inlet_outlet) - { - case (InletOutlet::inlet): - return "inlet"; - case (InletOutlet::outlet): - return "outlet"; - default: - return "INVALID_NAME"; - } - } - }; -}; - -//---------------------------------------------------------------------------// -// Residual evaluation, 2D -TEST_P(EvaluationTest, residual2D) -{ - InletOutlet inlet_outlet; - inlet_outlet = GetParam(); - testEval(inlet_outlet); -} - -//---------------------------------------------------------------------------// -// Residual evaluation, 3D -TEST_P(EvaluationTest, residual3D) -{ - InletOutlet inlet_outlet; - inlet_outlet = GetParam(); - testEval(inlet_outlet); -} - -//---------------------------------------------------------------------------// -// Jacobian evaluation, 2D -TEST_P(EvaluationTest, jacobian2D) -{ - InletOutlet inlet_outlet; - inlet_outlet = GetParam(); - testEval(inlet_outlet); -} - -//---------------------------------------------------------------------------// -// Jacobian evaluation, 3D -TEST_P(EvaluationTest, jacobian3D) -{ - InletOutlet inlet_outlet; - inlet_outlet = GetParam(); - testEval(inlet_outlet); -} - -//---------------------------------------------------------------------------// -// Generate test suite with inlet and outlet conditions -INSTANTIATE_TEST_SUITE_P(InletOutletBC, - EvaluationTest, - testing::Values(InletOutlet::inlet, - InletOutlet::outlet), - EvaluationTest::ParamNameGenerator{}); - -//---------------------------------------------------------------------------// -} // end namespace Test -} // namespace VertexCFD diff --git a/src/turbulence_models/boundary_conditions/unit_test/tstTurbulenceKEpsilonWallFunction.cpp b/src/turbulence_models/boundary_conditions/unit_test/tstTurbulenceKEpsilonWallFunction.cpp deleted file mode 100644 index 279ad62..0000000 --- a/src/turbulence_models/boundary_conditions/unit_test/tstTurbulenceKEpsilonWallFunction.cpp +++ /dev/null @@ -1,341 +0,0 @@ -#include "VertexCFD_EvaluatorTestHarness.hpp" -#include "turbulence_models/boundary_conditions/VertexCFD_BoundaryState_TurbulenceKEpsilonWallFunction.hpp" - -#include -#include -#include - -#include - -//---------------------------------------------------------------------------// -// TESTS -//---------------------------------------------------------------------------// -namespace VertexCFD -{ -namespace Test -{ -//---------------------------------------------------------------------------// -// Test data dependencies. -template -struct Dependencies : public PHX::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - using scalar_type = typename EvalType::ScalarT; - - PHX::MDField _k; - PHX::MDField _e; - PHX::MDField _vel_0; - PHX::MDField _vel_1; - PHX::MDField _vel_2; - - PHX::MDField _prod_k; - PHX::MDField _dest_k; - PHX::MDField _source_k; - - PHX::MDField _nu_t; - - PHX::MDField _grad_k; - PHX::MDField _grad_e; - - PHX::MDField _normals; - - const bool _low_k; - const double _nanval; - - Dependencies(const panzer::IntegrationRule& ir, const bool low_k) - : _k("turb_kinetic_energy", ir.dl_scalar) - , _e("turb_dissipation_rate", ir.dl_scalar) - , _vel_0("velocity_0", ir.dl_scalar) - , _vel_1("velocity_1", ir.dl_scalar) - , _vel_2("velocity_2", ir.dl_scalar) - , _prod_k("PRODUCTION_turb_kinetic_energy_equation", ir.dl_scalar) - , _dest_k("DESTRUCTION_turb_kinetic_energy_equation", ir.dl_scalar) - , _source_k("SOURCE_turb_kinetic_energy_equation", ir.dl_scalar) - , _nu_t("turbulent_eddy_viscosity", ir.dl_scalar) - , _grad_k("GRAD_turb_kinetic_energy", ir.dl_vector) - , _grad_e("GRAD_turb_dissipation_rate", ir.dl_vector) - , _normals("Side Normal", ir.dl_vector) - , _low_k(low_k) - , _nanval(std::numeric_limits::quiet_NaN()) - { - this->addEvaluatedField(_k); - this->addEvaluatedField(_e); - this->addEvaluatedField(_vel_0); - this->addEvaluatedField(_vel_1); - this->addEvaluatedField(_vel_2); - this->addEvaluatedField(_prod_k); - this->addEvaluatedField(_dest_k); - this->addEvaluatedField(_source_k); - this->addEvaluatedField(_nu_t); - this->addEvaluatedField(_grad_k); - this->addEvaluatedField(_grad_e); - this->addEvaluatedField(_normals); - this->setName( - "Turbulence Model K-Epsilon Wall Function Unit Test Dependencies"); - } - - void evaluateFields(typename panzer::Traits::EvalData d) override - { - Kokkos::parallel_for( - "turbulence k-epsilon wall function test dependencies", - Kokkos::RangePolicy(0, d.num_cells), - *this); - } - - KOKKOS_INLINE_FUNCTION void operator()(const int c) const - { - using std::pow; - - const int num_point = _k.extent(1); - const int num_space_dim = _normals.extent(2); - - for (int qp = 0; qp < num_point; ++qp) - { - _k(c, qp) = _low_k ? 0.25 : 2.5; - _e(c, qp) = 3.1; - _vel_0(c, qp) = 1.5; - _vel_1(c, qp) = -3.0; - _vel_2(c, qp) = num_space_dim == 3 ? 4.5 : _nanval; - - _prod_k(c, qp) = 7.5; - _dest_k(c, qp) = -2.2; - _source_k(c, qp) = 5.3; - - _nu_t(c, qp) = 4.8; - - for (int d = 0; d < num_space_dim; ++d) - { - _grad_k(c, qp, d) = 0.02 * (d + 1.0); - _grad_e(c, qp, d) = 0.03 * (d + 1.0); - _normals(c, qp, d) = 0.33 * (d + 1.0); - } - } - } -}; - -//---------------------------------------------------------------------------// -template -void testEval(const bool low_k, const bool neumann) -{ - // Test fixture - const int integration_order = 2; - const int basis_order = 1; - constexpr int num_space_dim = NumSpaceDim; - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - - // Create fluid properties - Teuchos::ParameterList fluid_prop_list; - fluid_prop_list.set("Kinematic viscosity", 0.0001); - fluid_prop_list.set("Artificial compressibility", 2.0); - fluid_prop_list.set("Build Temperature Equation", false); - const FluidProperties::ConstantFluidProperties fluid_prop(fluid_prop_list); - - // Create boundary parameters - Teuchos::ParameterList bc_params; - bc_params.set("Epsilon Condition Type", neumann ? "Neumann" : "Dirichlet"); - - // Create dependencies - const auto dep_eval - = Teuchos::rcp(new Dependencies(*test_fixture.ir, low_k)); - test_fixture.registerEvaluator(dep_eval); - - // Create wall function evaluator - const auto wall_eval = Teuchos::rcp( - new BoundaryCondition::TurbulenceKEpsilonWallFunction( - *test_fixture.ir, bc_params, fluid_prop)); - test_fixture.registerEvaluator(wall_eval); - - // Add required test fields. - test_fixture.registerTestField(wall_eval->_boundary_k); - test_fixture.registerTestField(wall_eval->_boundary_e); - test_fixture.registerTestField(wall_eval->_boundary_grad_k); - test_fixture.registerTestField(wall_eval->_boundary_grad_e); - test_fixture.registerTestField(wall_eval->_boundary_u_tau); - test_fixture.registerTestField(wall_eval->_boundary_y_plus); - test_fixture.registerTestField(wall_eval->_wall_func_nu_t); - - // Evaluate values - test_fixture.evaluate(); - - // Check values - const auto boundary_k_result - = test_fixture.getTestFieldData(wall_eval->_boundary_k); - const auto boundary_e_result - = test_fixture.getTestFieldData(wall_eval->_boundary_e); - const auto boundary_grad_k_result - = test_fixture.getTestFieldData(wall_eval->_boundary_grad_k); - const auto boundary_grad_e_result - = test_fixture.getTestFieldData(wall_eval->_boundary_grad_e); - const auto boundary_u_tau_result - = test_fixture.getTestFieldData(wall_eval->_boundary_u_tau); - const auto boundary_y_plus_result - = test_fixture.getTestFieldData(wall_eval->_boundary_y_plus); - const auto wall_func_nu_t_result - = test_fixture.getTestFieldData(wall_eval->_wall_func_nu_t); - - // Set expected values (see doc script) - const double exp_k = low_k ? 0.25 : 2.5; - - const double nan_val = std::numeric_limits::quiet_NaN(); - - const double exp_grad_k_2D[3] = {0.00911, 0.01822, nan_val}; - const double exp_grad_k_3D[3] = {-0.010492, -0.020984, -0.031476}; - const auto exp_grad_k = (num_space_dim == 3) ? exp_grad_k_3D - : exp_grad_k_2D; - - // Set expected epsilon boundary value for Dirichlet condition (see doc - // file) - const double exp_e_dir_2D = low_k ? 18.65286527037969 : 1240.4622237904111; - const double exp_e_dir_3D = low_k ? 146.23846371977686 : 1240.4622237904111; - const double exp_e_dir = num_space_dim == 3 ? exp_e_dir_3D : exp_e_dir_2D; - - // Expected epsilon boundary value for Neumann condition is interior value - const double exp_e_neu = 3.1; - - // Set expected boundary epsilon based on condition type - const double exp_e = neumann ? exp_e_neu : exp_e_dir; - - // Expected boundary epsilon gradient equal to interior gradient for - // Dirichlet condition - const double exp_grad_e_dir[3] - = {0.03, 0.06, num_space_dim == 3 ? 0.09 : nan_val}; - - // Expected boundary gradient calculated for Neumann condition (see doc - // file) - const double exp_grad_e_2D[3] - = {320533.19035428844, 641066.3807085769, nan_val}; - const double exp_grad_e_2D_low_k[3] - = {1687.8312232028663, 3375.6624464057327, nan_val}; - const double exp_grad_e_3D[3] - = {320533.1609512885, 641066.321902577, 961599.4828538651}; - const double exp_grad_e_3D_low_k[3] - = {22142.174555921218, 44284.349111842435, 66426.52366776364}; - const auto exp_grad_e_neu - = (num_space_dim == 3) ? (low_k ? exp_grad_e_3D_low_k : exp_grad_e_3D) - : (low_k ? exp_grad_e_2D_low_k : exp_grad_e_2D); - - // Set expected epsilon values based on condition type - const auto exp_grad_e = neumann ? exp_grad_e_neu : exp_grad_e_dir; - - // Set other boundary turbulence quantities - const auto exp_u_tau_2D = low_k ? 0.3032641922468069 : 0.8660254037844386; - const auto exp_u_tau_3D = low_k ? 0.507458054264097 : 0.8660254037844386; - const auto exp_u_tau = num_space_dim == 3 ? exp_u_tau_3D : exp_u_tau_2D; - const auto exp_y_plus = 11.06; - const auto neu_nu_t = 0.00045346000000000004; - const auto dir_nu_t = low_k ? 0.001814516129032258 : 0.1814516129032258; - const auto exp_wall_func_nu_t = neumann ? neu_nu_t : dir_nu_t; - - // Check boundary values - const int num_point = boundary_k_result.extent(1); - - for (int qp = 0; qp < num_point; ++qp) - { - EXPECT_DOUBLE_EQ(exp_k, fieldValue(boundary_k_result, 0, qp)); - EXPECT_DOUBLE_EQ(exp_e, fieldValue(boundary_e_result, 0, qp)); - - for (int d = 0; d < num_space_dim; ++d) - { - EXPECT_DOUBLE_EQ(exp_grad_k[d], - fieldValue(boundary_grad_k_result, 0, qp, d)); - EXPECT_DOUBLE_EQ(exp_grad_e[d], - fieldValue(boundary_grad_e_result, 0, qp, d)); - } - - EXPECT_DOUBLE_EQ(exp_u_tau, fieldValue(boundary_u_tau_result, 0, qp)); - EXPECT_DOUBLE_EQ(exp_y_plus, fieldValue(boundary_y_plus_result, 0, qp)); - EXPECT_DOUBLE_EQ(exp_wall_func_nu_t, - fieldValue(wall_func_nu_t_result, 0, qp)); - } -} - -//---------------------------------------------------------------------------// -// 2-D case -TEST(Test2DTurbulenceKEpsilonWallFunctionDirichlet, residual) -{ - testEval(false, false); -} - -TEST(Test2DTurbulenceKEpsilonWallFunctionDirichlet, jacobian) -{ - testEval(false, false); -} - -TEST(Test2DTurbulenceKEpsilonWallFunctionLowKDirichlet, residual) -{ - testEval(true, false); -} - -TEST(Test2DTurbulenceKEpsilonWallFunctionLowKDirichlet, jacobian) -{ - testEval(true, false); -} - -TEST(Test2DTurbulenceKEpsilonWallFunctionNeumann, residual) -{ - testEval(false, true); -} - -TEST(Test2DTurbulenceKEpsilonWallFunctionNeumann, jacobian) -{ - testEval(false, true); -} - -TEST(Test2DTurbulenceKEpsilonWallFunctionLowKNeumann, residual) -{ - testEval(true, true); -} - -TEST(Test2DTurbulenceKEpsilonWallFunctionLowKNeumann, jacobian) -{ - testEval(true, true); -} - -//---------------------------------------------------------------------------// -// 3-D case -TEST(Test3DTurbulenceKEpsilonWallFunctionDirichlet, residual) -{ - testEval(false, false); -} - -TEST(Test3DTurbulenceKEpsilonWallFunctionDirichlet, jacobian) -{ - testEval(false, false); -} - -TEST(Test3DTurbulenceKEpsilonWallFunctionLowKDirichlet, residual) -{ - testEval(true, false); -} - -TEST(Test3DTurbulenceKEpsilonWallFunctionLowKDirichlet, jacobian) -{ - testEval(true, false); -} - -TEST(Test3DTurbulenceKEpsilonWallFunctionNeumann, residual) -{ - testEval(false, true); -} - -TEST(Test3DTurbulenceKEpsilonWallFunctionNeumann, jacobian) -{ - testEval(false, true); -} - -TEST(Test3DTurbulenceKEpsilonWallFunctionLowKNeumann, residual) -{ - testEval(true, true); -} - -TEST(Test3DTurbulenceKEpsilonWallFunctionLowKNeumann, jacobian) -{ - testEval(true, true); -} - -//---------------------------------------------------------------------------// -} // end namespace Test -} // end namespace VertexCFD diff --git a/src/turbulence_models/boundary_conditions/unit_test/tstTurbulenceSymmetry.cpp b/src/turbulence_models/boundary_conditions/unit_test/tstTurbulenceSymmetry.cpp deleted file mode 100644 index 47973d2..0000000 --- a/src/turbulence_models/boundary_conditions/unit_test/tstTurbulenceSymmetry.cpp +++ /dev/null @@ -1,155 +0,0 @@ -#include "turbulence_models/boundary_conditions/VertexCFD_BoundaryState_TurbulenceSymmetry.hpp" -#include - -#include -#include -#include - -#include - -//---------------------------------------------------------------------------// -// TESTS -//---------------------------------------------------------------------------// -namespace VertexCFD -{ -namespace Test -{ -//---------------------------------------------------------------------------// -// Test data dependencies. -template -struct Dependencies : public PHX::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - using scalar_type = typename EvalType::ScalarT; - - PHX::MDField _variable; - - PHX::MDField - _grad_variable; - - PHX::MDField _normals; - - Dependencies(const panzer::IntegrationRule& ir) - : _variable("variable", ir.dl_scalar) - , _grad_variable("GRAD_variable", ir.dl_vector) - , _normals("Side Normal", ir.dl_vector) - { - this->addEvaluatedField(_variable); - this->addEvaluatedField(_grad_variable); - this->addEvaluatedField(_normals); - this->setName("Turbulence Model Symmetry Unit Test Dependencies"); - } - - void evaluateFields(typename panzer::Traits::EvalData d) override - { - Kokkos::parallel_for( - "turbulence symmetry test dependencies", - Kokkos::RangePolicy(0, d.num_cells), - *this); - } - - KOKKOS_INLINE_FUNCTION void operator()(const int c) const - { - using std::sqrt; - - const int num_point = _variable.extent(1); - const int num_space_dim = _normals.extent(2); - - for (int qp = 0; qp < num_point; ++qp) - { - _variable(c, qp) = 2.0; - - for (int d = 0; d < num_space_dim; ++d) - { - _grad_variable(c, qp, d) = 0.02 * (d + 1.0); - _normals(c, qp, d) = 0.33 * (d + 1.0); - } - } - } -}; - -//---------------------------------------------------------------------------// -template -void testEval(const int num_grad_dim) -{ - // Test fixture - const int integration_order = 2; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_grad_dim, integration_order, basis_order); - - // Create dependencies - const auto dep_eval - = Teuchos::rcp(new Dependencies(*test_fixture.ir)); - test_fixture.registerEvaluator(dep_eval); - - // Create symmetry evaluator. - const std::string variable_name = "variable"; - const auto symm_eval = Teuchos::rcp( - new BoundaryCondition::TurbulenceSymmetry( - *test_fixture.ir, variable_name)); - test_fixture.registerEvaluator(symm_eval); - - // Add required test fields. - test_fixture.registerTestField(symm_eval->_boundary_variable); - test_fixture.registerTestField( - symm_eval->_boundary_grad_variable); - - // Evaluate values - test_fixture.evaluate(); - - // Check values - const auto boundary_var_result = test_fixture.getTestFieldData( - symm_eval->_boundary_variable); - const auto boundary_grad_var_result - = test_fixture.getTestFieldData( - symm_eval->_boundary_grad_variable); - - const int num_point = boundary_var_result.extent(1); - - const double nan_val = std::numeric_limits::quiet_NaN(); - - const double exp_grad_2D[3] = {0.00911, 0.01822, nan_val}; - const double exp_grad_3D[3] = { - -0.010492000000000001, -0.020984000000000003, -0.031476000000000004}; - const auto exp_grad_value = (num_grad_dim == 3) ? exp_grad_3D : exp_grad_2D; - - for (int qp = 0; qp < num_point; ++qp) - { - EXPECT_DOUBLE_EQ(2.0, fieldValue(boundary_var_result, 0, qp)); - - for (int d = 0; d < num_grad_dim; ++d) - { - EXPECT_DOUBLE_EQ(exp_grad_value[d], - fieldValue(boundary_grad_var_result, 0, qp, d)); - } - } -} - -//---------------------------------------------------------------------------// -// 2-D case -TEST(Test2DTurbulenceSymmetry, residual) -{ - testEval(2); -} - -TEST(Test2DTurbulenceSymmetry, jacobian) -{ - testEval(2); -} - -//---------------------------------------------------------------------------// -// 3-D case -TEST(Test3DTurbulenceSymmetry, residual) -{ - testEval(3); -} - -TEST(Test3DTurbulenceSymmetry, jacobian) -{ - testEval(3); -} - -//---------------------------------------------------------------------------// -} // end namespace Test -} // end namespace VertexCFD diff --git a/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleKEpsilonDiffusivityCoefficient.cpp b/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleKEpsilonDiffusivityCoefficient.cpp deleted file mode 100644 index d5b8d11..0000000 --- a/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleKEpsilonDiffusivityCoefficient.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_Closure_IncompressibleKEpsilonDiffusivityCoefficient.hpp" -#include "VertexCFD_Closure_IncompressibleKEpsilonDiffusivityCoefficient_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS( - VertexCFD::ClosureModel::IncompressibleKEpsilonDiffusivityCoefficient) diff --git a/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleKEpsilonDiffusivityCoefficient.hpp b/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleKEpsilonDiffusivityCoefficient.hpp deleted file mode 100644 index 5deebf3..0000000 --- a/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleKEpsilonDiffusivityCoefficient.hpp +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef VERTEXCFD_CLOSURE_INCOMPRESSIBLEKEPSILONDIFFUSIVITYCOEFFICIENT_HPP -#define VERTEXCFD_CLOSURE_INCOMPRESSIBLEKEPSILONDIFFUSIVITYCOEFFICIENT_HPP - -#include "incompressible_solver/fluid_properties/VertexCFD_ConstantFluidProperties.hpp" - -#include -#include - -#include -#include -#include -#include - -#include - -namespace VertexCFD -{ -namespace ClosureModel -{ -//---------------------------------------------------------------------------// -// Diffusion coefficients for standard K-Epsilon turbulence model -//---------------------------------------------------------------------------// -template -class IncompressibleKEpsilonDiffusivityCoefficient - : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - - IncompressibleKEpsilonDiffusivityCoefficient( - const panzer::IntegrationRule& ir, - const FluidProperties::ConstantFluidProperties& fluid_prop, - const double sigma_k = 1.0, - const double sigma_e = 1.3, - const std::string field_prefix = ""); - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - private: - PHX::MDField _nu_t; - - double _nu; - double _sigma_k; - double _sigma_e; - int _num_grad_dim; - - public: - PHX::MDField _diffusivity_var_k; - PHX::MDField _diffusivity_var_e; -}; - -//---------------------------------------------------------------------------// - -} // end namespace ClosureModel -} // end namespace VertexCFD - -#endif // end - // VERTEXCFD_CLOSURE_INCOMPRESSIBLEKEPSILONDIFFUSIVITYCOEFFICIENT_HPP diff --git a/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleKEpsilonEddyViscosity.cpp b/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleKEpsilonEddyViscosity.cpp deleted file mode 100644 index 654048c..0000000 --- a/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleKEpsilonEddyViscosity.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_Closure_IncompressibleKEpsilonEddyViscosity.hpp" -#include "VertexCFD_Closure_IncompressibleKEpsilonEddyViscosity_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS( - VertexCFD::ClosureModel::IncompressibleKEpsilonEddyViscosity) diff --git a/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleKEpsilonEddyViscosity.hpp b/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleKEpsilonEddyViscosity.hpp deleted file mode 100644 index 136b50f..0000000 --- a/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleKEpsilonEddyViscosity.hpp +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef VERTEXCFD_CLOSURE_INCOMPRESSIBLEKEPSILONEDDYVISCOSITY_HPP -#define VERTEXCFD_CLOSURE_INCOMPRESSIBLEKEPSILONEDDYVISCOSITY_HPP - -#include -#include - -#include -#include -#include -#include - -#include - -namespace VertexCFD -{ -namespace ClosureModel -{ -//---------------------------------------------------------------------------// -// Turbulent eddy viscosity for standard K-Epsilon turbulence model -//---------------------------------------------------------------------------// -template -class IncompressibleKEpsilonEddyViscosity - : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - - IncompressibleKEpsilonEddyViscosity(const panzer::IntegrationRule& ir); - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - private: - PHX::MDField - _turb_kinetic_energy; - PHX::MDField - _turb_dissipation_rate; - - double _C_nu; - int _num_grad_dim; - - public: - PHX::MDField _nu_t; -}; - -//---------------------------------------------------------------------------// - -} // end namespace ClosureModel -} // end namespace VertexCFD - -#endif // end - // VERTEXCFD_CLOSURE_INCOMPRESSIBLEKEPSILONEDDYVISCOSITY_HPP diff --git a/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleKEpsilonSource.cpp b/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleKEpsilonSource.cpp deleted file mode 100644 index a195156..0000000 --- a/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleKEpsilonSource.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_Closure_IncompressibleKEpsilonSource.hpp" -#include "VertexCFD_Closure_IncompressibleKEpsilonSource_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS_NUMSPACEDIM( - VertexCFD::ClosureModel::IncompressibleKEpsilonSource) diff --git a/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleKEpsilonSource.hpp b/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleKEpsilonSource.hpp deleted file mode 100644 index 9a6a5ce..0000000 --- a/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleKEpsilonSource.hpp +++ /dev/null @@ -1,68 +0,0 @@ -#ifndef VERTEXCFD_CLOSURE_INCOMPRESSIBLEKEPSILONSOURCE_HPP -#define VERTEXCFD_CLOSURE_INCOMPRESSIBLEKEPSILONSOURCE_HPP - -#include -#include - -#include -#include -#include -#include - -#include - -namespace VertexCFD -{ -namespace ClosureModel -{ -//---------------------------------------------------------------------------// -// Source term for standard K-Epsilon turbulence model -//---------------------------------------------------------------------------// -template -class IncompressibleKEpsilonSource - : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - static constexpr int num_space_dim = NumSpaceDim; - - IncompressibleKEpsilonSource(const panzer::IntegrationRule& ir); - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - private: - PHX::MDField _nu_t; - PHX::MDField - _turb_kinetic_energy; - PHX::MDField - _turb_dissipation_rate; - - Kokkos::Array< - PHX::MDField, - num_space_dim> - _grad_velocity; - - double _C_1; - double _C_2; - - public: - PHX::MDField _k_source; - PHX::MDField _k_prod; - PHX::MDField _k_dest; - PHX::MDField _e_source; - PHX::MDField _e_prod; - PHX::MDField _e_dest; -}; - -//---------------------------------------------------------------------------// - -} // end namespace ClosureModel -} // end namespace VertexCFD - -#endif // end - // VERTEXCFD_CLOSURE_INCOMPRESSIBLEKEPSILONSOURCE_HPP diff --git a/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleKOmegaDiffusivityCoefficient.cpp b/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleKOmegaDiffusivityCoefficient.cpp deleted file mode 100644 index b0aa2a7..0000000 --- a/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleKOmegaDiffusivityCoefficient.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_Closure_IncompressibleKOmegaDiffusivityCoefficient.hpp" -#include "VertexCFD_Closure_IncompressibleKOmegaDiffusivityCoefficient_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS( - VertexCFD::ClosureModel::IncompressibleKOmegaDiffusivityCoefficient) diff --git a/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleKOmegaDiffusivityCoefficient.hpp b/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleKOmegaDiffusivityCoefficient.hpp deleted file mode 100644 index f1bae19..0000000 --- a/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleKOmegaDiffusivityCoefficient.hpp +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef VERTEXCFD_CLOSURE_INCOMPRESSIBLEKOMEGADIFFUSIVITYCOEFFICIENT_HPP -#define VERTEXCFD_CLOSURE_INCOMPRESSIBLEKOMEGADIFFUSIVITYCOEFFICIENT_HPP - -#include "incompressible_solver/fluid_properties/VertexCFD_ConstantFluidProperties.hpp" - -#include -#include - -#include -#include -#include -#include - -#include - -namespace VertexCFD -{ -namespace ClosureModel -{ -//---------------------------------------------------------------------------// -// Diffusivity coefficients for Wilcox (2006) K-Omega turbulence model -//---------------------------------------------------------------------------// -template -class IncompressibleKOmegaDiffusivityCoefficient - : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - - IncompressibleKOmegaDiffusivityCoefficient( - const panzer::IntegrationRule& ir, - const FluidProperties::ConstantFluidProperties& fluid_prop, - const Teuchos::ParameterList& user_params); - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - private: - PHX::MDField - _turb_kinetic_energy; - PHX::MDField - _turb_specific_dissipation_rate; - - double _nu; - double _sigma_k; - double _sigma_w; - - public: - PHX::MDField _diffusivity_var_k; - PHX::MDField _diffusivity_var_w; -}; - -//---------------------------------------------------------------------------// - -} // end namespace ClosureModel -} // end namespace VertexCFD - -#endif // end - // VERTEXCFD_CLOSURE_INCOMPRESSIBLEKOMEGADIFFUSIVITYCOEFFICIENT_HPP diff --git a/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleKOmegaEddyViscosity.cpp b/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleKOmegaEddyViscosity.cpp deleted file mode 100644 index 1edba0f..0000000 --- a/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleKOmegaEddyViscosity.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_Closure_IncompressibleKOmegaEddyViscosity.hpp" -#include "VertexCFD_Closure_IncompressibleKOmegaEddyViscosity_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS_NUMSPACEDIM( - VertexCFD::ClosureModel::IncompressibleKOmegaEddyViscosity) diff --git a/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleKOmegaEddyViscosity.hpp b/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleKOmegaEddyViscosity.hpp deleted file mode 100644 index a825327..0000000 --- a/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleKOmegaEddyViscosity.hpp +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef VERTEXCFD_CLOSURE_INCOMPRESSIBLEKOMEGAEDDYVISCOSITY_HPP -#define VERTEXCFD_CLOSURE_INCOMPRESSIBLEKOMEGAEDDYVISCOSITY_HPP - -#include -#include - -#include -#include -#include -#include - -#include - -namespace VertexCFD -{ -namespace ClosureModel -{ -//---------------------------------------------------------------------------// -// Turbulent eddy viscosity for the Wilcox (2006) K-Omega turbulence model -//---------------------------------------------------------------------------// -template -class IncompressibleKOmegaEddyViscosity - : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - static constexpr int num_space_dim = NumSpaceDim; - - IncompressibleKOmegaEddyViscosity(const panzer::IntegrationRule& ir); - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - private: - PHX::MDField - _turb_kinetic_energy; - PHX::MDField - _turb_specific_dissipation_rate; - - Kokkos::Array< - PHX::MDField, - num_space_dim> - _grad_velocity; - - double _C_lim; - double _beta_star; - - public: - PHX::MDField _nu_t; -}; - -//---------------------------------------------------------------------------// - -} // end namespace ClosureModel -} // end namespace VertexCFD - -#endif // end - // VERTEXCFD_CLOSURE_INCOMPRESSIBLEKOMEGAEDDYVISCOSITY_HPP diff --git a/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleKOmegaSource.cpp b/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleKOmegaSource.cpp deleted file mode 100644 index 9fd109d..0000000 --- a/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleKOmegaSource.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_Closure_IncompressibleKOmegaSource.hpp" -#include "VertexCFD_Closure_IncompressibleKOmegaSource_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS_NUMSPACEDIM( - VertexCFD::ClosureModel::IncompressibleKOmegaSource) diff --git a/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleKOmegaSource.hpp b/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleKOmegaSource.hpp deleted file mode 100644 index c3a1bd1..0000000 --- a/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleKOmegaSource.hpp +++ /dev/null @@ -1,78 +0,0 @@ -#ifndef VERTEXCFD_CLOSURE_INCOMPRESSIBLEKOMEGASOURCE_HPP -#define VERTEXCFD_CLOSURE_INCOMPRESSIBLEKOMEGASOURCE_HPP - -#include -#include - -#include -#include -#include -#include - -#include - -namespace VertexCFD -{ -namespace ClosureModel -{ -//---------------------------------------------------------------------------// -// Source term for the Wilcox (2006) K-Omega turbulence model with/without -// limiter -//---------------------------------------------------------------------------// -template -class IncompressibleKOmegaSource - : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - static constexpr int num_space_dim = NumSpaceDim; - - IncompressibleKOmegaSource(const panzer::IntegrationRule& ir, - const Teuchos::ParameterList& user_params); - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - private: - PHX::MDField _nu_t; - PHX::MDField - _turb_kinetic_energy; - PHX::MDField - _turb_specific_dissipation_rate; - - PHX::MDField - _grad_turb_kinetic_energy; - PHX::MDField - _grad_turb_specific_dissipation_rate; - Kokkos::Array< - PHX::MDField, - num_space_dim> - _grad_velocity; - - double _beta_star; - double _gamma; - double _beta_0; - double _sigma_d; - bool _limit_production; - - public: - PHX::MDField _k_source; - PHX::MDField _k_prod; - PHX::MDField _k_dest; - PHX::MDField _w_source; - PHX::MDField _w_prod; - PHX::MDField _w_dest; - PHX::MDField _w_cross; -}; - -//---------------------------------------------------------------------------// - -} // end namespace ClosureModel -} // end namespace VertexCFD - -#endif // end - // VERTEXCFD_CLOSURE_INCOMPRESSIBLEKOMEGASOURCE_HPP diff --git a/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleRealizableKEpsilonEddyViscosity.cpp b/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleRealizableKEpsilonEddyViscosity.cpp deleted file mode 100644 index 451fa3c..0000000 --- a/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleRealizableKEpsilonEddyViscosity.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_Closure_IncompressibleRealizableKEpsilonEddyViscosity.hpp" -#include "VertexCFD_Closure_IncompressibleRealizableKEpsilonEddyViscosity_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS_NUMSPACEDIM( - VertexCFD::ClosureModel::IncompressibleRealizableKEpsilonEddyViscosity) diff --git a/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleRealizableKEpsilonEddyViscosity.hpp b/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleRealizableKEpsilonEddyViscosity.hpp deleted file mode 100644 index 82a677a..0000000 --- a/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleRealizableKEpsilonEddyViscosity.hpp +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef VERTEXCFD_CLOSURE_INCOMPRESSIBLEREALIZABLEKEPSILONEDDYVISCOSITY_HPP -#define VERTEXCFD_CLOSURE_INCOMPRESSIBLEREALIZABLEKEPSILONEDDYVISCOSITY_HPP - -#include -#include - -#include -#include -#include -#include - -#include - -namespace VertexCFD -{ -namespace ClosureModel -{ -//---------------------------------------------------------------------------// -// Turbulent eddy viscosity for Realizable K-Epsilon turbulence model -//---------------------------------------------------------------------------// -template -class IncompressibleRealizableKEpsilonEddyViscosity - : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - static constexpr int num_space_dim = NumSpaceDim; - - IncompressibleRealizableKEpsilonEddyViscosity( - const panzer::IntegrationRule& ir); - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - private: - PHX::MDField - _turb_kinetic_energy; - PHX::MDField - _turb_dissipation_rate; - - Kokkos::Array< - PHX::MDField, - num_space_dim> - _grad_velocity; - - double _A_0; - - public: - PHX::MDField _nu_t; -}; - -//---------------------------------------------------------------------------// - -} // end namespace ClosureModel -} // end namespace VertexCFD - -#endif // end - // VERTEXCFD_CLOSURE_INCOMPRESSIBLEREALIZABLEKEPSILONEDDYVISCOSITY_HPP diff --git a/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleRealizableKEpsilonSource.cpp b/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleRealizableKEpsilonSource.cpp deleted file mode 100644 index bc6ee70..0000000 --- a/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleRealizableKEpsilonSource.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_Closure_IncompressibleRealizableKEpsilonSource.hpp" -#include "VertexCFD_Closure_IncompressibleRealizableKEpsilonSource_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS_NUMSPACEDIM( - VertexCFD::ClosureModel::IncompressibleRealizableKEpsilonSource) diff --git a/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleRealizableKEpsilonSource.hpp b/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleRealizableKEpsilonSource.hpp deleted file mode 100644 index ef5f2d7..0000000 --- a/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleRealizableKEpsilonSource.hpp +++ /dev/null @@ -1,72 +0,0 @@ -#ifndef VERTEXCFD_CLOSURE_INCOMPRESSIBLEREALIZABLEKEPSILONSOURCE_HPP -#define VERTEXCFD_CLOSURE_INCOMPRESSIBLEREALIZABLEKEPSILONSOURCE_HPP - -#include "incompressible_solver/fluid_properties/VertexCFD_ConstantFluidProperties.hpp" - -#include -#include - -#include -#include -#include -#include - -#include - -namespace VertexCFD -{ -namespace ClosureModel -{ -//---------------------------------------------------------------------------// -// Source term for realizable K-Epsilon turbulence model -//---------------------------------------------------------------------------// -template -class IncompressibleRealizableKEpsilonSource - : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - static constexpr int num_space_dim = NumSpaceDim; - - IncompressibleRealizableKEpsilonSource( - const panzer::IntegrationRule& ir, - const FluidProperties::ConstantFluidProperties& fluid_prop); - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - private: - PHX::MDField _nu_t; - PHX::MDField - _turb_kinetic_energy; - PHX::MDField - _turb_dissipation_rate; - - Kokkos::Array< - PHX::MDField, - num_space_dim> - _grad_velocity; - - double _nu; - double _C_2; - - public: - PHX::MDField _k_source; - PHX::MDField _k_prod; - PHX::MDField _k_dest; - PHX::MDField _e_source; - PHX::MDField _e_prod; - PHX::MDField _e_dest; -}; - -//---------------------------------------------------------------------------// - -} // end namespace ClosureModel -} // end namespace VertexCFD - -#endif // end - // VERTEXCFD_CLOSURE_INCOMPRESSIBLEREALIZABLEKEPSILONSOURCE_HPP diff --git a/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleSpalartAllmarasDiffusivityCoefficient.cpp b/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleSpalartAllmarasDiffusivityCoefficient.cpp deleted file mode 100644 index 6d524b3..0000000 --- a/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleSpalartAllmarasDiffusivityCoefficient.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_Closure_IncompressibleSpalartAllmarasDiffusivityCoefficient.hpp" -#include "VertexCFD_Closure_IncompressibleSpalartAllmarasDiffusivityCoefficient_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS( - VertexCFD::ClosureModel::IncompressibleSpalartAllmarasDiffusivityCoefficient) diff --git a/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleSpalartAllmarasDiffusivityCoefficient.hpp b/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleSpalartAllmarasDiffusivityCoefficient.hpp deleted file mode 100644 index f0ad41b..0000000 --- a/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleSpalartAllmarasDiffusivityCoefficient.hpp +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef VERTEXCFD_CLOSURE_INCOMPRESSIBLESPALARTALLMARASDIFFUSIVITYCOEFFICIENT_HPP -#define VERTEXCFD_CLOSURE_INCOMPRESSIBLESPALARTALLMARASDIFFUSIVITYCOEFFICIENT_HPP - -#include "incompressible_solver/fluid_properties/VertexCFD_ConstantFluidProperties.hpp" - -#include -#include - -#include -#include -#include -#include - -#include - -#include - -namespace VertexCFD -{ -namespace ClosureModel -{ -//---------------------------------------------------------------------------// -// Diffusion coefficient for Spalart-Allmaras turbulence model (SA-neg) -//---------------------------------------------------------------------------// -template -class IncompressibleSpalartAllmarasDiffusivityCoefficient - : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - - IncompressibleSpalartAllmarasDiffusivityCoefficient( - const panzer::IntegrationRule& ir, - const FluidProperties::ConstantFluidProperties& fluid_prop); - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - private: - PHX::MDField _sa_var; - - const double _nu; - const double _cn1; - const double _sigma; - const scalar_type _one; - const int _num_grad_dim; - - public: - PHX::MDField _diffusivity_var; -}; - -//---------------------------------------------------------------------------// - -} // end namespace ClosureModel -} // end namespace VertexCFD - -#endif // end - // VERTEXCFD_CLOSURE_INCOMPRESSIBLESPALARTALLMARASDIFFUSIVITYCOEFFICIENT_HPP diff --git a/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleSpalartAllmarasEddyViscosity.cpp b/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleSpalartAllmarasEddyViscosity.cpp deleted file mode 100644 index 79c1a7b..0000000 --- a/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleSpalartAllmarasEddyViscosity.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_Closure_IncompressibleSpalartAllmarasEddyViscosity.hpp" -#include "VertexCFD_Closure_IncompressibleSpalartAllmarasEddyViscosity_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS( - VertexCFD::ClosureModel::IncompressibleSpalartAllmarasEddyViscosity) diff --git a/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleSpalartAllmarasEddyViscosity.hpp b/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleSpalartAllmarasEddyViscosity.hpp deleted file mode 100644 index d3e64e6..0000000 --- a/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleSpalartAllmarasEddyViscosity.hpp +++ /dev/null @@ -1,60 +0,0 @@ -#ifndef VERTEXCFD_CLOSURE_INCOMPRESSIBLESPALARTALLMARASEDDYVISCOSITY_HPP -#define VERTEXCFD_CLOSURE_INCOMPRESSIBLESPALARTALLMARASEDDYVISCOSITY_HPP - -#include "incompressible_solver/fluid_properties/VertexCFD_ConstantFluidProperties.hpp" - -#include -#include - -#include -#include -#include -#include - -#include - -#include - -namespace VertexCFD -{ -namespace ClosureModel -{ -//---------------------------------------------------------------------------// -// Turbulent eddy viscosity for Spalart-Allmaras turbulence model (SA-neg) -//---------------------------------------------------------------------------// -template -class IncompressibleSpalartAllmarasEddyViscosity - : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - - IncompressibleSpalartAllmarasEddyViscosity( - const panzer::IntegrationRule& ir, - const FluidProperties::ConstantFluidProperties& fluid_prop); - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - private: - PHX::MDField _sa_var; - - const double _nu; - const double _cv1; - const int _num_grad_dim; - - public: - PHX::MDField _nu_t; -}; - -//---------------------------------------------------------------------------// - -} // end namespace ClosureModel -} // end namespace VertexCFD - -#endif // end - // VERTEXCFD_CLOSURE_INCOMPRESSIBLESPALARTALLMARASEDDYVISCOSITY_HPP diff --git a/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleSpalartAllmarasSource.cpp b/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleSpalartAllmarasSource.cpp deleted file mode 100644 index 6276d59..0000000 --- a/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleSpalartAllmarasSource.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_Closure_IncompressibleSpalartAllmarasSource.hpp" -#include "VertexCFD_Closure_IncompressibleSpalartAllmarasSource_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS_NUMSPACEDIM( - VertexCFD::ClosureModel::IncompressibleSpalartAllmarasSource) diff --git a/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleSpalartAllmarasSource.hpp b/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleSpalartAllmarasSource.hpp deleted file mode 100644 index 1d476aa..0000000 --- a/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleSpalartAllmarasSource.hpp +++ /dev/null @@ -1,80 +0,0 @@ -#ifndef VERTEXCFD_CLOSURE_INCOMPRESSIBLESPALARTALLMARASSOURCE_HPP -#define VERTEXCFD_CLOSURE_INCOMPRESSIBLESPALARTALLMARASSOURCE_HPP - -#include "incompressible_solver/fluid_properties/VertexCFD_ConstantFluidProperties.hpp" - -#include -#include - -#include -#include -#include -#include - -#include - -namespace VertexCFD -{ -namespace ClosureModel -{ -//---------------------------------------------------------------------------// -// Source term for Spalart-Allmaras turbulence model (SA-neg) -//---------------------------------------------------------------------------// -template -class IncompressibleSpalartAllmarasSource - : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - static constexpr int num_space_dim = NumSpaceDim; - - IncompressibleSpalartAllmarasSource( - const panzer::IntegrationRule& ir, - const FluidProperties::ConstantFluidProperties& fluid_prop); - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - private: - PHX::MDField _sa_var; - PHX::MDField _distance; - - PHX::MDField - _grad_sa_var; - Kokkos::Array< - PHX::MDField, - num_space_dim> - _grad_velocity; - - const double _nu; - const double _sigma; - const double _kappa; - const double _c_b1; - const double _c_b2; - const double _c_t3; - const double _c_t4; - const double _c_v1; - const double _c_v2; - const double _c_v3; - const double _c_w1; - const double _c_w2; - const double _c_w3; - const scalar_type _rlim; - - public: - PHX::MDField _sa_source; - PHX::MDField _sa_prod; - PHX::MDField _sa_dest; -}; - -//---------------------------------------------------------------------------// - -} // end namespace ClosureModel -} // end namespace VertexCFD - -#endif // end - // VERTEXCFD_CLOSURE_INCOMPRESSIBLESPALARTALLMARASSOURCE_HPP diff --git a/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleVariableConvectiveFlux.cpp b/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleVariableConvectiveFlux.cpp deleted file mode 100644 index af0b9bf..0000000 --- a/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleVariableConvectiveFlux.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_Closure_IncompressibleVariableConvectiveFlux.hpp" -#include "VertexCFD_Closure_IncompressibleVariableConvectiveFlux_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS_NUMSPACEDIM( - VertexCFD::ClosureModel::IncompressibleVariableConvectiveFlux) diff --git a/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleVariableConvectiveFlux.hpp b/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleVariableConvectiveFlux.hpp deleted file mode 100644 index f02f741..0000000 --- a/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleVariableConvectiveFlux.hpp +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef VERTEXCFD_CLOSURE_INCOMPRESSIBLEVARIABLECONVECTIVEFLUX_HPP -#define VERTEXCFD_CLOSURE_INCOMPRESSIBLEVARIABLECONVECTIVEFLUX_HPP - -#include -#include - -#include -#include -#include -#include - -#include - -#include - -namespace VertexCFD -{ -namespace ClosureModel -{ -//---------------------------------------------------------------------------// -// Conservative term for incompressible turbulence variable equation -//---------------------------------------------------------------------------// -template -class IncompressibleVariableConvectiveFlux - : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - static constexpr int num_space_dim = NumSpaceDim; - - IncompressibleVariableConvectiveFlux( - const panzer::IntegrationRule& ir, - const Teuchos::ParameterList& closure_params, - const std::string& flux_prefix = "", - const std::string& field_prefix = ""); - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - private: - std::string _variable_name; - std::string _equation_name; - - public: - PHX::MDField _var_flux; - - private: - PHX::MDField _var; - Kokkos::Array, - num_space_dim> - _velocity; -}; - -//---------------------------------------------------------------------------// - -} // end namespace ClosureModel -} // end namespace VertexCFD - -#endif // end VERTEXCFD_CLOSURE_INCOMPRESSIBLEVARIABLECONVECTIVEFLUX_HPP diff --git a/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleVariableDiffusionFlux.cpp b/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleVariableDiffusionFlux.cpp deleted file mode 100644 index 6f122ed..0000000 --- a/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleVariableDiffusionFlux.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_Closure_IncompressibleVariableDiffusionFlux.hpp" -#include "VertexCFD_Closure_IncompressibleVariableDiffusionFlux_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS_NUMSPACEDIM( - VertexCFD::ClosureModel::IncompressibleVariableDiffusionFlux) diff --git a/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleVariableDiffusionFlux.hpp b/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleVariableDiffusionFlux.hpp deleted file mode 100644 index d1338d6..0000000 --- a/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleVariableDiffusionFlux.hpp +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef VERTEXCFD_CLOSURE_INCOMPRESSIBLEVARIABLEDIFFUSIONFLUX_HPP -#define VERTEXCFD_CLOSURE_INCOMPRESSIBLEVARIABLEDIFFUSIONFLUX_HPP - -#include -#include - -#include -#include -#include -#include - -#include - -#include - -namespace VertexCFD -{ -namespace ClosureModel -{ -//---------------------------------------------------------------------------// -// Diffusion term for incompressible turbulence variable equation -//---------------------------------------------------------------------------// -template -class IncompressibleVariableDiffusionFlux - : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - static constexpr int num_space_dim = NumSpaceDim; - - IncompressibleVariableDiffusionFlux( - const panzer::IntegrationRule& ir, - const Teuchos::ParameterList& closure_params, - const std::string& flux_prefix = "", - const std::string& gradient_prefix = ""); - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - private: - std::string _variable_name; - std::string _equation_name; - - public: - PHX::MDField - _var_diff_flux; - - private: - PHX::MDField _diffusivity_var; - PHX::MDField - _grad_var; -}; - -//---------------------------------------------------------------------------// - -} // end namespace ClosureModel -} // end namespace VertexCFD - -#endif // end VERTEXCFD_CLOSURE_INCOMPRESSIBLEVARIABLEDIFFUSIONFLUX_HPP diff --git a/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleWALEEddyViscosity.cpp b/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleWALEEddyViscosity.cpp deleted file mode 100644 index c421eca..0000000 --- a/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleWALEEddyViscosity.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp" - -#include "VertexCFD_Closure_IncompressibleWALEEddyViscosity.hpp" -#include "VertexCFD_Closure_IncompressibleWALEEddyViscosity_impl.hpp" - -VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS_NUMSPACEDIM( - VertexCFD::ClosureModel::IncompressibleWALEEddyViscosity) diff --git a/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleWALEEddyViscosity.hpp b/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleWALEEddyViscosity.hpp deleted file mode 100644 index e6dbd41..0000000 --- a/src/turbulence_models/closure_models/VertexCFD_Closure_IncompressibleWALEEddyViscosity.hpp +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef VERTEXCFD_CLOSURE_INCOMPRESSIBLEWALEEDDYVISCOSITY_HPP -#define VERTEXCFD_CLOSURE_INCOMPRESSIBLEWALEEDDYVISCOSITY_HPP - -#include -#include - -#include -#include -#include -#include - -#include - -namespace VertexCFD -{ -namespace ClosureModel -{ -//---------------------------------------------------------------------------// -// Turbulent eddy viscosity for WALE LES turbulence model -//---------------------------------------------------------------------------// -template -class IncompressibleWALEEddyViscosity - : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - static constexpr int num_space_dim = NumSpaceDim; - - IncompressibleWALEEddyViscosity(const panzer::IntegrationRule& ir, - const Teuchos::ParameterList& user_params); - - void evaluateFields(typename Traits::EvalData workset) override; - - KOKKOS_INLINE_FUNCTION - void operator()( - const Kokkos::TeamPolicy::member_type& team) const; - - private: - PHX::MDField - _element_length; - - Kokkos::Array< - PHX::MDField, - num_space_dim> - _grad_velocity; - - double _C_k; - double _C_w; - - public: - PHX::MDField _k_sgs; - PHX::MDField _nu_t; -}; - -//---------------------------------------------------------------------------// - -} // end namespace ClosureModel -} // end namespace VertexCFD - -#endif // end - // VERTEXCFD_CLOSURE_INCOMPRESSIBLEWALEEDDYVISCOSITY_HPP diff --git a/src/turbulence_models/closure_models/VertexCFD_TurbulenceClosureModelFactory.hpp b/src/turbulence_models/closure_models/VertexCFD_TurbulenceClosureModelFactory.hpp deleted file mode 100644 index 931f12c..0000000 --- a/src/turbulence_models/closure_models/VertexCFD_TurbulenceClosureModelFactory.hpp +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef VERTEXCFD_TURBULENCECLOSUREMODELFACTORY_HPP -#define VERTEXCFD_TURBULENCECLOSUREMODELFACTORY_HPP - -#include - -#include - -#include -#include - -namespace VertexCFD -{ -namespace ClosureModel -{ -//---------------------------------------------------------------------------// -template -class TurbulenceFactory -{ - public: - static constexpr int num_space_dim = NumSpaceDim; - - void buildClosureModel( - const Teuchos::RCP& ir, - const Teuchos::ParameterList& user_params, - const std::string& turbulence_model_name, - Teuchos::RCP>>> - evaluators); -}; - -//---------------------------------------------------------------------------// - -} // end namespace ClosureModel -} // end namespace VertexCFD - -#endif // end VERTEXCFD_TURBULENCECLOSUREMODELFACTORY_HPP diff --git a/src/turbulence_models/closure_models/VertexCFD_TurbulenceClosureModelFactory_Hessian2d.cpp b/src/turbulence_models/closure_models/VertexCFD_TurbulenceClosureModelFactory_Hessian2d.cpp deleted file mode 100644 index 95987f9..0000000 --- a/src/turbulence_models/closure_models/VertexCFD_TurbulenceClosureModelFactory_Hessian2d.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include "VertexCFD_TurbulenceClosureModelFactory.hpp" -#include "VertexCFD_TurbulenceClosureModelFactory_impl.hpp" - -template class VertexCFD::ClosureModel::TurbulenceFactory; diff --git a/src/turbulence_models/closure_models/VertexCFD_TurbulenceClosureModelFactory_Hessian3d.cpp b/src/turbulence_models/closure_models/VertexCFD_TurbulenceClosureModelFactory_Hessian3d.cpp deleted file mode 100644 index 6ebb8e7..0000000 --- a/src/turbulence_models/closure_models/VertexCFD_TurbulenceClosureModelFactory_Hessian3d.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include "VertexCFD_TurbulenceClosureModelFactory.hpp" -#include "VertexCFD_TurbulenceClosureModelFactory_impl.hpp" - -template class VertexCFD::ClosureModel::TurbulenceFactory; diff --git a/src/turbulence_models/closure_models/VertexCFD_TurbulenceClosureModelFactory_Jacobian2d.cpp b/src/turbulence_models/closure_models/VertexCFD_TurbulenceClosureModelFactory_Jacobian2d.cpp deleted file mode 100644 index 36a17ea..0000000 --- a/src/turbulence_models/closure_models/VertexCFD_TurbulenceClosureModelFactory_Jacobian2d.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include "VertexCFD_TurbulenceClosureModelFactory.hpp" -#include "VertexCFD_TurbulenceClosureModelFactory_impl.hpp" - -template class VertexCFD::ClosureModel::TurbulenceFactory; diff --git a/src/turbulence_models/closure_models/VertexCFD_TurbulenceClosureModelFactory_Jacobian3d.cpp b/src/turbulence_models/closure_models/VertexCFD_TurbulenceClosureModelFactory_Jacobian3d.cpp deleted file mode 100644 index 005b3ed..0000000 --- a/src/turbulence_models/closure_models/VertexCFD_TurbulenceClosureModelFactory_Jacobian3d.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include "VertexCFD_TurbulenceClosureModelFactory.hpp" -#include "VertexCFD_TurbulenceClosureModelFactory_impl.hpp" - -template class VertexCFD::ClosureModel::TurbulenceFactory; diff --git a/src/turbulence_models/closure_models/VertexCFD_TurbulenceClosureModelFactory_Residual2d.cpp b/src/turbulence_models/closure_models/VertexCFD_TurbulenceClosureModelFactory_Residual2d.cpp deleted file mode 100644 index f49442f..0000000 --- a/src/turbulence_models/closure_models/VertexCFD_TurbulenceClosureModelFactory_Residual2d.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include "VertexCFD_TurbulenceClosureModelFactory.hpp" -#include "VertexCFD_TurbulenceClosureModelFactory_impl.hpp" - -template class VertexCFD::ClosureModel::TurbulenceFactory; diff --git a/src/turbulence_models/closure_models/VertexCFD_TurbulenceClosureModelFactory_Residual3d.cpp b/src/turbulence_models/closure_models/VertexCFD_TurbulenceClosureModelFactory_Residual3d.cpp deleted file mode 100644 index 9537454..0000000 --- a/src/turbulence_models/closure_models/VertexCFD_TurbulenceClosureModelFactory_Residual3d.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include "VertexCFD_TurbulenceClosureModelFactory.hpp" -#include "VertexCFD_TurbulenceClosureModelFactory_impl.hpp" - -template class VertexCFD::ClosureModel::TurbulenceFactory; diff --git a/src/turbulence_models/closure_models/VertexCFD_TurbulenceClosureModelFactory_Tangent2d.cpp b/src/turbulence_models/closure_models/VertexCFD_TurbulenceClosureModelFactory_Tangent2d.cpp deleted file mode 100644 index 5da7546..0000000 --- a/src/turbulence_models/closure_models/VertexCFD_TurbulenceClosureModelFactory_Tangent2d.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include "VertexCFD_TurbulenceClosureModelFactory.hpp" -#include "VertexCFD_TurbulenceClosureModelFactory_impl.hpp" - -template class VertexCFD::ClosureModel::TurbulenceFactory; diff --git a/src/turbulence_models/closure_models/VertexCFD_TurbulenceClosureModelFactory_Tangent3d.cpp b/src/turbulence_models/closure_models/VertexCFD_TurbulenceClosureModelFactory_Tangent3d.cpp deleted file mode 100644 index be2f2ce..0000000 --- a/src/turbulence_models/closure_models/VertexCFD_TurbulenceClosureModelFactory_Tangent3d.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include "VertexCFD_TurbulenceClosureModelFactory.hpp" -#include "VertexCFD_TurbulenceClosureModelFactory_impl.hpp" - -template class VertexCFD::ClosureModel::TurbulenceFactory; diff --git a/src/turbulence_models/closure_models/unit_test/doc/KEpsilonSource_reference.py b/src/turbulence_models/closure_models/unit_test/doc/KEpsilonSource_reference.py deleted file mode 100644 index 6509da7..0000000 --- a/src/turbulence_models/closure_models/unit_test/doc/KEpsilonSource_reference.py +++ /dev/null @@ -1,50 +0,0 @@ -import numpy as np -import math - -# Turbulent quantities -nu_t = 3.0 -k = 4.0 -e = 5.0 - -# KEpsilon model constants -C_1 = 1.44 -C_2 = 1.92 - -# 2D and 3D velocity gradients -grad_vel_2D = np.array([[-0.25, 0.5], [-0.5, 1.0]]) -grad_vel_3D = np.array([[-0.25, 0.5, -0.75], [-0.5, 1.0, -1.5], - [-0.125, 0.25, -0.375]]) - -dims = [2, 3] - -for dim in dims: - print("Computing turbulence quantities in ", dim, "D\n") - - grad_vel = grad_vel_2D - - if (dim == 3): - grad_vel = grad_vel_3D - - Sij_Sij = 0.0 - - for i in range(0, dim): - for j in range(0, dim): - Sij_Sij += pow(0.5 * (grad_vel[i, j] + grad_vel[j, i]), 2.0) - - print(" Sij_Sij = ", Sij_Sij, "\n") - - k_prod = 2.0 * nu_t * Sij_Sij - k_dest = -e - k_source = k_prod + k_dest - - print(" k prod: ", k_prod) - print(" k dest: ", k_dest) - print(" k source: ", k_source, "\n") - - e_prod = C_1 * e / k * k_prod - e_dest = -C_2 * e * e / k - e_source = e_prod + e_dest - - print(" e prod: ", e_prod) - print(" e dest: ", e_dest) - print(" e source: ", e_source, "\n") diff --git a/src/turbulence_models/closure_models/unit_test/doc/KOmegaEddyViscosity_reference.py b/src/turbulence_models/closure_models/unit_test/doc/KOmegaEddyViscosity_reference.py deleted file mode 100644 index 8195246..0000000 --- a/src/turbulence_models/closure_models/unit_test/doc/KOmegaEddyViscosity_reference.py +++ /dev/null @@ -1,48 +0,0 @@ -import numpy as np -import math - -# Turbulent quantities -k = 2.5 -omegas = [1, 10] - -# Wilcox k-w model constants -beta_star = 0.09 -C_lim = 7.0 / 8.0 - -# 2D and 3D velocity gradients -grad_vel_2D = np.array([[-0.25, 0.5], [-0.5, 1.0]]) -grad_vel_3D = np.array([[-0.25, 0.5, -0.75], [-0.5, 1.0, -1.5], - [-0.125, 0.25, -0.375]]) - -dim_list = [2, 3] - -for dim in dim_list: - print("Computing turbulence quantities in ", dim, "D\n") - - grad_vel = grad_vel_2D - - if (dim == 3): - grad_vel = grad_vel_3D - - S2 = 0.0 - - # COMMENT: This calculation ignores the divergence of u term - # which will be required for compressible flows - for i in range(0, dim): - for j in range(0, dim): - S2 += pow(0.5 * (grad_vel[i, j] + grad_vel[j, i]), 2.0) - - print(" S2 = ", S2, "\n") - - omega_lim = C_lim * math.sqrt(2.0 * S2 / beta_star) - - print(" Limiting value of omega: ", omega_lim) - - for omega in omegas: - print(" Omega = ", omega) - - omega_tilda = max(omega, omega_lim) - - nu_t = k / omega_tilda - - print(" nu_t = ", nu_t, "\n") diff --git a/src/turbulence_models/closure_models/unit_test/doc/RealizableKEpsilonEddyViscosity_reference.py b/src/turbulence_models/closure_models/unit_test/doc/RealizableKEpsilonEddyViscosity_reference.py deleted file mode 100644 index 07e5fba..0000000 --- a/src/turbulence_models/closure_models/unit_test/doc/RealizableKEpsilonEddyViscosity_reference.py +++ /dev/null @@ -1,60 +0,0 @@ -import numpy as np -import math - -# Turbulent quantities -k = 4.0 -e = 5.0 - -# Realizable K-Epsilon model constants -A_0 = 4.0 - -# 2D and 3D velocity gradients -grad_vel_2D = np.array([[-0.25, 0.5], [-0.5, 1.0]]) -grad_vel_3D = np.array([[-0.25, 0.5, -0.75], [-0.5, 1.0, -1.5], - [-0.125, 0.25, -0.375]]) - -dims = [2, 3] - -for dim in dims: - print("Computing turbulence quantities in ", dim, "D\n") - - grad_vel = grad_vel_2D - - if (dim == 3): - grad_vel = grad_vel_3D - - S2 = 0.0 - Omega2 = 0.0 - W = 0.0 - - # COMMENT: The Omega2 calculation must change if the equations - # are to be solved in a rotating reference frame - for i in range(0, dim): - for j in range(0, dim): - S2 += pow(0.5 * (grad_vel[i, j] + grad_vel[j, i]), 2.0) - Omega2 += pow(0.5 * (grad_vel[i, j] - grad_vel[j, i]), 2.0) - for l in range(0, dim): - W += 1.0 / 8.0 * (grad_vel[i, j] + grad_vel[j, i]) * ( - grad_vel[j, l] + grad_vel[l, j]) * (grad_vel[l, i] + - grad_vel[i, l]) - - W = W / pow(S2, 3.0 / 2.0) - - print(" S2 = ", S2, "\n") - print(" Omega2 = ", Omega2, "\n") - print(" W = ", W, "\n") - - Us = math.sqrt(S2 + Omega2) - phi = 1.0 / 3.0 * math.acos(max(min(math.sqrt(6.0) * W, 1.0), -1.0)) - As = math.sqrt(6.0) * math.cos(phi) - - C_nu = 1.0 / (A_0 + (As * Us * k / e)) - - print(" Us = ", Us, "\n") - print(" phi = ", phi, "\n") - print(" As = ", As, "\n") - print(" C_nu = ", C_nu, "\n") - - nu_t = C_nu * k * k / e - - print(" nu_t = ", nu_t, "\n\n") diff --git a/src/turbulence_models/closure_models/unit_test/doc/RealizableKEpsilonSource_reference.py b/src/turbulence_models/closure_models/unit_test/doc/RealizableKEpsilonSource_reference.py deleted file mode 100644 index 4c83936..0000000 --- a/src/turbulence_models/closure_models/unit_test/doc/RealizableKEpsilonSource_reference.py +++ /dev/null @@ -1,63 +0,0 @@ -import numpy as np -import math - -# Fluid properties -nu = 0.25 - -# Turbulent quantities -nu_t = 3.0 -k = 4.0 -e = 5.0 - -# Realizable KEpsilon model constants -C_2 = 1.9 - -# 2D and 3D velocity gradients -grad_vel_2D = np.array([[-0.25, 0.5], [-0.5, 1.0]]) -grad_vel_3D = np.array([[-0.25, 0.5, -0.75], [-0.5, 1.0, -1.5], - [-0.125, 0.25, -0.375]]) - -dims = [2, 3] - -for dim in dims: - print("Computing turbulence quantities in ", dim, "D\n") - - grad_vel = grad_vel_2D - - if (dim == 3): - grad_vel = grad_vel_3D - - S2 = 0.0 - grad_u_sqr = 0.0 - - for i in range(0, dim): - for j in range(0, dim): - grad_u_sqr += pow(grad_vel[i, j], 2.0) - S2 += pow(0.5 * (grad_vel[i, j] + grad_vel[j, i]), 2.0) - - S = math.sqrt(2 * S2) - - print(" S = ", S, "\n") - print(" grad_u_sqr = ", grad_u_sqr, "\n") - - eta = S * k / e - C_1 = max(0.43, eta / (5 + eta)) - - print(" eta = ", eta, "\n") - print(" C_1 = ", C_1, "\n") - - k_prod = nu_t * grad_u_sqr - k_dest = -e - k_source = k_prod + k_dest - - print(" k prod: ", k_prod) - print(" k dest: ", k_dest) - print(" k source: ", k_source, "\n") - - e_prod = C_1 * S * e - e_dest = -C_2 * pow(e, 2.0) / (k + math.sqrt(nu * e)) - e_source = e_prod + e_dest - - print(" e prod: ", e_prod) - print(" e dest: ", e_dest) - print(" e source: ", e_source, "\n") diff --git a/src/turbulence_models/closure_models/unit_test/doc/SADiffusivityCoefficient_reference.py b/src/turbulence_models/closure_models/unit_test/doc/SADiffusivityCoefficient_reference.py deleted file mode 100644 index 25a4502..0000000 --- a/src/turbulence_models/closure_models/unit_test/doc/SADiffusivityCoefficient_reference.py +++ /dev/null @@ -1,19 +0,0 @@ -nu = 0.25 -cn1 = 16.0 -sigma = 2.0 / 3.0 - -# Negative SA variable -sa_var = -3.0 -xi = sa_var / nu -xi3 = xi * xi * xi -f_n = (cn1 + xi3) / (cn1 - xi3) - -print("Negative SA variable:", (nu + sa_var * f_n) / sigma) - -# Positive SA variable -sa_var = 3.0 -xi = sa_var / nu -xi3 = xi * xi * xi -f_n = 1.0 - -print("Positive SA variable:", (nu + sa_var * f_n) / sigma) diff --git a/src/turbulence_models/closure_models/unit_test/doc/SAEddyViscosity_reference.py b/src/turbulence_models/closure_models/unit_test/doc/SAEddyViscosity_reference.py deleted file mode 100644 index a9d567f..0000000 --- a/src/turbulence_models/closure_models/unit_test/doc/SAEddyViscosity_reference.py +++ /dev/null @@ -1,16 +0,0 @@ -cv1 = 7.1 -nu = 0.25 - -# Negative SA variable with or without temperature equation -sa_var = -3.0 - -print("Negative SA variable:", 0.0) - -# Positive SA variable but larger than max tolerance without temperature equation -sa_var = 3.0 -xi = sa_var / nu -xi3 = xi * xi * xi -f_v1 = xi3 / (xi3 + cv1 * cv1 * cv1) - -print("Positive SA variable (larger then tolerrance). SA Eddy viscosity is:", - sa_var * f_v1) diff --git a/src/turbulence_models/closure_models/unit_test/doc/SASource_reference.py b/src/turbulence_models/closure_models/unit_test/doc/SASource_reference.py deleted file mode 100644 index 7e94b9d..0000000 --- a/src/turbulence_models/closure_models/unit_test/doc/SASource_reference.py +++ /dev/null @@ -1,102 +0,0 @@ -import numpy as np -import math - -# Thermophysical constants -nu = 0.25 -wall_dist = 0.1 -sa_vars = [-3.0, 3.0] - -# SA model constants -sigma = 2.0 / 3.0 -kappa = 0.41 -cb1 = 0.1355 -cb2 = 0.622 -ct3 = 1.2 -ct4 = 0.5 -cv1 = 7.1 -cv2 = 0.7 -cv3 = 0.9 -cw1 = cb1 / kappa / kappa + (1.0 + cb2) / sigma -cw2 = 0.3 -cw3 = 2.0 -rlim = 10 - -# 2D and 3D velocity gradients -grad_vel_2D = np.array([[-0.25, 0.5], [-0.5, 1.0]]) -grad_vel_3D = np.array([[-0.25, 0.5, -0.75], [-0.5, 1.0, -1.5], - [-0.125, 0.25, -0.375]]) - -dims = [2, 3] - -for dim in dims: - for sa_var in sa_vars: - print("Computing turbulence quantities in ", dim, "D") - print(" with sa_var = ", sa_var) - - grad_vel = grad_vel_2D - - if (dim == 3): - grad_vel = grad_vel_3D - - S2 = pow(grad_vel[1, 0] - grad_vel[0, 1], 2.0) - - if (dim == 3): - S2 += (pow(grad_vel[2, 1] - grad_vel[1, 2], 2.0) + - pow(grad_vel[0, 2] - grad_vel[2, 0], 2.0)) - - S = math.sqrt(S2) - - print(" S = ", S) - - grad_sa = 3 * grad_vel[0] - - sa_source = cb2 / sigma * np.dot(grad_sa, grad_sa) - - print(" grad sa contributuion: ", sa_source) - - chi = sa_var / nu - - fv1 = pow(chi, 3.0) / (pow(chi, 3.0) + pow(cv1, 3.0)) - fv2 = 1.0 - chi / (1 + chi * fv1) - - ft2 = ct3 * math.exp(-ct4 * chi * chi) - - Sbar = sa_var * fv2 / kappa / kappa / wall_dist / wall_dist - - Stilda = 0 - - if (Sbar > -cv2 * S): - Stilda = S + Sbar - else: - Stilda = S + S * (cv2 * cv2 * S + cv3 * Sbar) / ( - (cv3 - 2 * cv2) * S - Sbar) - - # Calculate production term - sa_prod = 0.0 - if (sa_var > 0): - sa_prod = cb1 * (1.0 - ft2) * Stilda * sa_var - else: - sa_prod = cb1 * (1.0 - ct3) * S * sa_var - - print(" sa_prod: ", sa_prod) - - # Calculations for destruction term - r = min(sa_var / Stilda / kappa / kappa / wall_dist / wall_dist, rlim) - g = r + cw2 * (pow(r, 6.0) - r) - fw = g * pow( - (1.0 + pow(cw3, 6.0)) / (pow(g, 6.0) + pow(cw3, 6.0)), 1.0 / 6.0) - - # Calculate destruction term - sa_dest = 0.0 - if (sa_var > 0): - sa_dest = -(cw1 * fw - cb1 * ft2 / kappa / kappa) * pow( - sa_var / wall_dist, 2.0) - else: - sa_dest = cw1 * pow(sa_var / wall_dist, 2.0) - print(" sa_dest: ", sa_dest) - - # Add production and destruction terms - sa_source += (sa_prod + sa_dest) - - print(" total SA source: ", sa_source) - print("") diff --git a/src/turbulence_models/closure_models/unit_test/doc/WALEEddyViscosity_reference.py b/src/turbulence_models/closure_models/unit_test/doc/WALEEddyViscosity_reference.py deleted file mode 100644 index 735ffb2..0000000 --- a/src/turbulence_models/closure_models/unit_test/doc/WALEEddyViscosity_reference.py +++ /dev/null @@ -1,53 +0,0 @@ -import numpy as np -import math - -# Realizable K-Epsilon model constants -C_w = 0.500 -C_k = 0.094 - -# 2D and 3D velocity gradients -grad_vel_2D = np.array([[-0.25, 0.5], [-0.5, 1.0]]) -grad_vel_3D = np.array([[-0.25, 0.5, -0.75], [-0.5, 1.0, -1.5], - [-0.125, 0.25, -0.375]]) - -dim_list = [2, 3] - -for dim in dim_list: - print("Computing turbulence quantities in ", dim, "D\n") - - grad_vel = grad_vel_2D - - if (dim == 3): - grad_vel = grad_vel_3D - - # Element length (=3x du/dx_i) - element_length = 3.0 * grad_vel[0, :] - delta = np.linalg.norm(element_length) - - # Find symmetric and antisymmetric velocity gradient tensors - S = 0.5 * (grad_vel + np.transpose(grad_vel)) - W = 0.5 * (grad_vel - np.transpose(grad_vel)) - - # Find magnitude squared of S and W - magSqrS = pow(np.linalg.norm(S), 2.0) - magSqrW = pow(np.linalg.norm(W), 2.0) - - # Construct S_d tensor - S_d = np.matmul(S, S) + np.matmul( - W, W) - 1.0 / 3.0 * np.identity(dim) * (magSqrS - magSqrW) - magSqrSd = pow(np.linalg.norm(S_d), 2.0) - - # Compute sub-grid eddy viscosity - nu_sgs = pow(C_w * delta, 2.0) * pow(magSqrSd, 3.0 / 2.0) / ( - pow(magSqrS, 5.0 / 2.0) + pow(magSqrSd, 5.0 / 4.0)) - - # Compute sub-grid kinetic energy - k_sgs = pow(nu_sgs / C_k / delta, 2.0) - - # Output information - print(" magSqrS = ", magSqrS, "\n") - print(" magSqrW = ", magSqrW, "\n") - print(" magSqrSd = ", magSqrSd, "\n") - print(" delta = ", delta, "\n") - print(" nu_sgs = ", nu_sgs, "\n") - print(" k_sgs = ", k_sgs, "\n\n") diff --git a/src/turbulence_models/closure_models/unit_test/tstIncompressibleKEpsilonDiffusivityCoefficient.cpp b/src/turbulence_models/closure_models/unit_test/tstIncompressibleKEpsilonDiffusivityCoefficient.cpp deleted file mode 100644 index 3fc42ca..0000000 --- a/src/turbulence_models/closure_models/unit_test/tstIncompressibleKEpsilonDiffusivityCoefficient.cpp +++ /dev/null @@ -1,108 +0,0 @@ -#include -#include - -#include "incompressible_solver/fluid_properties/VertexCFD_ConstantFluidProperties.hpp" -#include - -#include - -namespace VertexCFD -{ -namespace Test -{ -template -struct Dependencies : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - using scalar_type = typename EvalType::ScalarT; - - PHX::MDField nu_t; - - Dependencies(const panzer::IntegrationRule& ir) - : nu_t("turbulent_eddy_viscosity", ir.dl_scalar) - { - this->addEvaluatedField(nu_t); - this->setName( - "K-Epsilon Incompressible Diffusivity Coefficient Unit " - "Test " - "Dependencies"); - } - - void evaluateFields(typename panzer::Traits::EvalData /**d**/) override - { - nu_t.deep_copy(1.5); - } -}; - -template -void testEval() -{ - const int num_space_dim = 2; - const int integration_order = 1; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - - const auto& ir = *test_fixture.ir; - - // Set turbulent quantities - const auto nu_t_value = 1.5; - const auto sigma_k = 1.00; - const auto sigma_e = 1.30; - - // Eval dependencies - const auto deps = Teuchos::rcp(new Dependencies(ir)); - test_fixture.registerEvaluator(deps); - - // Fluid properties - const auto nu = 0.25; - Teuchos::ParameterList fluid_prop_list; - fluid_prop_list.set("Kinematic viscosity", nu); - fluid_prop_list.set("Artificial compressibility", 2.0); - fluid_prop_list.set("Build Temperature Equation", false); - const FluidProperties::ConstantFluidProperties fluid_prop(fluid_prop_list); - - // Initialize and register - auto eval = Teuchos::rcp( - new ClosureModel::IncompressibleKEpsilonDiffusivityCoefficient< - EvalType, - panzer::Traits>(ir, fluid_prop)); - test_fixture.registerEvaluator(eval); - test_fixture.registerTestField(eval->_diffusivity_var_k); - test_fixture.registerTestField(eval->_diffusivity_var_e); - test_fixture.evaluate(); - - // Evaluate test fields - const auto fv_var_k - = test_fixture.getTestFieldData(eval->_diffusivity_var_k); - const auto fv_var_e - = test_fixture.getTestFieldData(eval->_diffusivity_var_e); - - // Expected values - const int num_point = ir.num_points; - const double exp_diffusivity_var_k = nu + nu_t_value / sigma_k; - const double exp_diffusivity_var_e = nu + nu_t_value / sigma_e; - - // Assert values - for (int qp = 0; qp < num_point; ++qp) - { - EXPECT_EQ(exp_diffusivity_var_k, fieldValue(fv_var_k, 0, qp)); - EXPECT_EQ(exp_diffusivity_var_e, fieldValue(fv_var_e, 0, qp)); - } -} - -//-----------------------------------------------------------------// -TEST(IncompressibleKEpsilonDiffusivityCoefficient, residual_test) -{ - testEval(); -} - -//-----------------------------------------------------------------// -TEST(IncompressibleKEpsilonDiffusivityCoefficient, jacobian_test) -{ - testEval(); -} - -//-----------------------------------------------------------------// -} // namespace Test -} // namespace VertexCFD diff --git a/src/turbulence_models/closure_models/unit_test/tstIncompressibleKEpsilonEddyViscosity.cpp b/src/turbulence_models/closure_models/unit_test/tstIncompressibleKEpsilonEddyViscosity.cpp deleted file mode 100644 index c8d5ce6..0000000 --- a/src/turbulence_models/closure_models/unit_test/tstIncompressibleKEpsilonEddyViscosity.cpp +++ /dev/null @@ -1,100 +0,0 @@ -#include -#include - -#include "incompressible_solver/fluid_properties/VertexCFD_ConstantFluidProperties.hpp" -#include "turbulence_models/closure_models/VertexCFD_Closure_IncompressibleKEpsilonEddyViscosity.hpp" - -#include - -namespace VertexCFD -{ -namespace Test -{ -template -struct Dependencies : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - using scalar_type = typename EvalType::ScalarT; - - PHX::MDField turb_kinetic_energy; - PHX::MDField turb_dissipation_rate; - - Dependencies(const panzer::IntegrationRule& ir) - : turb_kinetic_energy("turb_kinetic_energy", ir.dl_scalar) - , turb_dissipation_rate("turb_dissipation_rate", ir.dl_scalar) - { - this->addEvaluatedField(turb_kinetic_energy); - this->addEvaluatedField(turb_dissipation_rate); - this->setName( - "K-Epsilon Incompressible Eddy Viscosity Unit " - "Test " - "Dependencies"); - } - - void evaluateFields(typename panzer::Traits::EvalData /**d**/) override - { - turb_kinetic_energy.deep_copy(2.5); - turb_dissipation_rate.deep_copy(1.25); - } -}; - -template -void testEval() -{ - using std::pow; - const int num_space_dim = 2; - const int integration_order = 1; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - - const auto& ir = *test_fixture.ir; - - // Set turbulent quantities - const double C_nu = 0.09; - const double turb_kinetic_energy_value = 2.5; - const double turb_dissipation_rate_value = 1.25; - - // Eval dependencies - const auto deps = Teuchos::rcp(new Dependencies(ir)); - test_fixture.registerEvaluator(deps); - - // Initialize and register - auto eval = Teuchos::rcp( - new ClosureModel::IncompressibleKEpsilonEddyViscosity( - ir)); - test_fixture.registerEvaluator(eval); - test_fixture.registerTestField(eval->_nu_t); - test_fixture.evaluate(); - - // Evaluate test fields - const auto fv_nu_t = test_fixture.getTestFieldData(eval->_nu_t); - - // Expected values - const int num_point = ir.num_points; - const double exp_diffusivity_var = C_nu - * pow(turb_kinetic_energy_value, 2.0) - / turb_dissipation_rate_value; - - // Assert values - for (int qp = 0; qp < num_point; ++qp) - { - EXPECT_EQ(exp_diffusivity_var, fieldValue(fv_nu_t, 0, qp)); - } -} - -//-----------------------------------------------------------------// -TEST(IncompressibleKEpsilonEddyViscosity, residual_test) -{ - testEval(); -} - -//-----------------------------------------------------------------// -TEST(IncompressibleKEpsilonEddyViscosity, jacobian_test) -{ - testEval(); -} -//-----------------------------------------------------------------// -} // namespace Test -} // namespace VertexCFD diff --git a/src/turbulence_models/closure_models/unit_test/tstIncompressibleKEpsilonSource.cpp b/src/turbulence_models/closure_models/unit_test/tstIncompressibleKEpsilonSource.cpp deleted file mode 100644 index d3a50f8..0000000 --- a/src/turbulence_models/closure_models/unit_test/tstIncompressibleKEpsilonSource.cpp +++ /dev/null @@ -1,156 +0,0 @@ -#include -#include - -#include - -#include - -namespace VertexCFD -{ -namespace Test -{ -template -struct Dependencies : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - using scalar_type = typename EvalType::ScalarT; - const double _nanval = std::numeric_limits::quiet_NaN(); - - PHX::MDField grad_vel_0; - PHX::MDField grad_vel_1; - PHX::MDField grad_vel_2; - - PHX::MDField nu_t; - PHX::MDField turb_kinetic_energy; - PHX::MDField turb_dissipation_rate; - - Dependencies(const panzer::IntegrationRule& ir) - : grad_vel_0("GRAD_velocity_0", ir.dl_vector) - , grad_vel_1("GRAD_velocity_1", ir.dl_vector) - , grad_vel_2("GRAD_velocity_2", ir.dl_vector) - , nu_t("turbulent_eddy_viscosity", ir.dl_scalar) - , turb_kinetic_energy("turb_kinetic_energy", ir.dl_scalar) - , turb_dissipation_rate("turb_dissipation_rate", ir.dl_scalar) - { - this->addEvaluatedField(grad_vel_0); - this->addEvaluatedField(grad_vel_1); - this->addEvaluatedField(grad_vel_2); - this->addEvaluatedField(nu_t); - this->addEvaluatedField(turb_kinetic_energy); - this->addEvaluatedField(turb_dissipation_rate); - this->setName( - "K-Epsilon Incompressible Source Unit " - "Test " - "Dependencies"); - } - - void evaluateFields(typename panzer::Traits::EvalData d) override - { - Kokkos::parallel_for( - "K-Epsilon source test dependencies", - Kokkos::RangePolicy(0, d.num_cells), - *this); - } - - KOKKOS_INLINE_FUNCTION void operator()(const int c) const - { - const int num_point = grad_vel_0.extent(1); - const int num_space_dim = grad_vel_0.extent(2); - using std::pow; - - for (int qp = 0; qp < num_point; ++qp) - { - for (int dim = 0; dim < num_space_dim; ++dim) - { - const int sign = pow(-1, dim + 1); - const int dimqp = (dim + 1) * sign; - grad_vel_0(c, qp, dim) = 0.250 * dimqp; - grad_vel_1(c, qp, dim) = 0.500 * dimqp; - grad_vel_2(c, qp, dim) = num_space_dim == 3 ? 0.125 * dimqp - : _nanval; - } - - nu_t(c, qp) = 3.0; - turb_kinetic_energy(c, qp) = 4.0; - turb_dissipation_rate(c, qp) = 5.0; - } - } -}; - -template -void testEval() -{ - const int num_space_dim = NumSpaceDim; - const int integration_order = 2; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - - const auto& ir = *test_fixture.ir; - - // Eval dependencies - const auto deps = Teuchos::rcp(new Dependencies(ir)); - test_fixture.registerEvaluator(deps); - - // Initialize and register - auto eval = Teuchos::rcp( - new ClosureModel::IncompressibleKEpsilonSource(ir)); - test_fixture.registerEvaluator(eval); - test_fixture.registerTestField(eval->_k_source); - test_fixture.registerTestField(eval->_e_source); - test_fixture.evaluate(); - - // Evaluate test fields - const auto fv_var_k - = test_fixture.getTestFieldData(eval->_k_source); - const auto fv_var_e - = test_fixture.getTestFieldData(eval->_e_source); - - // Expected values - double exp_k_source = 1.375; - double exp_e_source = -0.5250000000000004; - - if (num_space_dim == 3) - { - exp_k_source = 9.203125; - exp_e_source = 13.565624999999997; - } - - // Assert values - const int num_point = ir.num_points; - for (int qp = 0; qp < num_point; ++qp) - { - EXPECT_DOUBLE_EQ(exp_k_source, fieldValue(fv_var_k, 0, qp)); - EXPECT_DOUBLE_EQ(exp_e_source, fieldValue(fv_var_e, 0, qp)); - } -} - -//-----------------------------------------------------------------// -TEST(IncompressibleKEpsilonSource2D, residual_test) -{ - testEval(); -} - -//-----------------------------------------------------------------// -TEST(IncompressibleKEpsilonSource2D, jacobian_test) -{ - testEval(); -} - -//-----------------------------------------------------------------// -TEST(IncompressibleKEpsilonSource3D, residual_test) -{ - testEval(); -} - -//-----------------------------------------------------------------// -TEST(IncompressibleKEpsilonSource3D, jacobian_test) -{ - testEval(); -} - -//-----------------------------------------------------------------// -} // namespace Test -} // namespace VertexCFD diff --git a/src/turbulence_models/closure_models/unit_test/tstIncompressibleKOmegaDiffusivityCoefficient.cpp b/src/turbulence_models/closure_models/unit_test/tstIncompressibleKOmegaDiffusivityCoefficient.cpp deleted file mode 100644 index 58f98fe..0000000 --- a/src/turbulence_models/closure_models/unit_test/tstIncompressibleKOmegaDiffusivityCoefficient.cpp +++ /dev/null @@ -1,131 +0,0 @@ -#include "VertexCFD_EvaluatorTestHarness.hpp" -#include "closure_models/unit_test/VertexCFD_ClosureModelFactoryTestHarness.hpp" -#include "incompressible_solver/fluid_properties/VertexCFD_ConstantFluidProperties.hpp" -#include "turbulence_models/closure_models/VertexCFD_Closure_IncompressibleKOmegaDiffusivityCoefficient.hpp" - -#include - -namespace VertexCFD -{ -namespace Test -{ -template -struct Dependencies : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - using scalar_type = typename EvalType::ScalarT; - - double _k; - double _w; - - PHX::MDField _turb_kinetic_energy; - PHX::MDField - _turb_specific_dissipation_rate; - - Dependencies(const panzer::IntegrationRule& ir, - const double k, - const double w) - : _k(k) - , _w(w) - , _turb_kinetic_energy("turb_kinetic_energy", ir.dl_scalar) - , _turb_specific_dissipation_rate("turb_specific_dissipation_rate", - ir.dl_scalar) - { - this->addEvaluatedField(_turb_kinetic_energy); - this->addEvaluatedField(_turb_specific_dissipation_rate); - this->setName( - "K-Omega Incompressible Diffusivity Coefficient Unit " - "Test " - "Dependencies"); - } - - void evaluateFields(typename panzer::Traits::EvalData /**d**/) override - { - _turb_kinetic_energy.deep_copy(_k); - _turb_specific_dissipation_rate.deep_copy(_w); - } -}; - -template -void testEval() -{ - const int num_space_dim = 2; - const int integration_order = 1; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - - const auto& ir = *test_fixture.ir; - - // Set turbulent quantities - const double k_value = 1.5; - const double w_value = 3.5; - const double sigma_k = 0.7; - const double sigma_w = 0.65; - - // Create parameter list for user-defined constants - Teuchos::ParameterList user_params; - user_params.sublist("Turbulence Parameters") - .sublist("K-Omega Parameters") - .set("sigma_k", sigma_k); - user_params.sublist("Turbulence Parameters") - .sublist("K-Omega Parameters") - .set("sigma_w", sigma_w); - - // Eval dependencies - const auto deps - = Teuchos::rcp(new Dependencies(ir, k_value, w_value)); - test_fixture.registerEvaluator(deps); - - // Fluid properties - const double nu = 0.25; - Teuchos::ParameterList fluid_prop_list; - fluid_prop_list.set("Kinematic viscosity", nu); - fluid_prop_list.set("Artificial compressibility", 2.0); - fluid_prop_list.set("Build Temperature Equation", false); - const FluidProperties::ConstantFluidProperties fluid_prop(fluid_prop_list); - - // Initialize and register - auto eval = Teuchos::rcp( - new ClosureModel::IncompressibleKOmegaDiffusivityCoefficient< - EvalType, - panzer::Traits>(ir, fluid_prop, user_params)); - test_fixture.registerEvaluator(eval); - test_fixture.registerTestField(eval->_diffusivity_var_k); - test_fixture.registerTestField(eval->_diffusivity_var_w); - test_fixture.evaluate(); - - // Evaluate test fields - const auto fv_var_k - = test_fixture.getTestFieldData(eval->_diffusivity_var_k); - const auto fv_var_w - = test_fixture.getTestFieldData(eval->_diffusivity_var_w); - - // Expected values - const int num_point = ir.num_points; - const double exp_diffusivity_var_k = nu + sigma_k * k_value / w_value; - const double exp_diffusivity_var_w = nu + sigma_w * k_value / w_value; - - // Assert values - for (int qp = 0; qp < num_point; ++qp) - { - EXPECT_DOUBLE_EQ(exp_diffusivity_var_k, fieldValue(fv_var_k, 0, qp)); - EXPECT_DOUBLE_EQ(exp_diffusivity_var_w, fieldValue(fv_var_w, 0, qp)); - } -} - -//-----------------------------------------------------------------// -TEST(IncompressibleKOmegaDiffusivityCoefficient, residual_test) -{ - testEval(); -} - -//-----------------------------------------------------------------// -TEST(IncompressibleKOmegaDiffusivityCoefficient, jacobian_test) -{ - testEval(); -} - -//-----------------------------------------------------------------// -} // namespace Test -} // namespace VertexCFD diff --git a/src/turbulence_models/closure_models/unit_test/tstIncompressibleKOmegaEddyViscosity.cpp b/src/turbulence_models/closure_models/unit_test/tstIncompressibleKOmegaEddyViscosity.cpp deleted file mode 100644 index 9d229fb..0000000 --- a/src/turbulence_models/closure_models/unit_test/tstIncompressibleKOmegaEddyViscosity.cpp +++ /dev/null @@ -1,171 +0,0 @@ -#include "VertexCFD_EvaluatorTestHarness.hpp" -#include "closure_models/unit_test/VertexCFD_ClosureModelFactoryTestHarness.hpp" - -#include "incompressible_solver/fluid_properties/VertexCFD_ConstantFluidProperties.hpp" -#include "turbulence_models/closure_models/VertexCFD_Closure_IncompressibleKOmegaEddyViscosity.hpp" - -#include - -namespace VertexCFD -{ -namespace Test -{ -template -struct Dependencies : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - using scalar_type = typename EvalType::ScalarT; - const double _nanval = std::numeric_limits::quiet_NaN(); - - PHX::MDField grad_vel_0; - PHX::MDField grad_vel_1; - PHX::MDField grad_vel_2; - - PHX::MDField turb_kinetic_energy; - PHX::MDField - turb_specific_dissipation_rate; - - const bool _limited; - - Dependencies(const panzer::IntegrationRule& ir, const bool limited) - : grad_vel_0("GRAD_velocity_0", ir.dl_vector) - , grad_vel_1("GRAD_velocity_1", ir.dl_vector) - , grad_vel_2("GRAD_velocity_2", ir.dl_vector) - , turb_kinetic_energy("turb_kinetic_energy", ir.dl_scalar) - , turb_specific_dissipation_rate("turb_specific_dissipation_rate", - ir.dl_scalar) - , _limited(limited) - { - this->addEvaluatedField(grad_vel_0); - this->addEvaluatedField(grad_vel_1); - this->addEvaluatedField(grad_vel_2); - this->addEvaluatedField(turb_kinetic_energy); - this->addEvaluatedField(turb_specific_dissipation_rate); - this->setName( - "Incompressible K-Omega Eddy Viscosity Unit Test Dependencies"); - } - - void evaluateFields(typename panzer::Traits::EvalData d) override - { - Kokkos::parallel_for( - "K-Omega eddy viscosity test dependencies", - Kokkos::RangePolicy(0, d.num_cells), - *this); - } - - KOKKOS_INLINE_FUNCTION void operator()(const int c) const - { - const int num_point = grad_vel_0.extent(1); - const int num_space_dim = grad_vel_0.extent(2); - using std::pow; - - for (int qp = 0; qp < num_point; ++qp) - { - for (int dim = 0; dim < num_space_dim; ++dim) - { - const int sign = pow(-1, dim + 1); - const int dimqp = (dim + 1) * sign; - grad_vel_0(c, qp, dim) = 0.250 * dimqp; - grad_vel_1(c, qp, dim) = 0.500 * dimqp; - grad_vel_2(c, qp, dim) = num_space_dim == 3 ? 0.125 * dimqp - : _nanval; - } - - turb_kinetic_energy(c, qp) = 2.5; - turb_specific_dissipation_rate(c, qp) = _limited ? 1.0 : 10.0; - } - } -}; - -template -void testEval(const bool limited) -{ - constexpr int num_space_dim = NumSpaceDim; - const int integration_order = 1; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - - const auto& ir = *test_fixture.ir; - - // Eval dependencies - const auto deps = Teuchos::rcp(new Dependencies(ir, limited)); - test_fixture.registerEvaluator(deps); - - // Initialize and register - auto eval = Teuchos::rcp( - new ClosureModel::IncompressibleKOmegaEddyViscosity(ir)); - test_fixture.registerEvaluator(eval); - test_fixture.registerTestField(eval->_nu_t); - test_fixture.evaluate(); - - // Evaluate test fields - const auto fv_nu_t = test_fixture.getTestFieldData(eval->_nu_t); - - // Expected values - const int num_point = ir.num_points; - double exp_var = 0.25; - if (limited) - { - exp_var = num_space_dim == 3 ? 0.393932564311835 : 0.5879951490600304; - } - - // Assert values - for (int qp = 0; qp < num_point; ++qp) - { - EXPECT_EQ(exp_var, fieldValue(fv_nu_t, 0, qp)); - } -} - -//-----------------------------------------------------------------// -TEST(IncompressibleKOmegaEddyViscosity2D, residual_test) -{ - testEval(false); -} - -//-----------------------------------------------------------------// -TEST(IncompressibleKOmegaEddyViscosity2D, jacobian_test) -{ - testEval(false); -} - -//-----------------------------------------------------------------// -TEST(IncompressibleKOmegaEddyViscosity3D, residual_test) -{ - testEval(false); -} - -//-----------------------------------------------------------------// -TEST(IncompressibleKOmegaEddyViscosity3D, jacobian_test) -{ - testEval(false); -} - -//-----------------------------------------------------------------// -TEST(IncompressibleKOmegaEddyViscosityLimited2D, residual_test) -{ - testEval(true); -} - -//-----------------------------------------------------------------// -TEST(IncompressibleKOmegaEddyViscosityLimited2D, jacobian_test) -{ - testEval(true); -} - -//-----------------------------------------------------------------// -TEST(IncompressibleKOmegaEddyViscosityLimited3D, residual_test) -{ - testEval(true); -} - -//-----------------------------------------------------------------// -TEST(IncompressibleKOmegaEddyViscosityLimited3D, jacobian_test) -{ - testEval(true); -} -//-----------------------------------------------------------------// -} // namespace Test -} // namespace VertexCFD diff --git a/src/turbulence_models/closure_models/unit_test/tstIncompressibleRealizableKEpsilonEddyViscosity.cpp b/src/turbulence_models/closure_models/unit_test/tstIncompressibleRealizableKEpsilonEddyViscosity.cpp deleted file mode 100644 index 52c9ec5..0000000 --- a/src/turbulence_models/closure_models/unit_test/tstIncompressibleRealizableKEpsilonEddyViscosity.cpp +++ /dev/null @@ -1,143 +0,0 @@ -#include -#include - -#include - -#include - -namespace VertexCFD -{ -namespace Test -{ -template -struct Dependencies : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - using scalar_type = typename EvalType::ScalarT; - const double _nanval = std::numeric_limits::quiet_NaN(); - - PHX::MDField grad_vel_0; - PHX::MDField grad_vel_1; - PHX::MDField grad_vel_2; - - PHX::MDField turb_kinetic_energy; - PHX::MDField turb_dissipation_rate; - - Dependencies(const panzer::IntegrationRule& ir) - : grad_vel_0("GRAD_velocity_0", ir.dl_vector) - , grad_vel_1("GRAD_velocity_1", ir.dl_vector) - , grad_vel_2("GRAD_velocity_2", ir.dl_vector) - , turb_kinetic_energy("turb_kinetic_energy", ir.dl_scalar) - , turb_dissipation_rate("turb_dissipation_rate", ir.dl_scalar) - { - this->addEvaluatedField(grad_vel_0); - this->addEvaluatedField(grad_vel_1); - this->addEvaluatedField(grad_vel_2); - this->addEvaluatedField(turb_kinetic_energy); - this->addEvaluatedField(turb_dissipation_rate); - this->setName( - "Incompressible Realizable K-Epsilon Eddy Viscosity Unit " - "Test " - "Dependencies"); - } - - void evaluateFields(typename panzer::Traits::EvalData d) override - { - Kokkos::parallel_for( - "Realizable K-Epsilon Eddy Viscosity test dependencies", - Kokkos::RangePolicy(0, d.num_cells), - *this); - } - - KOKKOS_INLINE_FUNCTION void operator()(const int c) const - { - const int num_point = grad_vel_0.extent(1); - const int num_space_dim = grad_vel_0.extent(2); - using std::pow; - - for (int qp = 0; qp < num_point; ++qp) - { - for (int dim = 0; dim < num_space_dim; ++dim) - { - const int sign = pow(-1, dim + 1); - const int dimqp = (dim + 1) * sign; - grad_vel_0(c, qp, dim) = 0.250 * dimqp; - grad_vel_1(c, qp, dim) = 0.500 * dimqp; - grad_vel_2(c, qp, dim) = num_space_dim == 3 ? 0.125 * dimqp - : _nanval; - } - - turb_kinetic_energy(c, qp) = 4.0; - turb_dissipation_rate(c, qp) = 5.0; - } - } -}; - -template -void testEval() -{ - const int num_space_dim = NumSpaceDim; - const int integration_order = 2; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - - const auto& ir = *test_fixture.ir; - - // Eval dependencies - const auto deps = Teuchos::rcp(new Dependencies(ir)); - test_fixture.registerEvaluator(deps); - - // Initialize and register - auto eval = Teuchos::rcp( - new ClosureModel::IncompressibleRealizableKEpsilonEddyViscosity< - EvalType, - panzer::Traits, - NumSpaceDim>(ir)); - test_fixture.registerEvaluator(eval); - test_fixture.registerTestField(eval->_nu_t); - test_fixture.evaluate(); - - // Evaluate test fields - const auto fv_var = test_fixture.getTestFieldData(eval->_nu_t); - - // Expected values - const int num_point = ir.num_points; - - const double exp_nu_t = num_space_dim == 3 ? 0.3930283177441859 - : 0.496163282309383; - - // Assert values - for (int qp = 0; qp < num_point; ++qp) - { - EXPECT_DOUBLE_EQ(exp_nu_t, fieldValue(fv_var, 0, qp)); - } -} - -//-----------------------------------------------------------------// -TEST(IncompressibleRealizableKEpsilonEddyViscosity2D, residual_test) -{ - testEval(); -} - -//-----------------------------------------------------------------// -TEST(IncompressibleRealizableKEpsilonEddyViscosity2D, jacobian_test) -{ - testEval(); -} - -//-----------------------------------------------------------------// -TEST(IncompressibleRealizableKEpsilonEddyViscosity3D, residual_test) -{ - testEval(); -} - -//-----------------------------------------------------------------// -TEST(IncompressibleRealizableKEpsilonEddyViscosity3D, jacobian_test) -{ - testEval(); -} - -//-----------------------------------------------------------------// -} // namespace Test -} // namespace VertexCFD diff --git a/src/turbulence_models/closure_models/unit_test/tstIncompressibleRealizableKEpsilonSource.cpp b/src/turbulence_models/closure_models/unit_test/tstIncompressibleRealizableKEpsilonSource.cpp deleted file mode 100644 index 636a4e5..0000000 --- a/src/turbulence_models/closure_models/unit_test/tstIncompressibleRealizableKEpsilonSource.cpp +++ /dev/null @@ -1,160 +0,0 @@ -#include -#include - -#include "incompressible_solver/fluid_properties/VertexCFD_ConstantFluidProperties.hpp" -#include "turbulence_models/closure_models/VertexCFD_Closure_IncompressibleRealizableKEpsilonSource.hpp" - -#include - -namespace VertexCFD -{ -namespace Test -{ -template -struct Dependencies : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - using scalar_type = typename EvalType::ScalarT; - const double _nanval = std::numeric_limits::quiet_NaN(); - - PHX::MDField grad_vel_0; - PHX::MDField grad_vel_1; - PHX::MDField grad_vel_2; - - PHX::MDField nu_t; - PHX::MDField turb_kinetic_energy; - PHX::MDField turb_dissipation_rate; - - Dependencies(const panzer::IntegrationRule& ir) - : grad_vel_0("GRAD_velocity_0", ir.dl_vector) - , grad_vel_1("GRAD_velocity_1", ir.dl_vector) - , grad_vel_2("GRAD_velocity_2", ir.dl_vector) - , nu_t("turbulent_eddy_viscosity", ir.dl_scalar) - , turb_kinetic_energy("turb_kinetic_energy", ir.dl_scalar) - , turb_dissipation_rate("turb_dissipation_rate", ir.dl_scalar) - { - this->addEvaluatedField(grad_vel_0); - this->addEvaluatedField(grad_vel_1); - this->addEvaluatedField(grad_vel_2); - this->addEvaluatedField(nu_t); - this->addEvaluatedField(turb_kinetic_energy); - this->addEvaluatedField(turb_dissipation_rate); - this->setName( - "Realizable K-Epsilon Incompressible Source Unit " - "Test " - "Dependencies"); - } - - void evaluateFields(typename panzer::Traits::EvalData d) override - { - Kokkos::parallel_for( - "Realizable K-Epsilon source test dependencies", - Kokkos::RangePolicy(0, d.num_cells), - *this); - } - - KOKKOS_INLINE_FUNCTION void operator()(const int c) const - { - const int num_point = grad_vel_0.extent(1); - const int num_space_dim = grad_vel_0.extent(2); - using std::pow; - - for (int qp = 0; qp < num_point; ++qp) - { - for (int dim = 0; dim < num_space_dim; ++dim) - { - const int sign = pow(-1, dim + 1); - const int dimqp = (dim + 1) * sign; - grad_vel_0(c, qp, dim) = 0.250 * dimqp; - grad_vel_1(c, qp, dim) = 0.500 * dimqp; - grad_vel_2(c, qp, dim) = num_space_dim == 3 ? 0.125 * dimqp - : _nanval; - } - - nu_t(c, qp) = 3.0; - turb_kinetic_energy(c, qp) = 4.0; - turb_dissipation_rate(c, qp) = 5.0; - } - } -}; - -template -void testEval() -{ - const int num_space_dim = NumSpaceDim; - const int integration_order = 2; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - - const auto& ir = *test_fixture.ir; - - // Eval dependencies - const auto deps = Teuchos::rcp(new Dependencies(ir)); - test_fixture.registerEvaluator(deps); - - // Fluid properties - Teuchos::ParameterList fluid_prop_list; - fluid_prop_list.set("Kinematic viscosity", 0.25); - fluid_prop_list.set("Artificial compressibility", 2.0); - fluid_prop_list.set("Build Temperature Equation", false); - const FluidProperties::ConstantFluidProperties fluid_prop(fluid_prop_list); - - // Initialize and register - auto eval = Teuchos::rcp( - new ClosureModel::IncompressibleRealizableKEpsilonSource( - ir, fluid_prop)); - test_fixture.registerEvaluator(eval); - test_fixture.registerTestField(eval->_k_source); - test_fixture.registerTestField(eval->_e_source); - test_fixture.evaluate(); - - // Evaluate test fields - const auto fv_var_k - = test_fixture.getTestFieldData(eval->_k_source); - const auto fv_var_e - = test_fixture.getTestFieldData(eval->_e_source); - - // Expected values - const double exp_k_source = num_space_dim == 2 ? -0.3125 : 8.78125; - const double exp_e_source = num_space_dim == 2 ? -6.146770850376922 - : -4.602804412745295; - - // Assert values - const int num_point = ir.num_points; - for (int qp = 0; qp < num_point; ++qp) - { - EXPECT_DOUBLE_EQ(exp_k_source, fieldValue(fv_var_k, 0, qp)); - EXPECT_DOUBLE_EQ(exp_e_source, fieldValue(fv_var_e, 0, qp)); - } -} - -//-----------------------------------------------------------------// -TEST(IncompressibleRealizableKEpsilonSource2D, residual_test) -{ - testEval(); -} - -//-----------------------------------------------------------------// -TEST(IncompressibleRealizableKEpsilonSource2D, jacobian_test) -{ - testEval(); -} - -//-----------------------------------------------------------------// -TEST(IncompressibleRealizableKEpsilonSource3D, residual_test) -{ - testEval(); -} - -//-----------------------------------------------------------------// -TEST(IncompressibleRealizableKEpsilonSource3D, jacobian_test) -{ - testEval(); -} - -//-----------------------------------------------------------------// -} // namespace Test -} // namespace VertexCFD diff --git a/src/turbulence_models/closure_models/unit_test/tstIncompressibleSpalartAllmarasDiffusivityCoefficient.cpp b/src/turbulence_models/closure_models/unit_test/tstIncompressibleSpalartAllmarasDiffusivityCoefficient.cpp deleted file mode 100644 index a540d1d..0000000 --- a/src/turbulence_models/closure_models/unit_test/tstIncompressibleSpalartAllmarasDiffusivityCoefficient.cpp +++ /dev/null @@ -1,113 +0,0 @@ -#include -#include - -#include "incompressible_solver/fluid_properties/VertexCFD_ConstantFluidProperties.hpp" -#include - -#include - -namespace VertexCFD -{ -namespace Test -{ -template -struct Dependencies : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - using scalar_type = typename EvalType::ScalarT; - - PHX::MDField sa_var; - const double _sa_var_value; - - Dependencies(const panzer::IntegrationRule& ir, const double sa_var_value) - : sa_var("spalart_allmaras_variable", ir.dl_scalar) - , _sa_var_value(sa_var_value) - { - this->addEvaluatedField(sa_var); - this->setName( - "Spalart-Allmaras Incompressible Diffusivity Coefficient Unit " - "Test " - "Dependencies"); - } - - void evaluateFields(typename panzer::Traits::EvalData /**d**/) override - { - sa_var.deep_copy(_sa_var_value); - } -}; - -template -void testEval(const double sa_var_value) -{ - const int num_space_dim = 2; - const int integration_order = 1; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - - const auto& ir = *test_fixture.ir; - - // Eval dependencies - const auto deps - = Teuchos::rcp(new Dependencies(ir, sa_var_value)); - test_fixture.registerEvaluator(deps); - - // Closure parameters - Teuchos::ParameterList fluid_prop_list; - fluid_prop_list.set("Kinematic viscosity", 0.25); - fluid_prop_list.set("Artificial compressibility", 2.0); - fluid_prop_list.set("Build Temperature Equation", false); - const FluidProperties::ConstantFluidProperties fluid_prop(fluid_prop_list); - - // Initialize and register - auto eval = Teuchos::rcp( - new ClosureModel::IncompressibleSpalartAllmarasDiffusivityCoefficient< - EvalType, - panzer::Traits>(ir, fluid_prop)); - test_fixture.registerEvaluator(eval); - test_fixture.registerTestField(eval->_diffusivity_var); - test_fixture.evaluate(); - - // Evaluate test fields - const auto fv_var - = test_fixture.getTestFieldData(eval->_diffusivity_var); - - // Expected values - const int num_point = ir.num_points; - const double exp_diffusivity_var = sa_var_value < 0 ? 4.79243119266055 - : 4.875; - - // Assert values - for (int qp = 0; qp < num_point; ++qp) - { - EXPECT_EQ(exp_diffusivity_var, fieldValue(fv_var, 0, qp)); - } -} - -//-----------------------------------------------------------------// -TEST(IncompressibleSADiffusivityCoefficientPositive, residual_test) -{ - testEval(3.0); -} - -//-----------------------------------------------------------------// -TEST(IncompressibleSADiffusivityCoefficientPositive, jacobian_test) -{ - testEval(3.0); -} - -//-----------------------------------------------------------------// -TEST(IncompressibleSADiffusivityCoefficientNegative, residual_test) -{ - testEval(-3.0); -} - -//-----------------------------------------------------------------// -TEST(IncompressibleSADiffusivityCoefficientNegative, jacobian_test) -{ - testEval(-3.0); -} - -//-----------------------------------------------------------------// -} // namespace Test -} // namespace VertexCFD diff --git a/src/turbulence_models/closure_models/unit_test/tstIncompressibleSpalartAllmarasEddyViscosity.cpp b/src/turbulence_models/closure_models/unit_test/tstIncompressibleSpalartAllmarasEddyViscosity.cpp deleted file mode 100644 index 0c813e5..0000000 --- a/src/turbulence_models/closure_models/unit_test/tstIncompressibleSpalartAllmarasEddyViscosity.cpp +++ /dev/null @@ -1,111 +0,0 @@ -#include -#include - -#include "incompressible_solver/fluid_properties/VertexCFD_ConstantFluidProperties.hpp" -#include "turbulence_models/closure_models/VertexCFD_Closure_IncompressibleSpalartAllmarasEddyViscosity.hpp" - -#include - -namespace VertexCFD -{ -namespace Test -{ -template -struct Dependencies : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - using scalar_type = typename EvalType::ScalarT; - - PHX::MDField sa_var; - const double _sa_var_value; - - Dependencies(const panzer::IntegrationRule& ir, const double sa_var_value) - : sa_var("spalart_allmaras_variable", ir.dl_scalar) - , _sa_var_value(sa_var_value) - { - this->addEvaluatedField(sa_var); - this->setName( - "Spalart-Allmaras Incompressible Eddy Viscosity Unit " - "Test " - "Dependencies"); - } - - void evaluateFields(typename panzer::Traits::EvalData /**d**/) override - { - sa_var.deep_copy(_sa_var_value); - } -}; - -template -void testEval(const double sa_var_value) -{ - const int num_space_dim = 2; - const int integration_order = 1; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - - const auto& ir = *test_fixture.ir; - - // Eval dependencies - const auto deps - = Teuchos::rcp(new Dependencies(ir, sa_var_value)); - test_fixture.registerEvaluator(deps); - - // Closure parameters - Teuchos::ParameterList fluid_prop_list; - fluid_prop_list.set("Kinematic viscosity", 0.25); - fluid_prop_list.set("Artificial compressibility", 2.0); - fluid_prop_list.set("Build Temperature Equation", false); - const FluidProperties::ConstantFluidProperties fluid_prop(fluid_prop_list); - - // Initialize and register - auto eval = Teuchos::rcp( - new ClosureModel::IncompressibleSpalartAllmarasEddyViscosity< - EvalType, - panzer::Traits>(ir, fluid_prop)); - test_fixture.registerEvaluator(eval); - test_fixture.registerTestField(eval->_nu_t); - test_fixture.evaluate(); - - // Evaluate test fields - const auto fv_nu_t = test_fixture.getTestFieldData(eval->_nu_t); - - // Expected values - const int num_point = ir.num_points; - const double exp_diffusivity_var = sa_var_value < 0 ? 0.0 - : 2.485245055997116; - // Assert values - for (int qp = 0; qp < num_point; ++qp) - { - EXPECT_DOUBLE_EQ(exp_diffusivity_var, fieldValue(fv_nu_t, 0, qp)); - } -} - -//-----------------------------------------------------------------// -TEST(IncompressibleSAEddyViscosityPositive, residual_test) -{ - testEval(3.0); -} - -//-----------------------------------------------------------------// -TEST(IncompressibleSAEddyViscosityPositive, jacobian_test) -{ - testEval(3.0); -} - -//-----------------------------------------------------------------// -TEST(IncompressibleSAEddyViscosityNegative, residual_test) -{ - testEval(-3.0); -} - -//-----------------------------------------------------------------// -TEST(IncompressibleSAEddyViscosityNegative, jacobian_test) -{ - testEval(-3.0); -} - -//-----------------------------------------------------------------// -} // namespace Test -} // namespace VertexCFD diff --git a/src/turbulence_models/closure_models/unit_test/tstIncompressibleSpalartAllmarasSource.cpp b/src/turbulence_models/closure_models/unit_test/tstIncompressibleSpalartAllmarasSource.cpp deleted file mode 100644 index 568398a..0000000 --- a/src/turbulence_models/closure_models/unit_test/tstIncompressibleSpalartAllmarasSource.cpp +++ /dev/null @@ -1,191 +0,0 @@ -#include -#include - -#include "incompressible_solver/fluid_properties/VertexCFD_ConstantFluidProperties.hpp" -#include - -#include - -namespace VertexCFD -{ -namespace Test -{ -template -struct Dependencies : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - using scalar_type = typename EvalType::ScalarT; - const double _nanval = std::numeric_limits::quiet_NaN(); - - PHX::MDField grad_vel_0; - PHX::MDField grad_vel_1; - PHX::MDField grad_vel_2; - PHX::MDField grad_sa_var; - - PHX::MDField sa_var; - PHX::MDField wall_dist; - - const double _sa_var_value; - - Dependencies(const panzer::IntegrationRule& ir, const double sa_var_value) - : grad_vel_0("GRAD_velocity_0", ir.dl_vector) - , grad_vel_1("GRAD_velocity_1", ir.dl_vector) - , grad_vel_2("GRAD_velocity_2", ir.dl_vector) - , grad_sa_var("GRAD_spalart_allmaras_variable", ir.dl_vector) - , sa_var("spalart_allmaras_variable", ir.dl_scalar) - , wall_dist("distance", ir.dl_scalar) - , _sa_var_value(sa_var_value) - { - this->addEvaluatedField(grad_vel_0); - this->addEvaluatedField(grad_vel_1); - this->addEvaluatedField(grad_vel_2); - this->addEvaluatedField(grad_sa_var); - this->addEvaluatedField(sa_var); - this->addEvaluatedField(wall_dist); - this->setName( - "Spalart-Allmaras Incompressible Source Unit " - "Test " - "Dependencies"); - } - - void evaluateFields(typename panzer::Traits::EvalData d) override - { - Kokkos::parallel_for( - "SA source test dependencies", - Kokkos::RangePolicy(0, d.num_cells), - *this); - } - - KOKKOS_INLINE_FUNCTION void operator()(const int c) const - { - const int num_point = grad_vel_0.extent(1); - const int num_space_dim = grad_vel_0.extent(2); - using std::pow; - - for (int qp = 0; qp < num_point; ++qp) - { - for (int dim = 0; dim < num_space_dim; ++dim) - { - const int sign = pow(-1, dim + 1); - const int dimqp = (dim + 1) * sign; - grad_vel_0(c, qp, dim) = 0.250 * dimqp; - grad_vel_1(c, qp, dim) = 0.500 * dimqp; - grad_vel_2(c, qp, dim) = num_space_dim == 3 ? 0.125 * dimqp - : _nanval; - - grad_sa_var(c, qp, dim) = 0.750 * dimqp; - } - - sa_var(c, qp) = _sa_var_value; - wall_dist(c, qp) = 0.1; - } - } -}; - -template -void testEval(const double sa_var_value) -{ - const int num_space_dim = NumSpaceDim; - const int integration_order = 2; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - - const auto& ir = *test_fixture.ir; - - // Eval dependencies - const auto deps - = Teuchos::rcp(new Dependencies(ir, sa_var_value)); - test_fixture.registerEvaluator(deps); - - // Closure parameters - Teuchos::ParameterList fluid_prop_list; - fluid_prop_list.set("Kinematic viscosity", 0.25); - fluid_prop_list.set("Artificial compressibility", 2.0); - fluid_prop_list.set("Build Temperature Equation", false); - const FluidProperties::ConstantFluidProperties fluid_prop(fluid_prop_list); - - // Initialize and register - auto eval = Teuchos::rcp( - new ClosureModel::IncompressibleSpalartAllmarasSource( - ir, fluid_prop)); - test_fixture.registerEvaluator(eval); - test_fixture.registerTestField(eval->_sa_source); - test_fixture.evaluate(); - - // Evaluate test fields - const auto fv_var - = test_fixture.getTestFieldData(eval->_sa_source); - - // Expected values - const int num_point = ir.num_points; - - double exp_sa_source = 0.0; - - if (num_space_dim < 3) - exp_sa_source = sa_var_value < 0 ? 2917.866397598156 - : -5842.742478724074; - else - exp_sa_source = sa_var_value < 0 ? 2922.6799728440574 - : -5837.973707512366; - - // Assert values - for (int qp = 0; qp < num_point; ++qp) - { - EXPECT_DOUBLE_EQ(exp_sa_source, fieldValue(fv_var, 0, qp)); - } -} - -//-----------------------------------------------------------------// -TEST(IncompressibleSASourcePositive2D, residual_test) -{ - testEval(3.0); -} - -//-----------------------------------------------------------------// -TEST(IncompressibleSASourcePositive2D, jacobian_test) -{ - testEval(3.0); -} - -//-----------------------------------------------------------------// -TEST(IncompressibleSASourceNegative2D, residual_test) -{ - testEval(-3.0); -} - -//-----------------------------------------------------------------// -TEST(IncompressibleSASourceNegative2D, jacobian_test) -{ - testEval(-3.0); -} - -//-----------------------------------------------------------------// -TEST(IncompressibleSASourcePositive3D, residual_test) -{ - testEval(3.0); -} - -//-----------------------------------------------------------------// -TEST(IncompressibleSASourcePositive3D, jacobian_test) -{ - testEval(3.0); -} - -//-----------------------------------------------------------------// -TEST(IncompressibleSASourceNegative3D, residual_test) -{ - testEval(-3.0); -} - -//-----------------------------------------------------------------// -TEST(IncompressibleSASourceNegative3D, jacobian_test) -{ - testEval(-3.0); -} - -//-----------------------------------------------------------------// -} // namespace Test -} // namespace VertexCFD diff --git a/src/turbulence_models/closure_models/unit_test/tstIncompressibleVariableConvectiveFlux.cpp b/src/turbulence_models/closure_models/unit_test/tstIncompressibleVariableConvectiveFlux.cpp deleted file mode 100644 index 8a0222d..0000000 --- a/src/turbulence_models/closure_models/unit_test/tstIncompressibleVariableConvectiveFlux.cpp +++ /dev/null @@ -1,122 +0,0 @@ -#include -#include - -#include - -#include - -namespace VertexCFD -{ -namespace Test -{ -template -struct Dependencies : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - using scalar_type = typename EvalType::ScalarT; - - PHX::MDField var; - PHX::MDField vel_0; - PHX::MDField vel_1; - PHX::MDField vel_2; - - Dependencies(const panzer::IntegrationRule& ir) - : var("spalart_allmaras_variable", ir.dl_scalar) - , vel_0("velocity_0", ir.dl_scalar) - , vel_1("velocity_1", ir.dl_scalar) - , vel_2("velocity_2", ir.dl_scalar) - - { - this->addEvaluatedField(var); - this->addEvaluatedField(vel_0); - this->addEvaluatedField(vel_1); - this->addEvaluatedField(vel_2); - - this->setName("Variable Convective Flux Unit Test Dependencies"); - } - - void evaluateFields(typename panzer::Traits::EvalData) override - { - var.deep_copy(2.0); - vel_0.deep_copy(4.0); - vel_1.deep_copy(-5.0); - vel_2.deep_copy(6.0); - } -}; - -template -void testEval() -{ - constexpr int num_space_dim = NumSpaceDim; - const int integration_order = 2; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - - const auto& ir = *test_fixture.ir; - - // Closure parameters - Teuchos::ParameterList closure_params; - closure_params.set("Field Name", "spalart_allmaras_variable"); - closure_params.set("Equation Name", "spalart_allmaras_equation"); - - // Eval dependencies - auto deps = Teuchos::rcp(new Dependencies(ir)); - test_fixture.registerEvaluator(deps); - - auto eval = Teuchos::rcp( - new ClosureModel::IncompressibleVariableConvectiveFlux( - ir, closure_params)); - - // Register and evaluate - test_fixture.registerEvaluator(eval); - test_fixture.registerTestField(eval->_var_flux); - test_fixture.evaluate(); - const auto fc_var - = test_fixture.getTestFieldData(eval->_var_flux); - - // Expected values - const double exp_var_flux[3] = { - 8.0, - -10.0, - num_space_dim == 3 ? 12.0 : std::numeric_limits::quiet_NaN()}; - - // Assert values - const int num_point = ir.num_points; - for (int qp = 0; qp < num_point; ++qp) - { - for (int dim = 0; dim < num_space_dim; dim++) - { - EXPECT_EQ(exp_var_flux[dim], fieldValue(fc_var, 0, qp, dim)); - } - } -} - -//-----------------------------------------------------------------// -TEST(IncompressibleVariableConvectiveFlux2D, residual_test) -{ - testEval(); -} - -//-----------------------------------------------------------------// -TEST(IncompressibleVariableConvectiveFlux2D, jacobian_test) -{ - testEval(); -} - -//-----------------------------------------------------------------// -TEST(IncompressibleVariableConvectiveFlux3D, residual_test) -{ - testEval(); -} - -//-----------------------------------------------------------------// -TEST(IncompressibleVariableConvectiveFlux3D, jacobian_test) -{ - testEval(); -} - -} // namespace Test -} // namespace VertexCFD diff --git a/src/turbulence_models/closure_models/unit_test/tstIncompressibleVariableDiffusionFlux.cpp b/src/turbulence_models/closure_models/unit_test/tstIncompressibleVariableDiffusionFlux.cpp deleted file mode 100644 index f020c5d..0000000 --- a/src/turbulence_models/closure_models/unit_test/tstIncompressibleVariableDiffusionFlux.cpp +++ /dev/null @@ -1,132 +0,0 @@ -#include -#include - -#include - -#include - -namespace VertexCFD -{ -namespace Test -{ -template -struct Dependencies : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - using scalar_type = typename EvalType::ScalarT; - - PHX::MDField grad_var; - PHX::MDField diffusivity_var; - - Dependencies(const panzer::IntegrationRule& ir) - : grad_var("GRAD_spalart_allmaras_variable", ir.dl_vector) - , diffusivity_var("diffusivity_spalart_allmaras_variable", ir.dl_scalar) - { - this->addEvaluatedField(grad_var); - this->addEvaluatedField(diffusivity_var); - this->setName( - "Incompressible Variable Diffusion Flux Unit Test Dependencies"); - } - - void evaluateFields(typename panzer::Traits::EvalData d) override - { - diffusivity_var.deep_copy(2.0); - - Kokkos::parallel_for( - "incompressible variable diffusion flux test dependencies", - Kokkos::RangePolicy(0, d.num_cells), - *this); - } - - KOKKOS_INLINE_FUNCTION void operator()(const int c) const - { - const int num_point = grad_var.extent(1); - const int num_space_dim = grad_var.extent(2); - using std::pow; - for (int qp = 0; qp < num_point; ++qp) - { - for (int dim = 0; dim < num_space_dim; ++dim) - { - grad_var(c, qp, dim) = 13.0 * (dim + 1); - } - } - } -}; - -template -void testEval() -{ - constexpr int num_space_dim = NumSpaceDim; - const int integration_order = 2; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - - const auto& ir = *test_fixture.ir; - - // Eval dependencies - const auto deps = Teuchos::rcp(new Dependencies(ir)); - test_fixture.registerEvaluator(deps); - - // Closure parameters - Teuchos::ParameterList closure_params; - closure_params.set("Field Name", "spalart_allmaras_variable"); - closure_params.set("Equation Name", "spalart_allmaras_equation"); - - // Initialize and register - auto eval = Teuchos::rcp( - new ClosureModel::IncompressibleVariableDiffusionFlux( - ir, closure_params)); - test_fixture.registerEvaluator(eval); - test_fixture.registerTestField(eval->_var_diff_flux); - test_fixture.evaluate(); - - // Evaluate test fields - const auto fv_var - = test_fixture.getTestFieldData(eval->_var_diff_flux); - - // Expected values - const int num_point = ir.num_points; - const double exp_var_diff_flux[3] = { - 26.0, - 52.0, - num_space_dim == 2 ? std::numeric_limits::quiet_NaN() : 78.0}; - - // Assert values - for (int qp = 0; qp < num_point; ++qp) - { - for (int dim = 0; dim < num_space_dim; ++dim) - { - EXPECT_EQ(exp_var_diff_flux[dim], fieldValue(fv_var, 0, qp, dim)); - } - } -} - -//-----------------------------------------------------------------// -TEST(IncompressibleVariableDiffusionFlux2D, residual_test) -{ - testEval(); -} - -//-----------------------------------------------------------------// -TEST(IncompressibleVariableDiffusionFlux2D, jacobian_test) -{ - testEval(); -} - -//-----------------------------------------------------------------// -TEST(IncompressibleVariableDiffusionFlux3D, residual_test) -{ - testEval(); -} - -//-----------------------------------------------------------------// -TEST(IncompressibleVariableDiffusionFlux3D, jacobian_test) -{ - testEval(); -} - -} // namespace Test -} // namespace VertexCFD diff --git a/src/turbulence_models/closure_models/unit_test/tstIncompressibleWALEEddyViscosity.cpp b/src/turbulence_models/closure_models/unit_test/tstIncompressibleWALEEddyViscosity.cpp deleted file mode 100644 index fa086f1..0000000 --- a/src/turbulence_models/closure_models/unit_test/tstIncompressibleWALEEddyViscosity.cpp +++ /dev/null @@ -1,147 +0,0 @@ -#include -#include - -#include - -#include - -namespace VertexCFD -{ -namespace Test -{ -template -struct Dependencies : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - using scalar_type = typename EvalType::ScalarT; - const double _nanval = std::numeric_limits::quiet_NaN(); - - PHX::MDField grad_vel_0; - PHX::MDField grad_vel_1; - PHX::MDField grad_vel_2; - PHX::MDField element_length; - - Dependencies(const panzer::IntegrationRule& ir) - : grad_vel_0("GRAD_velocity_0", ir.dl_vector) - , grad_vel_1("GRAD_velocity_1", ir.dl_vector) - , grad_vel_2("GRAD_velocity_2", ir.dl_vector) - , element_length("les_element_length", ir.dl_vector) - { - this->addEvaluatedField(grad_vel_0); - this->addEvaluatedField(grad_vel_1); - this->addEvaluatedField(grad_vel_2); - this->addEvaluatedField(element_length); - this->setName( - "Incompressible WALE Eddy Viscosity Unit " - "Test " - "Dependencies"); - } - - void evaluateFields(typename panzer::Traits::EvalData d) override - { - Kokkos::parallel_for( - "Incompressible WALE eddy viscosity test dependencies", - Kokkos::RangePolicy(0, d.num_cells), - *this); - } - - KOKKOS_INLINE_FUNCTION void operator()(const int c) const - { - const int num_point = grad_vel_0.extent(1); - const int num_space_dim = grad_vel_0.extent(2); - using std::pow; - - for (int qp = 0; qp < num_point; ++qp) - { - for (int dim = 0; dim < num_space_dim; ++dim) - { - const int sign = pow(-1, dim + 1); - const int dimqp = (dim + 1) * sign; - grad_vel_0(c, qp, dim) = 0.250 * dimqp; - grad_vel_1(c, qp, dim) = 0.500 * dimqp; - grad_vel_2(c, qp, dim) = num_space_dim == 3 ? 0.125 * dimqp - : _nanval; - element_length(c, qp, dim) = 0.750 * dimqp; - } - } - } -}; - -template -void testEval() -{ - const int num_space_dim = NumSpaceDim; - const int integration_order = 2; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_space_dim, integration_order, basis_order); - - const auto& ir = *test_fixture.ir; - - // Create parameter list for user-defined constants - Teuchos::ParameterList user_params; - user_params.sublist("Turbulence Parameters").set("C_w", 0.500); - user_params.sublist("Turbulence Parameters").set("C_k", 0.094); - - // Eval dependencies - const auto deps = Teuchos::rcp(new Dependencies(ir)); - test_fixture.registerEvaluator(deps); - - // Initialize and register - auto eval = Teuchos::rcp( - new ClosureModel::IncompressibleWALEEddyViscosity( - ir, user_params)); - test_fixture.registerEvaluator(eval); - test_fixture.registerTestField(eval->_nu_t); - test_fixture.registerTestField(eval->_k_sgs); - test_fixture.evaluate(); - - // Evaluate test fields - const auto fv_nu_t = test_fixture.getTestFieldData(eval->_nu_t); - const auto fv_k_sgs = test_fixture.getTestFieldData(eval->_k_sgs); - - // Expected values - const int num_point = ir.num_points; - - const double exp_nu_t = num_space_dim == 3 ? 0.04137844429829328 - : 0.14112104197373945; - const double exp_k_sgs = num_space_dim == 3 ? 0.024606058225685103 - : 0.8013741154973666; - - // Assert values - for (int qp = 0; qp < num_point; ++qp) - { - EXPECT_DOUBLE_EQ(exp_nu_t, fieldValue(fv_nu_t, 0, qp)); - EXPECT_DOUBLE_EQ(exp_k_sgs, fieldValue(fv_k_sgs, 0, qp)); - } -} - -//-----------------------------------------------------------------// -TEST(IncompressibleWALEEddyViscosity2D, residual_test) -{ - testEval(); -} - -//-----------------------------------------------------------------// -TEST(IncompressibleWALEEddyViscosity2D, jacobian_test) -{ - testEval(); -} - -//-----------------------------------------------------------------// -TEST(IncompressibleWALEEddyViscosity3D, residual_test) -{ - testEval(); -} - -//-----------------------------------------------------------------// -TEST(IncompressibleWALEEddyViscosity3D, jacobian_test) -{ - testEval(); -} - -//-----------------------------------------------------------------// -} // namespace Test -} // namespace VertexCFD diff --git a/src/utils/CMakeLists.txt b/src/utils/CMakeLists.txt deleted file mode 100644 index 8868550..0000000 --- a/src/utils/CMakeLists.txt +++ /dev/null @@ -1,57 +0,0 @@ -configure_file(VertexCFD_Utils_config.hpp.cmakein VertexCFD_Utils_config.hpp) - -set(UTILS_HEADERS - VertexCFD_EvaluatorBase.hpp - VertexCFD_Utils_Constants.hpp - VertexCFD_Utils_ExplicitTemplateInstantiation.hpp - VertexCFD_Utils_VectorField.hpp - VertexCFD_Utils_ParameterPack.hpp - VertexCFD_Utils_NonlinearSolver.hpp - VertexCFD_Utils_ScalarToVector.hpp - VertexCFD_Utils_SmoothMath.hpp - VertexCFD_Utils_VelocityDim.hpp - VertexCFD_Utils_VelocityLayout.hpp - VertexCFD_Utils_TypeTraits.hpp - VertexCFD_Utils_Version.hpp - VertexCFD_Utils_MatrixMath.hpp - VertexCFD_Utils_VectorizeOutputFieldNames.hpp - ) - -set(UTILS_SOURCES - VertexCFD_Utils_VelocityDim.cpp - VertexCFD_Utils_VelocityLayout.cpp - VertexCFD_Utils_Version.cpp - ) - -add_library(Utils ${UTILS_SOURCES}) - -target_link_libraries(Utils PUBLIC - MPI::MPI_CXX - Kokkos::kokkos - ) - -target_include_directories(Utils - PUBLIC - $ - $ - $) - -install(TARGETS Utils - EXPORT VertexCFDUtilsTargets - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) - -install(EXPORT VertexCFDUtilsTargets - FILE VertexCFDUtilsTargets.cmake - NAMESPACE VertexCFD:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/VertexCFD) - -install(FILES ${UTILS_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) - -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/VertexCFD_Utils_config.hpp DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) - -include(CMakePackageConfigHelpers) - -if(VertexCFD_ENABLE_TESTING) - add_subdirectory(unit_test) -endif() diff --git a/src/utils/VertexCFD_EvaluatorBase.hpp b/src/utils/VertexCFD_EvaluatorBase.hpp deleted file mode 100644 index 1df9a21..0000000 --- a/src/utils/VertexCFD_EvaluatorBase.hpp +++ /dev/null @@ -1,47 +0,0 @@ -#ifndef VERTEXCFD_EVALUATORBASE_HPP -#define VERTEXCFD_EVALUATORBASE_HPP - -#include - -#include -#include -#include - -#include - -namespace VertexCFD -{ -//---------------------------------------------------------------------------// -template -class EvaluatorBase : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - public: - using scalar_type = typename EvalType::ScalarT; - - EvaluatorBase(); - - void postRegistrationSetup(typename Traits::SetupData d, - PHX::FieldManager& vm) override; - void preEvaluate(typename Traits::PreEvalData d) override; - void evaluateFields(typename Traits::EvalData d) override; - void postEvaluate(typename Traits::PostEvalData d) override; - - protected: - virtual void postRegistrationSetupImpl(typename Traits::SetupData d, - PHX::FieldManager& vm); - virtual void preEvaluateImpl(typename Traits::PreEvalData d); - virtual void evaluateFieldsImpl(typename Traits::EvalData d) = 0; - virtual void postEvaluateImpl(typename Traits::PostEvalData d); - - private: - Teuchos::RCP _param_update_trigger; -}; - -//---------------------------------------------------------------------------// - -} // end namespace VertexCFD - -#include "VertexCFD_EvaluatorBase_impl.hpp" - -#endif // end VERTEXCFD_EVALUATORBASE_HPP diff --git a/src/utils/VertexCFD_EvaluatorBase_impl.hpp b/src/utils/VertexCFD_EvaluatorBase_impl.hpp deleted file mode 100644 index 7bce233..0000000 --- a/src/utils/VertexCFD_EvaluatorBase_impl.hpp +++ /dev/null @@ -1,77 +0,0 @@ -#ifndef VERTEXCFD_EVALUATORBASE_IMPL_HPP -#define VERTEXCFD_EVALUATORBASE_IMPL_HPP - -#include - -#include -#include - -namespace VertexCFD -{ -//---------------------------------------------------------------------------// -template -EvaluatorBase::EvaluatorBase() -{ - // Add scalar parameter trigger - auto dummy_layout = Teuchos::rcp(new PHX::MDALayout(0)); - _param_update_trigger = Teuchos::rcp( - new PHX::Tag("scalar_parameter_eval", dummy_layout)); - this->addDependentField(*_param_update_trigger); -} - -//---------------------------------------------------------------------------// -template -void EvaluatorBase::postRegistrationSetup( - typename Traits::SetupData d, PHX::FieldManager& vm) -{ - this->postRegistrationSetupImpl(d, vm); -} - -//---------------------------------------------------------------------------// -template -void EvaluatorBase::preEvaluate(typename Traits::PreEvalData d) -{ - this->preEvaluateImpl(d); -} - -//---------------------------------------------------------------------------// -template -void EvaluatorBase::evaluateFields(typename Traits::EvalData d) -{ - this->evaluateFieldsImpl(d); -} - -//---------------------------------------------------------------------------// -template -void EvaluatorBase::postEvaluate( - typename Traits::PostEvalData d) -{ - this->postEvaluateImpl(d); -} - -//---------------------------------------------------------------------------// -template -void EvaluatorBase::postRegistrationSetupImpl( - typename Traits::SetupData, PHX::FieldManager&) -{ -} - -//---------------------------------------------------------------------------// -template -void - EvaluatorBase::preEvaluateImpl(typename Traits::PreEvalData) -{ -} - -//---------------------------------------------------------------------------// -template -void EvaluatorBase::postEvaluateImpl( - typename Traits::PostEvalData) -{ -} - -//---------------------------------------------------------------------------// - -} // end namespace VertexCFD - -#endif // end VERTEXCFD_EVALUATORBASE_IMPL_HPP diff --git a/src/utils/VertexCFD_Utils_Constants.hpp b/src/utils/VertexCFD_Utils_Constants.hpp deleted file mode 100644 index 0dbd838..0000000 --- a/src/utils/VertexCFD_Utils_Constants.hpp +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef VERTEXCFD_UTILS_CONSTANTS_HPP -#define VERTEXCFD_UTILS_CONSTANTS_HPP - -#include -#include - -namespace VertexCFD -{ -namespace Constants -{ -// Generic pi for any floating point type. -template -constexpr T pi_v = std::enable_if_t::value, T>{ - 3.141592653589793238462643383279502884L}; - -// Most common case. -constexpr double pi = pi_v; - -} // namespace Constants -} // namespace VertexCFD - -#endif // VERTEXCFD_UTILS_CONSTANTS_HPP diff --git a/src/utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp b/src/utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp deleted file mode 100644 index 8253e83..0000000 --- a/src/utils/VertexCFD_Utils_ExplicitTemplateInstantiation.hpp +++ /dev/null @@ -1,47 +0,0 @@ -#ifndef VERTEXCFD_UTILS_EXPLICITTEMPLATEINSTANTIATION_HPP -#define VERTEXCFD_UTILS_EXPLICITTEMPLATEINSTANTIATION_HPP - -#include -#include - -// Explicit instantation of standard panzer classes. -#define VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL(name) \ - PANZER_INSTANTIATE_TEMPLATE_CLASS_ONE_T(name) - -// Explicit instantation of standard panzer classes. -#define VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS(name) \ - PANZER_INSTANTIATE_TEMPLATE_CLASS_TWO_T(name) - -// Explicit instantation of classes. -#define VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_RESIDUAL_NUMSPACEDIM(name) \ - template class name; \ - template class name; - -#define VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_TANGENT_NUMSPACEDIM(name) \ - template class name; \ - template class name; - -#define VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_JACOBIAN_NUMSPACEDIM(name) \ - template class name; \ - template class name; - -#ifdef Panzer_BUILD_HESSIAN_SUPPORT -#define VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_HESSIAN_NUMSPACEDIM(name) \ - template class name; \ - template class name; -#else -#define VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_HESSIAN_NUMSPACEDIM(name) -#endif - -#define VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_NUMSPACEDIM(name) \ - VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_RESIDUAL_NUMSPACEDIM(name) \ - VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_TANGENT_NUMSPACEDIM(name) \ - VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_JACOBIAN_NUMSPACEDIM(name) \ - VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_HESSIAN_NUMSPACEDIM(name) - -// Explicit instantation of classes. -#define VERTEXCFD_INSTANTIATE_TEMPLATE_CLASS_EVAL_TRAITS_NUMSPACEDIM(name) \ - PANZER_INSTANTIATE_TEMPLATE_CLASS_THREE_T(name, 2) \ - PANZER_INSTANTIATE_TEMPLATE_CLASS_THREE_T(name, 3) - -#endif // end VERTEXCFD_UTILS_EXPLICITTEMPLATEINSTANTIATION_HPP diff --git a/src/utils/VertexCFD_Utils_KokkosFadFixup.hpp b/src/utils/VertexCFD_Utils_KokkosFadFixup.hpp deleted file mode 100644 index 229ea00..0000000 --- a/src/utils/VertexCFD_Utils_KokkosFadFixup.hpp +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef VERTEXCFD_UTILS_KOKKOSFADFIXUP_HPP -#define VERTEXCFD_UTILS_KOKKOSFADFIXUP_HPP - -// This file brings in certain Kokkos instantiations that need to precede any -// VertexCFD includes any time a panzer::FunctionalResponse_Builder is used -#include - -#endif // end VERTEXCFD_UTILS_KOKKOSFADFIXUP_HPP diff --git a/src/utils/VertexCFD_Utils_MatrixMath.hpp b/src/utils/VertexCFD_Utils_MatrixMath.hpp deleted file mode 100644 index 77e92b3..0000000 --- a/src/utils/VertexCFD_Utils_MatrixMath.hpp +++ /dev/null @@ -1,105 +0,0 @@ -#ifndef VERTEXCFD_UTILS_MATRIXMATH_HPP -#define VERTEXCFD_UTILS_MATRIXMATH_HPP - -#include "VertexCFD_Utils_Constants.hpp" -#include "VertexCFD_Utils_TypeTraits.hpp" - -#include - -#include - -namespace VertexCFD -{ -namespace MatrixMath -{ -//---------------------------------------------------------------------------// -// LU decomposition (partial pivoting). -// Finds permutation p and rewrites matrix A so that A[[p]] = LU -// Input matrix A must have full rank or division by zero pivot may occur -//---------------------------------------------------------------------------// -template -KOKKOS_INLINE_FUNCTION void LUP(Matrix& A, Permutation& p) -{ - using std::abs; - - const int N = p.extent(0); - - using value_type = typename Matrix::value_type; - - // Initialize permutation vector - for (int i = 0; i < N; ++i) - p(i) = i; - - for (int k = 0; k < N; ++k) - { - int pivot = k; - // max is only used for finding the pivot so doesn't need derivatives. - double max = abs(Sacado::ScalarValue::eval(A(p(pivot), k))); - - for (int i = k + 1; i < N; ++i) - { - const int row = p(i); - // temp is only used for finding the pivot so doesn't need - // derivatives. - const double temp - = abs(Sacado::ScalarValue::eval(A(row, k))); - if (temp > max) - { - max = temp; - pivot = i; - } - } - - if (p(pivot) != p(k)) - { - const int swap = p(pivot); - p(pivot) = p(k); - p(k) = swap; - } - - pivot = p(k); - for (int i = k + 1; i < N; ++i) - { - const int row = p(i); - A(row, k) /= A(pivot, k); - for (int j = k + 1; j < N; ++j) - A(row, j) -= A(row, k) * A(pivot, j); - } - } -} - -//---------------------------------------------------------------------------// -// LU solve (partial pivoting). -// Takes matrix A and permutation p such that A[[p]] = LU and solves Ax = b -// Solution vector is stored in b upon completion. -//---------------------------------------------------------------------------// -template -KOKKOS_INLINE_FUNCTION void -LUP_solve(const Matrix& LU, const Permutation& p, Vector& work, Vector& b) -{ - const int N = p.extent(0); - - for (int i = 0; i < N; ++i) - work(i) = b(i); - - for (int i = 1; i < N; ++i) - for (int j = 0; j < i; ++j) - work(p(i)) -= LU(p(i), j) * work(p(j)); - - for (int i = N - 1; i >= 0; --i) - { - for (int j = i + 1; j < N; ++j) - work(p(i)) -= LU(p(i), j) * work(p(j)); - - work(p(i)) /= LU(p(i), i); - } - - for (int i = 0; i < N; ++i) - b(i) = work(p(i)); -} -//---------------------------------------------------------------------------// - -} // end namespace MatrixMath -} // end namespace VertexCFD - -#endif // end VERTEXCFD_UTILS_MATRIXMATH_HPP diff --git a/src/utils/VertexCFD_Utils_NonlinearSolver.hpp b/src/utils/VertexCFD_Utils_NonlinearSolver.hpp deleted file mode 100644 index 64be831..0000000 --- a/src/utils/VertexCFD_Utils_NonlinearSolver.hpp +++ /dev/null @@ -1,292 +0,0 @@ -#ifndef VERTEXCFD_UTILS_NONLINEARSOLVER_HPP -#define VERTEXCFD_UTILS_NONLINEARSOLVER_HPP - -#include - -#include -#include - -#include -#include - -namespace VertexCFD -{ -namespace Utils -{ -namespace NonlinearSolver -{ -namespace Impl -{ -//---------------------------------------------------------------------------// -// Access an element of the residual. -template -KOKKOS_INLINE_FUNCTION Scalar -f_i(const Kokkos::Array, N>& f_eval, - const int i) -{ - static_assert(N == NumDeriv, "Jacobian must be square"); - return f_eval[i].val(); -} - -//---------------------------------------------------------------------------// -// Access an element of the Jacobian. -template -KOKKOS_INLINE_FUNCTION Scalar -J_ij(const Kokkos::Array, N>& f_eval, - const int i, - const int j) -{ - static_assert(N == NumDeriv, "Jacobian must be square"); - return f_eval[i].fastAccessDx(j); -} - -//---------------------------------------------------------------------------// -// Jacobian determinant. -template -KOKKOS_INLINE_FUNCTION Scalar -detJ(const Kokkos::Array, 1>& f_eval) -{ - return J_ij(f_eval, 0, 0); -} - -//---------------------------------------------------------------------------// -// Jacobian determinant. -template -KOKKOS_INLINE_FUNCTION Scalar -detJ(const Kokkos::Array, 2>& f_eval) -{ - return J_ij(f_eval, 0, 0) * J_ij(f_eval, 1, 1) - - J_ij(f_eval, 0, 1) * J_ij(f_eval, 1, 0); -} - -//---------------------------------------------------------------------------// -// Jacobian determinant. -template -KOKKOS_INLINE_FUNCTION Scalar -detJ(const Kokkos::Array, 3>& f_eval) -{ - return J_ij(f_eval, 0, 0) * J_ij(f_eval, 1, 1) * J_ij(f_eval, 2, 2) - + J_ij(f_eval, 0, 1) * J_ij(f_eval, 1, 2) * J_ij(f_eval, 2, 0) - + J_ij(f_eval, 0, 2) * J_ij(f_eval, 1, 0) * J_ij(f_eval, 2, 1) - - J_ij(f_eval, 0, 2) * J_ij(f_eval, 1, 1) * J_ij(f_eval, 2, 0) - - J_ij(f_eval, 0, 1) * J_ij(f_eval, 1, 0) * J_ij(f_eval, 2, 2) - - J_ij(f_eval, 0, 0) * J_ij(f_eval, 1, 2) * J_ij(f_eval, 2, 1); -} - -//---------------------------------------------------------------------------// -// Jacobian inverse. -template -KOKKOS_INLINE_FUNCTION bool -invJ(Kokkos::Array, 1>& J_inv, - const Kokkos::Array, 1>& f_eval, - const typename Sacado::ScalarType::type degen_j_tol) -{ - using std::abs; - Scalar det_j = detJ(f_eval); - if (abs(Sacado::ScalarValue::eval(det_j)) < degen_j_tol) - { - return false; - } - J_inv[0][0] = 1.0 / det_j; - return true; -} - -//---------------------------------------------------------------------------// -// Jacobian inverse. -template -KOKKOS_INLINE_FUNCTION bool -invJ(Kokkos::Array, 2>& J_inv, - const Kokkos::Array, 2>& f_eval, - const typename Sacado::ScalarType::type degen_j_tol) -{ - using std::abs; - Scalar det_j = detJ(f_eval); - if (abs(Sacado::ScalarValue::eval(det_j)) < degen_j_tol) - { - return false; - } - Scalar det_j_inv = 1.0 / det_j; - J_inv[0][0] = J_ij(f_eval, 1, 1) * det_j_inv; - J_inv[0][1] = -J_ij(f_eval, 0, 1) * det_j_inv; - J_inv[1][0] = -J_ij(f_eval, 1, 0) * det_j_inv; - J_inv[1][1] = J_ij(f_eval, 0, 0) * det_j_inv; - return true; -} - -//---------------------------------------------------------------------------// -// Jacobian inverse. -template -KOKKOS_INLINE_FUNCTION bool -invJ(Kokkos::Array, 3>& J_inv, - const Kokkos::Array, 3>& f_eval, - const typename Sacado::ScalarType::type degen_j_tol) -{ - using std::abs; - Scalar det_j = detJ(f_eval); - if (abs(Sacado::ScalarValue::eval(det_j)) < degen_j_tol) - { - return false; - } - Scalar det_j_inv = 1.0 / det_j; - - J_inv[0][0] = (J_ij(f_eval, 1, 1) * J_ij(f_eval, 2, 2) - - J_ij(f_eval, 1, 2) * J_ij(f_eval, 2, 1)) - * det_j_inv; - J_inv[0][1] = (J_ij(f_eval, 0, 2) * J_ij(f_eval, 2, 1) - - J_ij(f_eval, 0, 1) * J_ij(f_eval, 2, 2)) - * det_j_inv; - J_inv[0][2] = (J_ij(f_eval, 0, 1) * J_ij(f_eval, 1, 2) - - J_ij(f_eval, 0, 2) * J_ij(f_eval, 1, 1)) - * det_j_inv; - - J_inv[1][0] = (J_ij(f_eval, 1, 2) * J_ij(f_eval, 2, 0) - - J_ij(f_eval, 1, 0) * J_ij(f_eval, 2, 2)) - * det_j_inv; - J_inv[1][1] = (J_ij(f_eval, 0, 0) * J_ij(f_eval, 2, 2) - - J_ij(f_eval, 0, 2) * J_ij(f_eval, 2, 0)) - * det_j_inv; - J_inv[1][2] = (J_ij(f_eval, 0, 2) * J_ij(f_eval, 1, 0) - - J_ij(f_eval, 0, 0) * J_ij(f_eval, 1, 2)) - * det_j_inv; - - J_inv[2][0] = (J_ij(f_eval, 1, 0) * J_ij(f_eval, 2, 1) - - J_ij(f_eval, 1, 1) * J_ij(f_eval, 2, 0)) - * det_j_inv; - J_inv[2][1] = (J_ij(f_eval, 0, 1) * J_ij(f_eval, 2, 0) - - J_ij(f_eval, 0, 0) * J_ij(f_eval, 2, 1)) - * det_j_inv; - J_inv[2][2] = (J_ij(f_eval, 0, 0) * J_ij(f_eval, 1, 1) - - J_ij(f_eval, 0, 1) * J_ij(f_eval, 1, 0)) - * det_j_inv; - - return true; -} - -//---------------------------------------------------------------------------// -// Evaluate and differentiate the residual -template -KOKKOS_INLINE_FUNCTION void -evaluateResidual(Kokkos::Array, N>& f_eval, - Kokkos::Array, N>& u, - const Kokkos::Array& x, - const ResidualFunc& F) -{ - static_assert(N == NumDeriv, "Jacobian must be square"); - - // Setup derivatives. - for (std::size_t i = 0; i < N; ++i) - { - u[i] = x[i]; - u[i].diff(i, N); - } - - // Evaluate and differentiate the residual. - F(u, f_eval); -} - -//---------------------------------------------------------------------------// -// Update the solution using Newton's method. -template -KOKKOS_INLINE_FUNCTION bool updateSolution( - Kokkos::Array& x, - Kokkos::Array, N>& J_inv, - const Kokkos::Array, N>& f_eval, - const typename Sacado::ScalarType::type degen_j_tol) -{ - static_assert(N == NumDeriv, "Jacobian must be square"); - - // Invert the Jacobian and check for degeneracy. - bool success = invJ(J_inv, f_eval, degen_j_tol); - if (!success) - { - return false; - } - - // Solve the linear problem: update = J^-1 * -F(u) and - // apply the update: x += update - for (std::size_t i = 0; i < N; ++i) - { - for (std::size_t j = 0; j < N; ++j) - { - x[i] -= J_inv[i][j] * f_i(f_eval, j); - } - } - return true; -} - -//---------------------------------------------------------------------------// - -} // end namespace Impl - -//---------------------------------------------------------------------------// -// Perform a thread-local nonlinear solve with Newton's method. -// -// An initial guess is given by x and the solution is also output in x. -// -// The Residual Func signature accepts a const Kokkos array for x and a -// non-const Kokkos array for the residual evaluation. -// -// This function returns false if convergence was not achieved. -template -KOKKOS_INLINE_FUNCTION bool -solve(Kokkos::Array& x, - const ResidualFunc& F, - const typename Sacado::ScalarType::type newton_tolerance, - const int max_iters) -{ - using std::abs; - using fad_type = Sacado::Fad::SFad; - using value_type = typename Sacado::ScalarType::type; - - // Evaluate the initial residual and Jacobian. - Kokkos::Array u; - Kokkos::Array f_eval; - Impl::evaluateResidual(f_eval, u, x, F); - - // Iterate until converged or maximum iteration count is reached. - Kokkos::Array, N> J_inv; - value_type j_tol = 10.0 * Kokkos::Experimental::epsilon::value; - for (int k = 0; k < max_iters; ++k) - { - // Update the solution. - bool success = Impl::updateSolution(x, J_inv, f_eval, j_tol); - - // Check for degeneracy of the Jacobian. If it is degenerate then the - // problem is ill-conditioned and we don't expect convergence. - if (!success) - { - return false; - } - - // Check for convergence of the absolute infinity norm of the - // residual. - bool is_converged = true; - for (std::size_t i = 0; i < N; ++i) - { - if (newton_tolerance - < abs(Sacado::ScalarValue::eval(f_eval[i]))) - { - is_converged = false; - break; - } - } - if (is_converged) - { - return true; - } - - // Evaluate the residual and Jacobian. - Impl::evaluateResidual(f_eval, u, x, F); - } - - // Convergence was not achieved within the maxiumum number of iterations. - return false; -} - -//---------------------------------------------------------------------------// - -} // end namespace NonlinearSolver -} // end namespace Utils -} // end namespace VertexCFD - -#endif // end VERTEXCFD_UTILS_NONLINEARSOLVER_HPP diff --git a/src/utils/VertexCFD_Utils_ParameterPack.hpp b/src/utils/VertexCFD_Utils_ParameterPack.hpp deleted file mode 100644 index bbbed4e..0000000 --- a/src/utils/VertexCFD_Utils_ParameterPack.hpp +++ /dev/null @@ -1,184 +0,0 @@ -#ifndef VERTEXCFD_PARAMETERPACK_HPP -#define VERTEXCFD_PARAMETERPACK_HPP - -#include - -#include -#include - -namespace VertexCFD -{ -namespace Utils -{ -//---------------------------------------------------------------------------// -// Parameter pack device capture. -// -// NOTE: In general this would not be needed but NVCC cannot capture parameter -// packs in lambda functions hence we need to wrap them in something that can -// be captured. -//---------------------------------------------------------------------------// -// Get the type at the given index of a paremeter pack. -template -struct PackTypeAtIndexImpl; - -template -struct PackTypeAtIndexImpl<0, T, Types...> -{ - using type = T; -}; - -template -struct PackTypeAtIndexImpl -{ - using type = typename PackTypeAtIndexImpl::type; -}; - -template -struct PackTypeAtIndex -{ - using type = typename PackTypeAtIndexImpl::type; - static_assert(N < sizeof...(Types), "Type index out of bounds"); -}; - -//---------------------------------------------------------------------------// -// Parameter pack element. -template -struct ParameterPackElement -{ - T _m; -}; - -//---------------------------------------------------------------------------// -// Capture a parameter pack. All parameter pack elements must be copyable to -// device. -template -struct ParameterPackImpl; - -template -struct ParameterPackImpl, Types...> - : ParameterPackElement... -{ -}; - -template -struct ParameterPack - : ParameterPackImpl, Types...> -{ - template - using value_type = typename PackTypeAtIndex::type; - - template - using const_value_type = typename std::add_const>::type; - - template - using element_type = ParameterPackElement>; - - static constexpr std::size_t size = sizeof...(Types); -}; - -//---------------------------------------------------------------------------// -// Static type checker. -template -struct is_parameter_pack_impl : public std::false_type -{ -}; - -template -struct is_parameter_pack_impl> : public std::true_type -{ -}; - -template -struct is_parameter_pack - : public is_parameter_pack_impl::type>::type -{ -}; - -//---------------------------------------------------------------------------// - -} // end namespace Utils - -//---------------------------------------------------------------------------// -// Get an element from a parameter pack. Note that this has been inserted in -// the main VertexCFD namespace as it will be used heavily. -template -KOKKOS_FORCEINLINE_FUNCTION - typename std::enable_if::value, - typename ParameterPack_t::template value_type&>::type - get(ParameterPack_t& pp) -{ - return static_cast&>(pp) - ._m; -} - -template -KOKKOS_FORCEINLINE_FUNCTION typename std::enable_if< - Utils::is_parameter_pack::value, - typename ParameterPack_t::template const_value_type&>::type -get(const ParameterPack_t& pp) -{ - return static_cast&>( - pp) - ._m; -} - -//---------------------------------------------------------------------------// -namespace Utils -{ -//---------------------------------------------------------------------------// -// Fill a parameter pack. Note the indexing is such that the Nth element of a -// parameter pack is the Nth element of the tuple. -template -void fillParameterPackImpl(ParameterPack_t& pp, - const std::integral_constant, - const T& t, - const Types&...) -{ - get(pp) = t; -} - -template -void fillParameterPackImpl(ParameterPack_t& pp, - const std::integral_constant, - const T& t, - const Types&... ts) -{ - get(pp) = t; - fillParameterPackImpl( - pp, std::integral_constant(), ts...); -} - -template -void fillParameterPack(ParameterPack_t& pp, const Types&... ts) -{ - fillParameterPackImpl( - pp, - std::integral_constant(), - ts...); -} - -// Empty case. -template -void fillParameterPack(ParameterPack_t&) -{ -} - -//---------------------------------------------------------------------------// -// Create a parameter pack. -template -ParameterPack makeParameterPack(const Types&... ts) -{ - ParameterPack pp; - fillParameterPack(pp, ts...); - return pp; -} - -//---------------------------------------------------------------------------// - -} // end namespace Utils - -//---------------------------------------------------------------------------// - -} // end namespace VertexCFD - -#endif // end VERTEXCFD_PARAMETERPACK_HPP diff --git a/src/utils/VertexCFD_Utils_ScalarFieldView.hpp b/src/utils/VertexCFD_Utils_ScalarFieldView.hpp deleted file mode 100644 index 15fe161..0000000 --- a/src/utils/VertexCFD_Utils_ScalarFieldView.hpp +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef VERTEXCFD_UTILS_SCALARFIELDVIEW_HPP -#define VERTEXCFD_UTILS_SCALARFIELDVIEW_HPP - -#include -#include -#include - -#include -#include - -#include - -#include - -namespace VertexCFD -{ -namespace Utils -{ -//---------------------------------------------------------------------------// -// This function registers an evaluated Kokkos View of scalar fields indexed by -// the number of equations. -template -void addEvaluatedScalarFieldView( - PHX::EvaluatorWithBaseImpl& f, - const Teuchos::RCP& data_layout, - const int num_entries, - Kokkos::View*>& kokkos_view, - const std::string& base_name) -{ - for (int entry = 0; entry < num_entries; ++entry) - { - const std::string name = base_name + std::to_string(entry); - kokkos_view(entry) - = PHX::MDField(name, data_layout); - f.addEvaluatedField(kokkos_view(entry)); - } -} - -//---------------------------------------------------------------------------// -// This function registers a dependent Kokkos View of fields indexed by -// the number of velocity equations. -template -void addDependentScalarFieldView( - PHX::EvaluatorWithBaseImpl& f, - const Teuchos::RCP& data_layout, - const int num_entries, - Kokkos::View*>& kokkos_view, - const std::string& base_name) -{ - for (int entry = 0; entry < num_entries; ++entry) - { - const std::string name = base_name + std::to_string(entry); - kokkos_view(entry) - = PHX::MDField(name, data_layout); - f.addDependentField(kokkos_view(entry)); - } -} - -} // end namespace Utils -} // end namespace VertexCFD - -#endif // end VERTEXCFD_UTILS_SCALARFIELDVIEW_HPP diff --git a/src/utils/VertexCFD_Utils_ScalarToVector.hpp b/src/utils/VertexCFD_Utils_ScalarToVector.hpp deleted file mode 100644 index 2a18b7b..0000000 --- a/src/utils/VertexCFD_Utils_ScalarToVector.hpp +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef VERTEXCFD_UTILS_SCALARTOVECTOR_HPP -#define VERTEXCFD_UTILS_SCALARTOVECTOR_HPP - -#include -#include - -#include -#include - -namespace VertexCFD -{ -namespace Utils -{ -//---------------------------------------------------------------------------// -template -class ScalarToVector : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - private: - using ScalarT = typename EvalType::ScalarT; - - public: - ScalarToVector(const panzer::IntegrationRule& ir, - const std::string& field_name, - const int num_scalars, - const bool time_deriv); - - void evaluateFields(typename panzer::Traits::EvalData); - - private: - // Dependent scalar fields - std::vector> - _scalar_fields; - std::vector> - _scalar_dxdt_fields; - std::vector< - PHX::MDField> - _scalar_grad_fields; - - public: - // Evaluated vector fields - PHX::MDField _vector_fields; - PHX::MDField _vector_dxdt_fields; - PHX::MDField - _vector_grad_fields; -}; - -//---------------------------------------------------------------------------// - -} // namespace Utils -} // namespace VertexCFD - -#include "VertexCFD_Utils_ScalarToVector_impl.hpp" - -#endif // VERTEXCFD_UTILS_SCALARTOVECTOR_HPP diff --git a/src/utils/VertexCFD_Utils_ScalarToVector_impl.hpp b/src/utils/VertexCFD_Utils_ScalarToVector_impl.hpp deleted file mode 100644 index 800ffae..0000000 --- a/src/utils/VertexCFD_Utils_ScalarToVector_impl.hpp +++ /dev/null @@ -1,139 +0,0 @@ -#ifndef VERTEXCFD_UTILS_SCALARTOVECTOR_IMPL_HPP -#define VERTEXCFD_UTILS_SCALARTOVECTOR_IMPL_HPP - -#include "VertexCFD_Utils_ScalarToVector.hpp" - -#include - -#include - -namespace VertexCFD -{ -namespace Utils -{ -//---------------------------------------------------------------------------// -template -ScalarToVector::ScalarToVector( - const panzer::IntegrationRule& ir, - const std::string& field_name, - const int num_scalars, - const bool time_deriv) -{ - // Build scalar and gradient fields - _scalar_fields.reserve(num_scalars); - _scalar_grad_fields.reserve(num_scalars); - std::string name; - for (int sc = 0; sc < num_scalars; ++sc) - { - name = field_name + "_" + std::to_string(sc); - _scalar_fields.emplace_back(name, ir.dl_scalar); - - name = "GRAD_" + field_name + "_" + std::to_string(sc); - _scalar_grad_fields.emplace_back(name, ir.dl_vector); - } - - // Create new data layout for vector component - Teuchos::RCP vector_layout; - - // field is Cell, Point - vector_layout - = Teuchos::rcp(new PHX::MDALayout( - ir.dl_scalar->extent(0), ir.dl_scalar->extent(1), num_scalars)); - _vector_fields = PHX::MDField( - field_name, vector_layout); - - // GRAD field is Cell, Point, Dim - vector_layout = Teuchos::rcp( - new PHX::MDALayout( - ir.dl_vector->extent(0), - ir.dl_vector->extent(1), - ir.dl_vector->extent(2), - num_scalars)); - _vector_grad_fields - = PHX::MDField( - "GRAD_" + field_name, vector_layout); - - // Add dependent/evaluated fields - this->addEvaluatedField(_vector_fields); - this->addEvaluatedField(_vector_grad_fields); - - for (int sc = 0; sc < num_scalars; ++sc) - { - this->addDependentField(_scalar_fields[sc]); - this->addDependentField(_scalar_grad_fields[sc]); - } - - // Add time-derivative components if requested - if (time_deriv) - { - // Set up scalar fields - _scalar_dxdt_fields.reserve(num_scalars); - for (int sc = 0; sc < num_scalars; ++sc) - { - name = "DXDT_" + field_name + "_" + std::to_string(sc); - _scalar_dxdt_fields.emplace_back(name, ir.dl_scalar); - } - - // Create vector layout/field - vector_layout = Teuchos::rcp( - new PHX::MDALayout( - ir.dl_scalar->extent(0), ir.dl_scalar->extent(1), num_scalars)); - _vector_dxdt_fields - = PHX::MDField( - "DXDT_" + field_name, vector_layout); - - // Register fields - this->addEvaluatedField(_vector_dxdt_fields); - for (int sc = 0; sc < num_scalars; ++sc) - this->addDependentField(_scalar_dxdt_fields[sc]); - } - - this->setName("ScalarToVector"); -} - -//---------------------------------------------------------------------------// -template -void ScalarToVector::evaluateFields( - typename panzer::Traits::EvalData) -{ - const int num_scalars = _scalar_fields.size(); - - // Process scalars sequentially - for (int sc = 0; sc < num_scalars; ++sc) - { - // Copy field - auto scalar_field_view = _scalar_fields[sc].get_view(); - auto vector_field_view = Kokkos::subview( - _vector_fields.get_view(), Kokkos::ALL(), Kokkos::ALL(), sc); - Kokkos::deep_copy(vector_field_view, scalar_field_view); - - if (_scalar_dxdt_fields.size() > 0) - { - // Copy DXDT field - auto scalar_dxdt_field_view = _scalar_dxdt_fields[sc].get_view(); - auto vector_dxdt_field_view - = Kokkos::subview(_vector_dxdt_fields.get_view(), - Kokkos::ALL(), - Kokkos::ALL(), - sc); - Kokkos::deep_copy(vector_dxdt_field_view, scalar_dxdt_field_view); - } - - // Copy GRAD field - auto scalar_grad_field_view = _scalar_grad_fields[sc].get_view(); - auto vector_grad_field_view - = Kokkos::subview(_vector_grad_fields.get_view(), - Kokkos::ALL(), - Kokkos::ALL(), - Kokkos::ALL(), - sc); - Kokkos::deep_copy(vector_grad_field_view, scalar_grad_field_view); - } -} - -//---------------------------------------------------------------------------// - -} // namespace Utils -} // namespace VertexCFD - -#endif // VERTEXCFD_UTILS_SCALARTOVECTOR_IMPL_HPP diff --git a/src/utils/VertexCFD_Utils_SmoothMath.hpp b/src/utils/VertexCFD_Utils_SmoothMath.hpp deleted file mode 100644 index 8ebd32b..0000000 --- a/src/utils/VertexCFD_Utils_SmoothMath.hpp +++ /dev/null @@ -1,250 +0,0 @@ -#ifndef VERTEXCFD_UTILS_SMOOTHMATH_HPP -#define VERTEXCFD_UTILS_SMOOTHMATH_HPP - -#include "VertexCFD_Utils_Constants.hpp" -#include "VertexCFD_Utils_TypeTraits.hpp" - -#include - -#include - -namespace VertexCFD -{ -namespace SmoothMath -{ -//---------------------------------------------------------------------------// -template -KOKKOS_INLINE_FUNCTION ResultType abs(const T& x, const double tol) -{ - if (x >= tol) - { - return x; - } - else if (x <= -tol) - { - return -x; - } - else - { - return 0.5 * (x * x / tol + tol); - } -} - -//---------------------------------------------------------------------------// -template -KOKKOS_INLINE_FUNCTION ResultType -max(const T1& x, const T2& y, const double tol) -{ - if (tol == 0.0) - { - if (x < y) - { - return y; - } - else - { - return x; - } - } - else - { - return 0.5 * (x + y + abs(x - y, tol)); - } -} - -//---------------------------------------------------------------------------// -template -KOKKOS_INLINE_FUNCTION ResultType -min(const T1& x, const T2& y, const double tol) -{ - if (tol == 0.0) - { - if (x > y) - { - return y; - } - else - { - return x; - } - } - else - { - return 0.5 * (x + y - abs(x - y, tol)); - } -} - -//---------------------------------------------------------------------------// -template -KOKKOS_INLINE_FUNCTION ResultType -clamp(const T1& x, const T2& lo, const T3& hi, const double tol) -{ - // Note: This could be implemented as min(max(x, lo, tol), hi, tol) or - // similar, but that would result in more temporary/intermediate values - // being allocated. - - // -inf < x < inf - if (x <= lo - tol) - { - return lo; - } - - // lo - tol < x < inf - else if (x >= hi + tol) - { - return hi; - } - - // lo - tol < x < hi + tol - else if (x < lo + tol) - { - // lo - tol < x < lo + tol => -tol < (x-lo) < tol - return 0.5 * (x + lo + 0.5 * ((x - lo) * (x - lo) / tol + tol)); - } - - // lo + tol <= x < hi + tol - else if (x > hi - tol) - { - // hi - tol < x < hi + tol => -tol < (x-hi) < tol - return 0.5 * (x + hi - 0.5 * ((x - hi) * (x - hi) / tol + tol)); - } - - // lo + tol <= x <= h - tol - else - { - return x; - } -} - -//---------------------------------------------------------------------------// -template -KOKKOS_INLINE_FUNCTION ResultType -ramp(const T1& x, const T2& start, const T3& end) -{ - using std::sin; - constexpr double half_pi = 0.5 * Constants::pi; - if (x <= start) - { - return 0.0; - } - else if (x >= end) - { - return 1.0; - } - else - { - return 0.5 - * (sin(half_pi * (2.0 * x - (start + end)) / (end - start)) - + 1.0); - } -} - -//---------------------------------------------------------------------------// -template -KOKKOS_INLINE_FUNCTION ResultType -hypot(const T1& x, const T2& y, const double tol) -{ - using std::sqrt; - - const ResultType dotp = x * x + y * y; - const double tol2 = tol * tol; - - if (tol2 <= dotp) - { - return sqrt(dotp); - } - else - { - return 0.5 * (dotp + tol2) / tol; - } -} - -//---------------------------------------------------------------------------// -template -KOKKOS_INLINE_FUNCTION ResultType -hypot(const T1& x, const T2& y, const T3& z, const double tol) -{ - using std::sqrt; - - const ResultType dotp = x * x + y * y + z * z; - const double tol2 = tol * tol; - - if (tol2 <= dotp) - { - return sqrt(dotp); - } - else - { - return 0.5 * (dotp + tol2) / tol; - } -} - -template> -KOKKOS_INLINE_FUNCTION ReturnType norm(const T1& v, const double tol) -{ - using std::sqrt; - - using scalar_type = std::remove_cv_t; - scalar_type dotp = 0.0; - int num_space_dim = v.size(); - - for (int i = 0; i < num_space_dim; ++i) - { - dotp += v[i] * v[i]; - } - - const double tol2 = tol * tol; - if (tol2 <= dotp) - { - return sqrt(dotp); - } - else - { - return 0.5 * (dotp + tol2) / tol; - } -} - -//---------------------------------------------------------------------------// -template> -KOKKOS_INLINE_FUNCTION ReturnType norm(const T1& v, - const T2& M, - const double tol) -{ - using std::sqrt; - - using scalar_type = std::remove_cv_t; - scalar_type xi = 0.0; - scalar_type row_sum; - - int num_space_dim = M.extent(0); - - for (int i = 0; i < num_space_dim; ++i) - { - row_sum = 0.0; - for (int j = 0; j < num_space_dim; ++j) - { - row_sum += M(i, j) * v[j]; - } - xi += v[i] * row_sum; - } - - const double tol2 = tol * tol; - if (tol2 <= xi) - { - return sqrt(xi); - } - else - { - return 0.5 * (xi + tol2) / tol; - } -} - -//---------------------------------------------------------------------------// - -} // end namespace SmoothMath -} // end namespace VertexCFD - -#endif // end VERTEXCFD_UTILS_SMOOTHMATH_HPP diff --git a/src/utils/VertexCFD_Utils_TypeTraits.hpp b/src/utils/VertexCFD_Utils_TypeTraits.hpp deleted file mode 100644 index fa8c952..0000000 --- a/src/utils/VertexCFD_Utils_TypeTraits.hpp +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef VERTEXCFD_TYPETRAITS_HPP -#define VERTEXCFD_TYPETRAITS_HPP - -#include - -namespace VertexCFD -{ -namespace Utils -{ -namespace Impl -{ -//---------------------------------------------------------------------------// -// Get the resulting scalar type from a combination of one or more types which -// may be standard arithmetic types, AD scalars, or AD expression templates. -// -// This may be used as the return type of a generic function of one or more -// arguments and will ensure that a valid type is returned. -//---------------------------------------------------------------------------// -template -struct ResultType; - -//---------------------------------------------------------------------------// -// For a single type, forward to Sacado type trait to get the base type of an -// expression. -template -struct ResultType -{ - using type = typename Sacado::BaseExprType::type; -}; - -//---------------------------------------------------------------------------// -// For two types, forward to Sacado type trait for the promoted type of a -// binary operation. -template -struct ResultType -{ - using type = typename Sacado::Promote::type; -}; - -//---------------------------------------------------------------------------// -// For more than two types, apply the above recursively to get a single result -// type. -template -struct ResultType -{ - using type = - typename ResultType::type, - Types...>::type; -}; -//---------------------------------------------------------------------------// -} // namespace Impl -} // namespace Utils - -//---------------------------------------------------------------------------// -// User-facing type alias for all of the above. -// Since the primary use case is for return types of generic functions, add -// this alias to the VertexCFD namespace to avoid unnecessary verbosity. -template -using ResultType = typename Utils::Impl::ResultType::type; - -} // namespace VertexCFD - -#endif diff --git a/src/utils/VertexCFD_Utils_VectorField.hpp b/src/utils/VertexCFD_Utils_VectorField.hpp deleted file mode 100644 index 3f8c891..0000000 --- a/src/utils/VertexCFD_Utils_VectorField.hpp +++ /dev/null @@ -1,90 +0,0 @@ -#ifndef VERTEXCFD_UTILS_VECTORFIELD_HPP -#define VERTEXCFD_UTILS_VECTORFIELD_HPP - -#include - -#include -#include -#include - -#include - -#include - -#include - -namespace VertexCFD -{ -namespace Utils -{ -//---------------------------------------------------------------------------// -// This function registers an evaluated Kokkos Array and also handles the -// special cases of initial conditions ('ics_data = true'). -template -void addEvaluatedVectorField( - PHX::EvaluatorWithBaseImpl& f, - const Teuchos::RCP& data_layout, - Kokkos::Array, NumSpaceDim>& kokkos_array, - const std::string& scalar_name, - const bool unshared = false) -{ - constexpr size_t num_space_dim = NumSpaceDim; - - for (size_t dim = 0; dim < num_space_dim; ++dim) - { - std::string name = scalar_name + std::to_string(dim); - kokkos_array[dim] - = PHX::MDField(name, data_layout); - f.addEvaluatedField(kokkos_array[dim]); - if (unshared) - f.addUnsharedField(kokkos_array[dim].fieldTag().clone()); - } -} - -//---------------------------------------------------------------------------// -// This function registers a contributed Kokkos Array -template -void addContributedVectorField( - PHX::EvaluatorWithBaseImpl& f, - const Teuchos::RCP& data_layout, - Kokkos::Array, NumSpaceDim>& kokkos_array, - const std::string& scalar_name) -{ - constexpr size_t num_space_dim = NumSpaceDim; - - for (size_t dim = 0; dim < num_space_dim; ++dim) - { - std::string name = scalar_name + std::to_string(dim); - kokkos_array[dim] - = PHX::MDField(name, data_layout); - f.addContributedField(kokkos_array[dim]); - } -} - -//---------------------------------------------------------------------------// -// This function registers a dependent Kokkos Array -template -void addDependentVectorField( - PHX::EvaluatorWithBaseImpl& f, - const Teuchos::RCP& data_layout, - Kokkos::Array, NumSpaceDim>& - kokkos_array, - const std::string& scalar_name) -{ - constexpr size_t num_space_dim = NumSpaceDim; - - for (size_t dim = 0; dim < num_space_dim; ++dim) - { - std::string name = scalar_name + std::to_string(dim); - kokkos_array[dim] - = PHX::MDField(name, data_layout); - f.addDependentField(kokkos_array[dim]); - } -} - -//---------------------------------------------------------------------------// - -} // end namespace Utils -} // end namespace VertexCFD - -#endif // end VERTEXCFD_UTILS_VECTORFIELD_HPP diff --git a/src/utils/VertexCFD_Utils_VectorizeOutputFieldNames.hpp b/src/utils/VertexCFD_Utils_VectorizeOutputFieldNames.hpp deleted file mode 100644 index f8d3f7d..0000000 --- a/src/utils/VertexCFD_Utils_VectorizeOutputFieldNames.hpp +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef VERTEXCFD_UTILS_VECTORIZEOUTPUTFIELDNAMES_HPP -#define VERTEXCFD_UTILS_VECTORIZEOUTPUTFIELDNAMES_HPP - -#include -#include - -#include - -namespace VertexCFD -{ -namespace VectorizeOutputFieldNames -{ -inline std::vector tokenizeParameter( - const Teuchos::StringIndexedOrderedValueObjectContainerBase::KeyObjectPair< - Teuchos::ParameterEntry> p) -{ - const auto& fields = Teuchos::any_cast(p.second.getAny()); - std::vector tokens; - panzer::StringTokenizer(tokens, fields, ",", true); - return tokens; -} - -inline void getOutputFieldsByType(const Teuchos::ParameterList& params, - std::vector& fields) -{ - for (const auto& param : params) - { - const auto tokens = tokenizeParameter(param); - fields.insert(fields.end(), tokens.begin(), tokens.end()); - } -} - -inline void getOutputFields(const Teuchos::ParameterList& params, - std::vector& out_fields, - std::vector& out_vec_fields) -{ - // get the "Quantities" output names - getOutputFieldsByType(params.sublist("Nodal Quantities"), out_fields); - getOutputFieldsByType(params.sublist("Cell Quantities"), out_fields); - getOutputFieldsByType(params.sublist("Cell Average Quantities"), - out_fields); - // get rid of repeated names - std::set out_set(out_fields.begin(), out_fields.end()); - out_fields.assign(out_set.begin(), out_set.end()); - // do the same for vector outputs - getOutputFieldsByType(params.sublist("Cell Average Vectors"), - out_vec_fields); - std::set out_vec_set(out_vec_fields.begin(), - out_vec_fields.end()); - out_vec_fields.assign(out_vec_set.begin(), out_vec_set.end()); -} - -} // namespace VectorizeOutputFieldNames -} // namespace VertexCFD - -#endif // VERTEXCFD_UTILS_VECTORIZEOUTPUTFIELDNAMES_HPP diff --git a/src/utils/VertexCFD_Utils_VelocityDim.cpp b/src/utils/VertexCFD_Utils_VelocityDim.cpp deleted file mode 100644 index 7151a86..0000000 --- a/src/utils/VertexCFD_Utils_VelocityDim.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "VertexCFD_Utils_VelocityDim.hpp" - -namespace PHX -{ - -// Shortened version of tag when, e.g., printing DAGs -template<> -std::string print() -{ - return "Vel"; -} - -} // namespace PHX diff --git a/src/utils/VertexCFD_Utils_VelocityDim.hpp b/src/utils/VertexCFD_Utils_VelocityDim.hpp deleted file mode 100644 index a4c3e4a..0000000 --- a/src/utils/VertexCFD_Utils_VelocityDim.hpp +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef VERTEXCFD_UTILS_VELOCITYDIM_HPP -#define VERTEXCFD_UTILS_VELOCITYDIM_HPP - -#include - -namespace VertexCFD -{ - -// PHX tag denoting velocity dimension for an MDField -struct VelocityDim -{ -}; - -} // namespace VertexCFD - -namespace PHX -{ - -// Shortened version of tag for, e.g., printing DAG -template<> -std::string print(); - -} // namespace PHX - -// Register tag as PHX extent -PHX_IS_EXTENT(VertexCFD::VelocityDim) - -#endif // VERTEXCFD_UTILS_VELOCITYDIM_HPP diff --git a/src/utils/VertexCFD_Utils_VelocityLayout.cpp b/src/utils/VertexCFD_Utils_VelocityLayout.cpp deleted file mode 100644 index 4d3ddae..0000000 --- a/src/utils/VertexCFD_Utils_VelocityLayout.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include "VertexCFD_Utils_VelocityLayout.hpp" -#include "VertexCFD_Utils_VelocityDim.hpp" - -#include - -#include - -#include - -namespace VertexCFD -{ -namespace Utils -{ -Teuchos::RCP -buildVelocityLayout(const Teuchos::RCP& scalar_layout, - int num_vel_dims) -{ - return Teuchos::rcp( - new PHX::MDALayout( - scalar_layout->extent(0), scalar_layout->extent(1), num_vel_dims)); -} - -Teuchos::RCP buildVelocityGradLayout( - const Teuchos::RCP& vector_layout, int num_vel_dims) -{ - return Teuchos::rcp( - new PHX::MDALayout( - vector_layout->extent(0), - vector_layout->extent(1), - vector_layout->extent(2), - num_vel_dims)); -} - -} // namespace Utils -} // namespace VertexCFD diff --git a/src/utils/VertexCFD_Utils_VelocityLayout.hpp b/src/utils/VertexCFD_Utils_VelocityLayout.hpp deleted file mode 100644 index 0d3558a..0000000 --- a/src/utils/VertexCFD_Utils_VelocityLayout.hpp +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef VERTEXCFD_UTILS_VELOCITYLAYOUT_HPP -#define VERTEXCFD_UTILS_VELOCITYLAYOUT_HPP - -#include - -namespace VertexCFD -{ -namespace Utils -{ -// Build phalanx DataLayout corresponding to vector velocity field -Teuchos::RCP -buildVelocityLayout(const Teuchos::RCP& scalar_layout, - int num_vel_dims); - -// Build phalanx DataLayout corresponding to vector velocity gradient field -Teuchos::RCP -buildVelocityGradLayout(const Teuchos::RCP& vector_layout, - int num_vel_dims); -} // namespace Utils -} // namespace VertexCFD - -#endif // VERTEXCFD_UTILS_VELOCITYLAYOUT_HPP diff --git a/src/utils/VertexCFD_Utils_Version.cpp b/src/utils/VertexCFD_Utils_Version.cpp deleted file mode 100644 index 0c76fb7..0000000 --- a/src/utils/VertexCFD_Utils_Version.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include - -namespace VertexCFD -{ -namespace Utils -{ -std::string version() -{ - return VertexCFD_VERSION_STRING; -} - -std::string git_commit_hash() -{ - return VertexCFD_GIT_COMMIT_HASH; -} - -} // end namespace Utils -} // end namespace VertexCFD diff --git a/src/utils/VertexCFD_Utils_Version.hpp b/src/utils/VertexCFD_Utils_Version.hpp deleted file mode 100644 index 6a92dac..0000000 --- a/src/utils/VertexCFD_Utils_Version.hpp +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef VERTEXCFD_VERSION_HPP -#define VERTEXCFD_VERSION_HPP - -#include - -#include - -namespace VertexCFD -{ -namespace Utils -{ -std::string version(); - -std::string git_commit_hash(); - -} // end namespace Utils -} // end namespace VertexCFD - -#endif // end VERTEXCFD_VERSION_HPP diff --git a/src/utils/VertexCFD_Utils_config.hpp.cmakein b/src/utils/VertexCFD_Utils_config.hpp.cmakein deleted file mode 100644 index 58c9dc3..0000000 --- a/src/utils/VertexCFD_Utils_config.hpp.cmakein +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef VERTEXCFD_CORE_CONFIG_HPP -#define VERTEXCFD_CORE_CONFIG_HPP - -#define VertexCFD_VERSION_STRING "@PROJECT_VERSION@" - -#define VertexCFD_GIT_COMMIT_HASH "@VertexCFD_GIT_COMMIT_HASH@" - -#endif // VERTEXCFD_CORE_CONFIG_HPP diff --git a/src/utils/unit_test/CMakeLists.txt b/src/utils/unit_test/CMakeLists.txt deleted file mode 100644 index b897ac1..0000000 --- a/src/utils/unit_test/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -set(TEST_HARNESS_DIR ${CMAKE_SOURCE_DIR}/src/test_harness) -include(${TEST_HARNESS_DIR}/TestHarness.cmake) - -include_directories(${Trilinos_INCLUDE_DIRS} ${Trilinos_TPL_INCLUDE_DIRS}) -link_directories(${Trilinos_LIBRARY_DIRS} ${Trilinos_TPL_LIBRARY_DIRS}) - -VertexCFD_add_tests( - LIBS Utils ${Trilinos_LIBRARIES} ${Trilinos_TPL_LIBRARIES} - NAMES - Version - ParameterPack - SmoothMath - Constants - TypeTraits - MatrixMath - NonlinearSolver - ScalarToVector - VectorizeOutputFieldNames - ) diff --git a/src/utils/unit_test/doc/matrixMathReference.nb b/src/utils/unit_test/doc/matrixMathReference.nb deleted file mode 100644 index 7373b7b..0000000 --- a/src/utils/unit_test/doc/matrixMathReference.nb +++ /dev/null @@ -1,1173 +0,0 @@ -(* Content-type: application/vnd.wolfram.mathematica *) - -(*** Wolfram Notebook File ***) -(* http://www.wolfram.com/nb *) - -(* CreatedBy='Mathematica 12.1' *) - -(*CacheID: 234*) -(* Internal cache information: -NotebookFileLineBreakTest -NotebookFileLineBreakTest -NotebookDataPosition[ 158, 7] -NotebookDataLength[ 43604, 1163] -NotebookOptionsPosition[ 37169, 1060] -NotebookOutlinePosition[ 37564, 1076] -CellTagsIndexPosition[ 37521, 1073] -WindowFrame->Normal*) - -(* Beginning of Notebook Content *) -Notebook[{ -Cell[BoxData[ - RowBox[{"(*", " ", - RowBox[{ - "3", "x3", " ", "LUP", " ", "decomp", " ", "and", " ", "solve", " ", - "test"}], " ", "*)"}]], "Input", - CellChangeTimes->{{3.873885913334178*^9, 3.873885926222415*^9}}, - CellLabel-> - "In[786]:=",ExpressionUUID->"41e5b97b-b44f-4d15-87e6-9e053be85385"], - -Cell[BoxData[ - RowBox[{ - RowBox[{"A", "=", - RowBox[{"{", - RowBox[{ - RowBox[{"{", - RowBox[{"1.", ",", "2.", ",", "4."}], "}"}], ",", - RowBox[{"{", - RowBox[{"2.", ",", "1.", ",", "3."}], "}"}], ",", - RowBox[{"{", - RowBox[{"3.", ",", "2.", ",", "4."}], "}"}]}], "}"}]}], ";"}]], "Input",\ - - CellChangeTimes->{{3.873548257732329*^9, 3.873548316656966*^9}, { - 3.873548686073326*^9, 3.873548691745556*^9}, 3.873818660415629*^9, { - 3.873885910099312*^9, 3.873885911371307*^9}}, - CellLabel-> - "In[787]:=",ExpressionUUID->"6f7b8d72-9554-4028-aa5b-4e447c8682f1"], - -Cell[CellGroupData[{ - -Cell[BoxData[ - RowBox[{"A", "//", "MatrixForm"}]], "Input", - CellChangeTimes->{{3.873548312742869*^9, 3.873548321091855*^9}, { - 3.873548395043783*^9, 3.873548403457623*^9}}, - CellLabel-> - "In[788]:=",ExpressionUUID->"f25673d5-c4ab-4d90-aff9-c1075f28a925"], - -Cell[BoxData[ - TagBox[ - RowBox[{"(", "\[NoBreak]", GridBox[{ - {"1.`", "2.`", "4.`"}, - {"2.`", "1.`", "3.`"}, - {"3.`", "2.`", "4.`"} - }, - GridBoxAlignment->{"Columns" -> {{Center}}, "Rows" -> {{Baseline}}}, - GridBoxSpacings->{"Columns" -> { - Offset[0.27999999999999997`], { - Offset[0.7]}, - Offset[0.27999999999999997`]}, "Rows" -> { - Offset[0.2], { - Offset[0.4]}, - Offset[0.2]}}], "\[NoBreak]", ")"}], - Function[BoxForm`e$, - MatrixForm[BoxForm`e$]]]], "Output", - CellChangeTimes->{ - 3.873548321640725*^9, 3.873548398615109*^9, 3.873548693965193*^9, - 3.873818661864649*^9, 3.873818967095649*^9, 3.873820008326004*^9, - 3.873821529573874*^9, 3.8738215867307243`*^9, {3.87382162895057*^9, - 3.873821656354196*^9}, {3.873884591039816*^9, 3.873884609562522*^9}, - 3.87388487819849*^9, 3.873884937264092*^9, 3.873885017507765*^9, - 3.873885503681518*^9, 3.8738858536640673`*^9, 3.873885891832185*^9, - 3.873886061371482*^9, 3.8738862162039413`*^9, 3.8738863039216013`*^9, - 3.8738863550992813`*^9, 3.873886414516436*^9}, - CellLabel-> - "Out[788]//MatrixForm=",ExpressionUUID->"fa8a9d60-b48d-43ea-9780-\ -80209e904b9e"] -}, Open ]], - -Cell[BoxData[ - RowBox[{ - RowBox[{ - RowBox[{"{", - RowBox[{"lu", ",", "p", ",", "c"}], "}"}], "=", - RowBox[{"LUDecomposition", "[", "A", "]"}]}], ";"}]], "Input", - CellChangeTimes->{{3.873548323225016*^9, 3.873548359127983*^9}, - 3.8735484063800783`*^9, 3.873818667849622*^9}, - CellLabel-> - "In[789]:=",ExpressionUUID->"2b6cf90a-ed7e-46ba-9cbd-97ff2db95ff9"], - -Cell[BoxData[ - RowBox[{ - RowBox[{ - RowBox[{"lu", "//", "MatrixForm"}], "//", "Rationalize"}], ";"}]], "Input",\ - - CellChangeTimes->{{3.87354840844627*^9, 3.873548413639083*^9}, { - 3.873548701567439*^9, 3.873548703993381*^9}, 3.873885497823937*^9}, - CellLabel-> - "In[790]:=",ExpressionUUID->"817188e7-589a-4e7e-94fe-fa8020639d81"], - -Cell[BoxData[ - RowBox[{"(*", " ", - RowBox[{ - "expected", " ", "permutation", " ", "p", " ", "corrected", " ", "for", " ", - RowBox[{"C", "++"}], " ", "indexing"}], " ", "*)"}]], "Input", - CellChangeTimes->{{3.873884884865815*^9, 3.873884909733581*^9}}, - CellLabel-> - "In[791]:=",ExpressionUUID->"21cbb4e7-9a74-4bfb-b1d4-55ae75260b4d"], - -Cell[CellGroupData[{ - -Cell[BoxData[ - RowBox[{"expectedP", "=", - RowBox[{"p", "-", "1"}]}]], "Input", - CellChangeTimes->{ - 3.873549339177335*^9, {3.873818413511498*^9, 3.87381841358959*^9}, { - 3.87388491241017*^9, 3.873884922387897*^9}}, - CellLabel-> - "In[792]:=",ExpressionUUID->"b2739b32-3614-4b53-89be-12abf10d241c"], - -Cell[BoxData[ - RowBox[{"{", - RowBox[{"2", ",", "0", ",", "1"}], "}"}]], "Output", - CellChangeTimes->{ - 3.873549339437284*^9, 3.873818413929639*^9, 3.8738186704958553`*^9, - 3.873818968912184*^9, 3.873820008380271*^9, 3.873821529618164*^9, - 3.8738215867945127`*^9, {3.873821629020382*^9, 3.87382165639649*^9}, { - 3.873884591085081*^9, 3.873884609578476*^9}, 3.873884878246854*^9, { - 3.8738849247943974`*^9, 3.8738849373147793`*^9}, 3.8738850175649843`*^9, - 3.873885503785583*^9, 3.8738858537433968`*^9, 3.87388589189185*^9, - 3.873886061427105*^9, 3.873886216267989*^9, 3.873886303981415*^9, - 3.873886355155985*^9, 3.873886414566762*^9}, - CellLabel-> - "Out[792]=",ExpressionUUID->"b71f7dcd-4d67-47e6-b472-015d133fb489"] -}, Open ]], - -Cell[BoxData[ - RowBox[{"(*", " ", - RowBox[{ - RowBox[{ - "In", " ", "VertexCFD", " ", "the", " ", "LU", " ", "matrix", " ", "is", - " ", "stored", " ", "\"\\""}], ",", " ", - RowBox[{ - RowBox[{ - "the", " ", "expected", " ", "LU", " ", "matrix", " ", "should", " ", - "be", " ", "such", " ", "that", " ", - RowBox[{"A", "[", - RowBox[{"[", "p", "]"}], "]"}]}], " ", "=", " ", - RowBox[{ - "LU", " ", "where", " ", "LU", " ", "is", " ", "the", " ", "returned", - " ", "matrix", " ", "from", " ", "Mathematica", " ", - "LUDecomposition"}]}]}], " ", "*)"}]], "Input", - CellChangeTimes->{{3.873884702618126*^9, 3.8738848352981443`*^9}}, - CellLabel-> - "In[793]:=",ExpressionUUID->"9dec25d4-6691-4f80-95b6-6d31800fcc15"], - -Cell[BoxData[ - RowBox[{ - RowBox[{"pprime", "=", - RowBox[{"{", - RowBox[{"2", ",", "3", ",", "1"}], "}"}]}], ";"}]], "Input", - CellChangeTimes->{{3.8735493429708643`*^9, 3.8735493916229753`*^9}, { - 3.873818359166994*^9, 3.8738183641551657`*^9}, 3.873818675095749*^9}, - CellLabel-> - "In[794]:=",ExpressionUUID->"d8e98558-a838-471f-891b-f5fde99a5806"], - -Cell[CellGroupData[{ - -Cell[BoxData[{ - RowBox[{ - RowBox[{"expectedA", "=", - RowBox[{"lu", "[", - RowBox[{"[", "pprime", "]"}], "]"}]}], ";"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{"expectedA", "//", "MatrixForm"}], "//", - "Rationalize"}], "\[IndentingNewLine]", - RowBox[{"expectedA", "//", "Rationalize"}]}], "Input", - CellChangeTimes->{{3.873549355466848*^9, 3.8735493655874434`*^9}, { - 3.8738215444937468`*^9, 3.873821548219389*^9}, {3.8738848388709*^9, - 3.8738848727353697`*^9}, 3.873885845159299*^9, {3.873885879713991*^9, - 3.873885887174007*^9}}, - CellLabel-> - "In[795]:=",ExpressionUUID->"9daa7836-803d-4fec-b35e-e414268c5517"], - -Cell[BoxData[ - TagBox[ - RowBox[{"(", "\[NoBreak]", GridBox[{ - { - FractionBox["1", "3"], - FractionBox["4", "3"], - FractionBox["8", "3"]}, - { - FractionBox["2", "3"], - RowBox[{"-", - FractionBox["1", "4"]}], "1"}, - {"3", "2", "4"} - }, - GridBoxAlignment->{"Columns" -> {{Center}}, "Rows" -> {{Baseline}}}, - GridBoxSpacings->{"Columns" -> { - Offset[0.27999999999999997`], { - Offset[0.7]}, - Offset[0.27999999999999997`]}, "Rows" -> { - Offset[0.2], { - Offset[0.4]}, - Offset[0.2]}}], "\[NoBreak]", ")"}], - Function[BoxForm`e$, - MatrixForm[BoxForm`e$]]]], "Output", - CellChangeTimes->{{3.873549358307843*^9, 3.87354939471743*^9}, { - 3.873818353691806*^9, 3.8738183657065277`*^9}, 3.873818676495591*^9, - 3.873818970136085*^9, 3.873820008420864*^9, 3.8738215296558943`*^9, - 3.873821586832116*^9, {3.873821629055581*^9, 3.873821656433942*^9}, { - 3.873884591123021*^9, 3.873884609629637*^9}, {3.873884867415019*^9, - 3.873884878292452*^9}, 3.873884937355174*^9, 3.87388501761064*^9, - 3.873885503860903*^9, {3.873885845677463*^9, 3.873885853817615*^9}, { - 3.8738858875973797`*^9, 3.87388589194584*^9}, 3.873886061471549*^9, - 3.873886216323769*^9, 3.873886304030122*^9, 3.873886355168932*^9, - 3.873886414609803*^9}, - CellLabel-> - "Out[796]//MatrixForm=",ExpressionUUID->"87fe9717-8fd0-4878-8162-\ -f397c94a16ec"], - -Cell[BoxData[ - RowBox[{"{", - RowBox[{ - RowBox[{"{", - RowBox[{ - FractionBox["1", "3"], ",", - FractionBox["4", "3"], ",", - FractionBox["8", "3"]}], "}"}], ",", - RowBox[{"{", - RowBox[{ - FractionBox["2", "3"], ",", - RowBox[{"-", - FractionBox["1", "4"]}], ",", "1"}], "}"}], ",", - RowBox[{"{", - RowBox[{"3", ",", "2", ",", "4"}], "}"}]}], "}"}]], "Output", - CellChangeTimes->{{3.873549358307843*^9, 3.87354939471743*^9}, { - 3.873818353691806*^9, 3.8738183657065277`*^9}, 3.873818676495591*^9, - 3.873818970136085*^9, 3.873820008420864*^9, 3.8738215296558943`*^9, - 3.873821586832116*^9, {3.873821629055581*^9, 3.873821656433942*^9}, { - 3.873884591123021*^9, 3.873884609629637*^9}, {3.873884867415019*^9, - 3.873884878292452*^9}, 3.873884937355174*^9, 3.87388501761064*^9, - 3.873885503860903*^9, {3.873885845677463*^9, 3.873885853817615*^9}, { - 3.8738858875973797`*^9, 3.87388589194584*^9}, 3.873886061471549*^9, - 3.873886216323769*^9, 3.873886304030122*^9, 3.873886355168932*^9, - 3.8738864146118107`*^9}, - CellLabel-> - "Out[797]=",ExpressionUUID->"309e5573-4259-4baa-9368-d59ec2c596b6"] -}, Open ]], - -Cell[BoxData[ - RowBox[{"(*", " ", - RowBox[{ - "check", " ", "that", " ", "we", " ", "actually", " ", "get", " ", "lu", - " ", "using", " ", "p", " ", "as", " ", "intended"}], " ", "*)"}]], "Input",\ - - CellChangeTimes->{{3.873884984255637*^9, 3.873885009887908*^9}, { - 3.873885943767289*^9, 3.873885945720776*^9}}, - CellLabel-> - "In[798]:=",ExpressionUUID->"4a2871bb-acdf-4f0e-b33b-fe9c6e0d6f2b"], - -Cell[CellGroupData[{ - -Cell[BoxData[ - RowBox[{ - RowBox[{ - RowBox[{ - RowBox[{"expectedA", "[", - RowBox[{"[", "p", "]"}], "]"}], "-", "lu"}], "//", "MatrixForm"}], "//", - "Rationalize"}]], "Input", - CellChangeTimes->{{3.873884566989442*^9, 3.8738846054651623`*^9}, { - 3.873884859023572*^9, 3.873884861111637*^9}, {3.8738850121923523`*^9, - 3.873885013069188*^9}}, - CellLabel-> - "In[799]:=",ExpressionUUID->"4a9e265f-de0c-48aa-a0ef-6f9c598e5c51"], - -Cell[BoxData[ - TagBox[ - RowBox[{"(", "\[NoBreak]", GridBox[{ - {"0", "0", "0"}, - {"0", "0", "0"}, - {"0", "0", "0"} - }, - GridBoxAlignment->{"Columns" -> {{Center}}, "Rows" -> {{Baseline}}}, - GridBoxSpacings->{"Columns" -> { - Offset[0.27999999999999997`], { - Offset[0.7]}, - Offset[0.27999999999999997`]}, "Rows" -> { - Offset[0.2], { - Offset[0.4]}, - Offset[0.2]}}], "\[NoBreak]", ")"}], - Function[BoxForm`e$, - MatrixForm[BoxForm`e$]]]], "Output", - CellChangeTimes->{{3.8738845852851887`*^9, 3.8738846096381693`*^9}, - 3.8738848782984962`*^9, 3.873884937360505*^9, {3.873885013677095*^9, - 3.873885017620503*^9}, 3.8738855039346523`*^9, 3.8738858539533*^9, - 3.873885892010192*^9, 3.8738860614812603`*^9, 3.873886216376768*^9, - 3.873886304077029*^9, 3.873886355208338*^9, 3.8738864146197853`*^9}, - CellLabel-> - "Out[799]//MatrixForm=",ExpressionUUID->"4db56fae-df15-40dc-82dc-\ -cea0d9768988"] -}, Open ]], - -Cell[BoxData[ - RowBox[{ - RowBox[{"l", "=", - RowBox[{ - RowBox[{"lu", " ", - RowBox[{"SparseArray", "[", - RowBox[{ - RowBox[{ - RowBox[{ - RowBox[{"{", - RowBox[{"i_", ",", "j_"}], "}"}], "/;", - RowBox[{"j", "<", "i"}]}], "\[Rule]", "1"}], ",", - RowBox[{"{", - RowBox[{"3", ",", "3"}], "}"}]}], "]"}]}], "+", - RowBox[{"IdentityMatrix", "[", "3", "]"}]}]}], ";"}]], "Input", - CellChangeTimes->{{3.8738189531514263`*^9, 3.873818957142659*^9}, { - 3.873821490692011*^9, 3.873821492113802*^9}}, - CellLabel-> - "In[800]:=",ExpressionUUID->"bdab867a-b5a2-4fe0-836c-9bd36622b9ec"], - -Cell[BoxData[ - RowBox[{ - RowBox[{"u", "=", - RowBox[{"lu", " ", - RowBox[{"SparseArray", "[", - RowBox[{ - RowBox[{ - RowBox[{ - RowBox[{"{", - RowBox[{"i_", ",", "j_"}], "}"}], "/;", - RowBox[{"j", "\[GreaterEqual]", "i"}]}], "\[Rule]", "1"}], ",", - RowBox[{"{", - RowBox[{"3", ",", "3"}], "}"}]}], "]"}]}]}], ";"}]], "Input", - CellChangeTimes->{{3.8738189921521378`*^9, 3.8738189933210783`*^9}, { - 3.8738214996845427`*^9, 3.873821504802157*^9}}, - CellLabel-> - "In[801]:=",ExpressionUUID->"d9347773-9ae3-4df3-a691-e0a3bf335ca7"], - -Cell[CellGroupData[{ - -Cell[BoxData[{ - RowBox[{"MatrixForm", "[", "l", "]"}], "\[IndentingNewLine]", - RowBox[{"MatrixForm", "[", "u", "]"}], "\[IndentingNewLine]", - RowBox[{"MatrixForm", "[", - RowBox[{"l", ".", "u"}], "]"}]}], "Input", - CellChangeTimes->{{3.87381899900133*^9, 3.873819046537306*^9}, { - 3.873821521707954*^9, 3.873821525857964*^9}}, - CellLabel-> - "In[802]:=",ExpressionUUID->"67ab2db9-006a-4dbc-918c-f1595187f78b"], - -Cell[BoxData[ - TagBox[ - RowBox[{"(", "\[NoBreak]", GridBox[{ - {"1", "0", "0"}, - {"0.3333333333333333`", "1", "0"}, - {"0.6666666666666666`", - RowBox[{"-", "0.24999999999999992`"}], "1"} - }, - GridBoxAlignment->{"Columns" -> {{Center}}, "Rows" -> {{Baseline}}}, - GridBoxSpacings->{"Columns" -> { - Offset[0.27999999999999997`], { - Offset[0.7]}, - Offset[0.27999999999999997`]}, "Rows" -> { - Offset[0.2], { - Offset[0.4]}, - Offset[0.2]}}], "\[NoBreak]", ")"}], - Function[BoxForm`e$, - MatrixForm[BoxForm`e$]]]], "Output", - CellChangeTimes->{ - 3.87382158687075*^9, {3.873821629069867*^9, 3.873821656475794*^9}, { - 3.87388459116961*^9, 3.87388460968709*^9}, 3.873884878342246*^9, - 3.873884937402584*^9, 3.873885017662006*^9, 3.87388550399695*^9, - 3.873885854027176*^9, 3.8738858920689287`*^9, 3.8738860615273037`*^9, - 3.873886216424542*^9, 3.8738863041322412`*^9, 3.873886355252397*^9, - 3.873886414659128*^9}, - CellLabel-> - "Out[802]//MatrixForm=",ExpressionUUID->"e91bb598-3e5b-42c7-8e0e-\ -6eb46d06d4c5"], - -Cell[BoxData[ - TagBox[ - RowBox[{"(", "\[NoBreak]", GridBox[{ - {"3.`", "2.`", "4.`"}, - {"0", "1.3333333333333335`", "2.666666666666667`"}, - {"0", "0", "1.`"} - }, - GridBoxAlignment->{"Columns" -> {{Center}}, "Rows" -> {{Baseline}}}, - GridBoxSpacings->{"Columns" -> { - Offset[0.27999999999999997`], { - Offset[0.7]}, - Offset[0.27999999999999997`]}, "Rows" -> { - Offset[0.2], { - Offset[0.4]}, - Offset[0.2]}}], "\[NoBreak]", ")"}], - Function[BoxForm`e$, - MatrixForm[ - SparseArray[ - Automatic, {3, 3}, 0, { - 1, {{0, 3, 5, 6}, {{3}, {2}, {1}, {2}, {3}, {3}}}, {4., 2., 3., - 1.3333333333333335`, 2.666666666666667, 1.}}]]]]], "Output", - CellChangeTimes->{ - 3.87382158687075*^9, {3.873821629069867*^9, 3.873821656475794*^9}, { - 3.87388459116961*^9, 3.87388460968709*^9}, 3.873884878342246*^9, - 3.873884937402584*^9, 3.873885017662006*^9, 3.87388550399695*^9, - 3.873885854027176*^9, 3.8738858920689287`*^9, 3.8738860615273037`*^9, - 3.873886216424542*^9, 3.8738863041322412`*^9, 3.873886355252397*^9, - 3.87388641466195*^9}, - CellLabel-> - "Out[803]//MatrixForm=",ExpressionUUID->"7797d898-12b5-4f05-bfd8-\ -9eaa69004166"], - -Cell[BoxData[ - TagBox[ - RowBox[{"(", "\[NoBreak]", GridBox[{ - {"3.`", "2.`", "4.`"}, - {"1.`", "2.`", "4.`"}, - {"2.`", "1.`", "3.`"} - }, - GridBoxAlignment->{"Columns" -> {{Center}}, "Rows" -> {{Baseline}}}, - GridBoxSpacings->{"Columns" -> { - Offset[0.27999999999999997`], { - Offset[0.7]}, - Offset[0.27999999999999997`]}, "Rows" -> { - Offset[0.2], { - Offset[0.4]}, - Offset[0.2]}}], "\[NoBreak]", ")"}], - Function[BoxForm`e$, - MatrixForm[BoxForm`e$]]]], "Output", - CellChangeTimes->{ - 3.87382158687075*^9, {3.873821629069867*^9, 3.873821656475794*^9}, { - 3.87388459116961*^9, 3.87388460968709*^9}, 3.873884878342246*^9, - 3.873884937402584*^9, 3.873885017662006*^9, 3.87388550399695*^9, - 3.873885854027176*^9, 3.8738858920689287`*^9, 3.8738860615273037`*^9, - 3.873886216424542*^9, 3.8738863041322412`*^9, 3.873886355252397*^9, - 3.8738864146638193`*^9}, - CellLabel-> - "Out[804]//MatrixForm=",ExpressionUUID->"ac97130c-200c-423e-834b-\ -be1bfb97047a"] -}, Open ]], - -Cell[BoxData[ - RowBox[{"(*", " ", - RowBox[{"check", " ", "solve", " ", "step"}], " ", "*)"}]], "Input", - CellChangeTimes->{{3.873886029840823*^9, 3.8738860371994677`*^9}}, - CellLabel-> - "In[805]:=",ExpressionUUID->"bfdf5b61-e9bf-45ca-8335-c223dda8f4d6"], - -Cell[CellGroupData[{ - -Cell[BoxData[ - RowBox[{"b", "=", - RowBox[{"{", - RowBox[{"3", ",", "4", ",", "5"}], "}"}]}]], "Input", - CellChangeTimes->{{3.8738190651879673`*^9, 3.8738190803876038`*^9}, { - 3.8738193748964863`*^9, 3.87381937632789*^9}}, - CellLabel-> - "In[806]:=",ExpressionUUID->"5f62f4af-3da9-4418-a89f-9e9ed2034ecb"], - -Cell[BoxData[ - RowBox[{"{", - RowBox[{"3", ",", "4", ",", "5"}], "}"}]], "Output", - CellChangeTimes->{ - 3.873819377211627*^9, 3.873820008469236*^9, 3.873821529716867*^9, - 3.8738215869514837`*^9, {3.873821629160358*^9, 3.873821656559039*^9}, { - 3.873884591224436*^9, 3.873884609777454*^9}, 3.873884878431637*^9, - 3.87388493748067*^9, 3.8738850177162857`*^9, 3.873885504098394*^9, - 3.873885854113805*^9, 3.873885892164158*^9, 3.873886061576597*^9, - 3.873886216470271*^9, 3.873886304185693*^9, 3.873886355299405*^9, - 3.873886414700492*^9}, - CellLabel-> - "Out[806]=",ExpressionUUID->"7a5d7922-5f93-4aa7-ada6-b022923f8461"] -}, Open ]], - -Cell[BoxData[ - RowBox[{"(*", " ", - RowBox[{"using", " ", "LU", " ", "decomposition"}], " ", "*)"}]], "Input", - CellChangeTimes->{{3.87388608555926*^9, 3.873886093298985*^9}}, - CellLabel-> - "In[807]:=",ExpressionUUID->"99477342-5c67-45ac-8133-c92237cd5832"], - -Cell[BoxData[ - RowBox[{ - RowBox[{"y", "=", - RowBox[{"LinearSolve", "[", - RowBox[{"l", ",", - RowBox[{"b", "[", - RowBox[{"[", "p", "]"}], "]"}]}], "]"}]}], ";"}]], "Input", - CellChangeTimes->{{3.873819384901676*^9, 3.873819398114263*^9}, { - 3.873819989085167*^9, 3.873819995521783*^9}}, - CellLabel-> - "In[808]:=",ExpressionUUID->"282f3c34-4b37-4864-bb1c-1e55d0557afe"], - -Cell[CellGroupData[{ - -Cell[BoxData[ - RowBox[{"LinearSolve", "[", - RowBox[{"u", ",", "y"}], "]"}]], "Input", - CellChangeTimes->{{3.873819404323048*^9, 3.873819410009388*^9}}, - CellLabel-> - "In[809]:=",ExpressionUUID->"2e9bafd5-c3f0-4f20-ada5-c244e9da15df"], - -Cell[BoxData[ - RowBox[{"{", - RowBox[{"1.0000000000000002`", ",", - RowBox[{"-", "1.`"}], ",", "1.`"}], "}"}]], "Output", - CellChangeTimes->{ - 3.8738194110686007`*^9, 3.8738200085132713`*^9, 3.8738215297524033`*^9, - 3.8738215869854307`*^9, {3.873821629171023*^9, 3.873821656598094*^9}, { - 3.873884591261627*^9, 3.873884609827282*^9}, 3.8738848784765863`*^9, - 3.873884937515682*^9, 3.873885017755444*^9, 3.873885504148225*^9, - 3.87388585416967*^9, 3.873885892174415*^9, 3.8738860616237373`*^9, - 3.873886216515822*^9, 3.873886304242941*^9, 3.873886355345083*^9, - 3.873886414741547*^9}, - CellLabel-> - "Out[809]=",ExpressionUUID->"9a17b002-ad5e-4b6c-908a-ca6093153154"] -}, Open ]], - -Cell[BoxData[ - RowBox[{"(*", " ", - RowBox[{ - "let", " ", "Mathematica", " ", "solve", " ", "the", " ", "original", " ", - "system", " ", "as", " ", "a", " ", "check"}], " ", "*)"}]], "Input", - CellChangeTimes->{{3.873886095551296*^9, 3.8738861436355247`*^9}}, - CellLabel-> - "In[810]:=",ExpressionUUID->"ee22a100-a557-4a76-9309-a46c1731d8c7"], - -Cell[CellGroupData[{ - -Cell[BoxData[ - RowBox[{"LinearSolve", "[", - RowBox[{"A", ",", "b"}], "]"}]], "Input", - CellChangeTimes->{{3.8738860478725147`*^9, 3.873886056133404*^9}}, - CellLabel-> - "In[811]:=",ExpressionUUID->"cbca244e-4be6-4346-a7ab-dc5203e7bdef"], - -Cell[BoxData[ - RowBox[{"{", - RowBox[{"1.`", ",", - RowBox[{"-", "1.`"}], ",", "1.`"}], "}"}]], "Output", - CellChangeTimes->{{3.873886057488387*^9, 3.8738860616310577`*^9}, - 3.873886216559017*^9, 3.873886304253804*^9, 3.873886355355495*^9, - 3.873886414750389*^9}, - CellLabel-> - "Out[811]=",ExpressionUUID->"32fb9c23-f868-4c65-80f6-6f046aff4e6e"] -}, Open ]], - -Cell[BoxData[ - RowBox[{"(*", " ", - RowBox[{"Test", " ", "5", "x5", " ", "decomposition", " ", "only"}], " ", - "*)"}]], "Input", - CellChangeTimes->{{3.873886170997048*^9, 3.873886178058332*^9}}, - CellLabel-> - "In[812]:=",ExpressionUUID->"343c9c1b-6f39-477f-8d94-059828fedb35"], - -Cell[BoxData[ - RowBox[{ - RowBox[{"A", " ", "=", " ", - RowBox[{"{", - RowBox[{ - RowBox[{"{", - RowBox[{"8.", ",", - RowBox[{"-", "2."}], ",", - RowBox[{"-", "8."}], ",", "9.", ",", "6."}], "}"}], ",", - RowBox[{"{", - RowBox[{"9.", ",", "5.", ",", "5.", ",", "3.", ",", "1."}], "}"}], ",", - - RowBox[{"{", - RowBox[{"9.", ",", - RowBox[{"-", "7."}], ",", "2.", ",", "8.", ",", "4."}], "}"}], ",", - RowBox[{"{", - RowBox[{"9.", ",", "6.", ",", - RowBox[{"-", "9."}], ",", "0", ",", - RowBox[{"-", "8."}]}], "}"}], ",", - RowBox[{"{", - RowBox[{ - RowBox[{"-", "7."}], ",", "9.", ",", - RowBox[{"-", "9."}], ",", - RowBox[{"-", "7."}], ",", "6."}], "}"}]}], "}"}]}], ";"}]], "Input", - CellChangeTimes->{{3.8738184449190407`*^9, 3.8738184849828157`*^9}, { - 3.873818650526903*^9, 3.873818655517494*^9}, {3.873818686367817*^9, - 3.873818718008418*^9}}, - CellLabel-> - "In[813]:=",ExpressionUUID->"13a7c346-7eb1-46b0-86dc-035a5dfe3833"], - -Cell[CellGroupData[{ - -Cell[BoxData[ - RowBox[{"A", "//", "MatrixForm"}]], "Input", - CellChangeTimes->{{3.873818719049061*^9, 3.8738187218489656`*^9}}, - CellLabel-> - "In[814]:=",ExpressionUUID->"47a2829d-8e01-4bb0-893f-5b6e49dc6e33"], - -Cell[BoxData[ - TagBox[ - RowBox[{"(", "\[NoBreak]", GridBox[{ - {"8.`", - RowBox[{"-", "2.`"}], - RowBox[{"-", "8.`"}], "9.`", "6.`"}, - {"9.`", "5.`", "5.`", "3.`", "1.`"}, - {"9.`", - RowBox[{"-", "7.`"}], "2.`", "8.`", "4.`"}, - {"9.`", "6.`", - RowBox[{"-", "9.`"}], "0", - RowBox[{"-", "8.`"}]}, - { - RowBox[{"-", "7.`"}], "9.`", - RowBox[{"-", "9.`"}], - RowBox[{"-", "7.`"}], "6.`"} - }, - GridBoxAlignment->{"Columns" -> {{Center}}, "Rows" -> {{Baseline}}}, - GridBoxSpacings->{"Columns" -> { - Offset[0.27999999999999997`], { - Offset[0.7]}, - Offset[0.27999999999999997`]}, "Rows" -> { - Offset[0.2], { - Offset[0.4]}, - Offset[0.2]}}], "\[NoBreak]", ")"}], - Function[BoxForm`e$, - MatrixForm[BoxForm`e$]]]], "Output", - CellChangeTimes->{ - 3.8738187222913523`*^9, 3.873820008554089*^9, 3.873821529787386*^9, - 3.873821587019372*^9, {3.873821629204485*^9, 3.873821656637444*^9}, { - 3.8738845912965937`*^9, 3.873884609869782*^9}, 3.873884878517249*^9, - 3.873884937550674*^9, 3.873885017794985*^9, 3.8738855041986103`*^9, - 3.873885854222453*^9, 3.873885892217064*^9, 3.873886061680459*^9, - 3.873886216608362*^9, 3.873886304320012*^9, 3.873886355401146*^9, - 3.873886414792509*^9}, - CellLabel-> - "Out[814]//MatrixForm=",ExpressionUUID->"8573a0d9-eb3d-4586-ba90-\ -761fef5af103"] -}, Open ]], - -Cell[BoxData[ - RowBox[{ - RowBox[{ - RowBox[{"{", - RowBox[{"lu", ",", "p", ",", "c"}], "}"}], "=", - RowBox[{"LUDecomposition", "[", "A", "]"}]}], ";"}]], "Input", - CellLabel-> - "In[815]:=",ExpressionUUID->"37953d2b-014a-427a-887b-588a6aa10f2e"], - -Cell[CellGroupData[{ - -Cell[BoxData[ - RowBox[{"expectedP", "=", - RowBox[{"p", "-", "1"}]}]], "Input", - CellChangeTimes->{{3.873818760307156*^9, 3.873818760665497*^9}, { - 3.873886192387355*^9, 3.8738861948763523`*^9}}, - CellLabel-> - "In[816]:=",ExpressionUUID->"8d2e9e4e-96ba-42c1-9fc3-e845f655e08f"], - -Cell[BoxData[ - RowBox[{"{", - RowBox[{"1", ",", "4", ",", "0", ",", "3", ",", "2"}], "}"}]], "Output", - CellChangeTimes->{ - 3.873818761738782*^9, 3.873820008604332*^9, 3.8738215298539057`*^9, - 3.8738215870345173`*^9, {3.873821629242901*^9, 3.873821656680029*^9}, { - 3.873884591344514*^9, 3.873884609941598*^9}, 3.873884878533403*^9, - 3.873884937597088*^9, 3.8738850178409567`*^9, 3.873885504302503*^9, - 3.873885854280108*^9, 3.873885892234123*^9, 3.873886061729907*^9, { - 3.873886195654173*^9, 3.873886216623321*^9}, 3.873886304334384*^9, - 3.873886355444621*^9, 3.8738864148015127`*^9}, - CellLabel-> - "Out[816]=",ExpressionUUID->"53329e55-30da-499d-949c-c7cfccc3b0f9"] -}, Open ]], - -Cell[BoxData[ - RowBox[{ - RowBox[{"pprime", "=", - RowBox[{"{", - RowBox[{"3", ",", "1", ",", "5", ",", "4", ",", "2"}], "}"}]}], - ";"}]], "Input", - CellChangeTimes->{{3.873818773706819*^9, 3.873818828939896*^9}}, - CellLabel-> - "In[817]:=",ExpressionUUID->"626d7270-4e75-4b49-a8a8-42895eda885f"], - -Cell[CellGroupData[{ - -Cell[BoxData[{ - RowBox[{ - RowBox[{"expectedA", "=", - RowBox[{"lu", "[", - RowBox[{"[", "pprime", "]"}], "]"}]}], ";"}], "\[IndentingNewLine]", - RowBox[{ - RowBox[{"expectedA", "//", "MatrixForm"}], "//", - "Rationalize"}], "\[IndentingNewLine]", - RowBox[{"expectedA", "//", "Rationalize"}]}], "Input", - CellChangeTimes->{{3.873818830563217*^9, 3.873818841051112*^9}, { - 3.873886188332423*^9, 3.873886228996368*^9}}, - CellLabel-> - "In[818]:=",ExpressionUUID->"dea06982-b0de-45c7-8f63-cc86c1ca456d"], - -Cell[BoxData[ - TagBox[ - RowBox[{"(", "\[NoBreak]", GridBox[{ - { - FractionBox["8", "9"], - RowBox[{"-", - FractionBox["1", "2"]}], - RowBox[{"-", "15"}], "4", - FractionBox["17", "2"]}, - {"9", "5", "5", "3", "1"}, - {"1", - RowBox[{"-", - FractionBox["27", "29"]}], - FractionBox["15", "29"], - FractionBox["410", "1817"], - FractionBox["31989", "3634"]}, - {"1", - FractionBox["9", "116"], - FractionBox["263", "290"], - RowBox[{"-", - FractionBox["1817", "290"]}], - RowBox[{"-", - FractionBox["2499", "145"]}]}, - { - RowBox[{"-", - FractionBox["7", "9"]}], - FractionBox["116", "9"], - RowBox[{"-", - FractionBox["46", "9"]}], - RowBox[{"-", - FractionBox["14", "3"]}], - FractionBox["61", "9"]} - }, - GridBoxAlignment->{"Columns" -> {{Center}}, "Rows" -> {{Baseline}}}, - GridBoxSpacings->{"Columns" -> { - Offset[0.27999999999999997`], { - Offset[0.7]}, - Offset[0.27999999999999997`]}, "Rows" -> { - Offset[0.2], { - Offset[0.4]}, - Offset[0.2]}}], "\[NoBreak]", ")"}], - Function[BoxForm`e$, - MatrixForm[BoxForm`e$]]]], "Output", - CellChangeTimes->{ - 3.873818841845112*^9, 3.87382000864118*^9, 3.873821529888377*^9, - 3.873821587071231*^9, {3.8738216292755623`*^9, 3.873821656718169*^9}, { - 3.873884591354697*^9, 3.873884609978272*^9}, 3.87388487857213*^9, - 3.87388493763205*^9, 3.873885017850555*^9, 3.873885504361775*^9, - 3.8738858543366737`*^9, 3.873885892276359*^9, 3.87388606177212*^9, { - 3.8738862166654863`*^9, 3.873886229766782*^9}, 3.873886304380315*^9, - 3.873886355490202*^9, 3.873886414841305*^9}, - CellLabel-> - "Out[819]//MatrixForm=",ExpressionUUID->"660f4a7a-63f1-4d84-bc33-\ -76ef15c71a78"], - -Cell[BoxData[ - RowBox[{"{", - RowBox[{ - RowBox[{"{", - RowBox[{ - FractionBox["8", "9"], ",", - RowBox[{"-", - FractionBox["1", "2"]}], ",", - RowBox[{"-", "15"}], ",", "4", ",", - FractionBox["17", "2"]}], "}"}], ",", - RowBox[{"{", - RowBox[{"9", ",", "5", ",", "5", ",", "3", ",", "1"}], "}"}], ",", - RowBox[{"{", - RowBox[{"1", ",", - RowBox[{"-", - FractionBox["27", "29"]}], ",", - FractionBox["15", "29"], ",", - FractionBox["410", "1817"], ",", - FractionBox["31989", "3634"]}], "}"}], ",", - RowBox[{"{", - RowBox[{"1", ",", - FractionBox["9", "116"], ",", - FractionBox["263", "290"], ",", - RowBox[{"-", - FractionBox["1817", "290"]}], ",", - RowBox[{"-", - FractionBox["2499", "145"]}]}], "}"}], ",", - RowBox[{"{", - RowBox[{ - RowBox[{"-", - FractionBox["7", "9"]}], ",", - FractionBox["116", "9"], ",", - RowBox[{"-", - FractionBox["46", "9"]}], ",", - RowBox[{"-", - FractionBox["14", "3"]}], ",", - FractionBox["61", "9"]}], "}"}]}], "}"}]], "Output", - CellChangeTimes->{ - 3.873818841845112*^9, 3.87382000864118*^9, 3.873821529888377*^9, - 3.873821587071231*^9, {3.8738216292755623`*^9, 3.873821656718169*^9}, { - 3.873884591354697*^9, 3.873884609978272*^9}, 3.87388487857213*^9, - 3.87388493763205*^9, 3.873885017850555*^9, 3.873885504361775*^9, - 3.8738858543366737`*^9, 3.873885892276359*^9, 3.87388606177212*^9, { - 3.8738862166654863`*^9, 3.873886229766782*^9}, 3.873886304380315*^9, - 3.873886355490202*^9, 3.8738864148438883`*^9}, - CellLabel-> - "Out[820]=",ExpressionUUID->"eb717ef3-5ecf-4d7a-a71e-646410641d53"] -}, Open ]], - -Cell[BoxData[ - RowBox[{"(*", " ", - RowBox[{ - RowBox[{"check", " ", "that", " ", - RowBox[{"A_exp", "[", - RowBox[{"[", "p", "]"}], "]"}]}], " ", "=", " ", "lu"}], " ", - "*)"}]], "Input", - CellChangeTimes->{{3.87388636613663*^9, 3.873886377577084*^9}}, - CellLabel-> - "In[821]:=",ExpressionUUID->"4b28e487-55a0-44ce-8ff6-707135d41744"], - -Cell[CellGroupData[{ - -Cell[BoxData[ - RowBox[{ - RowBox[{ - RowBox[{"expectedA", "[", - RowBox[{"[", "p", "]"}], "]"}], "-", "lu"}], "//", - "MatrixForm"}]], "Input", - CellChangeTimes->{{3.873886340344843*^9, 3.873886352132577*^9}}, - CellLabel-> - "In[822]:=",ExpressionUUID->"69ef9827-97bf-4f09-b8d0-d064d9d7e538"], - -Cell[BoxData[ - TagBox[ - RowBox[{"(", "\[NoBreak]", GridBox[{ - {"0.`", "0.`", "0.`", "0.`", "0.`"}, - {"0.`", "0.`", "0.`", "0.`", "0.`"}, - {"0.`", "0.`", "0.`", "0.`", "0.`"}, - {"0.`", "0.`", "0.`", "0.`", "0.`"}, - {"0.`", "0.`", "0.`", "0.`", "0.`"} - }, - GridBoxAlignment->{"Columns" -> {{Center}}, "Rows" -> {{Baseline}}}, - GridBoxSpacings->{"Columns" -> { - Offset[0.27999999999999997`], { - Offset[0.7]}, - Offset[0.27999999999999997`]}, "Rows" -> { - Offset[0.2], { - Offset[0.4]}, - Offset[0.2]}}], "\[NoBreak]", ")"}], - Function[BoxForm`e$, - MatrixForm[BoxForm`e$]]]], "Output", - CellChangeTimes->{3.873886355497346*^9, 3.873886414852344*^9}, - CellLabel-> - "Out[822]//MatrixForm=",ExpressionUUID->"c59573a8-ab3e-48ce-a02d-\ -ed13c441b61f"] -}, Open ]], - -Cell[BoxData[ - RowBox[{"(*", " ", - RowBox[{"Test", " ", "solve", " ", "5", "x5"}], " ", "*)"}]], "Input", - CellChangeTimes->{{3.873886384282916*^9, 3.873886399819332*^9}}, - CellLabel-> - "In[823]:=",ExpressionUUID->"79f92fc0-4767-4a7f-aa0c-6d097ea669c3"], - -Cell[BoxData[ - RowBox[{ - RowBox[{"A", " ", "=", " ", - RowBox[{"{", - RowBox[{ - RowBox[{"{", - RowBox[{ - RowBox[{"-", "2.6"}], ",", - RowBox[{"-", "7.2"}], ",", - RowBox[{"-", "0.4"}], ",", "7.5", ",", "5.7"}], "}"}], ",", - RowBox[{"{", - RowBox[{"2.2", ",", - RowBox[{"-", "4.9"}], ",", "3.8", ",", - RowBox[{"-", "8.7"}], ",", - RowBox[{"-", "4.6"}]}], "}"}], ",", - RowBox[{"{", - RowBox[{"4.8", ",", - RowBox[{"-", "4.6"}], ",", "5.7", ",", "7.9", ",", - RowBox[{"-", "8.5"}]}], "}"}], ",", - RowBox[{"{", - RowBox[{ - RowBox[{"-", "4.5"}], ",", "1.4", ",", - RowBox[{"-", "9.5"}], ",", "2.7", ",", - RowBox[{"-", "7.2"}]}], "}"}], ",", - RowBox[{"{", - RowBox[{"2.1", ",", - RowBox[{"-", "2.6"}], ",", - RowBox[{"-", "7.4"}], ",", - RowBox[{"-", "5.3"}], ",", "0.3"}], "}"}]}], "}"}]}], ";"}]], "Input", - CellChangeTimes->{{3.873820234954137*^9, 3.8738203538483877`*^9}}, - CellLabel-> - "In[824]:=",ExpressionUUID->"7490cda9-db9e-4685-9141-0ea5557776e5"], - -Cell[CellGroupData[{ - -Cell[BoxData[ - RowBox[{"A", "//", "MatrixForm"}]], "Input", - CellChangeTimes->{{3.873820357471552*^9, 3.8738203599108152`*^9}}, - CellLabel-> - "In[825]:=",ExpressionUUID->"157fafe0-d722-4a26-b1f2-4dd55a612811"], - -Cell[BoxData[ - TagBox[ - RowBox[{"(", "\[NoBreak]", GridBox[{ - { - RowBox[{"-", "2.6`"}], - RowBox[{"-", "7.2`"}], - RowBox[{"-", "0.4`"}], "7.5`", "5.7`"}, - {"2.2`", - RowBox[{"-", "4.9`"}], "3.8`", - RowBox[{"-", "8.7`"}], - RowBox[{"-", "4.6`"}]}, - {"4.8`", - RowBox[{"-", "4.6`"}], "5.7`", "7.9`", - RowBox[{"-", "8.5`"}]}, - { - RowBox[{"-", "4.5`"}], "1.4`", - RowBox[{"-", "9.5`"}], "2.7`", - RowBox[{"-", "7.2`"}]}, - {"2.1`", - RowBox[{"-", "2.6`"}], - RowBox[{"-", "7.4`"}], - RowBox[{"-", "5.3`"}], "0.3`"} - }, - GridBoxAlignment->{"Columns" -> {{Center}}, "Rows" -> {{Baseline}}}, - GridBoxSpacings->{"Columns" -> { - Offset[0.27999999999999997`], { - Offset[0.7]}, - Offset[0.27999999999999997`]}, "Rows" -> { - Offset[0.2], { - Offset[0.4]}, - Offset[0.2]}}], "\[NoBreak]", ")"}], - Function[BoxForm`e$, - MatrixForm[BoxForm`e$]]]], "Output", - CellChangeTimes->{ - 3.873820360295783*^9, 3.8738215299203253`*^9, 3.873821587103825*^9, { - 3.873821629308641*^9, 3.8738216567526484`*^9}, {3.873884591390791*^9, - 3.8738846099871893`*^9}, 3.873884878581976*^9, 3.873884937665495*^9, - 3.873885017887765*^9, 3.873885504422566*^9, 3.8738858543995*^9, - 3.873885892321146*^9, 3.873886061814756*^9, 3.873886216705024*^9, - 3.873886304421962*^9, 3.873886355539104*^9, 3.8738864148965883`*^9}, - CellLabel-> - "Out[825]//MatrixForm=",ExpressionUUID->"14cc1f82-a6e4-4307-ad3d-\ -a53257cb251e"] -}, Open ]], - -Cell[BoxData[ - RowBox[{ - RowBox[{ - RowBox[{"{", - RowBox[{"lu", ",", "p", ",", "c"}], "}"}], "=", - RowBox[{"LUDecomposition", "[", "A", "]"}]}], ";"}]], "Input", - CellLabel-> - "In[826]:=",ExpressionUUID->"246494f5-8cb8-4f04-aba9-2fdb96fa19b5"], - -Cell[BoxData[ - RowBox[{ - RowBox[{"l", "=", - RowBox[{ - RowBox[{"lu", " ", - RowBox[{"SparseArray", "[", - RowBox[{ - RowBox[{ - RowBox[{ - RowBox[{"{", - RowBox[{"i_", ",", "j_"}], "}"}], "/;", - RowBox[{"j", "<", "i"}]}], "\[Rule]", "1"}], ",", - RowBox[{"{", - RowBox[{"5", ",", "5"}], "}"}]}], "]"}]}], "+", - RowBox[{"IdentityMatrix", "[", "5", "]"}]}]}], ";"}]], "Input", - CellChangeTimes->{{3.8738201246059017`*^9, 3.8738201287340612`*^9}}, - CellLabel-> - "In[827]:=",ExpressionUUID->"aecfa433-ab5e-4bdf-95b5-ed828e6fe08e"], - -Cell[BoxData[ - RowBox[{ - RowBox[{"u", "=", - RowBox[{"lu", " ", - RowBox[{"SparseArray", "[", - RowBox[{ - RowBox[{ - RowBox[{ - RowBox[{"{", - RowBox[{"i_", ",", "j_"}], "}"}], "/;", - RowBox[{"j", "\[GreaterEqual]", "i"}]}], "\[Rule]", "1"}], ",", - RowBox[{"{", - RowBox[{"5", ",", "5"}], "}"}]}], "]"}]}]}], ";"}]], "Input", - CellChangeTimes->{{3.8738201451434727`*^9, 3.873820146350107*^9}}, - CellLabel-> - "In[828]:=",ExpressionUUID->"789c9056-861a-4d2f-b50d-ccf966e52c55"], - -Cell[BoxData[ - RowBox[{ - RowBox[{"b", "=", - RowBox[{"{", - RowBox[{ - RowBox[{"-", "10.19"}], ",", " ", "101.92", ",", " ", "43.16", ",", - RowBox[{"-", "123.63"}], ",", "4.24"}], "}"}]}], ";"}]], "Input", - CellChangeTimes->{{3.873820037876417*^9, 3.8738200541880493`*^9}, - 3.8738200977675657`*^9, {3.873820164312252*^9, 3.87382018528706*^9}}, - CellLabel-> - "In[829]:=",ExpressionUUID->"eb5fb3dc-d0e9-4c2a-9231-fbdee6a69981"], - -Cell[BoxData[ - RowBox[{ - RowBox[{"y", "=", - RowBox[{"LinearSolve", "[", - RowBox[{"l", ",", - RowBox[{"b", "[", - RowBox[{"[", "p", "]"}], "]"}]}], "]"}]}], ";"}]], "Input", - CellLabel-> - "In[830]:=",ExpressionUUID->"85ddb7f7-078d-4d06-9cfc-e57143fdf917"], - -Cell[CellGroupData[{ - -Cell[BoxData[ - RowBox[{"LinearSolve", "[", - RowBox[{"u", ",", "y"}], "]"}]], "Input", - CellLabel-> - "In[831]:=",ExpressionUUID->"af25aa22-8833-4751-ae34-f83e5c012372"], - -Cell[BoxData[ - RowBox[{"{", - RowBox[{"6.500000000000001`", ",", - RowBox[{"-", "5.3`"}], ",", "6.699999999999999`", ",", - RowBox[{"-", "4.9`"}], ",", "1.3999999999999995`"}], "}"}]], "Output", - CellChangeTimes->{ - 3.873820187689494*^9, 3.873820345957288*^9, 3.873820395653883*^9, - 3.873821529965413*^9, 3.873821587146599*^9, {3.8738216293517313`*^9, - 3.8738216567982807`*^9}, {3.873884591439056*^9, 3.87388461003594*^9}, - 3.873884878631164*^9, 3.8738849377106953`*^9, 3.873885017936191*^9, - 3.8738855045009193`*^9, 3.873885854479301*^9, 3.873885892376915*^9, - 3.8738860618686333`*^9, 3.873886216751912*^9, 3.873886304470621*^9, - 3.873886355593725*^9, 3.87388641494897*^9}, - CellLabel-> - "Out[831]=",ExpressionUUID->"92429466-a378-4b8f-969b-5d3ba34bc72f"] -}, Open ]], - -Cell[CellGroupData[{ - -Cell[BoxData[ - RowBox[{"LinearSolve", "[", - RowBox[{"A", ",", "b"}], "]"}]], "Input", - CellChangeTimes->{{3.873886404466*^9, 3.873886410436647*^9}}, - CellLabel-> - "In[832]:=",ExpressionUUID->"59ac2e84-59e5-4162-b4e4-d5c9e3ad879f"], - -Cell[BoxData[ - RowBox[{"{", - RowBox[{"6.499999999999998`", ",", - RowBox[{"-", "5.300000000000001`"}], ",", "6.700000000000001`", ",", - RowBox[{"-", "4.900000000000001`"}], ",", "1.3999999999999992`"}], - "}"}]], "Output", - CellChangeTimes->{3.873886414988861*^9}, - CellLabel-> - "Out[832]=",ExpressionUUID->"1ac6f99c-bb9d-4b9d-9b81-830934bfdaba"] -}, Open ]] -}, -WindowSize->{808, 911}, -WindowMargins->{{Automatic, 167}, {64, Automatic}}, -FrontEndVersion->"12.1 for Mac OS X x86 (64-bit) (March 18, 2020)", -StyleDefinitions->"Default.nb", -ExpressionUUID->"dcdbbb14-eb6d-4fed-ba85-937c1f60b95b" -] -(* End of Notebook Content *) - -(* Internal cache information *) -(*CellTagsOutline -CellTagsIndex->{} -*) -(*CellTagsIndex -CellTagsIndex->{} -*) -(*NotebookFileOutline -Notebook[{ -Cell[558, 20, 302, 7, 30, "Input",ExpressionUUID->"41e5b97b-b44f-4d15-87e6-9e053be85385"], -Cell[863, 29, 597, 16, 30, "Input",ExpressionUUID->"6f7b8d72-9554-4028-aa5b-4e447c8682f1"], -Cell[CellGroupData[{ -Cell[1485, 49, 257, 5, 30, "Input",ExpressionUUID->"f25673d5-c4ab-4d90-aff9-c1075f28a925"], -Cell[1745, 56, 1198, 28, 76, "Output",ExpressionUUID->"fa8a9d60-b48d-43ea-9780-80209e904b9e"] -}, Open ]], -Cell[2958, 87, 369, 9, 30, "Input",ExpressionUUID->"2b6cf90a-ed7e-46ba-9cbd-97ff2db95ff9"], -Cell[3330, 98, 335, 8, 30, "Input",ExpressionUUID->"817188e7-589a-4e7e-94fe-fa8020639d81"], -Cell[3668, 108, 340, 7, 30, "Input",ExpressionUUID->"21cbb4e7-9a74-4bfb-b1d4-55ae75260b4d"], -Cell[CellGroupData[{ -Cell[4033, 119, 302, 7, 30, "Input",ExpressionUUID->"b2739b32-3614-4b53-89be-12abf10d241c"], -Cell[4338, 128, 739, 13, 34, "Output",ExpressionUUID->"b71f7dcd-4d67-47e6-b472-015d133fb489"] -}, Open ]], -Cell[5092, 144, 768, 18, 73, "Input",ExpressionUUID->"9dec25d4-6691-4f80-95b6-6d31800fcc15"], -Cell[5863, 164, 358, 8, 30, "Input",ExpressionUUID->"d8e98558-a838-471f-891b-f5fde99a5806"], -Cell[CellGroupData[{ -Cell[6246, 176, 636, 14, 73, "Input",ExpressionUUID->"9daa7836-803d-4fec-b35e-e414268c5517"], -Cell[6885, 192, 1426, 35, 92, "Output",ExpressionUUID->"87fe9717-8fd0-4878-8162-f397c94a16ec"], -Cell[8314, 229, 1154, 26, 51, "Output",ExpressionUUID->"309e5573-4259-4baa-9368-d59ec2c596b6"] -}, Open ]], -Cell[9483, 258, 401, 9, 30, "Input",ExpressionUUID->"4a2871bb-acdf-4f0e-b33b-fe9c6e0d6f2b"], -Cell[CellGroupData[{ -Cell[9909, 271, 436, 11, 30, "Input",ExpressionUUID->"4a9e265f-de0c-48aa-a0ef-6f9c598e5c51"], -Cell[10348, 284, 969, 24, 76, "Output",ExpressionUUID->"4db56fae-df15-40dc-82dc-cea0d9768988"] -}, Open ]], -Cell[11332, 311, 642, 18, 30, "Input",ExpressionUUID->"bdab867a-b5a2-4fe0-836c-9bd36622b9ec"], -Cell[11977, 331, 583, 16, 30, "Input",ExpressionUUID->"d9347773-9ae3-4df3-a691-e0a3bf335ca7"], -Cell[CellGroupData[{ -Cell[12585, 351, 413, 8, 73, "Input",ExpressionUUID->"67ab2db9-006a-4dbc-918c-f1595187f78b"], -Cell[13001, 361, 1089, 27, 76, "Output",ExpressionUUID->"e91bb598-3e5b-42c7-8e0e-6eb46d06d4c5"], -Cell[14093, 390, 1210, 30, 76, "Output",ExpressionUUID->"7797d898-12b5-4f05-bfd8-9eaa69004166"], -Cell[15306, 422, 1032, 26, 76, "Output",ExpressionUUID->"ac97130c-200c-423e-834b-be1bfb97047a"] -}, Open ]], -Cell[16353, 451, 256, 5, 30, "Input",ExpressionUUID->"bfdf5b61-e9bf-45ca-8335-c223dda8f4d6"], -Cell[CellGroupData[{ -Cell[16634, 460, 309, 7, 30, "Input",ExpressionUUID->"5f62f4af-3da9-4418-a89f-9e9ed2034ecb"], -Cell[16946, 469, 638, 12, 34, "Output",ExpressionUUID->"7a5d7922-5f93-4aa7-ada6-b022923f8461"] -}, Open ]], -Cell[17599, 484, 259, 5, 30, "Input",ExpressionUUID->"99477342-5c67-45ac-8133-c92237cd5832"], -Cell[17861, 491, 387, 10, 30, "Input",ExpressionUUID->"282f3c34-4b37-4864-bb1c-1e55d0557afe"], -Cell[CellGroupData[{ -Cell[18273, 505, 236, 5, 30, "Input",ExpressionUUID->"2e9bafd5-c3f0-4f20-ada5-c244e9da15df"], -Cell[18512, 512, 687, 13, 34, "Output",ExpressionUUID->"9a17b002-ad5e-4b6c-908a-ca6093153154"] -}, Open ]], -Cell[19214, 528, 347, 7, 30, "Input",ExpressionUUID->"ee22a100-a557-4a76-9309-a46c1731d8c7"], -Cell[CellGroupData[{ -Cell[19586, 539, 238, 5, 30, "Input",ExpressionUUID->"cbca244e-4be6-4346-a7ab-dc5203e7bdef"], -Cell[19827, 546, 355, 8, 34, "Output",ExpressionUUID->"32fb9c23-f868-4c65-80f6-6f046aff4e6e"] -}, Open ]], -Cell[20197, 557, 280, 6, 30, "Input",ExpressionUUID->"343c9c1b-6f39-477f-8d94-059828fedb35"], -Cell[20480, 565, 1036, 28, 52, "Input",ExpressionUUID->"13a7c346-7eb1-46b0-86dc-035a5dfe3833"], -Cell[CellGroupData[{ -Cell[21541, 597, 210, 4, 30, "Input",ExpressionUUID->"47a2829d-8e01-4bb0-893f-5b6e49dc6e33"], -Cell[21754, 603, 1404, 37, 110, "Output",ExpressionUUID->"8573a0d9-eb3d-4586-ba90-761fef5af103"] -}, Open ]], -Cell[23173, 643, 253, 7, 30, "Input",ExpressionUUID->"37953d2b-014a-427a-887b-588a6aa10f2e"], -Cell[CellGroupData[{ -Cell[23451, 654, 280, 6, 30, "Input",ExpressionUUID->"8d2e9e4e-96ba-42c1-9fc3-e845f655e08f"], -Cell[23734, 662, 687, 12, 34, "Output",ExpressionUUID->"53329e55-30da-499d-949c-c7cfccc3b0f9"] -}, Open ]], -Cell[24436, 677, 303, 8, 30, "Input",ExpressionUUID->"626d7270-4e75-4b49-a8a8-42895eda885f"], -Cell[CellGroupData[{ -Cell[24764, 689, 509, 12, 73, "Input",ExpressionUUID->"dea06982-b0de-45c7-8f63-cc86c1ca456d"], -Cell[25276, 703, 1822, 53, 142, "Output",ExpressionUUID->"660f4a7a-63f1-4d84-bc33-76ef15c71a78"], -Cell[27101, 758, 1676, 46, 90, "Output",ExpressionUUID->"eb717ef3-5ecf-4d7a-a71e-646410641d53"] -}, Open ]], -Cell[28792, 807, 347, 9, 30, "Input",ExpressionUUID->"4b28e487-55a0-44ce-8ff6-707135d41744"], -Cell[CellGroupData[{ -Cell[29164, 820, 297, 8, 30, "Input",ExpressionUUID->"69ef9827-97bf-4f09-b8d0-d064d9d7e538"], -Cell[29464, 830, 819, 22, 110, "Output",ExpressionUUID->"c59573a8-ab3e-48ce-a02d-ed13c441b61f"] -}, Open ]], -Cell[30298, 855, 256, 5, 30, "Input",ExpressionUUID->"79f92fc0-4767-4a7f-aa0c-6d097ea669c3"], -Cell[30557, 862, 1094, 31, 52, "Input",ExpressionUUID->"7490cda9-db9e-4685-9141-0ea5557776e5"], -Cell[CellGroupData[{ -Cell[31676, 897, 210, 4, 30, "Input",ExpressionUUID->"157fafe0-d722-4a26-b1f2-4dd55a612811"], -Cell[31889, 903, 1537, 42, 110, "Output",ExpressionUUID->"14cc1f82-a6e4-4307-ad3d-a53257cb251e"] -}, Open ]], -Cell[33441, 948, 253, 7, 30, "Input",ExpressionUUID->"246494f5-8cb8-4f04-aba9-2fdb96fa19b5"], -Cell[33697, 957, 595, 17, 30, "Input",ExpressionUUID->"aecfa433-ab5e-4bdf-95b5-ed828e6fe08e"], -Cell[34295, 976, 530, 15, 30, "Input",ExpressionUUID->"789c9056-861a-4d2f-b50d-ccf966e52c55"], -Cell[34828, 993, 443, 10, 30, "Input",ExpressionUUID->"eb5fb3dc-d0e9-4c2a-9231-fbdee6a69981"], -Cell[35274, 1005, 272, 8, 30, "Input",ExpressionUUID->"85ddb7f7-078d-4d06-9cfc-e57143fdf917"], -Cell[CellGroupData[{ -Cell[35571, 1017, 170, 4, 30, "Input",ExpressionUUID->"af25aa22-8833-4751-ae34-f83e5c012372"], -Cell[35744, 1023, 781, 14, 34, "Output",ExpressionUUID->"92429466-a378-4b8f-969b-5d3ba34bc72f"] -}, Open ]], -Cell[CellGroupData[{ -Cell[36562, 1042, 233, 5, 30, "Input",ExpressionUUID->"59ac2e84-59e5-4162-b4e4-d5c9e3ad879f"], -Cell[36798, 1049, 355, 8, 34, "Output",ExpressionUUID->"1ac6f99c-bb9d-4b9d-9b81-830934bfdaba"] -}, Open ]] -} -] -*) - -(* End of internal cache information *) - diff --git a/src/utils/unit_test/doc/nonlinearSolverReference.py b/src/utils/unit_test/doc/nonlinearSolverReference.py deleted file mode 100644 index 2aff1ec..0000000 --- a/src/utils/unit_test/doc/nonlinearSolverReference.py +++ /dev/null @@ -1,40 +0,0 @@ -from scipy.optimize import fsolve -import math - - -##---------------------------------------------------------------------------## -def quadratic2d(p): - x, y = p - return (y * y - x + 1, x * x - y - 1) - - -x, y = fsolve(quadratic2d, (1, 1), xtol=1.0e-13) - -print(x, y) -print(quadratic2d((x, y))) - - -##---------------------------------------------------------------------------## -def linear3d(p): - x, y, z = p - return (x - y + z - 1, 2 * x - z, x + 0.5 * y + 0.5 * z - 3) - - -x, y, z = fsolve(linear3d, (1, 1, 1), xtol=1.0e-13) - -print(x, y, z) -print(linear3d((x, y, z))) - - -##---------------------------------------------------------------------------## -def quadratic3d(p): - x, y, z = p - return (x * y * z + y - 1, y * y + x * x - 3, x * z + y - 5) - - -x, y, z = fsolve(quadratic3d, (1, 1, 1), xtol=1.0e-13) - -print(x, y, z) -print(quadratic3d((x, y, z))) - -##---------------------------------------------------------------------------## diff --git a/src/utils/unit_test/doc/smoothMath_reference.py b/src/utils/unit_test/doc/smoothMath_reference.py deleted file mode 100644 index 8ba3d1a..0000000 --- a/src/utils/unit_test/doc/smoothMath_reference.py +++ /dev/null @@ -1,196 +0,0 @@ -import math -import numpy as np - - -# Returns normalized vector -def normalize(v): - norm = np.linalg.norm(v) - if norm == 0: - return v - return v / norm - - -# The implementation of norm(x, tol) in SmoothMath -# for vectors -def smooth_norm(x, tol): - dotp = np.dot(x, x) - tol2 = tol * tol - - if (tol2 <= dotp): - return np.sqrt(dotp) - else: - return 0.5 * (dotp + tol2) / tol - - -def deriv_smooth_norm(x, tol, dir): - dotp = np.dot(x, x) - tol2 = tol * tol - - if (tol2 <= dotp): - return x[dir] / np.sqrt(dotp) - else: - return x[dir] / tol - - -# The implementation of norm(v, M, tol) in SmoothMath -# for vectors and a metric tensor -def smooth_metric_norm(x, M, tol): - dotp = x.T @ M @ x - tol2 = tol * tol - - if (tol2 <= dotp): - return np.sqrt(dotp) - else: - return 0.5 * (dotp + tol2) / tol - - -# See the following -# https://math.stackexchange.com/questions/189434/derivative-of-quadratic-form -def deriv_smooth_metric_norm(x, M, tol, dir): - dotp = x.T @ M @ x - tol2 = tol * tol - Dx = (M + M.T) @ x - - if (tol2 <= dotp): - return 0.5 * Dx[dir] / np.sqrt(dotp) - else: - return 0.5 * Dx[dir] / tol - - -# Test vectors -v2 = np.array([0.25, -0.166]) -v3 = np.array([0.175, 0.33, -0.92]) - -# Tolerance -tol = 1.0 - -# Print the norm of one of the vectors -print('smooth_norm v2: (0.0) ', smooth_norm(v2, 0.0)) -print('smooth_norm v2: (%d) ' % tol, smooth_norm(v2, tol)) - -print('deriv_smooth_norm v2: (0.0) ', deriv_smooth_norm(v2, 0.0, 0)) -print('deriv_smooth_norm v2: (0.0) ', deriv_smooth_norm(v2, 0.0, 1)) - -print('deriv_smooth_norm v2: (%d) ' % tol, deriv_smooth_norm(v2, tol, 0)) -print('deriv_smooth_norm v2: (%d) ' % tol, deriv_smooth_norm(v2, tol, 1)) - -print('smooth_norm v3: (0.0) ', smooth_norm(v3, 0.0)) -print('smooth_norm v3: (%d) ' % tol, smooth_norm(v3, tol)) - -print('deriv_smooth_norm v3: (0.0) ', deriv_smooth_norm(v3, 0.0, 0)) -print('deriv_smooth_norm v3: (0.0) ', deriv_smooth_norm(v3, 0.0, 1)) -print('deriv_smooth_norm v3: (0.0) ', deriv_smooth_norm(v3, 0.0, 2)) - -print('deriv_smooth_norm v3: (%d) ' % tol, deriv_smooth_norm(v3, tol, 0)) -print('deriv_smooth_norm v3: (%d) ' % tol, deriv_smooth_norm(v3, tol, 1)) -print('deriv_smooth_norm v3: (%d) ' % tol, deriv_smooth_norm(v3, tol, 2)) - -# Construct two orthonormal basis vectors -a = [1.0, 1.0] -b = [-1.0, 1.0] - -# Normalize -a = normalize(a) -b = normalize(b) - -# Build a matrix of eigenvectors -U = np.vstack([a, b]) - -# Element lengths -h1 = 0.5 -h2 = 1.0 - -# Diagonal matrix -S = np.diag([h1, h2]) - -# Construct a 2d metric tensor -M2 = U.T @ S @ U -print(M2) -# Print the norm of one of the vectors -print('smooth_metric_norm v2: (0.0) ', smooth_metric_norm(v2, M2, 0.0)) -print('smooth_metric_norm v2: (%d) ' % tol, smooth_metric_norm(v2, M2, tol)) - -print('deriv_smooth_metric_norm v2: (0.0) ', - deriv_smooth_metric_norm(v2, M2, 0.0, 0)) -print('deriv_smooth_metric_norm v2: (0.0) ', - deriv_smooth_metric_norm(v2, M2, 0.0, 1)) - -print('deriv_smooth_metric_norm v2: (%d) ' % tol, - deriv_smooth_metric_norm(v2, M2, tol, 0)) -print('deriv_smooth_metric_norm v2: (%d) ' % tol, - deriv_smooth_metric_norm(v2, M2, tol, 1)) - -# Now create a 3d orthonormal basis -a = [1.0, 1.0, 0] -b = [-1.0, 1.0, 0] -c = np.cross(a, b) -a = normalize(a) -b = normalize(b) -c = normalize(c) - -U = np.vstack([a, b, c]) - -# Element lengths -h1 = 0.5 -h2 = 0.25 -h3 = 1.0 - -S = np.diag([h1, h2, h3]) - -# Construct a 3d metric tensor -M3 = U.T @ S @ U -print(M3) - -print('smooth_metric_norm v3: (0.0) ', smooth_metric_norm(v3, M3, 0.0)) -print('smooth_metric_norm v3: (%d) ' % tol, smooth_metric_norm(v3, M3, tol)) - -print('deriv_smooth_metric_norm v3: (0.0) ', - deriv_smooth_metric_norm(v3, M3, 0.0, 0)) -print('deriv_smooth_metric_norm v3: (0.0) ', - deriv_smooth_metric_norm(v3, M3, 0.0, 1)) -print('deriv_smooth_netric_norm v3: (0.0) ', - deriv_smooth_metric_norm(v3, M3, 0.0, 2)) - -print('deriv_smooth_metric_norm v3: (%d) ' % tol, - deriv_smooth_metric_norm(v3, M3, tol, 0)) -print('deriv_smooth_metric_norm v3: (%d) ' % tol, - deriv_smooth_metric_norm(v3, M3, tol, 1)) -print('deriv_smooth_metric_norm v3: (%d) ' % tol, - deriv_smooth_metric_norm(v3, M3, tol, 2)) - -# Now test the identity -M2 = np.array([[1.0, 0.0], [0.0, 1.0]]) -print(M2) -print('smooth_metric_norm v2: (0.0) %.18f' % smooth_metric_norm(v2, M2, 0.0)) -print('smooth_metric_norm v2: (%d) %.18f' % - (tol, smooth_metric_norm(v2, M2, tol))) - -print('deriv_smooth_metric_norm v2: (0.0) %.18f' % - deriv_smooth_metric_norm(v2, M2, 0.0, 0)) -print('deriv_smooth_metric_norm v2: (0.0) %.18f' % - deriv_smooth_metric_norm(v2, M2, 0.0, 1)) - -print('deriv_smooth_metric_norm v2: (%d) %.18f' % - (tol, deriv_smooth_metric_norm(v2, M2, tol, 0))) -print('deriv_smooth_metric_norm v2: (%d) %.18f' % - (tol, deriv_smooth_metric_norm(v2, M2, tol, 1))) - -M3 = np.array([[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]]) -print(M3) -print('smooth_metric_norm v3: (0.0) %.18f' % smooth_metric_norm(v3, M3, 0.0)) -print('smooth_metric_norm v3: (%d) %.18f' % - (tol, smooth_metric_norm(v3, M3, tol))) - -print('deriv_smooth_metric_norm v3: (0.0) %.18f' % - deriv_smooth_metric_norm(v3, M3, 0.0, 0)) -print('deriv_smooth_netric_norm v3: (0.0) %.18f' % - deriv_smooth_metric_norm(v3, M3, 0.0, 1)) -print('deriv_smooth_netric_norm v3: (0.0) %.18f' % - deriv_smooth_metric_norm(v3, M3, 0.0, 2)) - -print('deriv_smooth_metric_norm v3: (%d) %.18f' % - (tol, deriv_smooth_metric_norm(v3, M3, tol, 0))) -print('deriv_smooth_metric_norm v3: (%d) %.18f' % - (tol, deriv_smooth_metric_norm(v3, M3, tol, 1))) -print('deriv_smooth_metric_norm v3: (%d) %.18f' % - (tol, deriv_smooth_metric_norm(v3, M3, tol, 2))) diff --git a/src/utils/unit_test/tstConstants.cpp b/src/utils/unit_test/tstConstants.cpp deleted file mode 100644 index 97ce8bd..0000000 --- a/src/utils/unit_test/tstConstants.cpp +++ /dev/null @@ -1,58 +0,0 @@ -#include - -#include - -#include - -#include - -#include - -using namespace VertexCFD; - -namespace Test -{ -//---------------------------------------------------------------------------// -void constantTest() -{ - // Test on the CPU. - EXPECT_EQ(std::acos(-1.0), Constants::pi); - EXPECT_EQ(acosf(-1.0f), Constants::pi_v); - EXPECT_EQ(acosl(-1.0L), Constants::pi_v); - - // Results views for testing on device. - // long double is not available in CUDA. - Kokkos::View dbl_result("dbl_result"); - Kokkos::View flt_result("flt_result"); - - // Assign constant in a kernel. - Kokkos::parallel_for( - "pi", - Kokkos::RangePolicy(0, 1), - KOKKOS_LAMBDA(const int) { - dbl_result(0) = Constants::pi; - flt_result(0) = Constants::pi_v; - }); - - // Copy results to host. - auto dbl_host - = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace{}, dbl_result); - auto flt_host - = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace{}, flt_result); - - // Make sure device value matches host value. - EXPECT_EQ(Constants::pi, dbl_host(0)); - EXPECT_EQ(Constants::pi_v, flt_host(0)); -} - -//---------------------------------------------------------------------------// -// RUN TESTS -//---------------------------------------------------------------------------// -TEST(Constants, pi) -{ - constantTest(); -} - -//---------------------------------------------------------------------------// - -} // namespace Test diff --git a/src/utils/unit_test/tstMatrixMath.cpp b/src/utils/unit_test/tstMatrixMath.cpp deleted file mode 100644 index 819468a..0000000 --- a/src/utils/unit_test/tstMatrixMath.cpp +++ /dev/null @@ -1,239 +0,0 @@ -#include - -#include - -#include - -#include - -using namespace VertexCFD; - -namespace Test -{ -//---------------------------------------------------------------------------// -void lupDecompAndSolveTest3x3() -{ - constexpr int dim = 3; - Kokkos::View A("A"); - Kokkos::View p("p"); - Kokkos::View b("b"); - Kokkos::View w("w"); - - // Create host mirror views - auto A_host = Kokkos::create_mirror_view(A); - auto p_host = Kokkos::create_mirror_view(p); - auto b_host = Kokkos::create_mirror_view(b); - - A_host(0, 0) = 1; - A_host(0, 1) = 2; - A_host(0, 2) = 4; - - A_host(1, 0) = 2; - A_host(1, 1) = 1; - A_host(1, 2) = 3; - - A_host(2, 0) = 3; - A_host(2, 1) = 2; - A_host(2, 2) = 4; - - b_host(0) = 3; - b_host(1) = 4; - b_host(2) = 5; - - // Deep copy the initialized view to device - Kokkos::deep_copy(A, A_host); - Kokkos::deep_copy(b, b_host); - - // Apply the operation in a kernel. - Kokkos::parallel_for( - "lu_decomp_and_solve", - Kokkos::RangePolicy(0, 1), - KOKKOS_LAMBDA(const int) { - MatrixMath::LUP(A, p); - MatrixMath::LUP_solve(A, p, w, b); - }); - - // Deep copy results to host - Kokkos::deep_copy(A_host, A); - Kokkos::deep_copy(p_host, p); - Kokkos::deep_copy(b_host, b); - - const double A_exp[dim][dim] - = {{1. / 3., 4. / 3., 8. / 3.}, {2. / 3., -1. / 4., 1.}, {3., 2., 4.}}; - - for (int i = 0; i < dim; ++i) - for (int j = 0; j < dim; ++j) - EXPECT_DOUBLE_EQ(A_exp[i][j], A_host(i, j)); - - const int p_exp[dim] = {2, 0, 1}; - const double b_exp[dim] = {1, -1, 1}; - - for (int i = 0; i < dim; ++i) - { - EXPECT_EQ(p_exp[i], p_host(i)); - EXPECT_DOUBLE_EQ(b_exp[i], b_host(i)); - } -} - -//---------------------------------------------------------------------------// -void lupDecompTest5x5() -{ - constexpr int dim = 5; - Kokkos::View A("A"); - Kokkos::View p("p"); - - // Create host mirror views - auto A_host = Kokkos::create_mirror_view(A); - auto p_host = Kokkos::create_mirror_view(p); - - A_host(0, 0) = 8; - A_host(0, 1) = -2; - A_host(0, 2) = -8; - A_host(0, 3) = 9; - A_host(0, 4) = 6; - - A_host(1, 0) = 9; - A_host(1, 1) = 5; - A_host(1, 2) = 5; - A_host(1, 3) = 3; - A_host(1, 4) = 1; - - A_host(2, 0) = 9; - A_host(2, 1) = -7; - A_host(2, 2) = 2; - A_host(2, 3) = 8; - A_host(2, 4) = 4; - - A_host(3, 0) = 9; - A_host(3, 1) = 6; - A_host(3, 2) = -9; - A_host(3, 3) = 0; - A_host(3, 4) = -8; - - A_host(4, 0) = -7; - A_host(4, 1) = 9; - A_host(4, 2) = -9; - A_host(4, 3) = -7; - A_host(4, 4) = 6; - - // Deep copy the initialized view to device - Kokkos::deep_copy(A, A_host); - - // Apply the operation in a kernel. - Kokkos::parallel_for( - "lu_decomp", - Kokkos::RangePolicy(0, 1), - KOKKOS_LAMBDA(const int) { MatrixMath::LUP(A, p); }); - - // Deep copy results to host - Kokkos::deep_copy(A_host, A); - Kokkos::deep_copy(p_host, p); - - const double A_exp[dim][dim] - = {{8.0 / 9.0, -0.5, -15.0, 4.0, 8.5}, - {9.0, 5.0, 5.0, 3.0, 1.0}, - {1.0, -27.0 / 29.0, 15.0 / 29.0, 410.0 / 1817.0, 31989.0 / 3634.0}, - {1.0, 9.0 / 116.0, 263.0 / 290.0, -1817.0 / 290.0, -2499.0 / 145.0}, - {-7.0 / 9.0, 116.0 / 9.0, -46.0 / 9.0, -14.0 / 3.0, 61.0 / 9.0}}; - - for (int i = 0; i < dim; ++i) - for (int j = 0; j < dim; ++j) - EXPECT_NEAR(A_exp[i][j], A_host(i, j), 5.0e-15); - - const int p_exp[dim] = {1, 4, 0, 3, 2}; - - for (int i = 0; i < dim; ++i) - EXPECT_EQ(p_exp[i], p_host(i)); -} - -//---------------------------------------------------------------------------// -void lupSolveTest5x5() -{ - constexpr int dim = 5; - Kokkos::View A("A"); - Kokkos::View p("p"); - Kokkos::View b("b"); - Kokkos::View w("w"); - - // Create host mirror views - auto A_host = Kokkos::create_mirror_view(A); - auto b_host = Kokkos::create_mirror_view(b); - - A_host(0, 0) = -2.6; - A_host(0, 1) = -7.2; - A_host(0, 2) = -0.4; - A_host(0, 3) = 7.5; - A_host(0, 4) = 5.7; - - A_host(1, 0) = 2.2; - A_host(1, 1) = -4.9; - A_host(1, 2) = 3.8; - A_host(1, 3) = -8.7; - A_host(1, 4) = -4.6; - - A_host(2, 0) = 4.8; - A_host(2, 1) = -4.6; - A_host(2, 2) = 5.7; - A_host(2, 3) = 7.9; - A_host(2, 4) = -8.5; - - A_host(3, 0) = -4.5; - A_host(3, 1) = 1.4; - A_host(3, 2) = -9.5; - A_host(3, 3) = 2.7; - A_host(3, 4) = -7.2; - - A_host(4, 0) = 2.1; - A_host(4, 1) = -2.6; - A_host(4, 2) = -7.4; - A_host(4, 3) = -5.3; - A_host(4, 4) = 0.3; - - b_host(0) = -10.19; - b_host(1) = 101.92; - b_host(2) = 43.16; - b_host(3) = -123.63; - b_host(4) = 4.24; - - // Deep copy the initialized view to device - Kokkos::deep_copy(A, A_host); - Kokkos::deep_copy(b, b_host); - - // Apply the operation in a kernel. - Kokkos::parallel_for( - "lu_decomp", - Kokkos::RangePolicy(0, 1), - KOKKOS_LAMBDA(const int) { - MatrixMath::LUP(A, p); - MatrixMath::LUP_solve(A, p, w, b); - }); - - // Deep copy results to host - Kokkos::deep_copy(A_host, A); - Kokkos::deep_copy(b_host, b); - - const double b_exp[dim] = {6.5, -5.3, 6.7, -4.9, 1.4}; - - for (int i = 0; i < dim; ++i) - EXPECT_DOUBLE_EQ(b_exp[i], b_host(i)); -} - -//---------------------------------------------------------------------------// -// RUN TESTS -//---------------------------------------------------------------------------// -TEST(MatrixMath, lupDecomp3x3) -{ - lupDecompAndSolveTest3x3(); -} -//---------------------------------------------------------------------------// -TEST(MatrixMath, lupDecomp5x5) -{ - lupDecompTest5x5(); -} -//---------------------------------------------------------------------------// -TEST(MatrixMath, lupSolve5x5) -{ - lupSolveTest5x5(); -} -//---------------------------------------------------------------------------// -} // namespace Test diff --git a/src/utils/unit_test/tstParameterPack.cpp b/src/utils/unit_test/tstParameterPack.cpp deleted file mode 100644 index 30bc8a1..0000000 --- a/src/utils/unit_test/tstParameterPack.cpp +++ /dev/null @@ -1,66 +0,0 @@ -#include - -#include - -#include - -#include - -using namespace VertexCFD; - -namespace Test -{ -//---------------------------------------------------------------------------// -void captureTest() -{ - // Make some Kokkos views. - Kokkos::View dbl_view("dbl_view"); - Kokkos::View int_view("int_view"); - - // Make a parameter pack so we can capture them as a group. - auto pack = Utils::makeParameterPack(dbl_view, int_view); - - // Update the pack in a kernel - Kokkos::parallel_for( - "fill_pack", - Kokkos::RangePolicy(0, 1), - KOKKOS_LAMBDA(const int) { - auto dv = get<0>(pack); - auto iv = get<1>(pack); - - dv(0) = 3.14; - iv(0, 0) = 12; - }); - - // Check the capture. - auto dbl_host - = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), dbl_view); - auto int_host - = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), int_view); - - EXPECT_EQ(3.14, dbl_host(0)); - EXPECT_EQ(12, int_host(0, 0)); -} - -//---------------------------------------------------------------------------// -void emptyTest() -{ - std::ignore = Utils::makeParameterPack(); -} - -//---------------------------------------------------------------------------// -// RUN TESTS -//---------------------------------------------------------------------------// -TEST(TEST_CATEGORY, parameter_pack_capture) -{ - captureTest(); -} - -TEST(TEST_CATEGORY, parameter_pack_empty) -{ - emptyTest(); -} - -//---------------------------------------------------------------------------// - -} // end namespace Test diff --git a/src/utils/unit_test/tstScalarToVector.cpp b/src/utils/unit_test/tstScalarToVector.cpp deleted file mode 100644 index 664e4a5..0000000 --- a/src/utils/unit_test/tstScalarToVector.cpp +++ /dev/null @@ -1,225 +0,0 @@ -#include - -#include -#include - -#include -#include - -#include -#include -#include -#include - -#include - -#include - -#include - -#include - -#include - -//---------------------------------------------------------------------------// -// TESTS -//---------------------------------------------------------------------------// -namespace VertexCFD -{ -namespace Test -{ -//---------------------------------------------------------------------------// -template -struct Dependencies : public panzer::EvaluatorWithBaseImpl, - public PHX::EvaluatorDerived -{ - using scalar_type = typename EvalType::ScalarT; - int num_vel_dim; - - // Array of field solutions - std::vector> velocities; - std::vector> - dxdt_velocities; - std::vector> - grad_velocities; - - Dependencies(const panzer::IntegrationRule& ir, int dim) - : num_vel_dim(dim) - { - velocities.resize(num_vel_dim); - dxdt_velocities.resize(num_vel_dim); - grad_velocities.resize(num_vel_dim); - std::string name; - for (int dim = 0; dim < num_vel_dim; ++dim) - { - name = "velocity_" + std::to_string(dim); - velocities[dim] - = PHX::MDField( - name, ir.dl_scalar); - - name = "DXDT_velocity_" + std::to_string(dim); - dxdt_velocities[dim] - = PHX::MDField( - name, ir.dl_scalar); - - name = "GRAD_velocity_" + std::to_string(dim); - grad_velocities[dim] = PHX:: - MDField( - name, ir.dl_vector); - - this->addEvaluatedField(velocities[dim]); - this->addEvaluatedField(dxdt_velocities[dim]); - this->addEvaluatedField(grad_velocities[dim]); - } - - this->setName("ScalarToVector Unit Test Dependencies"); - } - - void evaluateFields(typename panzer::Traits::EvalData workset) override - { - const int num_vel_dim = velocities.size(); - const int num_points = velocities[0].extent(1); - - for (int vel_dim = 0; vel_dim < num_vel_dim; ++vel_dim) - { - // Create host mirrors of fields - auto vel_view = velocities[vel_dim].get_view(); - auto dxdt_vel_view = dxdt_velocities[vel_dim].get_view(); - auto grad_vel_view = grad_velocities[vel_dim].get_view(); - auto host_vel = Kokkos::create_mirror(vel_view); - auto host_dxdt_vel = Kokkos::create_mirror(dxdt_vel_view); - auto host_grad_vel = Kokkos::create_mirror(grad_vel_view); - - for (int cell = 0; cell < workset.num_cells; ++cell) - { - for (int point = 0; point < num_points; ++point) - { - // Set velocity values - double val = static_cast(vel_dim + 3 * point); - host_vel(cell, point) = val; - - // Set dxdt_velocity values - val = static_cast(100 + vel_dim + 3 * point); - host_dxdt_vel(cell, point) = val; - - // Set grad_velocity values - int num_space_dim = grad_vel_view.extent(2); - for (int space_dim = 0; space_dim < num_space_dim; - ++space_dim) - { - val = static_cast(vel_dim + 3 * point - + 9 * space_dim); - host_grad_vel(cell, point, space_dim) = val; - } - } - } - Kokkos::deep_copy(vel_view, host_vel); - Kokkos::deep_copy(dxdt_vel_view, host_dxdt_vel); - Kokkos::deep_copy(grad_vel_view, host_grad_vel); - } - } -}; - -template -void testEval() -{ - // Setup test fixture. - constexpr int num_vel_dim = NumVelDim; - const int integration_order = 2; - const int basis_order = 1; - EvaluatorTestFixture test_fixture( - num_vel_dim, integration_order, basis_order); - - auto& ir = *test_fixture.ir; - - // Create test dependency to set initial fields - auto deps = Teuchos::rcp(new Dependencies(ir, num_vel_dim)); - test_fixture.registerEvaluator(deps); - - // Create evaluator. - auto eval = Teuchos::rcp(new Utils::ScalarToVector( - ir, "velocity", num_vel_dim, true)); - test_fixture.registerEvaluator(eval); - - // Add required test fields. - test_fixture.registerTestField(eval->_vector_fields); - test_fixture.registerTestField(eval->_vector_dxdt_fields); - test_fixture.registerTestField(eval->_vector_grad_fields); - - // Evaluate - test_fixture.evaluate(); - - // Check the values - const auto vector_vel - = test_fixture.getTestFieldData(eval->_vector_fields); - const auto vector_dxdt_vel - = test_fixture.getTestFieldData(eval->_vector_dxdt_fields); - const auto vector_grad_vel - = test_fixture.getTestFieldData(eval->_vector_grad_fields); - - // Check the solution - const int num_point = ir.num_points; - for (int qp = 0; qp < num_point; ++qp) - { - for (int vel_dim = 0; vel_dim < num_vel_dim; ++vel_dim) - { - // Test velocity - double expected = static_cast(vel_dim + 3 * qp); - EXPECT_DOUBLE_EQ(expected, fieldValue(vector_vel, 0, qp, vel_dim)); - - // Test dxdt_velocity - expected = static_cast(100 + vel_dim + 3 * qp); - EXPECT_DOUBLE_EQ(expected, - fieldValue(vector_dxdt_vel, 0, qp, vel_dim)); - - // Test grad_velocity - for (int space_dim = 0; space_dim < NumSpaceDim; ++space_dim) - { - expected - = static_cast(vel_dim + 3 * qp + 9 * space_dim); - EXPECT_DOUBLE_EQ( - expected, - fieldValue(vector_grad_vel, 0, qp, space_dim, vel_dim)); - } - } - } -} - -//---------------------------------------------------------------------------// -TEST(S2V_22, residual_test) -{ - testEval(); -} - -//---------------------------------------------------------------------------// -TEST(S2V_22, jacobian_test) -{ - testEval(); -} - -//---------------------------------------------------------------------------// -TEST(S2V_33, residual_test) -{ - testEval(); -} - -//---------------------------------------------------------------------------// -TEST(S2V_33, jacobian_test) -{ - testEval(); -} - -//---------------------------------------------------------------------------// -TEST(S2V_32, residual_test) -{ - testEval(); -} - -//---------------------------------------------------------------------------// -TEST(S2V_32, jacobian_test) -{ - testEval(); -} - -} // end namespace Test -} // end namespace VertexCFD diff --git a/src/utils/unit_test/tstTypeTraits.cpp b/src/utils/unit_test/tstTypeTraits.cpp deleted file mode 100644 index d8e3dfe..0000000 --- a/src/utils/unit_test/tstTypeTraits.cpp +++ /dev/null @@ -1,241 +0,0 @@ -#include "VertexCFD_Utils_TypeTraits.hpp" - -#include - -#include - -using namespace VertexCFD; - -namespace Test -{ -//---------------------------------------------------------------------------// -// Test ExpectedType against ResultType. -template -void testResultType(const Types&...) -{ - using Result = ResultType; - ::testing::StaticAssertTypeEq(); -} - -//---------------------------------------------------------------------------// -// Test with a single argument of different types. -TEST(TypeTraits, OneArgument) -{ - // int - testResultType(1); - - // double - testResultType(1.0); - - // Static FAD - using sfad_type = Sacado::Fad::SFad; - sfad_type a = 1.0; - - // SFad - testResultType(a); - - // SFad expr - testResultType(a * a + 1); - - // Dynamic FAD - using dfad_type = Sacado::Fad::DFad; - dfad_type x(1, 1.0); - - // DFad - testResultType(x); - - // DFad expr - testResultType(x * x + 1); - - // Nested FAD -> DFad - using nfad_type = Sacado::Fad::DFad; - nfad_type p(1, 1.0); - - // DFad - testResultType(p); - - // DFad expr - testResultType(p * p + 1); - - // DFad/DFad/SFad expr - testResultType(a * x + p); -} - -//---------------------------------------------------------------------------// -// Test with two arguments of various type combinations. -TEST(TypeTraits, TwoArgument) -{ - // int / int - testResultType(1, 2); - - // double / int - testResultType(1.0, 2); - testResultType(1, 2.0); - - // double / double - testResultType(1.0, 2.0); - - // Static FAD - using sfad_type = Sacado::Fad::SFad; - sfad_type a = 1.0; - sfad_type b = 2.0; - - // SFad / int - testResultType(a, 1); - testResultType(1, a); - - // SFad / double - testResultType(a, 1.0); - testResultType(1.0, a); - - // SFad / SFad - testResultType(a, b); - - // SFad expr / int - testResultType(a * a + 1, 1); - testResultType(1, a * a + 1); - - // SFad expr / double - testResultType(a * a + 1, 1.0); - testResultType(1.0, a * a + 1); - - // SFad expr / SFad - testResultType(a * a + 1, b); - testResultType(b, a * a + 1); - - // SFad expr / SFad expr - testResultType(a * a + 1, 2 * b + b); - - // Dynamic FAD - using dfad_type = Sacado::Fad::DFad; - dfad_type x(1, 1.0); - dfad_type y(1, 1.0); - - // DFad / int - testResultType(x, 1); - testResultType(1, x); - - // DFad / double - testResultType(x, 1.0); - testResultType(1.0, x); - - // DFad / DFad - testResultType(x, y); - - // DFad expr / int - testResultType(x * x + 1, 1); - testResultType(1, x * x + 1); - - // DFad expr / double - testResultType(x * x + 1, 1.0); - testResultType(1.0, x * x + 1); - - // DFad expr / DFad - testResultType(x * x + 1, y); - testResultType(y, x * x + 1); - - // DFad expr / DFad expr - testResultType(x * x + 1, 2 * y + y); - - // Nested FAD -> DFad - using nfad_type = Sacado::Fad::DFad; - nfad_type p(1, 1.0); - nfad_type q(1, 2.0); - - // DFad / int - testResultType(p, 1); - testResultType(1, p); - - // DFad / double - testResultType(p, 1.0); - testResultType(1.0, p); - - // DFad / SFad - testResultType(p, a); - testResultType(a, p); - - // DFad / SFad expr - testResultType(p, a * a + 1); - testResultType(a * a + 1, p); - - // DFad / DFad - testResultType(p, x); - testResultType(x, p); - - // DFad / DFad expr - testResultType(p, x * x + 1); - testResultType(x * x + 1, p); - - // DFad / DFad - testResultType(p, q); - - // DFad expr / int - testResultType(p * p + 1, 1); - testResultType(1, p * p + 1); - - // DFad expr / double - testResultType(p * p + 1, 1.0); - testResultType(1.0, p * p + 1); - - // DFad expr / SFad - testResultType(p * p + 1, a); - testResultType(a, p * p + 1); - - // DFad expr / SFad expr - testResultType(p * p + 1, 2 * a + 1); - testResultType(2 * a + 1, p * p + 1); - - // DFad expr / DFad - testResultType(p * p + 1, x); - testResultType(x, p * p + 1); - - // DFad expr / DFad expr - testResultType(p * p + 1, 2 * x + 1); - testResultType(2 * x + 1, p * p + 1); - - // DFad expr / DFad - testResultType(p * p + 1, q); - testResultType(q, p * p + 1); - - // DFad expr / DFad expr - testResultType(p * p + 1, 2 * q + q); -} - -//---------------------------------------------------------------------------// -// Test with many arguments of various types. -TEST(TypeTraits, ManyArgument) -{ - // int - testResultType(1, 2, 3, 4, 5); - - // double / int - testResultType(1, 2.0, 3, 4.0, 5); - - // Static FAD - using sfad_type = Sacado::Fad::SFad; - sfad_type a = 1.0; - sfad_type b = 2.0; - - // SFad expr / SFad / double / int - testResultType(1, a, 2.0, a * b + 1, b); - - // Dynamic FAD - using dfad_type = Sacado::Fad::DFad; - dfad_type x(1, 1.0); - dfad_type y(1, 1.0); - - // DFad expr / DFad / double / int - testResultType(1, x, 2.0, x * y + 1, y); - - // Nested FAD -> DFad - using nfad_type = Sacado::Fad::DFad; - nfad_type p(1, 1.0); - nfad_type q(1, 2.0); - - // Everything - testResultType( - 1, p, 2.0, p * q + 1, 2 * x + y, x, a, a * b - 1, a + x + p); -} - -//---------------------------------------------------------------------------// -} // namespace Test diff --git a/src/utils/unit_test/tstVectorizeOutputFieldNames.cpp b/src/utils/unit_test/tstVectorizeOutputFieldNames.cpp deleted file mode 100644 index 155dcde..0000000 --- a/src/utils/unit_test/tstVectorizeOutputFieldNames.cpp +++ /dev/null @@ -1,81 +0,0 @@ -#include "VertexCFD_Utils_VectorizeOutputFieldNames.hpp" - -#include - -#include - -using namespace VertexCFD; - -namespace Test -{ -//---------------------------------------------------------------------------// -void vectorizeOutputFieldNamesTest() -{ - Teuchos::ParameterList params; - params.sublist("Nodal Quantities") - .set("block_0", "node_val 0,node_val 1,all_val 0") - .set("block_1", "node_val 1,node_val 2,all_val 1"); - params.sublist("Cell Quantities") - .set("block_0", "cell_val 0,cell_val 1,all_val 0") - .set("block_1", "cell_val 1,cell_val 2,all_val 2"); - params.sublist("Cell Average Quantities") - .set("block_0", "cell_avg_val 0,cell_avg_val 1,all_val 3") - .set("block_1", "cell_avg_val 1,cell_avg_val 2,all_val 1"); - params.sublist("Cell Average Vectors") - .set("block_0", "cell_vec_val 0,cell_vec_val 1,all_val 0") - .set("block_1", "cell_vec_val 1,cell_vec_val 2,all_val 3"); - - // Expected returns are vectors of unique field names, which will - // be ordered - const std::vector exp_fields = {"all_val 0", - "all_val 1", - "all_val 2", - "all_val 3", - "cell_avg_val 0", - "cell_avg_val 1", - "cell_avg_val 2", - "cell_val 0", - "cell_val 1", - "cell_val 2", - "node_val 0", - "node_val 1", - "node_val 2"}; - const std::vector exp_vec_fields = {"all_val 0", - "all_val 3", - "cell_vec_val 0", - "cell_vec_val 1", - "cell_vec_val 2"}; - - std::vector out_fields; - std::vector out_vector_fields; - VectorizeOutputFieldNames::getOutputFields( - params, out_fields, out_vector_fields); - - const int size_ef = exp_fields.size(); - const int size_of = out_fields.size(); - EXPECT_EQ(size_ef, size_of); - for (int i = 0; i < size_ef; ++i) - { - EXPECT_EQ(exp_fields[i], out_fields[i]); - } - - const int size_evf = exp_vec_fields.size(); - const int size_ovf = out_vector_fields.size(); - EXPECT_EQ(size_evf, size_ovf); - for (int i = 0; i < size_evf; ++i) - { - EXPECT_EQ(exp_vec_fields[i], out_vector_fields[i]); - } -} - -//---------------------------------------------------------------------------// -// RUN TESTS -//---------------------------------------------------------------------------// -TEST(VectorizeOutputFieldNames, test) -{ - vectorizeOutputFieldNamesTest(); -} - -//---------------------------------------------------------------------------// - -} // namespace Test diff --git a/src/utils/unit_test/tstVersion.cpp b/src/utils/unit_test/tstVersion.cpp deleted file mode 100644 index 67adeb6..0000000 --- a/src/utils/unit_test/tstVersion.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include - -#include - -#include - -//---------------------------------------------------------------------------// -// TESTS -//---------------------------------------------------------------------------// -namespace Test -{ -TEST(vertexcfd_version, version_test) -{ - auto const version_id = VertexCFD::Utils::version(); - EXPECT_TRUE(!version_id.empty()); - std::cout << "VertexCFD version " << version_id << std::endl; - - auto const commit_hash = VertexCFD::Utils::git_commit_hash(); - EXPECT_TRUE(!commit_hash.empty()); - std::cout << "VertexCFD commit hash " << commit_hash << std::endl; -} - -} // end namespace Test