]> git.unchartedbackwaters.co.uk Git - francis/ofc.git/commitdiff
Work on converting to reciprocal space.
authorFrancis Russell <francis@unchartedbackwaters.co.uk>
Tue, 1 May 2012 09:14:43 +0000 (10:14 +0100)
committerFrancis Russell <francis@unchartedbackwaters.co.uk>
Tue, 1 May 2012 09:14:43 +0000 (10:14 +0100)
src/ofc/codegen/Expression.scala
src/ofc/generators/onetep/Laplacian.scala
src/ofc/generators/onetep/PPDFunctionSet.scala

index 474a4e2bc2ae15779f76fa5e03e0cd0fda261c9f..1e3e9ff39645c3dad2661d789adc41c24244b6a6 100644 (file)
@@ -76,6 +76,11 @@ class VarRef[T <: Type](symbol: VarSymbol[T]) extends Expression[T] with LeafExp
   def getType = symbol.getType
 }
 
+class FieldRef[T <: Type](symbol: FieldSymbol[T]) extends Expression[T] with LeafExpression {
+  def getSymbol = symbol
+  def getType = symbol.getType
+}
+
 // Struct and array accesses
 class FieldAccess[T <: Type](expression: Expression[StructType], field: FieldSymbol[T]) extends Expression[T] {
   def foreach[U](f: Expression[_] => U) = f(expression)
index 72a31b53d2b0d48a5321a70c50c329897552f884..9588fad3410901e853c15cf64a3576bc91414240 100644 (file)
@@ -2,5 +2,5 @@ package ofc.generators.onetep
 import ofc.codegen._
 
 class Laplacian(op: Field)  extends Field {
-  def getFragment(indices: Map[NamedIndex, Expression[IntType]]) = op.getFragment(indices)
+  def getFragment(indices: Map[NamedIndex, Expression[IntType]]) = op.getFragment(indices).toReciprocal
 }
index 23b87ae26b9235ba1e2ba2576d2edcac47351d45..176e5bd6230056478d95dee79c5decb4fc7099c8 100644 (file)
@@ -108,14 +108,17 @@ class PPDFunctionSet(basisName: String, dataName: String, indices: Seq[NamedInde
     val fftbox = new DeclaredVarSymbol[ArrayType[FloatType]]("fftbox", new ArrayType[FloatType](3))
 
     def setup(context: GenerationContext) {
+      import OnetepTypes.FFTBoxInfo
+
       context.addDeclaration(fftbox)
+      context += new AllocateStatement(fftbox, for (dim <- 0 to 2) yield FFTBoxInfo.public % FFTBoxInfo.totalPts(dim))
     }
 
     def teardown(context: GenerationContext) {
+      context += new DeallocateStatement(fftbox)
     }
   }
 
   def getFragment(indices: Map[NamedIndex, Expression[IntType]]) : FieldFragment =
     new LocalFragment(this)
-
 }