i'm working on lattice boltzmann method and i've written a matlab code. I would like to parallelize some parts of the code but i'm new to this so i'd appreciate your help. I'd like to know if it's possible to use the parfor for this part(collision operator):
for i=1:lx
for j=1:ly
fork=1:9
f(k,i,j)=f(k,i,j) .* (1 - omega) + omega .* feq(k,i,j);
end
end
end
I've tried to replace the outermost for loop with a parfor but the code seems to be slower.
any suggestions?
thanks in advance
lx
andly
? I could imagine that parfor will actually be slower due to overhead when the for loop is not that big – Michielparfor
is still slower but relatively it gets closer tofor
. What I noticed though is thatparfor
completely floods my memory with this loop, probably because it is passing big matrices around. Maybe that is the issue?! – Michiel