tataratat / splinepy

Library for prototyping spline geometries of arbitrary dimensions and degrees, and IGA
https://tataratat.github.io/splinepy
Other
47 stars 13 forks source link

Add drilled tile rebased #316

Closed mkofler96 closed 11 months ago

mkofler96 commented 12 months ago

Overview

added new microtile

Addressed issues

.

Showcase

A "short" example to highlight the (new) feature

# %%
import splinepy as sp
import gustaf as gus
import numpy as np
import vedo

# comment this line to visualize within the notebook (limited functionalities)
vedo.settings.default_backend = "vtk"

# %%
microstructure = sp.microstructure.Microstructure()
microstructure.deformation_function = sp.Bezier(
    degrees=[1, 1],
    control_points=[[0, 0], [0.5,0], [0, 1], [0.5, 1]],
)

angles = np.linspace(-np.pi/2+0.01,np.pi/2-0.01, 10)

tiles = []
for a in angles:
    parameters = np.ones((1,1))*a
    my_microtile = sp.microstructure.tiles.DrilledCrossTile1D()
    showable_tile = my_microtile.create_tile(parameters=parameters)
    tiles.append(showable_tile[0])
gus.show(*tiles, control_points=False)

# %%
# Parameter spline
para_s = sp.BSpline(
    degrees=[1, 1],
    knot_vectors=[[0, 0, 1, 1], [0, 0,0.5, 1, 1]],
    control_points=[[1], [0], [0], [0] , [1], [0]],
)

def pf_curved_tile(x):
    """
    Parametrization Function (determines thickness)
    """

    return np.pi/2*para_s.evaluate(x)

# %%
ms = sp.microstructure.Microstructure()
ms.deformation_function = sp.Bezier(
    degrees=[1, 1],
    control_points=[[0, 0], [0.5,0], [0, 1], [0.5, 1]],
)

my_microtile = sp.microstructure.tiles.DrilledCrossTile1D()
showable_tile = my_microtile.create_tile()

#ms.microtile = showable_tile[0]
ms.microtile = my_microtile
ms.tiling = [8, 16]
ms.parametrization_function = pf_curved_tile
ms.show(control_points=False, title="2D Lattice Microstructure", lighting="off")

Checklists

mkofler96 commented 12 months ago

First it was called DrilledCrossTile1D, but Jacques suggested to give it another name:

The name of the file should be in snake_case, please. Also, consider naming the tile DrilledCrossBeams or TwistedCrossBeams to avoid confusion...

Originally posted by @jzwar in https://github.com/tataratat/splinepy/issues/294#issuecomment-1810012860

j042 commented 12 months ago

@

First it was called DrilledCrossTile1D, but Jacques suggested to give it another name:

The name of the file should be in snake_case, please. Also, consider naming the tile DrilledCrossBeams or TwistedCrossBeams to avoid confusion...

Originally posted by @jzwar in #294 (comment)

so, Cross1D? @jzwar

jzwar commented 12 months ago

I don't want the dimensionality to be part of the tile's name. This is why I added the para_dim and dim properties to the tiles. If you feel like this is insufficient, we can change the directory structure to

tiles.
├── 1D
│   └── drilled_beam.py
├── 2D
│   └── cross_2d.py
│   └── ...
└── 3D
    └── ...
    └── ...

though I personally feel like this is unnecessary... We can add a module function show_available_tiles or something similar

j042 commented 11 months ago

@jzwar don't we already have Cross2D/Cross3D? However, I guess this is X. What about X?

j042 commented 11 months ago

as X is not recommended class name, let's go with Chi