On Mon, 4 Apr 2022 at 12:07, Joauma Marichal <[email protected]> wrote:
> Hello, > > I have written before as I am trying use the DMSwarm library to track > particles over a collocated non-uniform mesh with ghost cells. > I have been able to deal with the collocated and ghost cell issues by > creating an intermediate DMDA. > However, I lose particles when my mesh is non-uniform. I have re-written a > function similar to DMDASetUniformCoordinates but I still have issues when > my cells have varying sizes. > Right. As I wrote in my previous email, the native PIC support with DA will only work with coordinates created using DMDASetUniformCoordinates. The point location DMDA provides is very simple - you can find it here src/dm/impls/da/dageometry.c : DMLocatePoints_DA_Regular() If your cell DM coordinates are not uniform, then you need to provide your own point location routine to the DM. In your code, you would do this as follows da_swarm->ops->locatepoints = CUSTOM_POINT_LOCATION_FUNCTION with a signature matching *PetscErrorCode DMLocatePoints(DM dm,Vec pos,DMPointLocationType ltype,PetscSF cellSF)* > I attach a small code to this e-mail that reads particles coordinates from > a file and stores them in a DMSwarm structure. My code works well when I > use uniform coordinates but whenever I change this, I lose several > particles after calling the migration function. > > Can it be due to how I define my coordinates? If yes, why? Or is it due to > how the migrate function is implmented? > The problem has nothing to do with Migrate. Here is the issue. When you set the type to DMSWARM_PIC, a particular migration function was selected. The migration function selected does the following: * It calls the point location routine (DMLocatePoints) for the cellDM you provided for all swarm points * Any swarm points which were not located in the sub-domain of the cellDM are scattered to the neighbouring cellDM sub-domains. * When the scatter has finished, the DM point location routine is called again on the received swarm points. * If any received swarm points are located in the sub-domain, they are added to the swarm object. Thanks, Dave > Best regards, > > Joauma > > PS. the code is run with: mpirun -np 3 ./cobpor. >
