cratepy.clustering.adaptivity.crve_adaptivity.SpatialDiscontinuities

class SpatialDiscontinuities(adapt_mat_phase, phase_clusters, adapt_trigger_ratio=None, adapt_max_level=None, adapt_min_voxels=None, adapt_level_max_diff=None, swipe_dim_1_every=None, swipe_dim_2_every=None, swipe_dim_3_every=None, min_adapt_feature_val=None, magnitude_lower_factor=None)[source]

Bases: AdaptivityCriterion

Clustering adaptivity spatial discontinuities criterion.

The detailed description of the clustering adaptivity spatial discontinuities criterion can be found in Ferreira et. al (2022) [1].

_clusters_adapt_level

Adaptive level (item, int) of each cluster (key, str).

Type:

dict

_swipe_dims_every

Swipe frequency (item, int) of each spatial dimension. First and last (boundary) voxels are always considered, irrespective of the swipe frequency.

Type:

list[int], default=None

get_parameters()[source]

Get clustering adaptivity criterion parameters.

get_target_clusters(self, adapt_data_matrix, voxels_clusters)[source]

Get clustering adaptivity target clusters.

update_clusters_adapt_level(self, adaptive_clustering_map)[source]

Update clusters adaptive level after adaptive procedures.

get_clusters_adapt_level(self)[source]

Get clusters adaptive level.

get_min_adapt_feature_val(self)[source]

Get minimum significant value of clustering adaptivity feature.

_swipe_dimension(self, adapt_data_matrix, voxels_clusters, target_clusters, target_clusters_data, dim_loops)[source]

Evaluate spatial discontinuities along a given dimension.

_update_swipe_dims_init_idx(self)[source]

Randomly update the dimensions swipe frequency initial index.

Constructor.

Parameters:
  • adapt_mat_phase (str) – Adaptive material phase label.

  • phase_clusters (dict) – Clusters labels (item, list[int]) associated with each material phase (key, str).

  • adapt_trigger_ratio (float, default=None) – Threshold associated with the adaptivity trigger condition.

  • adapt_max_level (int, default=None) – Maximum cluster adaptive level.

  • adapt_min_voxels (int, default=None) – Minimum number of voxels that cluster must contain to be targeted for adaptivity.

  • adapt_level_max_diff (int, default=None) – Maximum adaptive level difference when targeting clusters of adjacent voxels.

  • swipe_dim_1_every (int, default=None) – Swipe frequency of spatial dimension 1. First and last (boundary) voxels are always considered.

  • swipe_dim_2_every (int, default=None) – Swipe frequency of spatial dimension 2. First and last (boundary) voxels are always considered.

  • swipe_dim_3_every (int, default=None) – Swipe frequency of spatial dimension 3. First and last (boundary) voxels are always considered.

  • min_adapt_feature_val (float, default=None) – Minimum significant value of clustering adaptivity control feature.

  • magnitude_lower_factor (float, default=None) – Factor which affects the maximum stored magnitude associated with the lower valued targeted cluster.

List of Public Methods

get_clusters_adapt_level

Get clusters adaptive level.

get_min_adapt_feature_val

Get minimum significant value of clustering adaptivity feature.

get_parameters

Get clustering adaptivity criterion parameters.

get_target_clusters

Get clustering adaptivity target clusters.

update_clusters_adapt_level

Update clusters adaptive level after adaptive procedures.

Methods

__init__(adapt_mat_phase, phase_clusters, adapt_trigger_ratio=None, adapt_max_level=None, adapt_min_voxels=None, adapt_level_max_diff=None, swipe_dim_1_every=None, swipe_dim_2_every=None, swipe_dim_3_every=None, min_adapt_feature_val=None, magnitude_lower_factor=None)[source]

Constructor.

