File: multi_process.py

package info (click to toggle)
gmsh 4.15.1%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 52,880 kB
  • sloc: cpp: 440,657; ansic: 114,930; f90: 15,611; python: 13,907; yacc: 7,438; java: 3,491; lisp: 3,206; lex: 633; perl: 571; makefile: 500; xml: 414; sh: 407; javascript: 113; modula3: 32
file content (22 lines) | stat: -rw-r--r-- 625 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from multiprocessing import Process
import gmsh

# to mesh independent entities you can of course run multiple independent Gmsh
# processes as well (cf. multi_thread.py for actual parallel mesh generation)

def f(i):
    gmsh.initialize()
    s = gmsh.model.occ.addRectangle(i,0,0, 1,1)
    gmsh.model.occ.synchronize()
    gmsh.option.setNumber('Mesh.MeshSizeMax', 0.005)
    gmsh.model.mesh.generate(2)
    gmsh.finalize()

if __name__ == '__main__':
    procs = []
    for i in range(5):
        p = Process(target=f, args=(i,))
        p.start()
        procs.append(p)
    for p in procs: p.join()
    print("All done")