ryosuke-hirai / HORMONE

Repository for hydrodynamical code HORMONE
GNU General Public License v3.0
0 stars 1 forks source link

Uninitialised grid variable in gravity solver #64

Closed conradtchan closed 1 month ago

conradtchan commented 2 months ago

On line 376 of gravity_hyperbolic.f90:

+ ( idx3(k)+idx3(k-1) )*dxi1(i)*dxi2(j) )

where k=gks-1,gke.

However, idx3 is only initialised from ks_global-1 (same as gks-1) in gridset.f90. So idx3(k-1) is a potentially uninitialised variable.

@ryosuke-hirai could you please help me understand what physical length dx3 and it's inverse idx3 describes? Naively, I would think that the k-1 value should be initialised because the grid is periodic in the phi direction. Or is there a mistake in the calculation of lap_coeff(0,i,j,k)?

ryosuke-hirai commented 1 month ago

I just did the Laplacian calculation again and I think that is a typo... It's supposed to be + ( idx3(k)+idx3(k+1) )*dxi1(i)*dxi2(j) )

The reason why the dx3 values are not really defined for the ks-2 indices is because it's sort of undefinable. The dxi3(k) values are the distances from interface to interface of the kth cell so that is defined by default. The dx3(k) values are the distances from cell centre to cell centre (cell k-1 to k) so unless the ks-3'th cell is defined, there is no way to calculate the distance for dx3(ks-2) in general. There should be nowhere in the code where this value is used, so this is simply a typo. Thanks for catching this!