16
16
# along with FFC. If not, see <http://www.gnu.org/licenses/>.
18
18
# First added: 2010-01-25
19
# Last changed: 2010-01-25
19
# Last changed: 2014-04-15
22
22
from ffc.log import debug
28
28
def estimate_cost(integral, function_replace_map):
30
Estimate cost of tensor representation for integrand. The cost is
30
Estimate cost of tensor representation for integral. The cost is
31
31
computed as the sum of the number of coefficients and derivatives,
32
32
if the integrand can be represented as a monomial, and -1 if not.
35
# TODO: Implement this to take integrand instead of integral? May allow simplification inn caller code.
35
# Check that integral type is supported
36
supported = ["cell", "exterior_facet", "interior_facet"]
37
if not integral.integral_type() in supported:
37
40
# Extract monomial integrand
41
integrand = integral.integrand()
39
monomial_form = extract_monomial_form([integral], function_replace_map)
43
monomial_form = extract_monomial_form([integrand], function_replace_map)
40
44
transform_monomial_form(monomial_form)
41
45
except Exception, exception:
42
46
debug("Monomial extraction failed: " + str(exception))
45
# Check that we get just one integral
46
if not len(monomial_form.integrals) == 1:
49
# Check that we get just one integrand
50
if not len(monomial_form) == 1:
47
51
error("Expecting just one integrand.")
50
(integrand, measure) = monomial_form.integrals[0]
52
for monomial in integrand.monomials:
53
cost = max(cost, len(monomial.coefficients) + len(monomial.transforms))
55
for integrand in monomial_form:
56
for monomial in integrand.monomials:
57
cost = max(cost, len(monomial.coefficients) + len(monomial.transforms))