Skip to content

Reply To: Modifying field values for neighboring cells inside a postprocessor

OpenLB – Open Source Lattice Boltzmann Code Forums on OpenLB General Topics Modifying field values for neighboring cells inside a postprocessor Reply To: Modifying field values for neighboring cells inside a postprocessor

#9106
Danial.Khazaeipoul
Participant

Good news for anyone interested, I managed to finally store pointers to “cells” within a container. The critical issue is to avoid using std::vector, queue, or stack when the platform is CUDA. Use either std::array or olb::Vector. The only downside is that with std::array or olb::Vector, you need to set the size of the container beforehand. Here is the sample test code that works on both CPU and GPU.

template <typename CELL, typename V>
void Test(CELL& cell, std::uint32_t& seed)
{
Vector<CELL*, 2> queued = {};
queued[0] = &cell;
auto neighborCell = queued[0]->neighbor(descriptors::c<DESCRIPTOR>(2));
queued[1] = &neighborCell;
queued[1]->template setField<FreeSurface::TEST_ID>(seed);
}

Thank you Adrian for your assistance and clarification.