val ppdIndex = producer.addIteration("ppd_index", 1, numPPDs)
val ppdGlobalCount = (~(basis % FieldSymbol[PointerType[ArrayType[IntType]]]("ppd_list"))).readAt(ppdIndex, 1) - 1
- // We need to calculate the integer co-ordinates of the PPD (0-based)
- val a3pos = ppdGlobalCount / (cellWidthInPPDs(0)*cellWidthInPPDs(1))
- val a2pos = (ppdGlobalCount % (cellWidthInPPDs(0)*cellWidthInPPDs(1)))/cellWidthInPPDs(0)
- val a1pos = ppdGlobalCount % cellWidthInPPDs(0)
+ // The integer co-ordinates of the PPD (0-based)
+ val a3pos = producer.addExpression("ppd_pos1", ppdGlobalCount / (cellWidthInPPDs(0)*cellWidthInPPDs(1)))
+ val a2pos = producer.addExpression("ppd_pos2", (ppdGlobalCount % (cellWidthInPPDs(0)*cellWidthInPPDs(1)))/cellWidthInPPDs(0))
+ val a1pos = producer.addExpression("ppd_pos3", ppdGlobalCount % cellWidthInPPDs(0))
val ppdPos = List(a1pos, a2pos, a3pos)
val tightbox = (~(basis % FieldSymbol[PointerType[ArrayType[StructType]]]("tight_boxes"))).readAt(sphereIndex)
val ppdStartOffsets = for(dim <- 1 to 3) yield tightbox % FieldSymbol[IntType]("start_pts"+dim)
val ppdFinishOffsets = for(dim <- 1 to 3) yield tightbox % FieldSymbol[IntType]("finish_pts"+dim)
- // The first and last PPDs in PPD co-ordinates (inside simulation cell)
+ // The first and last PPDs in PPD co-ordinates (0-based, inside simulation cell)
val startPPDs = for(dim <- 0 to 2) yield
- producer.addExpression("start_ppd"+(dim+1), (tightbox % FieldSymbol[IntType]("start_ppd"+(dim+1)) + cellWidthInPPDs(dim)) % cellWidthInPPDs(dim))
+ producer.addExpression("start_ppd"+(dim+1), (tightbox % FieldSymbol[IntType]("start_ppd"+(dim+1)) + cellWidthInPPDs(dim)-1) % cellWidthInPPDs(dim))
val finishPPDs = for(dim <- 0 to 2) yield
- producer.addExpression("finish_ppd"+(dim+1),(tightbox % FieldSymbol[IntType]("finish_ppd"+(dim+1)) + cellWidthInPPDs(dim)) % cellWidthInPPDs(dim))
+ producer.addExpression("finish_ppd"+(dim+1),(tightbox % FieldSymbol[IntType]("finish_ppd"+(dim+1)) + cellWidthInPPDs(dim)-1) % cellWidthInPPDs(dim))
// Offsets for the current PPD being iterated over
val loopStarts = for(dim <- 0 to 2) yield