Particle Tracking

class flatiron_tk.physics.particle_tracking.MasslessTracerTracker(mesh, dt)[source]

Bases: object

Track massless particles and write per-step .vtp files plus a .pvd collection (finalized automatically via atexit). Works under MPI: only rank 0 writes the .pvd, while all ranks may write .vtp files if desired.

Parameters:
  • mesh (Mesh) – The flatirion_tk mesh object.

  • dt (float) – Time step size for particle advection.

get_coordinates_on_boundary(boundary_id)[source]

Get the coordinates of all DOFs on a given boundary across all ranks. :param boundary_id: The boundary marker ID from which to get the coordinates. :type boundary_id: int

Returns:

coords – Nx3 array of coordinates on the given boundary across all ranks.

Return type:

np.ndarray

inject_particles(new_particle_positions)[source]

Inject new particles at specified positions. :param new_particle_positions: Iterable of new particle positions, each a 1D array-like of length 2 or 3. :type new_particle_positions: Sequence

inject_particles_from_boundary(boundary_id)[source]
set_particle_positions(particle_positions)[source]

Set the particle positions directly. :param particle_positions: Iterable of particle positions, each a 1D array-like of length 2 or 3. :type particle_positions: Sequence

set_particle_positions_from_boundary(boundary_id)[source]

Set the particle positions to all DOF coordinates on a given boundary. :param boundary_id: The boundary marker ID from which to get the coordinates. :type boundary_id: int

set_writer(output_dir)[source]

Prepare output folder and PVD writer. :param output_dir: Directory to write per-step files and particles.pvd. :type output_dir: str

update_particle_positions(current_velocity, previous_velocity=None, method='euler')[source]

Update particle positions based on the current and previous velocity fields. :param current_velocity: The current velocity field. :type current_velocity: dolfinx.fem.Function :param previous_velocity: The previous velocity field (required for Heun’s method). :type previous_velocity: dolfinx.fem.Function :param method: The time integration method to use (‘euler’ or ‘heun’). :type method: str

write(time_stamp=None)[source]

Write current particle positions to a .vtp file and add to a .pvd collection. :param time_stamp: Time stamp to associate with this write in the .pvd file. :type time_stamp: float