Skip to content

Commit 61ea629

Browse files
authored
Update compute_form_data and FormData to use a proper class and remove cell and facet average from balance modifiers. (#469)
* Cell and facet averages is not terminal modifiers. * Move form data creation into form data * Mypy fixes ones typing has been activated * Fix typehint * Make some consistency across Integral and IntegralData * Fixes related to @schnellerhase's comments
1 parent f65a287 commit 61ea629

8 files changed

Lines changed: 499 additions & 386 deletions

File tree

ufl/algorithms/apply_restrictions.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from ufl.corealg.map_dag import map_expr_dag
2020
from ufl.corealg.multifunction import MultiFunction
2121
from ufl.domain import Mesh, extract_unique_domain
22+
from ufl.integral import Integral
2223
from ufl.sobolevspace import H1
2324

2425
default_restriction_map = {
@@ -291,7 +292,9 @@ def facet_normal(self, o):
291292
return self._require_restriction(o)
292293

293294

294-
def apply_restrictions(expression: Expr, default_restrictions: dict | None = None) -> Expr:
295+
def apply_restrictions(
296+
expression: Expr | Integral, default_restrictions: dict | None = None
297+
) -> Expr:
295298
"""Propagate restriction nodes to wrap differential terminals directly.
296299
297300
Args:

ufl/algorithms/balancing.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
# SPDX-License-Identifier: LGPL-3.0-or-later
88

99
from ufl.classes import (
10-
CellAvg,
11-
FacetAvg,
1210
Grad,
1311
Indexed,
1412
NegativeRestricted,
@@ -26,8 +24,6 @@
2624
ReferenceValue,
2725
ReferenceGrad,
2826
Grad,
29-
CellAvg,
30-
FacetAvg,
3127
PositiveRestricted,
3228
NegativeRestricted,
3329
Indexed,
@@ -40,7 +36,6 @@ def balance_modified_terminal(expr):
4036
"""Balance modified terminal."""
4137
# NB! Assuming e.g. grad(cell_avg(expr)) does not occur,
4238
# i.e. it is simplified to 0 immediately.
43-
4439
if expr._ufl_is_terminal_:
4540
return expr
4641

@@ -85,8 +80,6 @@ def _modifier(self, expr, *ops):
8580
reference_value = _modifier
8681
reference_grad = _modifier
8782
grad = _modifier
88-
cell_avg = _modifier
89-
facet_avg = _modifier
9083
positive_restricted = _modifier
9184
negative_restricted = _modifier
9285

0 commit comments

Comments
 (0)