Exawind / amr-wind

AMReX-based structured wind solver
https://exawind.github.io/amr-wind
Other
112 stars 83 forks source link

Spurious currents created across coarse-fine boundary from hydrostatic pressure near air-water interface #1200

Open mbkuhn opened 3 months ago

mbkuhn commented 3 months ago

Bug description

When the air-water interface crosses a coarse-fine boundary, a flat, quiescent interface leads to spurious velocities. This is likely due to the discretization of the pressure equation in amrex (MLMG), in particular its interpolation of sigma (1/rho). More detail will be in comments below. No spuriousness arises when the interface is perfectly aligned with the cell boundaries (because then there is no gradient of density) and likewise when the density ratio between phases is unity.

Steps to reproduce

Simple case that can be run in serial, only needs one time step to show up. flat-surface-inp.txt

Steps to reproduce the behavior:

  1. Compiler used
    • [ ] GCC
    • [ ] LLVM
    • [ ] oneapi (Intel)
    • [ ] nvcc (NVIDIA)
    • [ ] rocm (AMD)
    • [x] with MPI
    • [x] other: apple-clang
  2. Operating system
    • [ ] Linux
    • [x] OSX
    • [ ] Windows
    • [ ] other (do tell ;)):
  3. Hardware:
    • [x] CPU
    • [ ] GPU
  4. Machine details ():
    basic amr-wind environment created using exawind-manager on my laptop
  5. Input file attachments
  6. Error (paste or attach):
    <!-- error output -->
  7. If this is a segfault, a stack trace from a debug build (paste or attach):
    <!-- stack trace -->

Expected behavior

Velocities to remain near 0.

AMR-Wind information

not a problem with a particular commit

==============================================================================
                AMR-Wind (https://github.com/exawind/amr-wind)

  AMR-Wind version :: v2.1.0-85-g741cb771
  AMR-Wind Git SHA :: 741cb77111da01fe7026512f0a0cfdb3b9072398
  AMReX version    :: 24.08-11-gb6ed5237987e

  Exec. time       :: Fri Aug 16 10:52:33 2024
  Build time       :: Aug 16 2024 10:51:55
  C++ compiler     :: AppleClang 14.0.3.14030022

  MPI              :: ON    (Num. ranks = 8)
  GPU              :: OFF
  OpenMP           :: OFF

  Enabled third-party libraries: 
    NetCDF    4.9.2
    HYPRE     2.31.0

           This software is released under the BSD 3-clause license.           
 See https://github.com/Exawind/amr-wind/blob/development/LICENSE for details. 
------------------------------------------------------------------------------

Additional context

see comments

mbkuhn commented 3 months ago

In this test case, the interface is placed 1 fine cell below z=0 and 0.5 coarse cell below z = 0, leading to the density distribution shown.

Screenshot 2024-08-16 at 11 05 02 AM

After 1 timestep, spurious currents show up near the interface

Screenshot 2024-08-16 at 10 54 30 AM

These occur alongside pressure gradient changes that also shouldn't be there

Screenshot 2024-08-16 at 10 53 13 AM Screenshot 2024-08-16 at 10 52 59 AM
mbkuhn commented 3 months ago

I went a bit deeper to isolate the problem more. It's not a problem with the fillpatch operations, changing them has no effect.

With this case beginning at rest, the only active term in the first time step is the gravity forcing. To simplify things a bit, I set the mac velocities to 0 to avoid having to look at both projections and to zero out the advection term. Diffusion is also inactive. After the explicit terms are added (rhs op), which includes the gravity term, the velocity fields are entirely uniform, with u = v = 0 and w = -g * dt. Then the algorithm goes to the projection. I also output the RHS of the projection, and the only nonzero divergence in the domain is at the top and bottom walls (as expected). After the nodal projection solve, the spurious currents arise. This has to do with how sigma is handled/interpolated across coarse-fine boundaries because, as mentioned in the description, if the interface is at z = 0, there is no problem, or if the density is uniform, there is no problem.

mbkuhn commented 3 months ago

It's difficult to say much about the long-term behavior of the spurious velocities because the pressure solver really struggles with this case (and maybe multi-level hypre needs to be applied here). However, after 10 timesteps the convective CFL has risen about 5x compared to the first time step.

github-actions[bot] commented 2 months ago

This issue is stale because it has been open 30 days with no activity.

mbkuhn commented 2 weeks ago

this paper seems to address the problem directly: https://www.sciencedirect.com/science/article/pii/S0021999124007332#sec0003