Skip to content

Commit

Permalink
Update existing tables (#418)
Browse files Browse the repository at this point in the history
* update existing tables

* do add "zero" table to existing tables

* fix flake8

* Update local existing tables copy in terminals loop

Co-authored-by: Michal Habera <michal.habera@gmail.com>
  • Loading branch information
IgorBaratta and michalhabera committed Nov 13, 2021
1 parent 4d3b540 commit f3f6a93
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions ffcx/ir/elementtables.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,9 @@ def permute_quadrature_quadrilateral(points, reflections=0, rotations=0):
return output


def build_optimized_tables(
quadrature_rule, cell, integral_type, entitytype, modified_terminals, existing_tables,
rtol=default_rtol, atol=default_atol
):
def build_optimized_tables(quadrature_rule, cell, integral_type, entitytype,
modified_terminals, existing_tables,
rtol=default_rtol, atol=default_atol):
"""Build the element tables needed for a list of modified terminals.
Input:
Expand All @@ -285,9 +284,10 @@ def build_optimized_tables(
unique_elements = ufl.algorithms.sort_elements(
ufl.algorithms.analysis.extract_sub_elements(all_elements))
element_numbers = {element: i for i, element in enumerate(unique_elements)}

mt_tables = {}

_existing_tables = existing_tables.copy()

for mt in modified_terminals:
res = analysis.get(mt)
if not res:
Expand Down Expand Up @@ -351,6 +351,7 @@ def build_optimized_tables(
# Clean up table
tbl = clamp_table_small_numbers(t['array'], rtol=rtol, atol=atol)
tabletype = analyse_table_type(tbl)

if tabletype in piecewise_ttypes:
# Reduce table to dimension 1 along num_points axis in generated code
tbl = tbl[:, :, :1, :]
Expand All @@ -363,12 +364,17 @@ def build_optimized_tables(
tbl = tbl[:1, :, :, :]

# Check for existing identical table
for table_name in existing_tables:
if equal_tables(tbl, existing_tables[table_name]):
new_table = True
for table_name in _existing_tables:
if equal_tables(tbl, _existing_tables[table_name]):
name = table_name
tbl = existing_tables[name]
tbl = _existing_tables[name]
new_table = False
break

if new_table:
_existing_tables[name] = tbl

cell_offset = 0
basix_element = create_element(element)

Expand Down

0 comments on commit f3f6a93

Please sign in to comment.