[GSOC 2025] 3D FEM
Description
This PR will add a support for 3D FEM, 3D meshing along with a mesh generator with support for prismatic and cylindrical geometry
Fixes # (issue)
Type of change
Please add a line in the relevant section of CHANGELOG.md to document the change (include PR #)
Important checks:
Please confirm the following before marking the PR as ready for review:
- [x] No style issues:
nox -s pre-commit - [x] All tests pass:
nox -s tests - [x] The documentation builds:
nox -s doctests - [x] Code is commented for hard-to-understand areas
- [x] Tests added that prove fix is effective or that feature works
I am facing few issue with BCs, few tests are failing mostly due to shape mismatches, I saw @aabills was implementing 2D FVM, I was following his pattern. So it would be great if Alec can have a look at this PR specifically around ghost nodes and neumann values and shift. And overall too if you can review the PR to see if there is any potential issues present due to which tests are failing.
Hey Rishab, yeah Ghost nodes are a real pain. Let me wrap mine up this week and I'll get back to you ASAP
thanks @aabills, in meantime I'll try to fix these errors myself.
@rtimms @aabills , I changed my approach, I realised to solve complex unstructured tetrahedra geometries we need FEM method not FVM, just wanted some confirmation on this, is this right? Can you please re review the PR since the whole method is changed.
Still spiral and cylindrical tests fail, can you have a look at it and check whether its because of the mesh quality or something else
FEM is complete seems to work with boxes and with simple equations with cylinder too.
The spiral tests give large innacurate values I tested everything, the problem was zero volume tets were there, I removed them, then added random jitters made it coarser etc etc, mesh is still full of silver poor quality tets, turns out for complex geometry like spiral and even for accuracy and solving complex equations in cylinder too we need a real tetrahedral mesher like pygmsh, pygalmesh all of which have licensing issues, tetgen has AGPL-3.0 license maybe can use that.
So the finite element works perfectly with boxes, cylinder too for simple equations and spiral is very innacurate, needed some suggestions on this on how to move forward with this PR.
I've removed spiral added heat diffusion examples everything seems to be working now, would love to get some feedback on this
Codecov Report
:x: Patch coverage is 99.26650% with 3 lines in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 99.10%. Comparing base (abaf83a) to head (ec23a96).
:warning: Report is 144 commits behind head on develop.
| Files with missing lines | Patch % | Lines |
|---|---|---|
| ...pybamm/spatial_methods/scikit_finite_element_3d.py | 98.70% | 3 Missing :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## develop #5009 +/- ##
=========================================
Coverage 99.09% 99.10%
=========================================
Files 307 309 +2
Lines 23708 24116 +408
=========================================
+ Hits 23494 23900 +406
- Misses 214 216 +2
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
@rtimms, I've addressed your reviews, can you please re-review it again?
@rtimms I've addressed all the reviews can you re-review it again?
@rtimms I've addressed all reviews, can you please re-review it again?
@Rishab87 thanks for addressing all the comments, looks great! @aabills I'd appreciate a second pair of eyes on this before merging, since you've been working on higher-dimensional models too
@aabills any updates on this?