Mfix
pysammos.data_read.mfix package
Subpackage for reading MFIX DEM data files.
Cell Data module
pysammos.data_read.mfix.cell_data module
This module provides functions to read and process cell data from MFIX simulations. So far, it only includes functionality for reading contact data. It extracts particle IDs, total forces, and contact points from the cell data, allowing for further analysis and manipulation. It is designed to work with VTK data structures, converting them into NumPy arrays for easier handling.
- The main function provided in this module is:
1.
contacts(): Extracts contact data from the input connection, including particle IDs, total forces and contact points.
- pysammos.data_read.mfix.cell_data.contacts(InputConnection, Part_ids_string='contact_ids', Force_ij_string='total_force', Contact_ij_string='contact_points')[source]
Extract contact data from the input connection, including particle IDs, total forces, and contact points. Inputs ------ InputConnection : vtk.vtkAlgorithmOutput
The input connection from which to extract cell data.
- Part_ids_stringstr, optional
The name of the array containing particle IDs in the cell data. Default is "contact_ids".
- Force_ij_stringstr, optional
The name of the array containing total forces in the cell data. Default is "total_force".
- Contact_ij_stringstr, optional
The name of the array containing contact points in the cell data. Default is "contact_points".
Outputs
- particle_indarray, shape (M,)
Array of particle IDs for the first particle in each contact.
- particle_jndarray, shape (M,)
Array of particle IDs for the second particle in each contact.
- total_forcendarray, shape (M, 3)
Array of total forces for each contact.
- contact_pointsndarray, shape (M, 3)
Array of contact points for each contact.
- rtype:
Tuple[ndarray,ndarray,ndarray,ndarray]
pysammos.data_read.mfix.file_read module
This module provides functionality to read VTK files and determine their type based on the file content. It supports both XML-based PolyData files (with .vtp extension) and legacy UnstructuredGrid files (with .vtk extension). The appropriate VTK reader is selected based on the detected file type, allowing for further processing of the data.
- The main functions provided in this module are:
get_file_type(): Detects the type of VTK file by inspecting the file content.reader(): Reads the VTK file using the appropriate reader based on the detected file type.
- pysammos.data_read.mfix.file_read.get_file_type(path)[source]
Detects the type of VTK file (PolyData or UnstructuredGrid) by inspecting the file content.
- Return type:
str
Inputs
- pathstr
The path to the VTK file.
Outputs
- str
The file type: "vtp" for PolyData or "vtk" for UnstructuredGrid.
- raises ValueError:
If the file format is unsupported or unknown.
- pysammos.data_read.mfix.file_read.reader(file_type, path)[source]
Reads the VTK file using the appropriate reader based on the detected file type.
- Parameters:
file_type (
str) -- The type of VTK file: "vtp" for PolyData or "vtk" for UnstructuredGrid.path (
str) -- The path to the VTK file.
- Returns:
The output data from the VTK reader.
- Return type:
vtkAlgorithmOutput- Raises:
ValueError -- If the file format is unsupported.
FileNotFoundError -- If the specified file does not exist.
IOError -- If the file cannot be opened or read.
Examples
>>> file_type = get_file_type("example.vtp") XML-based PolyData detected. >>> reader_output = reader(file_type, "example.vtp") >>> print(type(reader_output)) <class 'vtkmodules.vtkCommonExecutionModel.vtkAlgorithmOutput'> This indicates that the file has been read successfully and the output is a VTK algorithm output object.
pysammos.data_read.mfix.point_data module
This module provides functions to read and process point data from MFIX simulations. It extracts particle information such as position, global ID, velocity, diameter, density, volume, mass, and coordination number from the point data, allowing for further analysis and manipulation. It is designed to work with VTK data structures, converting them into NumPy arrays for easier handling.
- The main functions provided in this module are:
1.
particles(): Extracts particle data from the input connection, including position, global ID, velocity, diameter, density, volume, mass, and coordination number. 2.contacts(): Extracts contact data from the input connection, including particle IDs, total forces and contact points. 3.Reader_vtm(): Reads VTM files and extracts all PolyData blocks, merging them into a single PolyData object.
- pysammos.data_read.mfix.point_data.ContactData__JP(InputConnection, Part_ids_string='contact_ids', Force_ij_string='total_force', Contact_ij_string='contact_points')[source]
- pysammos.data_read.mfix.point_data.contacts(InputConnection, Particle_i_string='Particle_ID_1', Particle_j_string='Particle_ID_2', Force_ij_string='FORCE_CHAIN_FC', Contact_ij_string=None)[source]
Extracts contact data from the input connection, including particle IDs, total forces and contact points.
- Return type:
Tuple[ndarray,ndarray,ndarray,Optional[ndarray]]
Inputs
- InputConnectionvtk.vtkAlgorithmOutput
The input connection containing the VTK data.
- Particle_i_stringstr, optional
The name of the first particle ID variable in the point data (default is "Particle_ID_1").
- Particle_j_stringstr, optional
The name of the second particle ID variable in the point data (default is "Particle_ID_2").
- Force_ij_stringstr, optional
The name of the total force variable in the point data (default is "FORCE_CHAIN_FC").
- Contact_ij_stringstr, optional
The name of the contact points variable in the point data (default is None).
Otuputs
- Particle_inp.ndarray, shape (N,)
The particle IDs of the first particles involved in the contacts.
- Particle_jnp.ndarray, shape (N,)
The particle IDs of the second particles involved in the contacts.
- F_ijnp.ndarray, shape (N, 3)
The total forces acting on the contacts, if available.
- Contact_ijnp.ndarray, shape (N, 3), optional
The contact points between the particles, if available.
- raises ValueError:
If any of the required strings (Particle_i_string, Particle_j_string, Force_ij_string) are None or not provided.
Notes
The function retrieves the point data from the input connection and extracts the specified variables.
If any optional variables (Force_ij_string, Contact_ij_string) are not provided,
the corresponding output will be None. - The function returns the arrays of particle IDs, total forces, and contact points.
- pysammos.data_read.mfix.point_data.extract_all_polydata(dataset, level=0)[source]
Recursively extract all vtkPolyData blocks from any nested vtkMultiBlockDataSet or vtkMultiPieceDataSet.
- pysammos.data_read.mfix.point_data.particles(InputConnection, Global_ID_string='Particle_ID', Velocity_string='Velocity', Diameter_string='Diameter', Density_string='Density', Volume_string='Volume', Mass_string='Mass', Radius_string='Radius', Coordination_Number_string='Coordination_Number')[source]
Extracts particle data from the input connection, including position, global ID, velocity, diameter, density, volume, mass, and coordination number.
- Return type:
Tuple[ndarray,ndarray,Optional[ndarray],Optional[ndarray],Optional[ndarray],Optional[ndarray],Optional[ndarray],Optional[ndarray],Tuple]
Inputs
- InputConnectionvtk.vtkAlgorithmOutput
The input connection containing the VTK data.
- Global_ID_stringstr, optional
The name of the global ID variable in the point data (default is "Particle_ID").
- Velocity_stringstr, optional
The name of the velocity variable in the point data (default is "Velocity").
- Diameter_stringstr, optional
The name of the diameter variable in the point data (default is "Diameter").
- Density_stringstr, optional
The name of the density variable in the point data (default is "Density").
- Volume_stringstr, optional
The name of the volume variable in the point data (default is "Volume").
- Mass_stringstr, optional
The name of the mass variable in the point data (default is "Mass").
- Radius_stringstr, optional
The name of the radius variable in the point data (default is "Radius").
- Coordination_Number_stringstr, optional
The name of the coordination number variable in the point data (default is "Coordination_Number").
Outputs
- Position_sortednp.ndarray, shape (N, 3).
The sorted positions of the particles.
- Global_ID_sortednp.ndarray, shape (N,).
The sorted global IDs of the particles.
- Velocity_sortednp.ndarray, shape (N, 3), optional
The sorted velocities of the particles, if available.
- Diameter_sortednp.ndarray, shape (N,), optional
The sorted diameters of the particles, if available.
- Density_sortednp.ndarray, shape (N,), optional
The sorted densities of the particles, if available.
- Volume_sortednp.ndarray, shape (N,), optional
The sorted volumes of the particles, if available.
- Mass_sortednp.ndarray, shape (N,), optional
The sorted masses of the particles, if available.
- Coordination_Number_sortednp.ndarray, shape (N,), optional
The sorted coordination numbers of the particles, if available.
- Bounds_ttuple
The bounds of the point data, represented as a tuple of (xmin, xmax, ymin, ymax, zmin, zmax).
Raises:
- ValueError
If any of the required strings (Global_ID_string, Density_string, etc.) are None or not provided.
Notes
The function retrieves the point data from the input connection and extracts the specified variables.
The global IDs are sorted, and the corresponding positions, velocities, diameters, densities
volumes, masses, and coordination numbers are also sorted based on the global IDs. - If any optional variables (Velocity_string, Diameter_string, etc.) are not provided, the corresponding output will be None. - The function returns the sorted arrays and the bounds of the point data.
pysammos.data_read.mfix.utils module
- pysammos.data_read.mfix.utils.get_bounds(polydata_t0)[source]
Helper function to get bounds from polydata object.
Inputs
- polydata_t0vtk.vtkPolyData
The polydata object from which to extract bounds.
Outputs
- np.ndarray
An array containing the bounds of the polydata in the format [xmin, xmax, ymin, ymax, zmin, zmax].
- pysammos.data_read.mfix.utils.get_point_data_variable(var_name, polydata)[source]
Helper function to get point data variable from polydata.
- Parameters:
var_name (str) -- The name of the variable to extract from the point data.
polydata (vtk.vtkPolyData) -- The polydata object from which to extract the variable.
- Returns:
The variable data as a NumPy array.
- Return type:
np.ndarray