Skip to content

Commit

Permalink
add symmetric to finite element (#684)
Browse files Browse the repository at this point in the history
  • Loading branch information
mscroggs authored and jhale committed Apr 24, 2024
1 parent be5736a commit 38260c0
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions ffcx/codegeneration/C/finite_element.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def generator(ir, options):
d["num_sub_elements"] = ir.num_sub_elements
d["block_size"] = ir.block_size
d["discontinuous"] = "true" if ir.discontinuous else "false"
d["symmetric"] = "true" if ir.symmetric else "false"

if ir.lagrange_variant is None:
d["lagrange_variant"] = -1
Expand Down
1 change: 1 addition & 0 deletions ffcx/codegeneration/C/finite_element_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
.reference_value_shape = {reference_value_shape},
.reference_value_size = {reference_value_size},
.degree = {degree},
.symmetric = {symmetric},
.block_size = {block_size},
.basix_family = {basix_family},
.basix_cell = {basix_cell},
Expand Down
3 changes: 3 additions & 0 deletions ffcx/codegeneration/ufcx.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ extern "C"
/// Maximum polynomial degree of the finite element function space
int degree;

/// Is the value a symmetric 2-tensor
bool symmetric;

/// Block size for a VectorElement. For a TensorElement, this is the
/// product of the tensor's dimensions
int block_size;
Expand Down
4 changes: 4 additions & 0 deletions ffcx/ir/representation.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ class ElementIR(typing.NamedTuple):
space_dimension: int
reference_value_shape: tuple[int, ...]
degree: int
symmetric: bool
num_sub_elements: int
block_size: int
sub_elements: list[str]
Expand Down Expand Up @@ -296,6 +297,9 @@ def _compute_element_ir(element, element_numbers, finite_element_names):
ir["basix_cell"] = element.cell_type
ir["discontinuous"] = element.discontinuous
ir["degree"] = element.degree
ir["symmetric"] = isinstance(element, basix.ufl._BlockedElement) and isinstance(
element._pullback, ufl.pullback.SymmetricPullback
)
ir["reference_value_shape"] = element.reference_value_shape

ir["num_sub_elements"] = element.num_sub_elements
Expand Down

0 comments on commit 38260c0

Please sign in to comment.