Parameters:
  • adapt_mat_phase (str) – Adaptive material phase label.

  • phase_clusters (dict) – Clusters labels (item, list[int]) associated with each material phase (key, str).

  • adapt_trigger_ratio (float, default=None) – Threshold associated with the adaptivity trigger condition.

  • adapt_max_level (int, default=None) – Maximum cluster adaptive level.

  • adapt_min_voxels (int, default=None) – Minimum number of voxels that cluster must contain to be targeted for adaptivity.

  • adapt_level_max_diff (int, default=None) – Maximum adaptive level difference when targeting clusters of adjacent voxels.

  • swipe_dim_1_every (int, default=None) – Swipe frequency of spatial dimension 1. First and last (boundary) voxels are always considered.

  • swipe_dim_2_every (int, default=None) – Swipe frequency of spatial dimension 2. First and last (boundary) voxels are always considered.

  • swipe_dim_3_every (int, default=None) – Swipe frequency of spatial dimension 3. First and last (boundary) voxels are always considered.

  • min_adapt_feature_val (float, default=None) – Minimum significant value of clustering adaptivity control feature.

  • magnitude_lower_factor (float, default=None) – Factor which affects the maximum stored magnitude associated with the lower valued targeted cluster.

_swipe_dimension(adapt_data_matrix, voxels_clusters, target_clusters, target_clusters_data, dim_loops)[source]

Evaluate spatial discontinuities along a given dimension.

The spatial dimensions are cycled according to the code provided in dim_loops. The dimension where the spatial discontinuities are evaluated is always the first dimension specified in this code (assumed dimension i), while the others cycle the remainder dimensions (assumed dimensions j and k). During this process, both the list of target clusters and the dictionary containing associated data are updated.


Parameters:
  • adapt_data_matrix (numpy.ndarray (2d)) – Adaptivity feature data matrix (numpy.ndarray of shape (adapt_phase_n_clusters, 2)) that, for the i-th cluster of the adaptive material phase, contains the cluster label in adapt_data_matrix[i, 0] and the associated adaptive feature value in adapt_data_matrix[i, 1].

  • voxels_clusters (numpy.ndarray (2d or 3d)) – Regular grid of voxels (spatial discretization of the RVE), where each entry contains the cluster label (int) assigned to the corresponding voxel.

  • target_clusters (list[int]) – List containing the labels (int) of clusters to be adapted.

  • target_clusters_data (dict) – For each target cluster (key, str), store dictionary (item, dict) containing cluster associated parameters required for the adaptive procedures.

  • dim_loops (str) – Ordered specification of dimension cycles, being the spatial discontinuities evaluated along dimension dim_loops[0].

_update_swipe_dims_init_idx()[source]

Randomly update the dimensions swipe frequency initial index.

The detailed description of this procedure can be found in Ferreira et. al (2022) [2].

get_clusters_adapt_level()[source]

Get clusters adaptive level.

Returns:

clusters_adapt_level – Adaptive level (item, int) of each cluster (key, str).

Return type:

dict

get_min_adapt_feature_val()[source]

Get minimum significant value of clustering adaptivity feature.

Returns:

min_adapt_feature_val – Minimum significant value of clustering adaptivity control feature.

Return type:

float

static get_parameters()[source]

Get clustering adaptivity criterion parameters.

Besides returning the mandatory and optional adaptivity criterion parameters, this method establishes the default values for the optional parameters.


Returns:

  • mandatory_parameters (dict) – Mandatory adaptivity type parameters (str) and associated type (item, type).

  • optional_parameters (dict) – Optional adaptivity type parameters (key, str) and associated default value (item).

get_target_clusters(adapt_data_matrix, voxels_clusters)[source]

Get clustering adaptivity target clusters.

Parameters:
  • adapt_data_matrix (numpy.ndarray (2d)) – Adaptivity feature data matrix (numpy.ndarray of shape (adapt_phase_n_clusters, 2)) that, for the i-th cluster of the adaptive material phase, contains the cluster label in adapt_data_matrix[i, 0] and the associated adaptive feature value in adapt_data_matrix[i, 1].

  • voxels_clusters (numpy.ndarray (2d or 3d)) – Regular grid of voxels (spatial discretization of the RVE), where each entry contains the cluster label (int) assigned to the corresponding voxel.

Returns:

  • target_clusters (list[int]) – List containing the labels (int) of clusters to be adapted.

  • target_clusters_data (dict) – For each target cluster (key, str), store dictionary (item, dict) containing cluster associated parameters required for the adaptive procedures.

update_clusters_adapt_level(adaptive_clustering_map)[source]

Update clusters adaptive level after adaptive procedures.

Parameters:

adaptive_clustering_map (dict) – List of new cluster labels (item, list[int]) resulting from the adaptive procedures over each target cluster (key, str).