Add Ferrite.jl code examples - #574
Merged
Merged
Conversation
Add Ferrite.jl (https://github.com/Ferrite-FEM/Ferrite.jl) to the list of implementations, with Julia code snippets for creating each supported interpolation. New implementation class (defelement/implementations/ferrite.py): - Snippets construct interpolations as `Name{RefShape, order}()`, with DefElement cell names mapped to Ferrite reference shapes (e.g. interval -> RefLine). Vectorized interpolations use the `^vdim` syntax via a `vdim` parameter in the .def files. - Since Ferrite is not on PyPI, version() resolves the latest release from the Versions.toml registry file of Julia's General registry. Julia language support: - New Julia entry in defelement/languages.py. webtools has no Julia highlighter and the snippets are short, so a minimal local formatter highlights comments only (same color webtools uses). - Use "#" as the comment prefix for Julia example headers in defelement/implementations/core.py. Elements covered (all interpolations in Ferrite v1.6.0), with DEGREES restrictions matching the orders implemented in Ferrite: - Lagrange and discontinuous Lagrange (equispaced variant) on all seven reference cells - Crouzeix-Raviart (CrouzeixRaviart on simplices, RannacherTurek on quadrilateral/hexahedron) - bubble enriched Lagrange (triangle) - serendipity (Serendipity, degree 2 on quadrilateral/hexahedron) - Raviart-Thomas and Nedelec first kind (Lagrange variant, with DEGREEMAP=k+1 since Ferrite's lowest order is 1 where DefElement's degree is 0) - Brezzi-Douglas-Marini (Lagrange variant, triangle degree 1) - vector Lagrange, vector Q and vector bubble enriched Lagrange via VectorizedInterpolation (`ip^vdim`) Note on serendipity: Ferrite uses point evaluations at edge midpoints (classical Q8/Q20) where DefElement defines the edge DOFs as integral moments, giving a different basis for the same space. This is flagged with an implementation note on the element page. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
mscroggs
self-requested a review
August 6, 2026 15:21
mscroggs
approved these changes
Aug 6, 2026
Comment on lines
+11
to
+30
| def julia_highlight(code: str) -> str: | ||
| """Highlight comments in a Julia snippet and convert it to HTML. | ||
|
|
||
| webtools does not provide a Julia highlighter. The snippets are short enough that | ||
| keyword highlighting adds little, so only comments are highlighted, using the same | ||
| color that webtools uses. | ||
|
|
||
| Args: | ||
| code: Julia snippet | ||
|
|
||
| Returns: | ||
| Snippet with comments highlighted | ||
| """ | ||
| out = [] | ||
| for line in code.replace(" ", " ").split("\n"): | ||
| if "#" in line: | ||
| line, comment = line.split("#", 1) | ||
| line += f"<span style='color:#FF8800'>#{comment}</span>" | ||
| out.append(line) | ||
| return "<br />".join(out) |
Member
There was a problem hiding this comment.
This should at some point be moved to webtools, but that can be done after this is merged. Issue for this: DefElement/website-build-tools#41
Contributor
Author
|
Thanks! Looks like CI choked on main (GitHub issue most likely) so this never deployed (https://github.com/DefElement/DefElement/actions/runs/31116625753/job/92668950854). |
Member
Definitely a GitHub issue as different jobs failed on my first rerun. Hopefully enough time has passed now that the current rerun will succeed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add Ferrite.jl (https://github.com/Ferrite-FEM/Ferrite.jl) to the list of implementations, with Julia code snippets for creating each supported interpolation.
New implementation class (defelement/implementations/ferrite.py):
Name{RefShape, order}(), with DefElement cell names mapped to Ferrite reference shapes (e.g. interval -> RefLine). Vectorized interpolations use the^vdimsyntax via avdimparameter in the .def files.Julia language support:
Elements covered (all interpolations in Ferrite v1.6.0), with DEGREES restrictions matching the orders implemented in Ferrite:
ip^vdim)Note on serendipity: Ferrite uses point evaluations at edge midpoints (classical Q8/Q20) where DefElement defines the edge DOFs as integral moments, giving a different basis for the same space. This is flagged with an implementation note on the element page.
Generated by 🤖 and reviewed by me.