~ubuntu-branches/ubuntu/vivid/ffc/vivid

« back to all changes in this revision

Viewing changes to ffc/quadrature/parameters.py

  • Committer: Package Import Robot
  • Author(s): Johannes Ring
  • Date: 2014-06-03 18:26:02 UTC
  • mfrom: (1.1.15)
  • Revision ID: package-import@ubuntu.com-20140603182602-zvnubjjh7i78e1v0
Tags: 1.4.0-1
* New upstream release.
* debian/control:
  - Add swig in Build-Depends.
  - Remove python-ufc from Depends.
  - Add ufc and python-ufc to Provides, Conflicts and Replaces.
  - Remove python-ferari and python-dolfin from Suggests.
  - Bump minimum required version for python-fiat, python-instant and
    python-ufl to 1.4.0.
* debian/rules: Add override for auto clean target to remove generated
  cmake and pkg-config files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
"Quadrature representation class for UFL"
 
2
 
 
3
# Copyright (C) 2009-2014 Kristian B. Oelgaard
 
4
#
 
5
# This file is part of FFC.
 
6
#
 
7
# FFC is free software: you can redistribute it and/or modify
 
8
# it under the terms of the GNU Lesser General Public License as published by
 
9
# the Free Software Foundation, either version 3 of the License, or
 
10
# (at your option) any later version.
 
11
#
 
12
# FFC is distributed in the hope that it will be useful,
 
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 
15
# GNU Lesser General Public License for more details.
 
16
#
 
17
# You should have received a copy of the GNU Lesser General Public License
 
18
# along with FFC. If not, see <http://www.gnu.org/licenses/>.
 
19
#
 
20
# Modified by Anders Logg 2009, 2014
 
21
# Modified by Martin Alnaes 2013-2014
 
22
 
 
23
# FFC modules
 
24
from ffc.log import warning
 
25
 
 
26
def parse_optimise_parameters(parameters, itg_data):
 
27
 
 
28
    # Initialize parameters
 
29
    optimise_parameters = {"eliminate zeros":     False,
 
30
                           "optimisation":        False,
 
31
                           "ignore ones":         False,
 
32
                           "remove zero terms":   False,
 
33
                           "ignore zero tables":  False}
 
34
 
 
35
 
 
36
    # Set optimized parameters
 
37
    if parameters["optimize"] and itg_data.integral_type == "custom":
 
38
        warning("Optimization not available for custom integrals, skipping optimization.")
 
39
    elif parameters["optimize"]:
 
40
        optimise_parameters["ignore ones"]        = True
 
41
        optimise_parameters["remove zero terms"]  = True
 
42
        optimise_parameters["ignore zero tables"] = True
 
43
 
 
44
        # Do not include this in below if/else clause since we want to be
 
45
        # able to switch on this optimisation in addition to the other
 
46
        # optimisations.
 
47
        if "eliminate_zeros" in parameters:
 
48
            optimise_parameters["eliminate zeros"] = True
 
49
 
 
50
        if "simplify_expressions" in parameters:
 
51
            optimise_parameters["optimisation"] = "simplify_expressions"
 
52
        elif "precompute_ip_const" in parameters:
 
53
            optimise_parameters["optimisation"] = "precompute_ip_const"
 
54
        elif "precompute_basis_const" in parameters:
 
55
            optimise_parameters["optimisation"] = "precompute_basis_const"
 
56
        # The current default optimisation (for -O) is equal to
 
57
        # '-feliminate_zeros -fsimplify_expressions'.
 
58
        else:
 
59
            # If '-O -feliminate_zeros' was given on the command line, do not
 
60
            # simplify expressions
 
61
            if not "eliminate_zeros" in parameters:
 
62
                optimise_parameters["eliminate zeros"] = True
 
63
                optimise_parameters["optimisation"]    = "simplify_expressions"
 
64
 
 
65
    return optimise_parameters