Skip to content

[Feature] Blood, vessels and heart simulations #420

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions genesis/engine/entities/multiphase_sph_entity.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import taichi as ti
import genesis as gs
from .sph_entity import SPHEntity


@ti.data_oriented
class MultiphaseSPHEntity(SPHEntity):
"""
SPH-based particle entity with multiphase support.
"""

def __init__(
self,
scene,
solver,
material,
morph,
surface,
particle_size,
idx,
particle_start,
phase,
):
"""
Initialize a MultiphaseSPHEntity.
"""
self.phase = phase # Store phase information
super().__init__(
scene, solver, material, morph, surface, particle_size, idx, particle_start
)

def _add_to_solver_(self):
"""
Adds particles to the solver with phase information.
"""
self._solver._kernel_add_particles(
self._sim.cur_substep_local,
self.active,
self._particle_start,
self._n_particles,
self._material["rho"],
self._material["stiffness"],
self._material["exponent"],
self._material["mu"],
self._material["gamma"],
self._material["tau_y"],
self._material["K"],
self._material["n"],
self.phase, # Pass phase information
self._particles,
)

@gs.assert_built
def set_phase(self, f, phase):
"""
Sets the phase of the entity's particles.

Parameters:
f: Frame index or identifier.
phase: Integer identifier for the new phase.
"""
self.phase = phase
self.solver._kernel_set_particle_phase(
f,
self._particle_start,
self._n_particles,
phase,
)
Loading