facebookresearch / fmmax

Fourier modal method with Jax
MIT License
97 stars 10 forks source link

Avoid computing smoothness/fourier loss when weight is zero #75

Closed mfschubert closed 9 months ago

mfschubert commented 9 months ago

It seems that smoothness loss (used in generating tangent vector fields) can be problematic in some situations: in particular, it seems to result in long compile times on mac.

One option is to use the formulations using the Fourier loss; this penalizes terms corresponding to high frequencies in the Fourier representation of the tangent vector field, rather than directly penalizing non-smoothness of the fields in real space. However, currently the smoothness loss is calculated, even if the smoothness loss weight is zero (i.e. for the Fourier loss formulations).

In this PR, we update the logic so that Fourier loss and smoothness loss are calculated only if their corresponding weights are nonzero. Performance of the non-Fourier formulations could be investigated as a follow-up.