← Back to team overview

dolfin team mailing list archive

Patch with some bug fixes

 

Hello,

I recognized some small bugs in functions.py, and in the dg 
advection-diffusion python demo.

Johan
# HG changeset patch
# User "Johan Hake <hake@xxxxxxxxx>"
# Date 1215508817 -7200
# Node ID 8cfc24837d1fd146357e07e01546fb84882147ef
# Parent  517975e46702f13dc6e7cec97633c0ab1bc9719a
Bug fixes:
1) Added rank and dim information to a compiled function used in demo
2) Updates to function.py so Functions now works

diff -r 517975e46702 -r 8cfc24837d1f demo/pde/dg/advection_diffusion/python/functions2D.h
--- a/demo/pde/dg/advection_diffusion/python/functions2D.h	Mon Jul 07 23:17:09 2008 +0200
+++ b/demo/pde/dg/advection_diffusion/python/functions2D.h	Tue Jul 08 11:20:17 2008 +0200
@@ -36,6 +36,20 @@
     values[0] = -exp(x[0])*(x[1]*cos(x[1]) + sin(x[1]));
     values[1] = exp(x[0])*(x[1]*sin(x[1]));
   }
+  
+  dolfin::uint rank() const
+  {
+    return 1;
+  }
+  
+  dolfin::uint dim(dolfin::uint i) const
+  {
+    switch(i) {
+      case 0: return 2;
+    }
+    throw std::runtime_error("Invalid dimension i in dim(i).");
+  }
+  
 };
 
 class OutflowFacet2D : public dolfin::Function
diff -r 517975e46702 -r 8cfc24837d1f site-packages/dolfin/function.py
--- a/site-packages/dolfin/function.py	Mon Jul 07 23:17:09 2008 +0200
+++ b/site-packages/dolfin/function.py	Tue Jul 08 11:20:17 2008 +0200
@@ -25,6 +25,7 @@
 
 import ffc
 import dolfin
+from assemble import jit
 
 # Create new class inheriting from both FFC and DOLFIN Function
 class Function(ffc.Function, dolfin.cpp_Function):
@@ -34,17 +35,17 @@
         # Special case, Function(element, mesh, x), need to create simple form to get arguments
         if isinstance(element, (ffc.FiniteElement, ffc.MixedElement)) and \
                 len(others) == 2 and \
-                isinstance(others[0], Mesh) and \
+                isinstance(others[0], dolfin.Mesh) and \
                 isinstance(others[1], (dolfin.Vector, dolfin.GenericVector)):
             mesh = others[0]
             self.x = others[1]
             # Create simplest possible form
             if element.value_dimension(0) > 1:
-                form = ffc.TestFunction(element)[0]*dx
+                form = ffc.TestFunction(element)[0]*ffc.dx
             else:
-                form = ffc.TestFunction(element)*dx
+                form = ffc.TestFunction(element)*ffc.dx
             # Compile form and create dof map
-            (compiled_form, module, form_data) = _jit(form)
+            (compiled_form, module, form_data) = jit(form)
             self.dof_maps = dolfin.DofMapSet(compiled_form, mesh)
             # Initialize FFC and DOLFIN Function
             ffc.Function.__init__(self, element)