1
"Quadrature representation class for UFL"
3
# Copyright (C) 2009-2014 Kristian B. Oelgaard
5
# This file is part of FFC.
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.
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.
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/>.
20
# Modified by Anders Logg 2009, 2014
21
# Modified by Martin Alnaes 2013-2014
24
from ffc.log import warning
26
def parse_optimise_parameters(parameters, itg_data):
28
# Initialize parameters
29
optimise_parameters = {"eliminate zeros": False,
30
"optimisation": False,
32
"remove zero terms": False,
33
"ignore zero tables": False}
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
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
47
if "eliminate_zeros" in parameters:
48
optimise_parameters["eliminate zeros"] = True
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'.
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"
65
return optimise_parameters