Skip to content

Commit

Permalink
Group integrals by estimated_quadrature_degree
Browse files Browse the repository at this point in the history
  • Loading branch information
pbrubeck committed Jan 22, 2025
1 parent 83609f8 commit 909326f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
13 changes: 6 additions & 7 deletions ufl/algorithms/compute_form_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ def attach_estimated_degrees(form):
A new Form with estimate degrees attached.
"""
integrals = form.integrals()

new_integrals = []
for integral in integrals:
md = {}
Expand Down Expand Up @@ -278,6 +277,12 @@ def compute_form_data(

form = preprocess_form(form, complex_mode)

# Estimate polynomial degree of integrands now, before applying
# any pullbacks and geometric lowering. Otherwise quad degrees
# blow up horrifically.
if do_estimate_degrees:
form = attach_estimated_degrees(form)

# --- Group form integrals
# TODO: Refactor this, it's rather opaque what this does
# TODO: Is self.original_form.ufl_domains() right here?
Expand All @@ -288,12 +293,6 @@ def compute_form_data(
do_append_everywhere_integrals=do_append_everywhere_integrals,
)

# Estimate polynomial degree of integrands now, before applying
# any pullbacks and geometric lowering. Otherwise quad degrees
# blow up horrifically.
if do_estimate_degrees:
form = attach_estimated_degrees(form)

if do_apply_function_pullbacks:
# Rewrite coefficients and arguments in terms of their
# reference cell values with Piola transforms and symmetry
Expand Down
6 changes: 5 additions & 1 deletion ufl/algorithms/domain_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,11 @@ def calc_hash(cd):
for integral in integrals:
integral_type = integral.integral_type()
ufl_domain = integral.ufl_domain()
metadata = integral.metadata()
metadata = dict(integral.metadata())
# Group integrals only by quadrature_degree if it is available.
# Otherwise, group them by estimated_quadrature_degree.
if "quadrature_degree" in metadata:
metadata.pop("estimated_quadrature_degree", None)
meta_hash = hash(canonicalize_metadata(metadata))
subdomain_id = integral.subdomain_id()
subdomain_data = id_or_none(integral.subdomain_data())
Expand Down

0 comments on commit 909326f

Please sign in to comment.