PDE Toolbox extremely slow for cases with many boundaries

9 views (last 30 days)
We are writing some code using the PDE toolbox. Our domain is generated programmatically, and has many boundary edges. This is causing the PDE solver to execute extremely slowly. Based on the profiler, the issue is that the meshToPet function is being called for every boundary edge each iteration, even though the mesh boundaries never change.
Here is the output from top level of the profiler:
Top-level profiler
Here is the next level down showing how mshToPet is causing the slowdown.
The fix to pde3DBCImpl.generateBoundaryFacetData seems very simple. I can just call mshToPet once before the loop over all the boundaries, and cache the output.
Here is the question/issue:
  • I don't have write permissions to the PDEToolbox folder files. How can I edit that class method to test/implement my fix?
  • Is there a way to shadow that Toolbox class method with a local implementation so that we don't need to edit the base toolbox code?
  • I could make my own derived class to replace @pde3DBCImpl, but then I would also need to change all the other PDE toolbox classes up the chain to call my custom method.
  3 Comments
Alex Rattner
Alex Rattner on 12 Apr 2024
Hi Ravi,
Thanks for your note.
We ended up making a work-around. We just made a local copy of the whole pde toolbox, and edited two files.
In assembleBoundary.m, we modified the code to always use PackedBCs (not just for transient problems). It seems like this is useful for non-linear problems required multiple iterations.
In generateBoundaryFacetData.m, we added code to cache the FEMesh data rather than regenerate it for each bc in the loop.
Anyway, these couple tweaks gave us a 80-90% speedup for our nonlinear PDE with a bunch of boundaries.
Ravi Kumar
Ravi Kumar on 12 Apr 2024
Thanks, Alex! When I investigated this issue, I was looking at the transient cases. I will investigate the nonlinear solver case.
Regards,
Ravi

Sign in to comment.

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!