topoptlab.geometries module
- topoptlab.geometries.ball(nelx: int, nely: int, nelz: int, center: ndarray, radius: float, fill_value: int = 1) ndarray[source]
Create element flags for a ball located at the specified center with the specified radius.
- Parameters:
nelx (int) – number of elements in x direction.
nely (int) – number of elements in y direction.
nelz (int) – number of elements in z direction.
center (list or tuple or np.ndarray) – coordinates of sphere center.
radius (float) – sphere radius.
fill_value (int) – value that is prescribed to elements within ball.
- Returns:
el_flags – element flags of shape (nelx*nely*nelz)
- Return type:
np.ndarray
- topoptlab.geometries.bounding_rectangle(nelx: int, nely: int, faces: List = ['b', 't', 'r', 'l']) ndarray[source]
Create element flags for a bounding box of one element thickness. It is possible to draw only specified faces of the bounding box.
- Parameters:
nelx (int) – number of elements in x direction.
nely (int) – number of elements in y direction.
faces (list of str) – which faces of bounding box are supposed to be drawn. Possible values are “b” for bottom, “t” for top, “l” for left and “r” for right.
- Returns:
el_flags – element flags of shape (nelx*nely)
- Return type:
np.ndarray
- topoptlab.geometries.diracdelta(nelx: int, nely: int, nelz: None | int = None, location: None | int = None) ndarray[source]
Create element flags for a Dirac delta located at the specified location. Depending on the location and the number of elements in each direction this results in either a single element with flag 1 or 4/8 elements in 2/3 dimensions.
- Parameters:
nelx (int) – number of elements in x direction.
nely (int) – number of elements in y direction.
nelz (int) – number of elements in z direction.
location (list or tuple or np.ndarray) – coordinate of Dirac delta.
- Returns:
el_flags – element flags / densities
- Return type:
np.ndarray shape (nelx*nely) or shape (nelx*nely*nelz)
- topoptlab.geometries.ellipse(nelx: int, nely: int, center: ndarray, ax_half_lengths: ndarray, fill_value: int = 1) ndarray[source]
Create element flags for an axis-aligned ellipse.
- Parameters:
nelx (int) – number of elements in x direction.
nely (int) – number of elements in y direction.
center (np.ndarray) – (cx, cy) coordinates of ellipse center.
ax_half_lengths (np.ndarray) – (a, b) ellipse semi-axes lengths.
fill_value (int) – value assigned to elements inside the ellipse.
- Returns:
el_flags – element flags of shape (nelx*nely)
- Return type:
np.ndarray
- topoptlab.geometries.ellipsoid(nelx: int, nely: int, nelz: int, center: ndarray, ax_half_lengths: ndarray, fill_value: int = 1) ndarray[source]
Create element flags for an axis-aligned ellipse.
- Parameters:
nelx (int) – number of elements in x direction.
nely (int) – number of elements in y direction.
center (np.ndarray) – (cx, cy, cz) coordinates of ellipse center.
ax_half_lengths (np.ndarray) – (a, b,c) ellipse semi-axes lengths.
fill_value (int) – value assigned to elements inside the ellipse.
- Returns:
el_flags – element flags of shape (nelx*nely)
- Return type:
np.ndarray
- topoptlab.geometries.slab(nelx: int, nely: int, center: ndarray, widths: None | List = None, fill_value: int = 1) ndarray[source]
Create element flags for a slab located at the specified center with the specified width in each dimension.
- Parameters:
nelx (int) – number of elements in x direction.
nely (int) – number of elements in y direction.
center (list or tuple or np.ndarray) – coordinates of slab center.
widths (iterable of floats and None) – width in x and y direction. If one entry is None or it is width is None, then nelx/nely is taken as width in this direction.
fill_value (int) – value that is prescribed to elements within sphere.
- Returns:
el_flags – element flags of shape (nelx*nely)
- Return type:
np.ndarray
- topoptlab.geometries.sphere(nelx: int, nely: int, center: ndarray, radius: float, fill_value: int = 1) ndarray[source]
Create element flags for a sphere located at the specified center with the specified radius.
- Parameters:
nelx (int) – number of elements in x direction.
nely (int) – number of elements in y direction.
center (np.ndarray) – coordinates of sphere center.
radius (float) – sphere radius.
fill_value (int) – value that is prescribed to elements within sphere.
- Returns:
el_flags – element flags of shape (nelx*nely)
- Return type:
np.ndarray