← Back to team overview

ufl team mailing list archive

[noreply@xxxxxxxxxxxxx: [Branch ~ufl-core/ufl/main] Rev 1145: Made Form.*_domains into properties which emit]

 

I thought this was already fixed in DOLFIN.

--
Anders
--- Begin Message ---
------------------------------------------------------------
revno: 1145
committer: Martin Alnes <martinal@xxxxxxxxx>
branch nick: work
timestamp: Wed 2011-06-22 19:10:37 +0200
message:
  Made Form.*_domains into properties which emit
  a deprecation warning when they are set.
  
  We should get all pydolfin code over to use
  the dx[boundaries] syntax before 1.0 to avoid
  the bugs Form.*_domains make possible.
  
  Also did some docstring updates
modified:
  ufl/form.py


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

Your team UFL Core Team is subscribed to branch lp:ufl.
To unsubscribe from this branch go to https://code.launchpad.net/~ufl-core/ufl/main/+edit-subscription
=== modified file 'ufl/form.py'
--- ufl/form.py	2011-06-21 12:44:19 +0000
+++ ufl/form.py	2011-06-22 17:10:37 +0000
@@ -34,27 +34,49 @@
 class Form(object):
     """Description of a weak form consisting of a sum of integrals over subdomains."""
     __slots__ = ("_integrals",
-                 "_repr", "_hash", "_str", "_form_data", "_is_preprocessed",
-                 "cell_domains", "exterior_facet_domains", "interior_facet_domains")
-
-    # Note: cell_domains, exterior_facet_domains and interior_facet_domains
-    # are used by DOLFIN to pass data to the assembler. They can otherwise
-    # safely be ignored.
+                 "_repr", "_hash", "_str",
+                 "_form_data", "_is_preprocessed",
+                 "_cell_domains", "_exterior_facet_domains", "_interior_facet_domains")
 
     def __init__(self, integrals):
         self._integrals = tuple(integrals)
-        ufl_assert(all(isinstance(itg, Integral) for itg in integrals), "Expecting list of integrals.")
+        ufl_assert(all(isinstance(itg, Integral) for itg in integrals),
+                   "Expecting list of integrals.")
         self._str = None
         self._repr = None
         self._hash = None
         self._form_data = None
         self._is_preprocessed = False
 
-        # TODO: Can we attach non-ufl payloads in a more generic fashion?
-        # This seems prone to change with dolfin versions.
-        self.cell_domains = None
-        self.exterior_facet_domains = None
-        self.interior_facet_domains = None
+        # Note: cell_domains, exterior_facet_domains and interior_facet_domains
+        # are used by DOLFIN to pass data to the assembler. They are deprecated
+        # because they lead to bugs and will be removed.
+        self._cell_domains = None
+        self._exterior_facet_domains = None
+        self._interior_facet_domains = None
+
+    # TODO: Remove these completely!
+    @property
+    def cell_domains(self):
+        return self._cell_domains
+    @cell_domains.setter
+    def _set_cell_domains(self, domains):
+        warning("Deprecation warning! Attach your boundary indicators to the measure instead.")
+        self._cell_domains = domains
+    @property
+    def exterior_facet_domains(self):
+        return self._exterior_facet_domains
+    @exterior_facet_domains.setter
+    def _set_exterior_facet_domains(self, domains):
+        warning("Deprecation warning! Attach your boundary indicators to the measure instead.")
+        self._exterior_facet_domains = domains
+    @property
+    def interior_facet_domains(self):
+        return self._interior_facet_domains
+    @interior_facet_domains.setter
+    def _set_interior_facet_domains(self, domains):
+        warning("Deprecation warning! Attach your boundary indicators to the measure instead.")
+        self._interior_facet_domains = domains
 
     def cell(self):
         c = None
@@ -168,19 +190,25 @@
         return Form(newintegrals)
 
     def __sub__(self, other):
+        "Subtract other form from this one."
         return self + (-other)
 
     def __neg__(self):
-        # This enables the handy "-form" syntax for e.g. the linearized system (J, -F) from a nonlinear form F
+        """Negate all integrals in form.
+        
+        This enables the handy "-form" syntax for e.g. the
+        linearized system (J, -F) from a nonlinear form F."""
         return Form([-itg for itg in self._integrals])
 
     def __rmul__(self, scalar):
+        "Multiply all integrals in form with constant scalar value."
         # This enables the handy "0*form" syntax
-        ufl_assert(is_python_scalar(scalar), "Only multiplication by scalar literals currently supported.")
+        ufl_assert(is_python_scalar(scalar),
+                   "Only multiplication by scalar expressions currently supported.")
         return Form([scalar*itg for itg in self._integrals])
 
     def __mul__(self, coefficient):
-        "The action of this form on the given coefficient."
+        "UFL form operator: Take the action of this form on the given coefficient."
         from ufl.formoperators import action
         return action(self, coefficient)
 


--- End Message ---

Follow ups