SPHinXsys icon indicating copy to clipboard operation
SPHinXsys copied to clipboard

CLL update clarification

Open WeiyiVirtonomy opened this issue 6 months ago • 0 comments

@Xiangyu-Hu Hello, Prof. Hu, I still have some questions about the update of CLL we discussed last time.

I remember the last time you said that to get rid of concurrent vectors, we need to modify the function CellLinkedList::updateSplitCellLists, replacing the current mesh loop by two loops of i and j with a stride of 3, i.e.

From

mesh_parallel_for(
        MeshRange(Arrayi::Zero(), all_cells_),
        [&](const Arrayi &cell_index)
{// some code});

to

parallel_for( 0, all_cells_[0], 3, [&](size_t i)
{parallel_for( 0, all_cells_[1], 3, [&](size_t j){// some code});});

I'm still confused about this.

  1. SplitCellLists is not a ConcurrentVector, but a StdVec, but it is a vector of the concurrent vector CLL. The current mesh_parallel_for loop doesn't violate the memory of this StdVec
  2. The concurrent vector is cell_index_lists_, which stores the particles indices in each cell. However, concurrent is necessary for CLLs, otherwise the push_back is not safe in the parallel loop CellLinkedList::UpdateCellLists:
parallel_for(
        IndexRange(0, total_real_particles),
        [&](const IndexRange &r)
        {
            for (size_t i = r.begin(); i != r.end(); ++i)
            {
                insertParticleIndex(i, pos_n[i]);
            }
        },
        ap);

In short, I still don't understand the relation between CellLinkedList::updateSplitCellLists and the concurrent vector. It seems to me that the concurrent vector is related to CellLinkedList::UpdateCellLists, but this is the only we to update CLL in a parallel way without segmentation faults.

Could you take a look at this issue and explain a bit more about this? @Xiangyu-Hu @DongWuTUM Thanks a lot!

WeiyiVirtonomy avatar Aug 19 '24 16:08 WeiyiVirtonomy