Skip to content

Add reflecting boundary conditions#140

Merged
pgrete merged 20 commits into
mainfrom
pgrete/reflect
May 12, 2025
Merged

Add reflecting boundary conditions#140
pgrete merged 20 commits into
mainfrom
pgrete/reflect

Conversation

@pgrete
Copy link
Copy Markdown
Contributor

@pgrete pgrete commented Apr 4, 2025

What is says on the tin (and the docs).

Bonus: LW implosion test problem.

@pgrete pgrete requested a review from BenWibking April 4, 2025 11:41
@pgrete
Copy link
Copy Markdown
Contributor Author

pgrete commented Apr 4, 2025

Also, I just ran some quick test wrt symmetry preservation. RK3 with PPM is not that great (see also discussion around Athena++ and that method paper),but VL2+PLM is (density at t=2.4):
image

@BenWibking
Copy link
Copy Markdown
Contributor

Did you disable FMA instructions with a compiler flag? I don't think the reconstruction method should matter. In Quokka, RK2+PPM gives perfect symmetry preservation, as long as you disable FMA instructions.

@pgrete
Copy link
Copy Markdown
Contributor Author

pgrete commented Apr 4, 2025

Did you disable FMA instructions with a compiler flag? I don't think the reconstruction method should matter. In Quokka, RK2+PPM gives perfect symmetry preservation, as long as you disable FMA instructions.

I have not tried disabling FMA.

Copy link
Copy Markdown
Contributor

@BenWibking BenWibking left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comments below. The major concern I have is that the symmetry does not appear to be preserved when there are multiple MeshBlocks used for the LW problem.

Comment thread docs/input.md Outdated
Comment thread inputs/lw_implode.in Outdated
Comment thread src/bvals/boundary_conditions_apk.hpp
Comment thread src/bvals/boundary_conditions_apk.hpp
Comment thread src/pgen/lw_implode.cpp
@BenWibking
Copy link
Copy Markdown
Contributor

BenWibking commented Apr 16, 2025

Did you disable FMA instructions with a compiler flag? I don't think the reconstruction method should matter. In Quokka, RK2+PPM gives perfect symmetry preservation, as long as you disable FMA instructions.

I have not tried disabling FMA.

For CUDA, I disabled FMA in Quokka with these CMake flags:

if(DISABLE_FMAD)
  message(STATUS "Fused multiply-add (FMAD) is disabled for device code.")

  if(CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA")
    add_compile_options($<$<COMPILE_LANGUAGE:CUDA>:--fmad=false>)
  endif()

  if(CMAKE_CUDA_COMPILER_ID STREQUAL "Clang")
    add_compile_options($<$<COMPILE_LANGUAGE:CUDA>:-ffp-contract=off>)
    add_compile_options($<$<COMPILE_LANGUAGE:C>:-ffp-contract=off>)
    add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-ffp-contract=off>)
  endif()

  if(CMAKE_CUDA_COMPILER_ID STREQUAL "NVHPC")
    add_compile_options($<$<COMPILE_LANGUAGE:C>:-Mnofma>)
    add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Mnofma>)
    add_compile_options($<$<COMPILE_LANGUAGE:CUDA>:-gpu=nofma>)
  endif()
else()
  # fused MAD causes directional asymmetry -- enabled by default by nvcc and clang
  message(STATUS "Fused multiply-add (FMAD) is *enabled* for device code. Exact direction symmetry will NOT be preserved.")
endif(DISABLE_FMAD)

@pgrete
Copy link
Copy Markdown
Contributor Author

pgrete commented May 12, 2025

Alright, I think this is good to go now.

@pgrete pgrete enabled auto-merge (squash) May 12, 2025 13:51
@pgrete pgrete merged commit 7520da3 into main May 12, 2025
4 checks passed
@pgrete pgrete deleted the pgrete/reflect branch May 12, 2025 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants