splinepy icon indicating copy to clipboard operation
splinepy copied to clipboard

Error in examples: Microstructure hollow cube

Open clemens-fricke opened this issue 10 months ago • 6 comments

When running the examples two examples ['splinepy/examples/show_readme.py', 'splinepy/examples/show_microstructures.py'] fail both at the same part:

Traceback (most recent call last):
  File "splinepy/examples/show_readme.py", line 276, in <module>
    splinepy.microstructure.tiles.show(alpha=0.7, background=bg)
  File "xxx/envs/testsplinepy/lib/python3.12/site-packages/splinepy/microstructure/tiles/__init__.py", line 174, in show
    to_show.append([key, Multipatch(value().create_tile()[0])])
                                    ^^^^^^^^^^^^^^^^^^^^^
  File "xxx/envs/testsplinepy/lib/python3.12/site-packages/splinepy/microstructure/tiles/hollow_cube.py", line 75, in create_tile
    (parameters[:, 2:] > _np.deg2rad(-30))
ValueError: The truth value of an empty array is ambiguous. Use `array.size > 0` to check that an array is not empty.

and

^[Traceback (most recent call last):
  File "splinepy/examples/show_microstructures.py", line 45, in <module>
    splinepy.microstructure.tiles.show(
  File "xxx/envs/testsplinepy/lib/python3.12/site-packages/splinepy/microstructure/tiles/__init__.py", line 174, in show
    to_show.append([key, Multipatch(value().create_tile()[0])])
                                    ^^^^^^^^^^^^^^^^^^^^^
  File "xxx/envs/testsplinepy/lib/python3.12/site-packages/splinepy/microstructure/tiles/hollow_cube.py", line 75, in create_tile
    (parameters[:, 2:] > _np.deg2rad(-30))
ValueError: The truth value of an empty array is ambiguous. Use `array.size > 0` to check that an array is not empty.

I am not sure where this directly comes from. @markriegler, you are currently the one with the most expertise in the microstructure code. Could you take a look at this?

This also does not show up in the tests.

clemens-fricke avatar Feb 18 '25 10:02 clemens-fricke

I'll have a look at this

markriegler avatar Feb 18 '25 12:02 markriegler

I just talked to Konstantin and he brought to my attention another issue with this exact microtile. As far as I know it is unrelated to the current error, but might be something we should keep in mind.

in the corners of this microtile where the edge pieces meet is a hidden void. I would assume this is not supposed to be there. To fix this we would need to introduce a new patch in the corner connecting the side pieces. Since the structure on the end of the end pieces would be complicated if the void is to be removed.

Image Void shown via a cutting plane in one of the corners. @jzwar @j042 Was this an oversight or is this supposed to be like this?

clemens-fricke avatar Feb 18 '25 12:02 clemens-fricke

I found the issue: in the parameter check for the HollowCube-tile there is a second parameter check, which looks to me like some code relict. The check tries to find whether the rotation parameter is valid. But in the implementation there is no rotation going on. It looks to me, that at some point a rotation parametrization was planned but never implemented (at least to the main branch). Therefore, these lines should be deleted as they are not relevant to the tile.

As a sidenote, in my PR #457 the obsolete rotation parameter check is not there and hence the examples should work with that PR.

markriegler avatar Feb 19 '25 10:02 markriegler

Regarding the void: I think that may be an oversight. Here is a picture of one tile patch and one of the interfaces of this patch:

Image

The control points at the interface of adjacent patches are congruent. Because the patches are trilinear (order [1,1,1] Beziers), I think the idea was that the the Bezier would go in a straight line from control point to control point (see control points 1 and 2 in the right picture), but since we have a tensor-product, the connection between these two points is not straight and hence these voids occur.

One way I can think of to mitigate this problem is to split each of these patches into multiple ones so that the control points then connect in straight lines.

markriegler avatar Feb 19 '25 13:02 markriegler

Konstantin and I thought about it and our opinion is that maybe it is easiest and most straightforward if we add an additional patch in each corner. So that there is a rectangular patch in each corner connecting the side pieces. This would mean increasing the number of patches by 8, but we could not think of a way to fix the voids without increasing the patches by this amount.

clemens-fricke avatar Feb 20 '25 08:02 clemens-fricke

Any update on this? Also related to #481

jzwar avatar Nov 03 '25 20:11 jzwar