hookeai.material_model_finder.data.specimen_data.StructureMesh

class StructureMesh(nodes_coords_mesh_init, elements_type, connectivities, dirichlet_bool_mesh)[source]

Bases: object

FETorch structure finite element mesh.

_n_dim

Number of spatial dimensions.

Type:

int

_n_node_mesh

Number of nodes of finite element mesh.

Type:

int

_n_elem

Number of elements of finite element mesh.

Type:

int

_elements_type

FETorch element type (item, ElementType) of each finite element mesh element (str[int]). Elements are labeled from 1 to n_elem.

Type:

dict

_connectivities

Nodes (item, tuple[int]) of each finite element mesh element (key, str[int]). Nodes are labeled from 1 to n_node_mesh. Elements are labeled from 1 to n_elem.

Type:

dict

_nodes_coords_mesh_init

Initial coordinates of finite element mesh nodes stored as torch.Tensor(2d) of shape (n_node_mesh, n_dim).

Type:

torch.Tensor(2d)

_nodes_coords_mesh

Coordinates of finite element mesh nodes stored as torch.Tensor(2d) of shape (n_node_mesh, n_dim).

Type:

torch.Tensor(2d)

_nodes_coords_mesh_old

Last converged coordinates of finite element mesh nodes stored as torch.Tensor(2d) of shape (n_node_mesh, n_dim).

Type:

torch.Tensor(2d)

_nodes_disps_mesh

Displacements of finite element mesh nodes stored as torch.Tensor(2d) of shape (n_node_mesh, n_dim).

Type:

torch.Tensor(2d)

_nodes_disps_mesh_old

Last converged displacements of finite element mesh nodes stored as torch.Tensor(2d) of shape (n_node_mesh, n_dim).

Type:

torch.Tensor(2d)

_dirichlet_bool_mesh

Degrees of freedom of finite element mesh subject to Dirichlet boundary conditions. Stored as torch.Tensor(2d) of shape (n_node_mesh, n_dim) where constrained degrees of freedom are labeled 1, otherwise 0.

Type:

torch.Tensor(2d)

get_n_dim(self)[source]

Get number of spatial dimensions.

get_n_node_mesh(self)[source]

Get number of nodes of finite element mesh.

get_n_elem(self)[source]

Number of elements of finite element mesh.

get_elements_type(self)[source]

Get type of elements of finite element mesh.

get_n_element_type(self)[source]

Get the number of elements types of finite element mesh.

get_connectivities(self)[source]

Get finite element mesh elements connectivities.

get_connectivities_tensor(self)[source]

Get finite element mesh elements connectivities stored (tensor).

get_dirichlet_bool_mesh(self)[source]

Get degrees of freedom subject to Dirichlet boundary conditions.

get_n_dirichlet_dof(self)[source]

Get number of degrees of freedom subject to Dirichlet conditions.

get_element_configuration(self, element_id, time='current')[source]

Get element nodes coordinates and displacements.

get_mesh_configuration(self, time='current')[source]

Get finite element mesh configuration.

update_mesh_configuration(self, nodes_disps_mesh, nodes_disps_mesh_old=None, is_update_coords=True)[source]
element_assembler(self, elements_array)[source]

Assemble element level arrays into mesh level counterparts.

_element_assembler_1d(self, elements_array_1d)[source]

Assemble element level 1D array into mesh level counterpart.

element_extractor(self, mesh_array, element_id)[source]

Extract element level array from mesh level counterpart.

_element_extractor_1d(self, mesh_array, element_id)[source]

Extract element level 1D array from mesh level counterpart.

build_elements_mesh_indexing(self, n_dof_node)[source]

Build elements nodes degrees of freedom mesh indexes.

build_element_mesh_indexing(cls, element_nodes, n_dof_node)[source]

Get element nodes degrees of freedom mesh indexes.

_check_mesh_initialization(self, nodes_coords_mesh_init, elements_type,

connectivities)

Check finite element mesh initialization.

Constructor.

Parameters:
  • nodes_coords_mesh_init (torch.Tensor(2d)) – Initial coordinates of finite element mesh nodes stored as torch.Tensor(2d) of shape (n_node_mesh, n_dim).

  • elements_type (dict) – FETorch element type (item, ElementType) of each finite element mesh element (str[int]). Elements labels must be within the range of 1 to n_elem (included).

  • connectivities (dict) – Nodes (item, tuple[int]) of each finite element mesh element (key, str[int]). Nodes are labeled from 1 to n_node_mesh. Elements are labeled from 1 to n_elem.

  • dirichlet_bool_mesh (torch.Tensor(2d)) – Degrees of freedom of finite element mesh subject to Dirichlet boundary conditions. Stored as torch.Tensor(2d) of shape (n_node_mesh, n_dim) where constrained degrees of freedom are labeled 1, otherwise 0.

List of Public Methods

build_element_mesh_indexing

Get element nodes degrees of freedom mesh indexes.

build_elements_mesh_indexing

Build elements nodes degrees of freedom mesh indexes.

element_assembler

Assemble element level arrays into mesh level counterparts.

