MFC icon indicating copy to clipboard operation
MFC copied to clipboard

MHD Hyperbolic Divergence Cleaning

Open ChrisZYJ opened this issue 1 month ago • 3 comments

Description

Implements the correct hyperbolic divergence cleaning for 2D/3D MHD in place of the current Powell's method. It is fully working and validated (with results below).

It is based on an outdated MFC branch, so it needs to be rebased, cleaned up, and made GPU-ready. @danieljvickers might be interested in collaborating on this; otherwise, I will get this ready as time permits.

Formulation

image image

Type of change

  • [x] Bug fix (non-breaking change which fixes an issue)
  • [x] New feature (non-breaking change which adds functionality)
  • [ ] Something else

Scope

  • [x] This PR comprises a set of related changes with a common goal

How Has This Been Tested?

All the test cases are temporarily placed in the case_new folder.

  • [x] Gaussian divergence pulse image image image

  • [x] Slanted Shock Tube image image image

  • [x] Orszag-Tang Vortex

orszag_tang_all

Orszag-Tang result at final time; comparison across WENO variants. Top row is p. Bottom row is ∇·B. The last column shows the last saved time step before crashing, for a simulation without hyperbolic cleaning. 3Z is a typo; it should be 5Z.

  • [x] 2D Rotor Test image

Checklist

  • [ ] I have added comments for the new code
  • [ ] I added Doxygen docstrings to the new code
  • [ ] I have made corresponding changes to the documentation (docs/)
  • [ ] I have added regression tests to the test suite so that people can verify in the future that the feature is behaving as expected
  • [ ] I have added example cases in examples/ that demonstrate my new feature performing as expected. They run to completion and demonstrate "interesting physics"
  • [ ] I ran ./mfc.sh format before committing my code
  • [ ] New and existing tests pass locally with my changes, including with GPU capability enabled (both NVIDIA hardware with NVHPC compilers and AMD hardware with CRAY compilers) and disabled
  • [ ] This PR does not introduce any repeated code (it follows the DRY principle)
  • [ ] I cannot think of a way to condense this code and reduce any introduced additional line count

If your code changes any code source files (anything in src/simulation)

To make sure the code is performing as expected on GPU devices, I have:

  • [ ] Checked that the code compiles using NVHPC compilers
  • [ ] Checked that the code compiles using CRAY compilers
  • [ ] Ran the code on either V100, A100, or H100 GPUs and ensured the new feature performed as expected (the GPU results match the CPU results)
  • [ ] Ran the code on MI200+ GPUs and ensure the new features performed as expected (the GPU results match the CPU results)
  • [ ] Enclosed the new feature via nvtx ranges so that they can be identified in profiles
  • [ ] Ran a Nsight Systems profile using ./mfc.sh run XXXX --gpu -t simulation --nsys, and have attached the output file (.nsys-rep) and plain text results to this PR
  • [ ] Ran a Rocprof Systems profile using ./mfc.sh run XXXX --gpu -t simulation --rsys --hip-trace, and have attached the output file and plain text results to this PR.
  • [ ] Ran my code using various numbers of different GPUs (1, 2, and 8, for example) in parallel and made sure that the results scale similarly to what happens if you run without the new code/feature

ChrisZYJ avatar Dec 13 '25 01:12 ChrisZYJ