Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add demo for interpolating expressions #463

Merged
merged 4 commits into from
Feb 22, 2022
Merged

Conversation

jorgensd
Copy link
Sponsor Member

Superseding #453, using basix to obtain interpolation/quadrature points to generate integration kernels for various expressions that can be used for interpolation in C++.

demo/test_demos.py Outdated Show resolved Hide resolved
Copy link
Contributor

@michalhabera michalhabera left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, I think you can remove GradExpression.py demo. This demo is superset of it, we need to keep demos low, too many already.

@michalhabera michalhabera merged commit 36bb041 into main Feb 22, 2022
@michalhabera michalhabera deleted the dokken/expression-demo branch February 22, 2022 12:31
Copy link
Member

@garth-wells garth-wells left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

I found readability a little challenging in parts. I've left some suggestions to reduce the number of variables and to change some names.

@@ -0,0 +1,63 @@
# Copyright (C) 2022 Jørgen S. Dokken
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the short SPDX license header.


# Define mesh
cell = triangle
v_el = VectorElement("Lagrange", cell, 1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest reducing the number of variables to improve readabilty, e.g.

mesh = Mesh(VectorElement("Lagrange", cell, 1))

# Define mixed function space
el = FiniteElement("CG", cell, 2)
el_int = VectorElement("Discontinuous Lagrange", cell, 1)
me = MixedElement([el, el_int])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

element = MixedElement([FiniteElement("Lagrange", cell, 2), VectorElement("Discontinuous Lagrange", cell, 1)])

b_cell = basix.cell.string_to_type(cell.cellname())

# Find quadrature points for quadrature element
b_rule = basix.quadrature.string_to_type(q_rule)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can q_rule and q_degree be gotten directly from q_el?


# Get interpolation points for output space
family = basix.finite_element.string_to_family("Lagrange", cell.cellname())
b_element = basix.create_element(family, b_cell, 4, basix.LagrangeVariant.gll_warped, True)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the parameter 4?

# Get interpolation points for output space
family = basix.finite_element.string_to_family("Lagrange", cell.cellname())
b_element = basix.create_element(family, b_cell, 4, basix.LagrangeVariant.gll_warped, True)
interpolation_points = b_element.points
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

X = b_element.points

@michalhabera michalhabera restored the dokken/expression-demo branch February 22, 2022 12:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants