Skip to content
Snippets Groups Projects
Commit c6df6759 authored by Rafael Ravedutti Lucio Machado's avatar Rafael Ravedutti Lucio Machado
Browse files

Iterate over PBC particles when building cell lists

parent 0a80c073
No related branches found
No related tags found
No related merge requests found
...@@ -106,14 +106,16 @@ class For(): ...@@ -106,14 +106,16 @@ class For():
class ParticleFor(For): class ParticleFor(For):
def __init__(self, sim, block=None): def __init__(self, sim, block=None, local_only=True):
super().__init__(sim, 0, 0, block) super().__init__(sim, 0, 0, block)
self.local_only = local_only
def __str__(self): def __str__(self):
return f"ParticleFor<>" return f"ParticleFor<>"
def generate(self): def generate(self):
self.sim.code_gen.generate_for_preamble(self.iterator.generate(), 0, self.sim.nlocal.generate()) upper_range = self.sim.nlocal if self.local_only else self.sim.nlocal + self.sim.pbc.npbc
self.sim.code_gen.generate_for_preamble(self.iterator.generate(), 0, upper_range.generate())
self.block.generate() self.block.generate()
self.sim.code_gen.generate_for_epilogue() self.sim.code_gen.generate_for_epilogue()
......
...@@ -84,7 +84,7 @@ class CellListsBuild: ...@@ -84,7 +84,7 @@ class CellListsBuild:
for c in For(cl.sim, 0, cl.ncells_all): for c in For(cl.sim, 0, cl.ncells_all):
cl.cell_sizes[c].set(0) cl.cell_sizes[c].set(0)
for i in ParticleFor(cl.sim): for i in ParticleFor(cl.sim, local_only=False):
cell_index = [ cell_index = [
Cast.int(cl.sim, (positions[i][d] - grid.min(d)) / spc) Cast.int(cl.sim, (positions[i][d] - grid.min(d)) / spc)
for d in range(0, cl.sim.dimensions)] for d in range(0, cl.sim.dimensions)]
...@@ -95,9 +95,7 @@ class CellListsBuild: ...@@ -95,9 +95,7 @@ class CellListsBuild:
else flat_idx * cl.ncells[d] + cell_index[d]) else flat_idx * cl.ncells[d] + cell_index[d])
cell_size = cl.cell_sizes[flat_idx] cell_size = cl.cell_sizes[flat_idx]
for _ in Filter(cl.sim, for _ in Filter(cl.sim, Expr.and_op(flat_idx >= 0, flat_idx <= cl.ncells_all)):
Expr.and_op(flat_idx >= 0,
flat_idx <= cl.ncells_all)):
for cond in Branch(cl.sim, cell_size >= cl.cell_capacity): for cond in Branch(cl.sim, cell_size >= cl.cell_capacity):
if cond: if cond:
resize.set(cell_size) resize.set(cell_size)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment