Skip to content
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

Add force_injection! #199

Merged
merged 5 commits into from
Jan 21, 2025
Merged

Add force_injection! #199

merged 5 commits into from
Jan 21, 2025

Conversation

albert-de-montserrat
Copy link
Member

@albert-de-montserrat albert-de-montserrat commented Jan 21, 2025

This PR is addresses #186 and adds the function ``force_injection!` to inject a given set of new particles in a desired subset of cells.

Usage

  • Define the new p_new particles object. In the bi-dimensional case p_new::Array{Union{Point{2, Float64}, SVector{2, Float64}} 3} is of size $nx \times ny \times np$ where $np$ is the number of new particles per given cell. Indices of p_new where there is no new particle must be NaN.

  • Use case (1) Inject only new particle coordinates:

force_injection!(particles::Particles, p_new)
  • Use case (2) Inject new particles and specific values for given fields defined at the particles. For example, if we want all new particles to have a brand new phase we can do as:
phases, = init_cell_arrays(particles, Val(1))
phases.data .= 1
phases.data[:, 16:end, :] .= 2

force_injection!(particles, p_new, (phases,), (3e0,))

@albert-de-montserrat albert-de-montserrat merged commit 0f880b6 into main Jan 21, 2025
13 of 16 checks passed
@albert-de-montserrat albert-de-montserrat deleted the adm/inj branch January 21, 2025 13:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant