cratepy.main.VTKOutput

class VTKOutput(type, version, byte_order, format, precision, header_type, base_name, vtk_dir, pvd_dir=None)[source]

Bases: object

VTK output.

_vtk_collection

VTK collection output.

Type:

VTKCollection

write_vtk_file_clustering(self, crve)[source]

Write VTK file associated with the CRVE clustering.

write_vtk_file_time_step(self, time_step, strain_formulation, problem_type, crve, material_state, vtk_vars='all', adaptivity_manager=None)[source]

Write VTK file associated with time step (increment).

rewind_files(self, rewind_inc)[source]

Rewind VTK output files.

_set_image_data_parameters(rve_dims, n_voxels_dims)[source]

Set ImageData dataset parameters.

_set_cell_data_name(self, comp_order_sym, comp_order_nsym, var_name, var_type, idx=None, model_name=None)[source]

Set variable cell data array name.

_set_state_var_descriptors(self, n_dim, comp_order_sym, comp_order_nsym, var_name, source, model_state_variables=None, cluster=None, clusters_state=None)[source]

Set state variable descriptors required to output cell data array.

_state_var_cell_data_array(self, n_dim, comp_order_sym, comp_order_nsym, material_phases, material_phases_models, phase_clusters, voxels_clusters, clusters_state, var_name, var_type, comp_idx=None, model_name=None)[source]

Build state variable cell data array.

_reset_labels_from_zero(array_1d)[source]

Reset 1d array of integers starting from zero.

Constructor.

Parameters:
  • type (str) – VTK file type.

  • version (str) – VTK version.

  • byte_order (str) – VTK byte order.

  • format (str) – VTK file format.

  • precision ({'SinglePrecision', 'DoublePrecision'}) – VTK file data precision.

  • header_type (str) – VTK header type.

  • base_name (str) – Base name of VTK files.

  • vtk_dir (str) – Directory where VTK files are stored.

  • pvd_dir (str, default=None) – Directory where PVD file is stored.

List of Public Methods

rewind_files

Rewind VTK output files.

write_vtk_file_clustering

Write VTK file associated with the CRVE clustering.

write_vtk_file_time_step

Write VTK file associated with time step (increment).

Methods

__init__(type, version, byte_order, format, precision, header_type, base_name, vtk_dir, pvd_dir=None)[source]

Constructor.

Parameters:
  • type (str) – VTK file type.

  • version (str) – VTK version.

  • byte_order (str) – VTK byte order.

  • format (str) – VTK file format.

  • precision ({'SinglePrecision', 'DoublePrecision'}) – VTK file data precision.

  • header_type (str) – VTK header type.

  • base_name (str) – Base name of VTK files.

  • vtk_dir (str) – Directory where VTK files are stored.

  • pvd_dir (str, default=None) – Directory where PVD file is stored.

static _reset_labels_from_zero(array_1d)[source]

Reset 1d array of integers starting from zero.

Parameters:

array_1d (numpy.ndarray (1d)) – 1d array of integers.

Returns:

array_1d_new – Relabeled 1d array of integers.

Return type:

numpy.ndarray (1d)

_set_cell_data_name(comp_order_sym, comp_order_nsym, var_name, var_type, idx=None, model_name=None)[source]

Set variable cell data array name.

Parameters:
  • comp_order_sym (list[str]) – Strain/Stress components (str) order (symmetric).

  • comp_order_nsym (list[str]) – Strain/Stress components (str) order (non-symmetric).

  • var_name (str) – Variable name.

  • var_type (str) – Variable type.

  • idx (str, default=None) – Component index.

  • model_name (str, default=None) – Material constitutive model name. If provided, the model name is included as a prefix in the variable cell data array name.

static _set_image_data_parameters(rve_dims, n_voxels_dims)[source]

Set ImageData dataset parameters.

Parameters:
  • rve_dims (list[float]) – RVE size in each dimension.

  • n_voxels_dims (list[int]) – Number of voxels in each dimension of the regular grid (spatial discretization of the RVE).

Returns:

  • dataset_parameters (dict) – ImageData dataset parameters.

  • dataset_parameters (dict) – ImageData dataset piece parameters.

_set_state_var_descriptors(n_dim, comp_order_sym, comp_order_nsym, var_name, source, model_state_variables=None, cluster=None, clusters_state=None)[source]

Set state variable descriptors required to output cell data array.

Parameters:
  • n_dim (int) – Problem dimension.

  • comp_order_sym (list[str]) – Strain/Stress components (str) order (symmetric).

  • comp_order_nsym (list[str]) – Strain/Stress components (str) order (non-symmetric).

  • var_name (str) – State variable name.

  • source ({'model_state_variables', 'clusters_state'}) – Source where state variable is stored.

  • model_state_variables (dict, default=None) – Material model state variables (required if `source`=’model_state_variables’).

  • cluster (int, default=None) – Cluster label (required if `source`=’clusters_state’).

  • clusters_state (dict, default=None) – Material constitutive model state variables (item, dict) associated with each material cluster (key, str) (required if `source`=’clusters_state’).

Returns:

  • var ({int, float, bool, array}) – State variable.

  • var_type (str) – State variable type.

  • var_n_comp (int) – State variable number of components.

_state_var_cell_data_array(n_dim, comp_order_sym, comp_order_nsym, material_phases, material_phases_models, phase_clusters, voxels_clusters, clusters_state, var_name, var_type, comp_idx=None, model_name=None)[source]

Build state variable cell data array.

Parameters:
  • n_dim (int) – Problem dimension.

  • comp_order_sym (list[str]) – Strain/Stress components (str) order (symmetric).

  • comp_order_nsym (list[str]) – Strain/Stress components (str) order (non-symmetric).

  • material_phases (list[str]) – CRVE material phases labels (str).

  • material_phases_models (dict) – Material constitutive model (item, ConstitutiveModel) associated with each material phase (key, str).

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

  • 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.

  • clusters_state (dict) – Material constitutive model state variables (item, dict) associated with each material cluster (key, str) (required if `source`=’clusters_state’).

  • var_name (str) – State variable name.

  • var_type (str) – State variable type.

  • comp_idx (str, default=None) – Tensorial component index.

  • model_name (str, default=None) – Material constitutive model name. If not provided, it is assumed that the state variable is common to all material phases and associated constitutive models.

Returns:

rg_array – Array of state variable component of shape equal to RVE regular grid discretization array.

Return type:

numpy.ndarray (2d or 3d)

rewind_files(rewind_inc)[source]

Rewind VTK output files.

Parameters:

rewind_inc (int) – Increment associated with the rewind state.

write_vtk_file_clustering(crve)[source]

Write VTK file associated with the CRVE clustering.

Parameters:

crve (CRVE) – Cluster-Reduced Representative Volume Element.

write_vtk_file_time_step(time_step, strain_formulation, problem_type, crve, material_state, vtk_vars='all', adaptivity_manager=None)[source]

Write VTK file associated with time step (increment).

Parameters:
  • time_step (int) – Time step.

  • strain_formulation ({'infinitesimal', 'finite'}) – Problem strain formulation.

  • problem_type (int) – Problem type: 2D plane strain (1), 2D plane stress (2), 2D axisymmetric (3) and 3D (4).

  • crve (CRVE) – Cluster-Reduced Representative Volume Element.

  • material_state (MaterialState) – CRVE material constitutive state.

  • vtk_vars ({'all', 'common'}, default='all') – If ‘common’, only state variables common to all material phases constitutive models are output. Otherwise, all state variables are output.

  • adaptivity_manager (AdaptivityManager) – CRVE clustering adaptivity manager.