piernik-dev / piernik

Piernik MHD Code
GNU General Public License v3.0
15 stars 15 forks source link

An option for explicit diffusion restricted to act only below some level and interpolate to higher levels #471

Closed gawrysz closed 1 year ago

gawrysz commented 2 years ago

Since diffusion is limited by dx2, in AMR simulations it may severely slow down the computation even if the diffusion solver itself does not consume too much time. Assuming that we diffuse already smooth fields we may do the diffusion only up to certain level and keep the dt limited by other solvers. Finer levels may then be updated by high order interpolation (prolongation).

gawrysz commented 2 years ago

Difference between computed and analytic solution for CRtest with diffusion restricted to level 2. Note that most of the error is located on fine-coarse interface. cr_tst_0001_Slice_z_err1

The inaccuracy slightly distinguishes between left and right direction in each dimension, which may point to some issues with interpreting the magnetic field.

The implicit diffusion is much more accurate in this example.

EDIT: After #481 It should look much better, but will require some extra work on merge, due to conflicts.

gawrysz commented 2 years ago

ToDo1: diff_max_lev may be changed from a stiff parameter to an automatically computed variable and be the highest level that does not limit the timestep more than other solvers do. Some sanity checks would be necessary as that limiting level may happen to be below base level :)

ToDo2: A check whether the diffused field is smooth enough for particular restriction of the diffusion solver whould be nice. Unfortunately, without any prior assumptions, the cost may be comparable to checking for Loechner refinement criterion. But a smooth field may only get smoother, so such a check should be integrated into routines that create the field to be diffused.

gawrysz commented 1 year ago

Difference between computed and analytic solution for CRtest with diffusion restricted to level 2 after merging #481, resolving conflicts and other updates due to recent merges.

cr_tst_0001_Slice_z_err1

Small artifacts due to prolongation of a diagonal gradient are visible, but this is the most difficult case for any directional-split interpolation (such as bilinear or bi-cubic).

The same quantity without restrictions for diffusion: cr_ts4_0001_Slice_z_err1