project-asgard / asgard

MIT License
27 stars 20 forks source link

Divergence in global kronmult part 2 -- spherical coordinates. #680

Closed stefan-schnake closed 4 months ago

stefan-schnake commented 5 months ago

Describe the bug The global and local kronmults are giving different answers for the Lenard Bernstein operator in a spherical geometry $(r,\theta,\varphi)$. By assuming the solution is $\varphi$-independent, this is a 2D problem.

To Reproduce Steps to reproduce the behavior: Branch: https://github.com/stefan-schnake/asgard/tree/sphericalLB

Direct solve

$ ./asgard -p sphericalLB -d 3 -t 5e-4 -i -s direct -l "4 4" -f -n 30 --wave_freq 10
$ h5ls -d asgard_wavelet_30.h5 | grep "soln" -A 2
soln                     Dataset {2304}
    Data:
         0.264964329597886, -0.149014228533018, 0.0453808396932725, -0.326671680771401, 0.153262855582123, -0.0395087037216358,

Local Kronmult

$ ./asgard -p sphericalLB -d 3 -t 5e-4 -i -s gmres -l "4 4" -f -n 30 --wave_freq 10 --tol 1e-8
$ h5ls -d asgard_wavelet_30.h5 | grep "soln" -A 2
soln                     Dataset {2304}
    Data:
         0.26496432917609, -0.149014228326022, 0.0453808395745888, -0.326671680143496, 0.153262855270588, -0.0395087035134349,

Global kronmult

$ ./asgard -p sphericalLB -d 3 -t 5e-4 -i -s gmres -l "4 4" -f -n 30 --wave_freq 10 --tol 1e-8
$ h5ls -d asgard_wavelet_30.h5 | grep "soln" -A 2
soln                     Dataset {2304}
    Data:
         0.280384556797627, -0.103052290198367, 0.0177648573092251, -0.359258977366088, 0.111001778931191, -0.0167937880358365,

I've verified that the direct/local solve is correct. If u_f in https://github.com/stefan-schnake/asgard/blob/sphericalLB/src/pde/pde_sphericalLB.hpp#L38 is set to zero (so that the maxwellian is centered at the origin), all three solves agree.

System:

Additional context Add any other context about the problem here.

mkstoyanov commented 5 months ago

First thing that comes to mind is the mass matrix. Local Kronmult always applies the mass matrix even if it is identity (multiplying a bunch of zeros in the process). Global Kronmult skips the mass matrix

Check the code here. If this returns true then the corresponding term will not be applied to the equation.

https://github.com/project-asgard/asgard/blob/8c74b7b37c343fbb26b6abd9ef8ba8ea95913268/src/asgard_kronmult_matrix.cpp#L1173

If I understand correctly when you change the geometry then the mass matrix is never identity. One quick check is to see if the problem disappears if this method always returns false (i.e., put return false; at the top).

mkstoyanov commented 4 months ago

@stefan-schnake did we successfully resolve this one?

stefan-schnake commented 4 months ago

Yes we did.

On Wed, Jun 19, 2024, 17:22 Miroslav Stoyanov @.***> wrote:

@stefan-schnake https://github.com/stefan-schnake did we successfully resolve this one?

— Reply to this email directly, view it on GitHub https://github.com/project-asgard/asgard/issues/680#issuecomment-2179471119, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARIMHCFVRYXJWNRFAHLSV6TZIHY77AVCNFSM6AAAAABI2WL6B6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNZZGQ3TCMJRHE . You are receiving this because you were mentioned.Message ID: @.***>