]> git.unchartedbackwaters.co.uk Git - francis/ofc.git/commitdiff
Calculate x, y, z & data value in PPDFunctionSet.
authorFrancis Russell <francis@unchartedbackwaters.co.uk>
Sun, 8 Apr 2012 19:58:36 +0000 (20:58 +0100)
committerFrancis Russell <francis@unchartedbackwaters.co.uk>
Sun, 8 Apr 2012 19:58:36 +0000 (20:58 +0100)
src/ofc/generators/onetep/OnetepTypes.scala
src/ofc/generators/onetep/PPDFunctionSet.scala

index 40e6cc76684572815c8a322bb15aa4e0b37b6957..6c19b83121a1c5880a7ad58e23478b80732672be 100644 (file)
@@ -29,12 +29,15 @@ object OnetepTypes {
       new FieldSymbol[PointerType[ArrayType[IntType]]]("ppd_list", fieldType)
     }
 
+    val offset = new FieldSymbol[IntType]("offset")
+
     def getFortranAttributes = Set("type(SPHERE)")
   }
 
   object CellInfo extends StructType {
     val ppdWidth = {for (dim <- 1 to 3) yield new FieldSymbol[IntType]("n_pt"+dim)}.toSeq
     val numPPDs = {for (dim <- 1 to 3) yield new FieldSymbol[IntType]("n_ppds_a"+dim)}.toSeq
+    val pointsInPPD = new FieldSymbol[IntType]("n_pts")
     def getFortranAttributes = Set("type(CELL_INFO)")
   }
 
index ce91b26b41176474193b8b5f2c06e5abe85f79f0..94ee3f39e8e047fa84cf33c720de6cf04660daed 100644 (file)
@@ -17,7 +17,8 @@ class PPDFunctionSet(val basisName: String, dataName: String) extends FunctionSe
     val sphereIndex = producer.addIteration("sphere_index", 1, numSpheres)
     val numPPDs = (~(basis % FunctionBasis.numPPDsInSphere)).readAt(sphereIndex)
     val ppdIndex = producer.addIteration("ppd_index", 1, numPPDs)
-    val ppdGlobalCount = (~((~(basis % FunctionBasis.spheres)).readAt(sphereIndex) % Sphere.ppdList)).readAt(ppdIndex, 1) - 1
+    val sphere = (~(basis % FunctionBasis.spheres)).readAt(sphereIndex) 
+    val ppdGlobalCount = (~(sphere % Sphere.ppdList)).readAt(ppdIndex, 1) - 1
 
     // The integer co-ordinates of the PPD (0-based)
     val a3pos = producer.addExpression("ppd_pos1", ppdGlobalCount / (cellWidthInPPDs(0)*cellWidthInPPDs(1)))
@@ -47,6 +48,21 @@ class PPDFunctionSet(val basisName: String, dataName: String) extends FunctionSe
     // Loops for iterating over the PPD itself
     val ppdIndices = for(dim <- 0 to 2) yield producer.addIteration("point"+(dim+1), loopStarts(dim), loopEnds(dim)) 
     
+    // Values exposed as indices and data
+    val positions = for(dim <- 0 to 2) yield 
+      producer.addExpression("pos"+(dim+1), ppdPos(dim)*ppdWidths(dim) + ppdIndices(dim))
+
+    // TODO: We explicitly convert to Expression[IntType] here since we don't promote both sides of the addition for ppdDataIndex.
+    val ppdDataStart : Expression[IntType] = 
+      producer.addExpression("ppd_data_start", (sphere % Sphere.offset) + (ppdIndex-1) * (pubCell % CellInfo.pointsInPPD))
+
+    val ppdDataIndex = producer.addExpression("ppd_data_index", ppdDataStart 
+      + (ppdIndices(2)-1) * (pubCell % CellInfo.ppdWidth(1)) * (pubCell % CellInfo.ppdWidth(0))
+      + (ppdIndices(1)-1) * (pubCell % CellInfo.ppdWidth(0))
+      + (ppdIndices(0)-1))
+
+    val dataValue = producer.addExpression("data", data.readAt(ppdDataIndex))
+    
     producer
   }