Subject: [Ffc] [[email-masked]: [Branch ~ffc-core/ffc/main] Rev 1450: Bug fixes for tabulate_tensor for Enriched Mixed elements.]

From: Anders Logg <[email-masked]>
Date: Tue, 23 Mar 2010 23:17:35 +0100

Great! But wasn't it tabulate_dofs that was broken?

--
Anders

Subject: [Branch ~ffc-core/ffc/main] Rev 1450: Bug fixes for tabulate_tensor for Enriched Mixed elements.
From: [email-masked]
To: Anders Logg <[email-masked]>
Date: Tue, 23 Mar 2010 22:14:16 -0000

------------------------------------------------------------
revno: 1450
committer: Marie E. Rognes <[email-masked]>
branch nick: ffc
timestamp: Tue 2010-03-23 23:08:17 +0100
message:
  Bug fixes for tabulate_tensor for Enriched Mixed elements.
modified:
  ffc/codegeneration.py
  ffc/representation.py

--
lp:ffc
https://code.launchpad.net/~ffc-core/ffc/main

Your team FFC Core Team is subscribed to branch lp:ffc.
To unsubscribe from this branch go to https://code.launchpad.net/~ffc-core/ffc/main/+edit-subscription.
=== modified file 'ffc/codegeneration.py'
--- ffc/codegeneration.py	2010-02-15 18:35:39 +0000
+++ ffc/codegeneration.py	2010-03-23 22:08:17 +0000
@@ -11,7 +11,7 @@
 __copyright__ = "Copyright (C) 2009 " + __author__
 __license__  = "GNU GPL version 3 or any later version"
 
-# Last changed: 2010-02-09
+# Last changed: 2010-03-23
 
 # FFC modules
 from ffc.log import info, begin, end, debug_code
@@ -264,10 +264,10 @@
     entity_index =        format["entity index"]
     num_entities_format = format["num entities"]
     unsigned_int =        format["uint declaration"]
-    dofs =                format["argument dofs"]
+    dofs_variable =       format["argument dofs"]
 
     # Extract representation
-    (num_dofs_per_element, num_entities, need_offset) = ir
+    (dofs_per_element, num_dofs_per_element, num_entities, need_offset) = ir
 
     # Declare offset if needed
     code = []
@@ -278,26 +278,28 @@
 
     # Generate code for each element
     i = 0
-    for num_dofs in num_dofs_per_element:
+    for (no, num_dofs) in enumerate(dofs_per_element):
 
         # Generate code for each degree of freedom for each dimension
         for (dim, num) in enumerate(num_dofs):
 
             # Ignore if no dofs for this dimension
-            if num == 0: continue
+            if not num[0]: continue
 
-            for k in range(num_entities[dim]):
-                v = multiply([num, component(entity_index, (dim, k))])
-                for j in range(num):
+            for (k, dofs) in enumerate(num):
+                v = multiply([len(num[k]), component(entity_index, (dim, k))])
+                for (j, dof) in enumerate(dofs):
                     value = add([offset_name, v, j])
-                    code.append(assign(component(dofs, i), value))
-                    i += 1
+                    code.append(assign(component(dofs_variable, dof+i), value))
 
             # Update offset corresponding to mesh entity:
             if need_offset:
-                addition = multiply([num, component(num_entities_format, dim)])
+                addition = multiply([len(num[0]),
+                                     component(num_entities_format, dim)])
                 code.append(iadd("offset", addition))
 
+        i += num_dofs_per_element[no]
+
     return "\n".join(code)
 
 def _tabulate_coordinates(ir):

=== modified file 'ffc/representation.py'
--- ffc/representation.py	2010-03-22 12:39:22 +0000
+++ ffc/representation.py	2010-03-23 22:08:17 +0000
@@ -311,12 +311,20 @@
     elements = all_elements(element)
     num_dofs_per_element = [_num_dofs_per_entity(e) for e in elements]
 
+    # Extract local dof numbers per entity for each element
+    all_entity_dofs = [e.entity_dofs() for e in elements]
+    dofs_per_element = [[[list(dofs[dim][entity])
+                          for entity in sorted(dofs[dim].keys())]
+                         for dim in sorted(dofs.keys())]
+                        for dofs in all_entity_dofs]
+
     # Check whether we need offset
     multiple_entities =  any([sum(n > 0 for n in num_dofs) - 1
                               for num_dofs in num_dofs_per_element])
     need_offset = len(elements) > 1 or multiple_entities
 
-    return (num_dofs_per_element, num_entities, need_offset)
+    num_dofs_per_element = [e.space_dimension() for e in elements]
+    return (dofs_per_element, num_dofs_per_element, num_entities, need_offset)

 def _tabulate_facet_dofs(element, cell):