Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FVM_Cylinder_GMsh.ipynb returns KeyError: ('cells', False) #178

Open
StuvX opened this issue Oct 3, 2024 · 3 comments
Open

FVM_Cylinder_GMsh.ipynb returns KeyError: ('cells', False) #178

StuvX opened this issue Oct 3, 2024 · 3 comments

Comments

@StuvX
Copy link

StuvX commented Oct 3, 2024

When I try to run FVM_Cylinder_GMsh.ipynb I get the following error:


KeyError Traceback (most recent call last)
File ~/miniconda3/envs/grow2/lib/python3.10/site-packages/IPython/core/formatters.py:347, in BaseFormatter.call(self, obj)
345 method = get_real_method(obj, self.print_method)
346 if method is not None:
--> 347 return method()
348 return None
349 else:

File ~/miniconda3/envs/grow2/lib/python3.10/site-packages/matplotlib/animation.py:1362, in Animation.repr_html(self)
1360 fmt = mpl.rcParams['animation.html']
1361 if fmt == 'html5':
-> 1362 return self.to_html5_video()
1363 elif fmt == 'jshtml':
1364 return self.to_jshtml()

File ~/miniconda3/envs/grow2/lib/python3.10/site-packages/matplotlib/animation.py:1289, in Animation.to_html5_video(self, embed_limit)
1285 Writer = writers[mpl.rcParams['animation.writer']]
1286 writer = Writer(codec='h264',
1287 bitrate=mpl.rcParams['animation.bitrate'],
1288 fps=1000. / self._interval)
-> 1289 self.save(str(path), writer=writer)
1290 # Now open and base64 encode.
1291 vid64 = base64.encodebytes(path.read_bytes())

File ~/miniconda3/envs/grow2/lib/python3.10/site-packages/matplotlib/animation.py:1092, in Animation.save(self, filename, writer, fps, dpi, codec, bitrate, extra_args, metadata, extra_anim, savefig_kwargs, progress_callback)
1089 with writer.saving(self._fig, filename, dpi),
1090 cbook._setattr_cm(self._fig.canvas, _is_saving=True, manager=None):
1091 for anim in all_anim:
-> 1092 anim._init_draw() # Clear the initial frame
1093 frame_number = 0
1094 # TODO: Currently only FuncAnimation has a save_count
1095 # attribute. Can we generalize this to all Animations?

File ~/miniconda3/envs/grow2/lib/python3.10/site-packages/matplotlib/animation.py:1749, in FuncAnimation._init_draw(self)
1741 warnings.warn(
1742 "Can not start iterating the frames for the initial draw. "
1743 "This can be caused by passing in a 0 length sequence "
(...)
1746 "it may be exhausted due to a previous display or save."
1747 )
1748 return
-> 1749 self._draw_frame(frame_data)
1750 else:
1751 self._drawn_artists = self._init_func()

File ~/miniconda3/envs/grow2/lib/python3.10/site-packages/matplotlib/animation.py:1768, in FuncAnimation._draw_frame(self, framedata)
1764 self._save_seq = self._save_seq[-self._save_count:]
1766 # Call the func with framedata and args. If blitting is desired,
1767 # func needs to return a sequence of any artists that were modified.
-> 1768 self._drawn_artists = self._func(framedata, *self._args)
1770 if self._blit:
1772 err = RuntimeError('The animation function must return a sequence '
1773 'of Artist objects.')

File ~/miniconda3/envs/grow2/lib/python3.10/site-packages/phi/vis/_matplotlib/_matplotlib_plots.py:157, in MatplotlibPlots.animate..clear_and_plot(frame)
154 axis.set_subplotspec(specs[axis])
155 # subplot.set_title(titles[subplot])
156 # plt.tight_layout()
--> 157 plot_frame_function(frame)

File ~/miniconda3/envs/grow2/lib/python3.10/site-packages/phi/vis/_vis.py:399, in plot..plot_frame(frame)
397 for i, f in enumerate(fields):
398 idx = indices[pos][i]
--> 399 f = f[{animate.name: frame}]
400 plots.plot(f, figure, axes[pos], subplots[pos], min_val, max_val, show_color_bar, color[idx], alpha[idx], err[idx])
401 plots.finalize(figure)

File ~/miniconda3/envs/grow2/lib/python3.10/site-packages/phi/field/_field.py:641, in Field.getitem(self, item)
639 if not item:
640 return self
--> 641 boundary = domain_slice(self._boundary, item, self.resolution)
642 item_without_vec = {dim: selection for dim, selection in item.items() if dim != 'vector'}
643 geometry = self._geometry[item_without_vec]

File ~/miniconda3/envs/grow2/lib/python3.10/site-packages/phiml/math/extrapolation.py:1791, in domain_slice(ext, item, domain_dims)
1789 domain_dims = parse_dim_order(domain_dims)
1790 for dim in domain_dims:
-> 1791 lo = ext._getitem_with_domain(item, dim, False, domain_dims)
1792 up = ext._getitem_with_domain(item, dim, True, domain_dims)
1793 if lo == up:

File ~/miniconda3/envs/grow2/lib/python3.10/site-packages/phiml/math/extrapolation.py:1343, in _MixedExtrapolation._getitem_with_domain(self, item, dim, upper_edge, all_dims)
1341 if b in [dim, dim+('+' if upper_edge else '-')]:
1342 return ext._getitem_with_domain(item, b[:-1], b.endswith('+'), all_dims)
-> 1343 raise KeyError((dim, upper_edge))

