<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, 4 Apr 2022 at 12:07, Joauma Marichal <<a href="mailto:joauma.marichal@uclouvain.be">joauma.marichal@uclouvain.be</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">




<div dir="ltr">
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Hello, <br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
I have written before as I am trying use the DMSwarm library to track particles over a collocated non-uniform mesh with ghost cells.
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
I have been able to deal with the collocated and ghost cell issues by creating an intermediate DMDA.
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
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.
<br></div></div></blockquote><div><br></div><div>Right. <br></div><div><br></div><div>As I wrote in my previous email, the native PIC support with DA will only work with coordinates created using DMDASetUniformCoordinates.</div><div>The point location DMDA provides is very simple - you can find it here</div><div>  src/dm/impls/da/dageometry.c : DMLocatePoints_DA_Regular()</div><div><br></div><div>If your cell DM coordinates are not uniform, then you need to provide your own point location routine to the DM.</div><div>In your code, you would do this as follows<br></div><div>  da_swarm->ops->locatepoints = CUSTOM_POINT_LOCATION_FUNCTION</div><div>with a signature matching</div><div><pre width="80"><a name="line199"></a><strong><font color="#4169E1"><a name="DMLocatePoints_DA_Regular"></a>PetscErrorCode DMLocatePoints(DM dm,Vec pos,DMPointLocationType ltype,PetscSF cellSF)</font></strong></pre></div><div> <br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
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.</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Can it be due to how I define my coordinates? If yes, why? Or is it due to how the migrate function is implmented?
<br></div></div></blockquote><div><br></div><div>The problem has nothing to do with Migrate. Here is the issue.</div><div>When you set the type to DMSWARM_PIC, a particular migration function was selected.</div><div>The migration function selected does the following:</div><div>* It calls the point location routine (DMLocatePoints) for the cellDM you provided for all swarm points<br></div><div>* Any swarm points which were not located in the sub-domain of the cellDM are scattered to the neighbouring cellDM sub-domains.</div><div>* When the scatter has finished, the DM point location routine is called again on the received swarm points.</div><div>* If any received swarm points are located in the sub-domain, they are added to the swarm object.<br></div><div> </div><div>Thanks,</div><div>Dave</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Best regards, <br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Joauma</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
PS. the code is run with: mpirun -np 3 ./cobpor. <br>
</div>
</div>

</blockquote></div></div>