element_extractor

Extract element level array from mesh level counterpart.

get_connectivities

Get finite element mesh elements connectivities.

get_connectivities_tensor

Get finite element mesh elements connectivities (tensor).

get_dirichlet_bool_mesh

Get degrees of freedom subject to Dirichlet boundary conditions.

get_element_configuration

Get element nodes coordinates and displacements.

get_elements_type

Get type of elements of finite element mesh.

get_mesh_configuration

Get finite element mesh configuration.

get_n_dim

Get number of spatial dimensions.

get_n_dirichlet_dof

Get number of degrees of freedom subject to Dirichlet conditions.

get_n_elem

Number of elements of finite element mesh.

get_n_element_type

Get the number of elements types of finite element mesh.

get_n_node_mesh

Get number of nodes of finite element mesh.

update_mesh_configuration

Update finite element mesh configuration from nodes displacements.

Methods

__init__(nodes_coords_mesh_init, elements_type, connectivities, dirichlet_bool_mesh)[source]

Constructor.

Parameters:
  • nodes_coords_mesh_init (torch.Tensor(2d)) – Initial coordinates of finite element mesh nodes stored as torch.Tensor(2d) of shape (n_node_mesh, n_dim).

  • elements_type (dict) – FETorch element type (item, ElementType) of each finite element mesh element (str[int]). Elements labels must be within the range of 1 to n_elem (included).

  • connectivities (dict) – Nodes (item, tuple[int]) of each finite element mesh element (key, str[int]). Nodes are labeled from 1 to n_node_mesh. Elements are labeled from 1 to n_elem.

  • dirichlet_bool_mesh (torch.Tensor(2d)) – Degrees of freedom of finite element mesh subject to Dirichlet boundary conditions. Stored as torch.Tensor(2d) of shape (n_node_mesh, n_dim) where constrained degrees of freedom are labeled 1, otherwise 0.

_check_mesh_initialization(nodes_coords_mesh_init, elements_type, connectivities)[source]

Check finite element mesh initialization.

Parameters:
  • nodes_coords_mesh_init (torch.Tensor(2d)) – Initial coordinates of finite element mesh nodes stored as torch.Tensor(2d) of shape (n_node_mesh, n_dim).

  • elements_type (dict) – FETorch element type (item, ElementType) of each finite element mesh element (str[int]). Elements are labeled from 1 to n_elem.

  • connectivities (dict) – Nodes (item, tuple[int]) of each finite element mesh element (key, str[int]). Elements are labeled from 1 to n_elem.

_element_assembler_1d(elements_array_1d)[source]

Assemble element level 1D array into mesh level counterpart.

Assumes similar number of dimensions per node in the whole finite element mesh.

Parameters:

elements_arrays_1d (dict) – Generic array (item, torch.Tensor(1d)) associated with given finite element mesh element (key, str[int]). Elements labels must be within the range of 1 to n_elem (included).

Returns:

mesh_array – Mesh level array resulting from the assembly of the corresponding element level arrays. Mesh level array is always sorted and dimensioned accounting for the total number of nodes in the finite element mesh.

Return type:

torch.Tensor(1d)

_element_extractor_1d(mesh_array, element_id)[source]

Extract element level 1D array from mesh level counterpart.

Assumes similar number of dimensions per node in the whole finite element mesh.

Parameters:
  • mesh_array (torch.Tensor(1d)) – Mesh level array resulting from the assembly of the corresponding element level arrays. Mesh level array is always sorted and dimensioned accounting for the total number of nodes in the finite element mesh.

  • element_id (int) – Element label. Elements labels must be within the range of 1 to n_elem (included).

Returns:

element_array – Generic element array.

Return type:

torch.Tensor(1d)

classmethod build_element_mesh_indexing(element_nodes, n_dof_node)[source]

Get element nodes degrees of freedom mesh indexes.

Parameters:
  • element_nodes (torch.Tensor(1d)) – Finite element mesh element connectitivities stored as torch.Tensor(1d) of shape (n_node,). Nodes are labeled from 1 to n_node_mesh.

  • n_dof_node (int) – Number of degrees of freedom per element node.

Returns:

element_mesh_indexes – Element nodes degrees of freedom mesh indexes stored as torch.Tensor(1d) of shape (n_node*n_dof_node,).

Return type:

torch.Tensor(1d)

build_elements_mesh_indexing(n_dof_node)[source]

Build elements nodes degrees of freedom mesh indexes.

Parameters:

n_dof_node (int) – Number of degrees of freedom per element node.

Returns:

elements_mesh_indexes – Elements nodes degrees of freedom mesh indexes stored as torch.Tensor(2d) of shape (n_elem, n_node*n_dof_node).

Return type:

torch.Tensor(2d)

element_assembler(elements_array)[source]

Assemble element level arrays into mesh level counterparts.

Assumes similar number of dimensions per node in the whole finite element mesh.

Parameters:

elements_array (dict) – Generic array (item, torch.Tensor) associated with given finite element mesh element (key, str[int]). Elements labels must be within the range of 1 to n_elem (included).

