On 30 January 2010 20:20, <[email protected]> wrote:
------------------------------------------------------------ revno: 1602 committer: Anders Logg <[email protected]> branch nick: ffc-dev timestamp: Sat 2010-01-30 20:17:52 +0100 message: Some comments, cleanups and added option -f convert_exceptions_to_warnings
I like the long name, it will discourage people to use it :) Kristian
modified: ffc/codegeneration.py ffc/constants.py ffc/cpp.py ffc/evaluatebasis.py ffc/evaluatebasisderivatives.py ffc/fiatinterface.py ffc/interpolatevertexvalues.py ffc/quadratureelement.py test/regression/test.py -- lp:~ffc-core/ffc/dev https://code.launchpad.net/~ffc-core/ffc/dev You are subscribed to branch lp:~ffc-core/ffc/dev. To unsubscribe from this branch go to https://code.launchpad.net/~ffc-core/ffc/dev/+edit-subscription. === modified file 'ffc/codegeneration.py' --- ffc/codegeneration.py 2010-01-28 17:27:57 +0000 +++ ffc/codegeneration.py 2010-01-30 19:17:52 +0000 @@ -11,11 +11,12 @@ __copyright__ = "Copyright (C) 2009 " + __author__ __license__ = "GNU GPL version 3 or any later version" -# Last changed: 2010-01-28 +# Last changed: 2010-01-30 # FFC modules from ffc.log import info, begin, end, debug_code -from ffc.cpp import format, indent, set_float_formatting +from ffc.cpp import format, indent +from ffc.cpp import set_float_formatting, set_exception_handling # FFC code generation modules from ffc.evaluatebasis import _evaluate_basis, _evaluate_basis_all @@ -35,8 +36,12 @@ begin("Compiler stage 4: Generating code") - # Set floating point format - set_float_formatting(options) + # FIXME: Document option -fconvert_exceptions_to_warnings + # FIXME: Remove option epsilon and just rely on precision? + + # Set code generation options + set_float_formatting(int(options["precision"])) + set_exception_handling(options["convert_exceptions_to_warnings"]) # Extract representations ir_elements, ir_dofmaps, ir_integrals, ir_forms = ir === modified file 'ffc/constants.py' --- ffc/constants.py 2010-01-21 20:56:39 +0000 +++ ffc/constants.py 2010-01-30 19:17:52 +0000 @@ -4,26 +4,26 @@ __license__ = "GNU GPL version 3 or any later version" # Modified by Kristian B. Oelgaard, 2009 -# Last changed: 2010-01-21 +# Last changed: 2010-01-30 from log import INFO FFC_VERSION = "0.7.1" -FFC_OPTIONS = {"format": "ufc", # code generation format - "representation": "auto", # form representation / code generation strategy - "quadrature_rule": "auto", # quadrature rule used for integration of element tensors - "quadrature_degree": "auto", # quadrature degree used for computing integrals - "precision": "15", # precision used when writing numbers - "split": False, # split generated code into .h and .cpp file - "form_postfix": True, # postfix form name with "Function", "LinearForm" or BilinearForm - "cache_dir": None, # cache dir used by Instant - "output_dir": ".", # output directory for generated code - "cpp optimize": False, # optimization for the JIT compiler - "optimize": False, # optimise the quadrature code generation - "log_level": INFO, # log level, displaying only messages with level >= log_level - "log_prefix": "", # log prefix - "epsilon": 1e-14} # machine precision, used for dropping zero terms +FFC_OPTIONS = {"format": "ufc", # code generation format + "representation": "auto", # form representation / code generation strategy + "quadrature_rule": "auto", # quadrature rule used for integration of element tensors + "quadrature_degree": "auto", # quadrature degree used for computing integrals + "precision": "15", # precision used when writing numbers + "split": False, # split generated code into .h and .cpp file + "form_postfix": True, # postfix form name with "Function", "LinearForm" or BilinearForm + "cache_dir": None, # cache dir used by Instant + "output_dir": ".", # output directory for generated code + "cpp optimize": False, # optimization for the JIT compiler + "optimize": False, # optimise the quadrature code generation + "log_level": INFO, # log level, displaying only messages with level >= log_level + "log_prefix": "", # log prefix + "epsilon": 1e-14, # machine precision, used for dropping zero terms + "convert_exceptions_to_warnings": False} # convert all exceptions to warning in generated code -# FIXME: Change to 1.2 when we support UFC 1.2 -UFC_VERSION = "1.0" +UFC_VERSION = "1.2" === modified file 'ffc/cpp.py' --- ffc/cpp.py 2010-01-29 23:21:06 +0000 +++ ffc/cpp.py 2010-01-30 19:17:52 +0000 @@ -811,13 +811,8 @@ error("Unsupported domain_type: %s" % str(domain_type)) return code - - -def set_float_formatting(options): - "Set floating point formatting based on options." - - # Get number of digits - precision = int(options["precision"]) +def set_float_formatting(precision): + "Set floating point formatting based on precision." # Options for float formatting f1 = "%%.%df" % precision @@ -845,3 +840,8 @@ # Set machine precision format["epsilon"] = 10.0*eval("1e-%s" % precision) + +def set_exception_handling(convert_exceptions_to_warnings): + "Set handling of exceptions." + if convert_exceptions_to_warnings: + format["exception"] = format["warning"] === modified file 'ffc/evaluatebasis.py' --- ffc/evaluatebasis.py 2010-01-30 14:21:36 +0000 +++ ffc/evaluatebasis.py 2010-01-30 19:17:52 +0000 @@ -29,9 +29,9 @@ """Like evaluate_basis, but return the values of all basis functions (dofs).""" if isinstance(data_list, str): - return format["warning"]("evaluate_basis_all: %s" % data_list) + return format["exception"]("evaluate_basis_all: %s" % data_list) - format_r, format_s = format["free indices"][:2] + format_r, format_s = format["free indices"][:2] format_assign = format["assign"] # Initialise objects @@ -109,7 +109,7 @@ untested for tensor valued element.""" if isinstance(data_list, str): - return format["warning"]("evaluate_basis: %s" % data_list) + return format["exception"]("evaluate_basis: %s" % data_list) # Init return code and indent object code = [] === modified file 'ffc/evaluatebasisderivatives.py' --- ffc/evaluatebasisderivatives.py 2010-01-29 23:18:30 +0000 +++ ffc/evaluatebasisderivatives.py 2010-01-30 19:17:52 +0000 @@ -30,7 +30,7 @@ """Like evaluate_basis, but return the values of all basis functions (dofs).""" if isinstance(data_list, str): - return format["warning"]("evaluate_basis_derivatives_all: %s" % data_list) + return format["exception"]("evaluate_basis_derivatives_all: %s" % data_list) format_r, format_s = format["free indices"][:2] format_assign = format["assign"] @@ -126,7 +126,7 @@ Nedelec (broken?)""" if isinstance(data_list, str): - return format["warning"]("evaluate_basis_derivatives: %s" % data_list) + return format["exception"]("evaluate_basis_derivatives: %s" % data_list) # Init return code and indent object code = [] === modified file 'ffc/fiatinterface.py' --- ffc/fiatinterface.py 2010-01-30 17:59:11 +0000 +++ ffc/fiatinterface.py 2010-01-30 19:17:52 +0000 @@ -28,6 +28,8 @@ # instead? The same goes for similar dictionaries in UFL (geometry.py). After # all both FFC and UFL complies with UFC or not? # Mapping from domain to dimension +# FIXME: AL: They should be in UFL (and probably are there already). They +# FIXME: can't be in UFC since UFL cannot depend on UFC. domain2dim = {"vertex": 0, "interval": 1, "triangle": 2, @@ -49,16 +51,18 @@ debug("Reusing element from cache") return _cache[ufl_element] - # Initialize element based on type + # Create regular FIAT finite element if isinstance(ufl_element, ufl.FiniteElement): - element = create_fiat_element(ufl_element) + element = _create_fiat_element(ufl_element) + # Create mixed element (implemented by FFC) elif isinstance(ufl_element, ufl.MixedElement): elements = _extract_elements(ufl_element) element = MixedElement(elements) + # Create restricted element(implemented by FFC) elif isinstance(ufl_element, ufl.ElementRestriction): - element = create_restricted_element(ufl_element) + element = _create_restricted_element(ufl_element) else: error("Cannot handle this element type: %s" % str(ufl_element)) @@ -68,13 +72,16 @@ return element -def create_fiat_element(ufl_element): +def _create_fiat_element(ufl_element): "Create FIAT element corresponding to given finite element." family = ufl_element.family() - # Handle QuadrtureElement + + # FIXME: AL: Should this really be here? + # Handle QuadratureElement if family == "Quadrature": return FFCQuadratureElement(ufl_element) + # Check if finite element family is supported by FIAT elif not family in FIAT.element_classes: error("Sorry, finite element of type \"%s\" are not supported by FIAT.", family) @@ -129,8 +136,6 @@ return new_points - -# -- Extract elements from UFL mixed element def _extract_elements(ufl_element, domain=None): "Recursively extract un-nested list of (component) elements." @@ -146,9 +151,7 @@ elements += [create_element(ufl_element)] return elements - -# -- Restricted element initializer functions -def create_restricted_element(ufl_element): +def _create_restricted_element(ufl_element): "Create an FFC representation for an UFL ElementRestriction." if not isinstance(ufl_element, ufl.ElementRestriction): @@ -159,7 +162,7 @@ # If simple element -> create RestrictedElement from fiat_element if isinstance(base_element, ufl.FiniteElement): - element = create_fiat_element(base_element) + element = _create_fiat_element(base_element) return RestrictedElement(element, _indices(element, domain)) # If restricted mixed element -> convert to mixed restricted element @@ -180,4 +183,3 @@ for (entity, index) in entities.iteritems(): indices += index return indices - === modified file 'ffc/interpolatevertexvalues.py' --- ffc/interpolatevertexvalues.py 2010-01-29 23:18:30 +0000 +++ ffc/interpolatevertexvalues.py 2010-01-30 19:17:52 +0000 @@ -25,7 +25,7 @@ # Handle unsupported elements. if isinstance(ir, str): - return format["warning"]("interpolate_vertex_values: %s" % ir) + return format["exception"]("interpolate_vertex_values: %s" % ir) # Add code for Jacobian if necessary code = [] === modified file 'ffc/quadratureelement.py' --- ffc/quadratureelement.py 2010-01-29 15:02:09 +0000 +++ ffc/quadratureelement.py 2010-01-30 19:17:52 +0000 @@ -4,7 +4,7 @@ __license__ = "GNU GPL version 3 or any later version" # Modified by Garth N. Wells 2006-2009 -# Last changed: 2010-01-29 +# Last changed: 2010-01-30 # Python modules. import numpy @@ -121,4 +121,3 @@ # FFC modules to avoid circular import from ffc.fiatinterface import create_quadrature, reference_cell - === modified file 'test/regression/test.py' --- test/regression/test.py 2010-01-29 17:33:27 +0000 +++ test/regression/test.py 2010-01-30 19:17:52 +0000 @@ -96,7 +96,7 @@ for f in form_files: # Generate code - ok = run_command("ffc -d %s" % f) + ok = run_command("ffc -d -fconvert_exceptions_to_warnings %s" % f) # Check status if ok:
signature.asc
Description: OpenPGP digital signature
_______________________________________________ Mailing list: https://launchpad.net/~ffc Post to : [email protected] Unsubscribe : https://launchpad.net/~ffc More help : https://help.launchpad.net/ListHelp

