underworld3 icon indicating copy to clipboard operation
underworld3 copied to clipboard

What is the defined output of <mesh>.points_in_domain() when input is empty?

Open jcgraciosa opened this issue 5 months ago • 2 comments

What should we define as the output of .points_in_domain() when the input is empty (i.e. [])? Currently, it returns False. Do we stick with this behaviour? This is relevant when doing migrate with the basic swarm and a rank has no particles in it:

swarm_coord_array = swarm.dm.getField("DMSwarmPIC_coor").reshape((-1, swarm.dim)) # [] if rank has no particles
in_or_not = swarm.mesh.points_in_domain(swarm_coord_array) # in_or_not is False if swarm_coord_array is []
swarm.dm.restoreField("DMSwarmPIC_coor")

jcgraciosa avatar Aug 20 '25 07:08 jcgraciosa

The intention is that it should return an indexing array that can be used to mask out particles that are not in the domain. It should not fall over if the domain has no particles.

If this is failing, we should fix it !

lmoresi avatar Aug 20 '25 10:08 lmoresi

After discussion we now think - numpy.ndarray(shape=(0,0), dtype=bool)

lmoresi avatar Aug 23 '25 01:08 lmoresi