New Multithreaded LagrangianParticleTracker.

(Mathieu Westphal (Kitware)) #1

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.