KeyError: ('cells', False)

@StuvX StuvX changed the title FVM_Cylinder_GMsh.ipynb with custom SU2 mesh returns KeyError: ('cells', False) FVM_Cylinder_GMsh.ipynb returns KeyError: ('cells', False) Oct 4, 2024
@holl-
Copy link
Collaborator

holl- commented Oct 6, 2024

Hey, thanks for the bug report! I'll look into it soon. In the meantime, could you check whether this still occurs with the latest version 3.1.0?
pip install --upgrade phiflow

@StuvX
Copy link
Author

StuvX commented Oct 7, 2024

Now I receive the following error:

/usr/local/lib/python3.10/dist-packages/phiml/backend/torch/_torch_backend.py:800: UserWarning: Sparse CSR tensor support is in beta state. If you miss a functionality in the sparse tensor support, please submit a feature request to https://github.com/pytorch/pytorch/issues. (Triggered internally at ../aten/src/ATen/SparseCsrTensorImpl.cpp:53.)
return torch.sparse_csr_tensor(row_pointers, column_indices, values, shape, device=values.device)


AssertionError Traceback (most recent call last)

in <cell line: 4>()
2 boundary = {'x-': wind, 'x+': ZERO_GRADIENT, 'y': 0, 'cyl': 0}#, 'cells': True}
3 velocity = Field(mesh, tensor(vec(x=0, y=0)), boundary)
----> 4 v_trj = math.iterate(implicit_time_step, batch(time=100), velocity, dt=0.001, range=trange)

4 frames

/usr/local/lib/python3.10/dist-packages/phi/field/_field_math.py in stack(fields, dim, dim_bounds)
950 return PointCloud(geometry, values, boundary)
951 elif fields[0].is_mesh:
--> 952 assert all([f.geometry == fields[0].geometry for f in fields]), f"stacking fields with different geometries is not supported. Got {[f.geometry for f in fields]}"
953 values = math.stack([f.values for f in fields], dim)
954 return Field(fields[0].geometry, values, boundary)

AssertionError: stacking fields with different geometries is not supported. Got [Mesh(cellsⁱ=10566, vectorᶜ=x,y), Mesh(cellsⁱ=10566, vectorᶜ=x,y), Mesh(cellsⁱ=10566, vectorᶜ=x,y), Mesh(cellsⁱ=10566, vectorᶜ=x,y), Mesh(cellsⁱ=10566, vectorᶜ=x,y), Mesh(cellsⁱ=10566, vectorᶜ=x,y), Mesh(cellsⁱ=10566, vectorᶜ=x,y), Mesh(cellsⁱ=10566, vectorᶜ=x,y), Mesh(cellsⁱ=10566, vectorᶜ=x,y), Mesh(cellsⁱ=10566, vectorᶜ=x,y), Mesh(cellsⁱ=10566, vectorᶜ=x,y), Mesh(cellsⁱ=10566, vectorᶜ=x,y), Mesh(cellsⁱ=10566, vectorᶜ=x,y), Mesh(cellsⁱ=10566, vectorᶜ=x,y), Mesh(cellsⁱ=10566, vectorᶜ=x,y), Mesh(cellsⁱ=10566, vectorᶜ=x,y), Mesh(cellsⁱ=10566, vectorᶜ=x,y), Mesh(cellsⁱ=10566, vectorᶜ=x,y), Mesh(cellsⁱ=10566, vectorᶜ=x,y), Mesh(cellsⁱ=10566, vectorᶜ=x,y), Mesh(cellsⁱ=10566, vectorᶜ=x,y), Mesh(cellsⁱ=10566, vectorᶜ=x,y), Mesh(cellsⁱ=10566, vectorᶜ=x,y), Mesh(cellsⁱ=10566, vectorᶜ=x,y), Mesh(cellsⁱ=10566, vectorᶜ=x,y), Mesh(cellsⁱ=10566, vectorᶜ=x,y), Mesh(cellsⁱ=10566, vectorᶜ=x,y), Mesh(cellsⁱ=10566, vectorᶜ=x,y), Mesh(cellsⁱ=10566, vectorᶜ=x,y), Mesh(cellsⁱ=10566, vectorᶜ=x,y), Mesh(cellsⁱ=10566, vectorᶜ=x,y), Mesh(cellsⁱ=10566, vectorᶜ=x,y), Mesh(cellsⁱ=10566, vectorᶜ=x,y), Mesh(cellsⁱ=10566, vectorᶜ=x,y), Mesh(cellsⁱ=10566, vectorᶜ=x,y), Mesh(cellsⁱ=10566, vectorᶜ=x,y), Mesh(cellsⁱ=10566, vectorᶜ=x,y), Mesh(cellsⁱ=10566, vectorᶜ=x,y), Mesh(cellsⁱ=10566, vectorᶜ=x,y), Mesh(cellsⁱ=10566, vectorᶜ=x,y), Mesh(cellsⁱ=10566, vectorᶜ=x,y), Mesh(cellsⁱ=10566, vectorᶜ=x,y), Mesh(cellsⁱ=10566,

@holl-
Copy link
Collaborator

holl- commented Oct 12, 2024

It runs on my machine with the latest version. Could you try

pip uninstall phiflow phiml
pip install git+https://github.com/tum-pbs/PhiFlow@develop

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants