## cell linked method in matlab with parallelization trough domain splitting

I want to perform particle dynamics integration with cell linked method (all particles are assigned to different cells to speed up the calculation of the forces as in figure)

I am easily able to split paricles in cells trough the following function, where the grid stores the left vertex of the cells in x and y coordinates and ptcls.x stores the position of the particles as a 2 by NP (number of particles) mesh

function grd_to_ptcl = init_ptcl_mesh (grd, ptcls)

h = [grd.x(2) – grd.x(1); grd.y(2) – grd.y(1)];

idx = floor(ptcls.x./h) + 1;

indexPtcls = 1:size(ptcls.x,2);

grd_to_ptcl = accumarray(idx’,indexPtcls(:),[grd.ncx grd.ncy],@(x) {x});

end

Once I have the cell array I am easily able to run trough not empty cells and perform force calculation

index = cellfun(@numel, grd_to_ptcl, ‘UniformOutput’, true);

index = find(index >=1);

for i=index(:)

% calculation of the force

end

My question is how I can split the domain and perform the calculation in parallel updating the boundaries of each of the splitted domains as in figure in an efficient way

If possible would be usefull to have a simple example, thanks in advanceI want to perform particle dynamics integration with cell linked method (all particles are assigned to different cells to speed up the calculation of the forces as in figure)

I am easily able to split paricles in cells trough the following function, where the grid stores the left vertex of the cells in x and y coordinates and ptcls.x stores the position of the particles as a 2 by NP (number of particles) mesh

function grd_to_ptcl = init_ptcl_mesh (grd, ptcls)

h = [grd.x(2) – grd.x(1); grd.y(2) – grd.y(1)];

idx = floor(ptcls.x./h) + 1;

indexPtcls = 1:size(ptcls.x,2);

grd_to_ptcl = accumarray(idx’,indexPtcls(:),[grd.ncx grd.ncy],@(x) {x});

end

Once I have the cell array I am easily able to run trough not empty cells and perform force calculation

index = cellfun(@numel, grd_to_ptcl, ‘UniformOutput’, true);

index = find(index >=1);

for i=index(:)

% calculation of the force

end

My question is how I can split the domain and perform the calculation in parallel updating the boundaries of each of the splitted domains as in figure in an efficient way

If possible would be usefull to have a simple example, thanks in advance I want to perform particle dynamics integration with cell linked method (all particles are assigned to different cells to speed up the calculation of the forces as in figure)

I am easily able to split paricles in cells trough the following function, where the grid stores the left vertex of the cells in x and y coordinates and ptcls.x stores the position of the particles as a 2 by NP (number of particles) mesh

function grd_to_ptcl = init_ptcl_mesh (grd, ptcls)

h = [grd.x(2) – grd.x(1); grd.y(2) – grd.y(1)];

idx = floor(ptcls.x./h) + 1;

indexPtcls = 1:size(ptcls.x,2);

grd_to_ptcl = accumarray(idx’,indexPtcls(:),[grd.ncx grd.ncy],@(x) {x});

end

Once I have the cell array I am easily able to run trough not empty cells and perform force calculation

index = cellfun(@numel, grd_to_ptcl, ‘UniformOutput’, true);

index = find(index >=1);

for i=index(:)

% calculation of the force

end

My question is how I can split the domain and perform the calculation in parallel updating the boundaries of each of the splitted domains as in figure in an efficient way

If possible would be usefull to have a simple example, thanks in advance parallel computing toolbox, linked cell method, particle simulation MATLAB Answers — New Questions