What is typically the best way to multi thread the assembly loop in a finite element code? Does anyone have experience with implementing this, that they can share? I can think of a couple of ways of doing it:
Divide the mesh into different cell sets, where the elements in each set does not share dofs, such that the threads can add element-stiffness-matrices to the global stiffness matrix directly (without worrying about them accessing the same data).
Divide the mesh into cell sets and create a separate global stiffness matrix for each thread, and then combine the stiffness-matrices at the end.
Dont divide into cellsets, but rather spawn a new thread/tasks for each cell (this can be good for load balancing, if some of the elements are more expensive than others, while some are still elastic).