slim4.particles

Particles

Enums

class slim4.particles.ParticleBoundaryType(IntEnum)

Describes the behaviour of particles reaching boundaries

Values

slip: 0 — The particle will slip along the boundary with zero normal velocity
settle: 1 — The particle will be marked as settled and will not move anymore (removed from simulation)
leave: 2 — The particle will be marked as leaving the domain (removed from simulation)

Classes

class slim4.particles.ParticleArrays

Base class for particles arrays 2d and 3d, not to be used directly provide a common interface to be used e.g. in the polygon mesh intersection class.

Properties

size: int — size

Methods

get_position()

Get the 2D position of the particles

Returns

xy: NDArray[np.float64] — The position of the particles (dimension, n_particles)
get_triangle()

Get the triangle indices of the particles

Returns

tri: NDArray[np.int32] — The triangle indices of the particles (n_particles)
class slim4.particles.PolygonMeshIntersection

This class computes the intersection of a 2D mesh with a set of polygons, and allows to query if a point is in the intersection or not.

Constructor

__init__(mesh, polygons_start, polygons_x, polygons_tag, cut_poly=2000, use_clipper=False)

Create a PolygonMeshIntersection object

Parameters

mesh: slim2d.Mesh — The 2D mesh to intersect with the polygons
polygons_start: NDArray[np.int32] — The start indices of the polygons in the polygons_x array (n_polygons+1)
polygons_x: NDArray[np.float64] — The x coordinates of the vertices of the polygons (2, n_vertices)
polygons_tag: NDArray[np.int32] — The tag of each polygon (n_polygons) (should be positive)
cut_poly: float — The minimum area of the intersection to keep (in fraction of the triangle area)
use_clipper: bool — Whether to use the Clipper library for polygon intersection or a simple Sutherland-Hodgman algorithm

Methods

print_pos(filename)

Print the intersection polygons in a file in a format that can be visualized with Gmsh

Parameters

filename: str — The name of the file to write the intersection polygons to
particles_in_polygons(particles)

Get the tag of the polygons in which the particles are located. If a particle is not in any polygon, its tag will be -1.

Parameters

particles: ParticleArrays — The particle arrays to check for intersection

Returns

particles_in_poly: NDArray[np.int32] — An array with the tag of the polygon in which each particle is located (n_particles)
get_density()

Get the density of the intersection of the polygons with the mesh. The density is defined as the area of the intersection of the polygons with each triangle, divided by the area of the triangle.

Returns

density: NDArray[np.float64] — An array with the density of the intersection for each triangle (1, 3, n_triangles)