From 4ac9b249f40e6a13571484d952dc7613c708b9be Mon Sep 17 00:00:00 2001 From: Francis Russell Date: Sun, 8 Apr 2012 20:58:36 +0100 Subject: [PATCH] Calculate x, y, z & data value in PPDFunctionSet. --- src/ofc/generators/onetep/OnetepTypes.scala | 3 +++ src/ofc/generators/onetep/PPDFunctionSet.scala | 18 +++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/ofc/generators/onetep/OnetepTypes.scala b/src/ofc/generators/onetep/OnetepTypes.scala index 40e6cc7..6c19b83 100644 --- a/src/ofc/generators/onetep/OnetepTypes.scala +++ b/src/ofc/generators/onetep/OnetepTypes.scala @@ -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)") } diff --git a/src/ofc/generators/onetep/PPDFunctionSet.scala b/src/ofc/generators/onetep/PPDFunctionSet.scala index ce91b26..94ee3f3 100644 --- a/src/ofc/generators/onetep/PPDFunctionSet.scala +++ b/src/ofc/generators/onetep/PPDFunctionSet.scala @@ -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 } -- 2.47.3