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

Figure out how to pass neighborhood search to a TrixiParticles.jl simulation #27

Open
Tracked by #28
efaulhaber opened this issue Jun 12, 2024 · 1 comment · Fixed by #32
Open
Tracked by #28

Figure out how to pass neighborhood search to a TrixiParticles.jl simulation #27

efaulhaber opened this issue Jun 12, 2024 · 1 comment · Fixed by #32

Comments

@efaulhaber
Copy link
Member

efaulhaber commented Jun 12, 2024

Currently, we only pass the type of the neighborhood search, e.g.:

semi = Semidiscretization(system1, system2, neighborhood_search=GridNeighborhoodSearch)

This comes with two major problems:

  1. To use a new neighborhood search in TrixiParticles.jl, one has to add a function create_neighborhood_search for this type, which calls the constructor of the neighborhood search and initializes it.
  2. Options for the neighborhood search can't be passed. Currently, we only have the threaded_update kwarg, which can be passed to Semidiscretization and is then passed through create_neighborhood_search to the constructor of the NHS. This doesn't work with multiple neighborhood search implementations with different kwargs.

We can't just call the constructor and pass a neighborhood search object because we need multiple objects (one for each pair of physics systems).
My best idea so far is the following:

  1. Create and pass to the Semidiscretization an empty neighborhood search, setting all options in the constructor.
  2. Then, in PointNeighbors.jl, add a function copy_neighborhood_search, which takes a neighborhood search, a number of particles, and a search radius, and then creates a neighborhood search with the same type and options and the new size and search radius.
  3. In the NHS constructors, the number of particles is set to zero by default for convenience and the search radius to nothing or so. The resulting neighborhood search can't be actually used without a search radius, so it's only to be used with copy_neighborhood_search.

The line above would then become

semi = Semidiscretization(system1, system2, neighborhood_search=GridNeighborhoodSearch())

and setting options is easy and modular:

semi = Semidiscretization(system1, system2, neighborhood_search=GridNeighborhoodSearch(threaded_update=false))

For each pair of physics systems, TrixiParticles.jl would then call:

nhs = copy_neighborhood_search(dummy_nhs, search_radius, n_particles)

Does anyone have any other ideas?
@LasNikas @svchb @sloede

@LasNikas
Copy link
Collaborator

I'm fine with this approach. I can't see any drawbacks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants