<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; color: rgb(0, 0, 0); font-size: 16px; font-family: Calibri, sans-serif;">
<div>Will,</div>
<div><br>
</div>
<div>>So far we have implemented cubic, quartic and quintic SPH kernels.</div>
<div><br>
</div>
<div>There are more kernels you can easily adapt in the pv-meshless repo (they have been tested extensively over the years)</div>
<div><a href="https://github.com/biddisco/pv-meshless/tree/master/sph">https://github.com/biddisco/pv-meshless/tree/master/sph</a></div>
<div><br>
</div>
<div>(the sph interpolation classes in there handle a variable kernel size per point)</div>
<div><br>
</div>
<div>JB</div>
<div><br>
</div>
<span id="OLK_SRC_BODY_SECTION">
<div style="font-family:Calibri; font-size:11pt; text-align:left; color:black; BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; PADDING-BOTTOM: 0in; PADDING-LEFT: 0in; PADDING-RIGHT: 0in; BORDER-TOP: #b5c4df 1pt solid; BORDER-RIGHT: medium none; PADDING-TOP: 3pt">
<span style="font-weight:bold">From: </span>"<a href="mailto:vtk-developers-bounces@vtk.org">vtk-developers-bounces@vtk.org</a>" <<a href="mailto:vtk-developers-bounces@vtk.org">vtk-developers-bounces@vtk.org</a>> on behalf of Will Schroeder <<a href="mailto:will.schroeder@kitware.com">will.schroeder@kitware.com</a>><br>
<span style="font-weight:bold">Date: </span>Saturday 23 April 2016 at 13:56<br>
<span style="font-weight:bold">To: </span>Favre Jean <<a href="mailto:jfavre@cscs.ch">jfavre@cscs.ch</a>><br>
<span style="font-weight:bold">Cc: </span>VTK Developers <<a href="mailto:vtk-developers@vtk.org">vtk-developers@vtk.org</a>><br>
<span style="font-weight:bold">Subject: </span>Re: [vtk-developers] SPH Interpolator<br>
</div>
<div><br>
</div>
<div>
<div>
<div dir="ltr">Hey Jean-
<div><br>
</div>
<div>Here's a longer email than you'd probably like; hopefully it will give you a better idea of where this is heading. I want to emphasize that this a work in progress, and feedback from those more knowledgeable in this area is very welcome. </div>
<div><br>
</div>
<div>The recent efforts are partly due to the generous support of a collastomer (collaborator/customer), and the personal interest of myself and others at Kitware. For example, besides the SPH additions, I've implemented a bunch of point cloud algorithms in
 the vtkPointCloud remote module, and Ken Martin has put together a kick-butt point cloud renderer (also a VTK remote module vtkLODPointCloudMapper). We've also got some efforts going on with
<a href="http://www.paraview.org/Wiki/VeloView">VeloView</a>, which is a derivative ParaView application for point cloud visualization and analysis. Finally, I've been reworking many algorithms using threaded approaches (vtkSMPTools) including the new vtkStaticPointLocator
 which is typically much faster than any other point locators and is critical to the speed of the SPH operations. (Caveat: I'm guessing that highly dynamic data where point densities vary by orders of magnitude e.g., astrophysics will require more work, probably
 a hierarchical static point locator much like an AMR grid.)</div>
<div><br>
</div>
<div>Okay with that preamble behind me, the current thinking is to support three workflows.</div>
<div><br>
</div>
<div>1. Fixed kernel size / specified smoothing length h (also called spatial step). The cutoff distance (sphere around an interpolated point) is a function of the SPH kernel. For example, a quintic kernel has cutoff distance 3*h. The volume is approximated
 as h^3. This has been tested with real simulation data incompressible CFD and is being validated/verified against simulation data so I have confidence that we are in good shape here. So far we have implemented cubic, quartic and quintic SPH kernels.</div>
<div><br>
</div>
<div>2. Volume defined on a pointwise basis using a pair of mass/density arrays. The API is there to support this, but I believe the last I left it there is a touch more work to do to get it working correctly, and of course testing is necessary. We could really
 use some data to test this properly. It's probably a few hours work and I plan to get back to finishing it off once I return from some travel next week.</div>
<div><br>
</div>
<div>3. Currently in #1 the kernel neighbors are found in the cutoff sphere, with the sphere radius constant across each point. However it would be possible to support a variable radius per point through a provided external array. This is not hard to do, but
 I really need data before proceeding.</div>
