I need to conduct some FEM calculations and I am wondering whether parallelization would be a good idea. The trouble is that my model is not especially large so it takes few seconds to solve a single problem on my laptop. However I need to do optimization (there's a lot of different geometric parameters to test), so I need to run solver many times for slightly different geometry models. To my knowledge, most available free software (Elmer, Fenics, OpenFOAM, ...) enable parallel computation only after partitioning domain into subdomains. In this way assembling matrices and solving system of equations for separate subdomains are the tasks for separate processors/cores. I doubt whether parallelization at this stage would compensate the overhead.

Question no 1.: Is my thinking correct?

Since in the end there will be a lot of calculations (different parameters, different frequencies) I think some kind of parallelization would be of benefit, after all. I'm thinking about embedding FE code in other language to make a parallel split for separate tasks on a higher level.

Question no 2.: Is this workflow correct? Does there exist any better approach?

Question no 3.: If there is no better approach, then what would be the preferable language to do such things? Python? C? Something else? I'm thinking about using Elmer for FE stuff but I'm not decided yet.

I mainly program in Octave/Matlab and I've never written parallel program before so I don't have enough experience in this field. Unfortunately I don't have enough time do experiments on my own, so I would really appreciate your hints.

  • 1
    $\begingroup$ Hi, welcome to scicomp.stackexchange, when you talk about parallel computation what kind of hardware have you got in mind? (multicore, cluster of cpu, gpu,...) $\endgroup$ Jun 13, 2018 at 10:08
  • $\begingroup$ I have an access to linux virtual machine with up to 16 cores. $\endgroup$ Jun 13, 2018 at 18:43
  • $\begingroup$ Are you doing optimization or a parametric analysis? $\endgroup$
    – nicoguaro
    Jun 13, 2018 at 22:58
  • $\begingroup$ At first attempt I want to do parametric analysis $\endgroup$ Jun 14, 2018 at 8:31

1 Answer 1


Since your computations only take a few seconds, there will be hardly any benefit from parallelizing you FEM computation itself. But since you need to do many individual simulations you can parallelize that part. Instead of running each simulation in series you can run the simulations in parallel $\rightarrow$ one simulation per available core.

Python is a good choice to handle your processes. I recently had to implement something similar. The subprocess package came in very handy.

import subprocess

# parallel process
processes = []
for i in range(0, N):
    command = "yourCommand"
    processes.append(subprocess.Popen(command, shell=True))
    print("process started: ", command)
for p in processes[:]:

The code above starts N processes in parallel and waits for all of them to finish.

  • 1
    $\begingroup$ This would work, but I personally prefer the gnu "parallel" utility, which is a more feature-rich version of this, and allows you to flexibly specify input arguments. It also lets you limit the number of jobs in flight at a single time, defaulted to the number of logical cores on the machine. $\endgroup$ Jun 14, 2018 at 3:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.