sktopt.mesh.task

class sktopt.mesh.task.TaskConfig(E: float, nu: float, basis: CellBasis, dirichlet_nodes: ndarray, dirichlet_dofs: ndarray, dirichlet_elements: ndarray, force_nodes: ndarray | list[ndarray], force_dofs: ndarray | list[ndarray], force_elements: ndarray, force: ndarray | list[ndarray], design_elements: ndarray, free_dofs: ndarray, free_elements: ndarray, all_elements: ndarray, fixed_elements: ndarray, dirichlet_force_elements: ndarray, elements_volume: ndarray)

Bases: object

Container for storing finite element and optimization-related data used in topology optimization tasks.

This class holds material properties, boundary condition information, designable and non-designable element indices, as well as force vectors and volume data for each element. It is typically constructed using TaskConfig.from_defaults.

E

Young’s modulus of the base material.

Type:

float

nu

Poisson’s ratio of the base material.

Type:

float

basis

Finite element basis object associated with the mesh and function space.

Type:

skfem.Basis

dirichlet_dofs

Degrees of freedom constrained by Dirichlet (displacement) boundary conditions.

Type:

np.ndarray

dirichlet_elements

Elements that contain Dirichlet boundary points.

Type:

np.ndarray

force_dofs

Degrees of freedom where external forces are applied. Can be a list for multiple load cases.

Type:

np.ndarray or list of np.ndarray

force_elements

Elements that contain the force application points.

Type:

np.ndarray

force

External force vector(s) applied to the system. A list is used when multiple load cases are present.

Type:

np.ndarray or list of np.ndarray

design_elements

Indices of elements that are considered designable in the optimization.

Type:

np.ndarray

free_dofs

Degrees of freedom that are not fixed by boundary conditions.

Type:

np.ndarray

free_elements

Elements associated with the free degrees of freedom.

Type:

np.ndarray

all_elements

Array of all element indices in the mesh.

Type:

np.ndarray

fixed_elements

Elements excluded from the design domain.

Type:

np.ndarray

dirichlet_force_elements

Union of Dirichlet and force elements. Useful for identifying constrained and loaded regions.

Type:

np.ndarray

elements_volume

Volume of each finite element, used in volume constraints and integration.

Type:

np.ndarray

E: float
all_elements: ndarray
basis: CellBasis
design_elements: ndarray
dirichlet_dofs: ndarray
dirichlet_elements: ndarray
dirichlet_force_elements: ndarray
dirichlet_nodes: ndarray
elements_volume: ndarray
exlude_dirichlet_from_design()
export_analysis_condition_on_mesh(dst_path: str)
fixed_elements: ndarray
force: ndarray | list[ndarray]
force_dofs: ndarray | list[ndarray]
force_elements: ndarray
force_nodes: ndarray | list[ndarray]
property force_nodes_all: ndarray
free_dofs: ndarray
free_elements: ndarray
classmethod from_defaults(E: float, nu: float, basis: CellBasis, dirichlet_nodes: ndarray, dirichlet_dofs: ndarray, force_nodes: ndarray | list[ndarray], force_dofs: ndarray | list[ndarray], force_value: float | list[float], design_elements: ndarray) TaskConfig

Create a TaskConfig instance using basic material parameters and boundary conditions.

This method automatically computes the sets of Dirichlet and Neumann (force) elements, filters out non-designable elements, and constructs force vectors.

Parameters:
  • E (float) – Young’s modulus of the material.

  • nu (float) – Poisson’s ratio of the material.

  • basis (skfem.Basis) – Basis object from scikit-fem representing the finite element space.

  • dirichlet_nodes (np.ndarray) – Coordinates used to determine which elements are subject to Dirichlet boundary conditions.

  • dirichlet_dofs (np.ndarray) – Degrees of freedom fixed under Dirichlet boundary conditions.

  • force_nodes (np.ndarray or list of np.ndarray) – Coordinates used to determine which elements are subject to external forces.

  • force_dofs (np.ndarray or list of np.ndarray) – Degrees of freedom where external forces are applied.

  • force_value (float or list of float) – Magnitude(s) of the external force(s). If multiple load cases are used, provide a list.

  • design_elements (np.ndarray) – Initial set of element indices considered designable.

Returns:

A fully initialized TaskConfig object containing mesh, boundary condition, and load data.

Return type:

TaskConfig

Raises:

ValueError – If no force elements are found or if design elements are empty after filtering.

classmethod from_nodes(E: float, nu: float, basis: CellBasis, dirichlet_nodes: ndarray | list[ndarray], dirichlet_dir: Literal['u^1', 'u^2', 'u^3', 'all'] | list[Literal['u^1', 'u^2', 'u^3', 'all']], force_nodes: ndarray | list[ndarray], force_dir: Literal['u^1', 'u^2', 'u^3'] | list[Literal['u^1', 'u^2', 'u^3']], force_value: float | list[float], design_elements: ndarray)
property mesh
nodes_and_elements_stats(dst_path: str)
nu: float
scale(L_scale: float, F_scale: float)
sktopt.mesh.task.setdiff1d(a, b)