j-fu / VoronoiFVM.jl

Solution of nonlinear multiphysics partial differential equation systems using the Voronoi finite volume method
MIT License
202 stars 34 forks source link

Compatibility with multithreading #12

Open mjyshin opened 3 years ago

mjyshin commented 3 years ago

I wanted to look at a range of parameters on the same system, so I tried using Threads.@threads on the for loop, and I got the following error:

    nested task error: Allocations in assembly loop: cells: 208, bfaces: 0
    See the documentation of `check_allocs!` for more information

It runs just fine if I run it in series, but I thought I would try to speed up the process any way I could. Is this something VoronoiFVM cannot handle (yet), or did I fumble somewhere? Thank you!

j-fu commented 3 years ago

Hi, thanks for asking. Parallelization is in the plans, but this will need some work:

In the moment the multithreaded loop would end up in write conflicts.

mjyshin commented 3 years ago

Thank you for your reply, that sounds great, and I will patiently await the updates!

Two unrelated questions I had were 1) if there was a way to do unstructured/random Delaunay triangulation, even on a domain like (0,1) x (0,1), and 2) if you had any plans for an adaptive (i.e., time dependent) mesh at any point in the future?

j-fu commented 3 years ago

Hi,

as for 1) Have a look at SimplexGridFactory.jl - this package has been made for this purpose. For 2): this has lesser priority than other things (and would need some input from math regarding error estimators etc.)

j-fu commented 2 months ago

Multithreaded assembly has now bee implemented starting with v1.22, but not yet well documented. In the moment, see Examples 201 and 206 for clues. Please note that for being efficient, it needs to be combined with multihreaded linear solvers like Pardiso.jl or AMGCLWrap.jl. More options in this direction are WIP...