RefillingFlowDataset#
- class RefillingFlowDataset(mesh, slice_position, slice_normal, slice_thickness, lookup_map_spacing, seeding_vol_spacing, field_list, particle_creation_callables=None, slice_bounding_box=None)[source]#
Wraps a vtk-mesh of containing a velocity field. Functionality tackles the problem of in-/ out-flow of particles for a given imaging slice.
Methods:
__call__
(particle_density[, ...])Checks given particle positions and drops all that are out of bounds and sufficiently far away from the reseeding box.
Returns a C-ordered gridded 3D velocity-field and the corresponding physical extends of the grid.
initial_filling
(particle_density[, ...])Randomly uniform seeds particle into the rasterized version of the input mesh with the specified particle density.
project_density_to_mesh
(particles)Evaluates the density of given particle positions and projects it onto the geometry of the original mesh
update_mesh
(mesh, lookup_map_spacing)Processes the mesh handed in as argument, and saves the nessecary information into class attributes.
update_seeding_volume
([seeding_vol_spacing, ...])Creates a uniform grid which represents the surrounding cuboid of the selected slice from self.gridded_mesh.
Attributes:
Reference to the uniformly gridded input mesh
Reference to the seeding volume represented as an uniform grid
Spacing of the uniform grid used for defining the lookup-maps taken from original mesh
Property storing the mean particle density in the specified seeding volume
Reference to the original mesh, given as input
Normal vector of the re-seeding volume (formulated as plane +/ slice thickness/2)
Positional offset of the re-seeding volume in meter
Slice thickness the re-seeding volume in meter
Spacing of the uniform grid used for defining the seeding volume
Maximal extend of the cartesian bounding box for the re-seeding slice.
- Parameters:
- __call__(particle_density, residual_particle_pos=None, particle_properties=None, distance_tolerance=0.005, reseed_threshold=1)[source]#
Checks given particle positions and drops all that are out of bounds and sufficiently far away from the reseeding box.
- Parameters:
particle_density – target values for particle per 1/mm^3 cell of the grid
residual_particle_pos – np.ndarray - Shape (-1, 3)
particle_properties – dictionary of arrays (magnetization, T1, T2)
distance_tolerance (
float
) – float maximal distance to slice of particles that are reusedreseed_threshold (
float
) – [0,1], threshold as a fraction of particle density below which reseeding will occur. Positions with higher density than reseed_threshold*particle_density will not reseed
- Returns:
If no residual particles are handed in the returned tuple of properties is set to default values only. otherwise it contains the properties of the particles selected to keep Tuple[np.ndarray, (np.ndarray)] - Shape[(-1, 3), (-1, 3)] (particle_positions, (particle_properties), in_tolerance)
- get_lookup_table()[source]#
Returns a C-ordered gridded 3D velocity-field and the corresponding physical extends of the grid. Assumes that the internally stored mesh/ImageData is stored in Fortran order.
- Returns:
Array of shape [X, Y, Z, 3+N] containing the lookup-tables for velocity and N additional entries
- initial_filling(particle_density, slice_dictionary=None)[source]#
Randomly uniform seeds particle into the rasterized version of the input mesh with the specified particle density. The density of particles per mm^3 will be an integer multiple of rasterized cells within a cubic mm (defined by lookup_map_spacing on object initialization). Along with the positions, particle properties are returned (defined by the factory functions passed on object initialization)
- Parameters:
- Returns:
(-1, 3) particle positions, dict(“T1”: (-1), …) particle properties
- project_density_to_mesh(particles)[source]#
Evaluates the density of given particle positions and projects it onto the geometry of the original mesh
- Parameters:
particles (
ndarray
) – (-1, 3)- Return type:
UnstructuredGrid
- update_mesh(mesh, lookup_map_spacing)[source]#
Processes the mesh handed in as argument, and saves the nessecary information into class attributes.
- Sets the module attributes:
self.original_mesh
self.lookup_map_spacing
self.gridded_mesh
- Parameters:
mesh (
UnstructuredGrid
) – ‘pyvista.UnstructuredGrid’ 3D mesh of flow-fieldlookup_map_spacing (
ndarray
) – (3, ) in meter - determines the pixel size of the uniformly gridded mesh
- Returns:
None
- update_seeding_volume(seeding_vol_spacing=None, slice_position=None, slice_normal=None, slice_thickness=None, slice_bounding_box=None)[source]#
Creates a uniform grid which represents the surrounding cuboid of the selected slice from self.gridded_mesh. The pv.ImageData contains the arrays ‘in_slice’ and ‘in_mesh’. Using logical_and on those, yields the condition for positions being inside the sliced flow field.
- Sets the module attributes:
self.gridded_seeding_volume
self.seeding_slice_position
self.seeding_slice_normal
self.seeding_slice_thickness
self.slice_bounding_box
- Parameters:
seeding_vol_spacing (
ndarray
) – (3, ) in meter - determines the pixel size of the seeding volume, should be at least 4 times smaller that Voxel-size of the simulated imageslice_position (
ndarray
) – (3, ) in meterslice_normal (
ndarray
) – (3, )slice_thickness (
float
) – float in meterslice_bounding_box (
array
) – (3, ) in meter - user defined bounding box for slicing mesh.
-
gridded_mesh:
ImageData
# Reference to the uniformly gridded input mesh
-
gridded_seeding_volume:
ImageData
# Reference to the seeding volume represented as an uniform grid
-
lookup_map_spacing:
ndarray
# Spacing of the uniform grid used for defining the lookup-maps taken from original mesh
-
original_mesh:
UnstructuredGrid
# Reference to the original mesh, given as input