<div><br>
</div>
<div>My understanding from reading references like <a href="http://arxiv.org/pdf/1012.1885.pdf">
Price</a> is that another, less desirable possibility for basis is to use N neighbors, rather than the neighbors contained in the cutoff sphere. I have done this in vtkPointInterpolator / vtkGeneralizedKernel classes, which are close cousin classes to vtkSPHInterpolator
 / vtkSPHKernel. So this could easily be extended to the SPH side as well.</div>
<div><br>
</div>
<div>The current implementation uses a gather method, and is done in parallel using vtkSMPTools. For each point to be interpolated, the basis neighbors around the point are retrieved using a provided abstract point locator (typically an instance of vtkStaticPointLocator
 but others are possible). The provided kernel is then invoked to perform the interpolation. So you can see that a vtkSMPTools::For(0,npts,functor) works really well to thread the operation (typically TBB is used because I like the load balancing that it provides).</div>
<div><br>
</div>
<div>So any suggestions you might have, or data you can provide would be more than welcome. Also note that more testing is desired, for example the cubic and quartic SPH kernels need more testing. Bill Lorensen has been helping a lot in that he is adding some
 unit tests for the generalized kernels and has already uncovered a couple of bugs (which have been fixed).</div>
<div><br>
</div>
<div>Anyway I leave for a week of travel early this coming week. If you want to continue the conversation when I return in early May that would be great.</div>
<div><br>
</div>
<div>Best,</div>
<div>W</div>
<div><br>
</div>
<div><br>
</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Fri, Apr 22, 2016 at 10:28 AM, Favre Jean <span dir="ltr">
<<a href="mailto:jfavre@cscs.ch" target="_blank">jfavre@cscs.ch</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>
<div style="direction:ltr;font-family:Tahoma;color:#000000;font-size:10pt">Hello<br>
<br>
First of all, congrats on this new functionality. I am using it with results from an SPH simulation using the GADGET code[1]<br>
<br>
Our scientists are asking some pretty specific questions about the SPH kernels:<br>
<br>
Do you adopt a fixed kernel size for all particles or do you calculate it by adopting a certain number of neighbours? Do you use the scatter method (distributing each SPH particle on the grid) or the gather method (gathering the contribution of all SPH particles
 which are close enough to each grid point)?<br>
<br>
They further comment that "to calculate physical quantities, such as column density etc. , these details become important. For instance, it is important to know if the SPH interpolation scheme which is used is conserving the total mass or not when we map the
 mass from SPH distribution onto a uniform grid, which depend on the details of the SPH interpolation."<br>
<br>
If the Density and Mass arrays are set, [I use]:<br>
<br>
interpolator = vtkSPHInterpolator()<br>
interpolator.SetKernel(sphKernel)<br>
interpolator.SetDensityArrayName("Density")<br>
interpolator.SetMassArrayName("Mass")<br>
<br>
can I assume the above to be true?<br>
<br>
Thanks for clarifying these points. I anticipate some really good use of this new Interpolator.<br>
<br>
[1] <a href="http://wwwmpa.mpa-garching.mpg.de/gadget/" target="_blank">http://wwwmpa.mpa-garching.mpg.de/gadget/</a><br>
<div><br>
<div><font size="2"><span style="font-size:10pt">
<div>-----------------<br>
Jean/CSCS<br>
</div>
</span></font></div>
</div>
</div>
</div>
<br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">
http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Search the list archives at: <a href="http://markmail.org/search/?q=vtk-developers" rel="noreferrer" target="_blank">
http://markmail.org/search/?q=vtk-developers</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/vtk-developers" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/vtk-developers</a><br>
<br>
<br>
</blockquote>
</div>
<br>
<br clear="all">
<div><br>
</div>
-- <br>
<div class="gmail_signature">
<div dir="ltr">
<div>William J. Schroeder, PhD<br>
Kitware, Inc. - Building the World's Technical Computing Software<br>
28 Corporate Drive<br>
Clifton Park, NY 12065<br>
<a href="mailto:will.schroeder@kitware.com" target="_blank">will.schroeder@kitware.com</a><br>
<a href="http://www.kitware.com" target="_blank">http://www.kitware.com</a><br>
(518) 881-4902</div>
</div>
</div>
</div>
</div>
</div>
</span>
</body>
</html>