Returns:

mesh_array – Mesh level array resulting from the assembly of the corresponding element level arrays. Mesh level array is always sorted and dimensioned accounting for the total number of nodes in the finite element mesh.

Return type:

torch.Tensor

element_extractor(mesh_array, element_id)[source]

Extract element level array from mesh level counterpart.

Assumes similar number of dimensions per node in the whole finite element mesh.

Parameters:
  • mesh_array (torch.Tensor) – Mesh level array resulting from the assembly of the corresponding element level arrays. Mesh level array is always sorted and dimensioned accounting for the total number of nodes in the finite element mesh.

  • element_id (int) – Element label. Elements labels must be within the range of 1 to n_elem (included).

Returns:

element_array – Generic element array.

Return type:

torch.Tensor

get_connectivities()[source]

Get finite element mesh elements connectivities.

Returns:

connectivities – Nodes (item, tuple[int]) of each finite element mesh element (key, str[int]). Nodes are labeled from 1 to n_node_mesh. Elements are labeled from 1 to n_elem.

Return type:

dict

get_connectivities_tensor()[source]

Get finite element mesh elements connectivities (tensor).

Storage of finite element mesh elements connectivities in tensor, i.e., batching over the element dimension, requires that all finite element mesh elements have the same number of nodes.

Returns:

connectivities_tensor – Finite element mesh elements connectitivities stored as torch.Tensor(2d) of shape (n_elem, n_node). Elements are sorted according with their labels (1 to n_elem). Nodes are labeled from 1 to n_node_mesh.

Return type:

torch.Tensor(2d)

get_dirichlet_bool_mesh()[source]

Get degrees of freedom subject to Dirichlet boundary conditions.

Returns:

dirichlet_bool_mesh – Degrees of freedom of finite element mesh subject to Dirichlet boundary conditions. Stored as torch.Tensor(2d) of shape (n_node_mesh, n_dim) where constrained degrees of freedom are labeled 1, otherwise 0.

Return type:

torch.Tensor(2d)

get_element_configuration(element_id, time='current')[source]

Get element nodes coordinates and displacements.

Parameters:
  • element_id (int) – Element label. Elements labels must be within the range of 1 to n_elem (included).

  • time ({'init', 'last', 'current'}, default='current') – Time where element configuration is returned: initial configuration (‘init’), last converged configuration (‘last’), or current configuration (‘current’).

Returns:

  • nodes_coords (torch.Tensor(2d)) – Nodes coordinates stored as torch.Tensor(2d) of shape (n_node, n_dof_node).

  • nodes_disps (torch.Tensor(2d)) – Nodes displacements stored as torch.Tensor(2d) of shape (n_node, n_dof_node).

get_elements_type()[source]

Get type of elements of finite element mesh.

Returns:

elements_type – FETorch element type (item, ElementType) of each finite element mesh element (str[int]). Elements are labeled from 1 to n_elem.

Return type:

dict

get_mesh_configuration(time='current')[source]

Get finite element mesh configuration.

Parameters:

time ({'init', 'last', 'current'}, default='current') – Time where element configuration is returned: initial configuration (‘init’), last converged configuration (‘last’), or current configuration (‘current’).

Returns:

  • nodes_coords_mesh (torch.Tensor(2d)) – Coordinates of finite element mesh nodes stored as torch.Tensor(2d) of shape (n_node_mesh, n_dim).

  • nodes_disps_mesh (torch.Tensor(2d)) – Displacements of finite element mesh nodes stored as torch.Tensor(2d) of shape (n_node_mesh, n_dim).

get_n_dim()[source]

Get number of spatial dimensions.

Returns:

n_dim – Number of spatial dimensions.

Return type:

int

get_n_dirichlet_dof()[source]

Get number of degrees of freedom subject to Dirichlet conditions.

Returns:

n_dof_dirichlet – Number of degrees of freedom subject to Dirichlet boundary conditions.

Return type:

int

get_n_elem()[source]

Number of elements of finite element mesh.

Returns:

n_elem – Number of elements of finite element mesh.

Return type:

int

get_n_element_type()[source]

Get the number of elements types of finite element mesh.

Returns:

n_element_type – Number of element types of finite element mesh.

Return type:

int

get_n_node_mesh()[source]

Get number of nodes of finite element mesh.

Returns:

n_node_mesh – Number of nodes of finite element mesh.

Return type:

int

update_mesh_configuration(nodes_disps_mesh, time='current', is_update_coords=True)[source]

Update finite element mesh configuration from nodes displacements.

Parameters:
  • nodes_disps_mesh (torch.Tensor(2d)) – Displacements of finite element mesh nodes stored as torch.Tensor(2d) of shape (n_node_mesh, n_dim).

  • time ({'last', 'current'}, default='current') – Time where update of element state variables is performed: last converged state variables (‘last’) or current state variables (‘current’).

  • is_update_coords (bool, default=True) – If False, then only updates the displacements of the finite element mesh nodes, leaving the nodes coordinates unchanged. If True, then update both coordinates and displacements of finite element mesh nodes.