New Multithreaded LagrangianParticleTracker.

Multithreaded LagrangianParticleTracker

The LagragianParticleTracker filter, provided in a Plugin in ParaView,
has been reimplemented with an multithreaded algorithm using VTK SMP backed that one can benefit from when using TBB or OpenMP as SMP backend when compiling ParaView.
Note that those changes imply some update on user-developed Lagrangian Integration models
as some method signatures have been modified.

Important code changes

  1. A few methods signatures of vtkLagrangianParticleTracker, vtkLagrangianBasicIntegrationModel and vtkLagrangianParticle have changed:
  • vtkLagrangianParticleTracker::Integrate/ComputeNextStep(vtkInitialValueProblemSolver* integrator, …): Integrator are now passed to this method for further usage;
  • vtkLagrangianBasicIntegrationModel::FonctionValues/FindInLocator(vtkLagrangianParticle* particle, … ): There is no concept of CurrentParticle anymore and the particle are passed through these methods;
  • vtkLagrangianParticle::SetLastCell(vtkAbstractCellLocator* locator, …): The particle is now fully responsible of tracking last locator, data, cell and weights;
  1. Accessing flow or surface data within your FonctionValues is also now a little bit different:
      // Fetch flowVelocity at index 3  
      double flowVelocity[3]; 
      if (this->GetFlowOrSurfaceDataNumberOfComponents(3, dataSet) != 3 || 
        !this->GetFlowOrSurfaceData(3, dataSet, cellId, weights, flowVelocity)) 
      { 
        vtkErrorMacro(<< "Flow velocity is not set in source flow dataset or " 
                         "have incorrect number of components, cannot use Matida”
     “equations"); 
        return 0; 
      } 
  1. Some methods now need to be thread-safe, so that may impact your own implementation. Here is the exhaustive list:
    In vtkLagrangianParticleTracker: 
    GetNewParticleId 
    Integrate 
    ComputeNextStep 
     
    In vtkLagrangianBasicIntegrationModel: 
    FonctionValues 
    FindInLocators 
    CheckFreeFlightTermination  
    ManualIntegration 
    FindInLocator  
    TerminateParticle 
    BounceParticle 
    BreakParticle (use ParticleQueueMutex before adding new particle)  
    InteractWithSurface (use ParticleQueueMutex before adding new particle)  
    IntersectWithLine  
    InterpolateNextParticleVariables  
    CheckSurfacePerforation  
    GetSeedArray  
    GetFlowOrSurfaceData  
    GetFlowOrSurfaceDataNumberOfComponents  
    GetFlowOrSurfaceDataFieldAssociation 
  1. A few mutexes are present in the code, the only one you may need to use would be vtkLagrangianBasicIntegrationModel::ParticleQueueMutex before adding particles in the particleQueue, e.g. when interacting with a surface.

Almost all mutexes have been removed providing an even better speedup. See here :
https://gitlab.kitware.com/vtk/vtk/merge_requests/6240

1 Like

Hi Mathieu,

To make TBB enable, should i use “VTK_SMP_IMPLEMENTATION=TBB” or “VTK_SMP_IMPLEMENTATION_TYPE=TBB”?
I can found “VTK_SMP_IMPLEMENTATION_TYPE” in one of cmake files but cannot find VTK_SMP_IMPLEMENTATION" which is suggested in paraview build https://github.com/Kitware/ParaView/blob/master/Documentation/dev/build.md

VTK_SMP_IMPLEMENTATION_TYPE=TBB

There is a typo in build.md.

1 Like

Thank you Mathieu for your answers!

Best Regards,
Sharon

@sharon : Do you think you could take care of correcting the typographic issue ? That would be nice of you.

https://gitlab.kitware.com/paraview/paraview/merge_requests/3918

1 Like