# use openmp with StaticCellLocator

**URL:** https://discourse.vtk.org/t/use-openmp-with-staticcelllocator/1453
**Category:** Support
**Created:** [July 30, 2019, 3:08pm UTC](https://discourse.vtk.org/t/use-openmp-with-staticcelllocator/1453 "2019-07-30T15:08:51Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Dmitriy\_L](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/d/c5a1d2/32.png) [@Dmitriy\_L](https://discourse.vtk.org/u/Dmitriy_L)
#### Post date: [July 30, 2019, 3:08pm UTC](https://discourse.vtk.org/t/use-openmp-with-staticcelllocator/1453/1 "2019-07-30T15:08:51Z")

</div>

I’m trying to make routine to get cell index by point coordinates in unstructured 3D mesh to be used with OpenMP parallelized code. As far as I understand the documentation for vtkStaticCellLocator ([https://vtk.org/doc/nightly/html/classvtkStaticCellLocator.html](https://vtk.org/doc/nightly/html/classvtkStaticCellLocator.html)) it is thread-safe and could be used to fulfill this task. Yet once I’m comparing locator outputs for test geometries in sequential and OpenMP parallelized mode I get discrepancy in results.

The mesh is read from .vtk file by vtkUnstructuredGridReader. VTK was build with VTK\_SMP\_IMPLEMENTATION\_TYPE = OpenMP .

I’m using locator like this:

vtkSmartPointer cellLocator = vtkSmartPointer::New();  
cellLocator-\>SetDataSet(dataSet);  
cellLocator-\>BuildLocator();

#pragma omp parallel for num\_threads(2)  
for (int pid = 0; pid \< N\_points; ++pid) {  
locations\_vtk[pid] = cellLocator-\>FindCell(test\_points[pid]);  
}

Is there some problem with my code or did I probably misinterpret the documentation? Unfortunately I’m unable to use TBB SMP backend as the main code part strongly relies on OpenMP.

Any help would be greatly appreciated. Thank you in advance!
