~massing/ufl/1.0.x-interface

« back to all changes in this revision

Viewing changes to ufl/algorithms/formdata.py

  • Committer: Martin Sandve Alnæs
  • Date: 2011-12-06 12:38:18 UTC
  • Revision ID: martinal@simula.no-20111206123818-7w2rn2i5t2j77nvu
Add checks for mismatch between compute_form_data arguments and previously cached form data. Throwing errors which are a bit more informative instead of causing failures in arbitrary places otherwise in code.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
# Modified by Anders Logg, 2008.
21
21
#
22
22
# First added:  2008-09-13
23
 
# Last changed: 2011-06-02
 
23
# Last changed: 2011-12-06
24
24
 
25
25
from ufl.common import lstr, tstr, estr
 
26
from ufl.assertions import ufl_assert
26
27
 
27
28
class FormData(object):
28
29
    """
53
54
                     ("Coefficient names",                  lstr(self.coefficient_names)),
54
55
                     ("Unique elements",                    estr(self.unique_elements)),
55
56
                     ("Unique sub elements",                estr(self.unique_sub_elements))))
 
57
 
 
58
    def validate(self, object_names=None, common_cell=None, element_mapping=None):
 
59
        object_names = object_names or {}
 
60
        element_mapping = element_mapping or {}
 
61
        ufl_assert(object_names == self._input_object_names,
 
62
                   "Found non-matching object_names in form data validation.")
 
63
        ufl_assert(common_cell is None or common_cell == self.cell,
 
64
                   "Found non-matching cells in form data validation.")
 
65
        ufl_assert(element_mapping == self._input_element_mapping,
 
66
                   "Found non-matching element mappings in form data validation.")
 
67