FireDynamics / fdsreader

Python reader for FDS data
GNU General Public License v3.0
44 stars 18 forks source link

Problems with smoke3d to_global() #75

Open Sokdenumeros opened 5 months ago

Sokdenumeros commented 5 months ago

Hi, I've been getting some error messages when loading smoke3d data.

Here's what I got and what I think may be the issue from looking at the to_global() code in smoke3d.py:

1 ---- LINE: (214) subsmoke_data = np.concatenate((subsmoke_data, temp_data[dim][tuple(temp_data_slices)]), axis=axis + 1) ERROR MESSAGE: ValueError: all the input array dimensions except for the concatenation axis must match exactly, but along dimension 3, the array at index 0 has size 40 and the array at index 1 has size 21. POTENTIAL PROBEM: here it is trying to concatenate temp_data, which was calculated at line 188 and subsmoke_data which was modified at line 204. Moving the block of code between lines 195 and 206 before line 179 seems to fix that issue for me.

2 ---- LINE: (200): n_repeat = max(int(round( POTENTIAL PROBLEM: I think the two lines before that one were removed by mistake in the last commit "for axis in (0, 1, 2):" and "dim = ('x', 'y', 'z')[axis]" without those, this block of code is inside the "if masked" condition above which I don't think it's intended.

Finally, that's a non issue but I think the variables global_max and coord_max are the same, so one is probably redundant.

Sokdenumeros commented 5 months ago

For the second problem, I just noticed that if I add back the loops as follows: for axis in range(3): dim = ('x', 'y', 'z')[axis] # Add border points back again if needed if np.isclose(subsmoke.mesh.coordinates[dim][-1], global_max[dim]): temp_data_slices = [slice(s) for s in subsmoke_data.shape] temp_data_slices[axis + 1] = slice(None) subsmoke_data = np.concatenate((subsmoke_data, temp_data[dim][tuple(temp_data_slices)]), axis=axis + 1)

It can happen that if more than one dimension is close to the global_max, for the next axis it tries to concatenate arrays it will break. Because the shape of subsmoke_data will have been modified after the first concatenation.