New: multiprocess salome
This commit is contained in:
parent
034cc26a08
commit
ca1f5091b1
@ -1,42 +0,0 @@
|
|||||||
import os, sys
|
|
||||||
print(os.getcwd())
|
|
||||||
#sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
|
||||||
|
|
||||||
import salome
|
|
||||||
salome.salome_init()
|
|
||||||
|
|
||||||
import geometry, mesh
|
|
||||||
|
|
||||||
alpha = [ 0.1, 0.15, 0.2 ]
|
|
||||||
pore = []
|
|
||||||
|
|
||||||
for coef in alpha:
|
|
||||||
# TODO: Manage bc, not used
|
|
||||||
Pore, bc = geometry.create(coef)
|
|
||||||
geometry.geompy.addToStudy(Pore, 'Pore {}'.format(coef))
|
|
||||||
|
|
||||||
pore.append(Pore)
|
|
||||||
|
|
||||||
print("Geometry for alpha = {}".format(coef))
|
|
||||||
|
|
||||||
###
|
|
||||||
|
|
||||||
for Pore in pore:
|
|
||||||
print("Building mesh for {}".format(Pore.GetName()))
|
|
||||||
|
|
||||||
mesh_ = mesh.create(Pore, bc)
|
|
||||||
#isDone = mesh_.Compute()
|
|
||||||
|
|
||||||
#status = "Succesfully" if isDone else "Mesh is not computed"
|
|
||||||
#print(status)
|
|
||||||
|
|
||||||
#try:
|
|
||||||
# dirname = os.path.dirname(__file__)
|
|
||||||
# filename = os.path.join(dirname, '../build/mesh.unv')
|
|
||||||
# mesh.ExportUNV( filename )
|
|
||||||
# pass
|
|
||||||
#except:
|
|
||||||
# print('ExportUNV() failed. Invalid file name?')
|
|
||||||
|
|
||||||
if salome.sg.hasDesktop():
|
|
||||||
salome.sg.updateObjBrowser()
|
|
37
src/cube/main.py
Normal file
37
src/cube/main.py
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
import os, sys
|
||||||
|
#print(os.getcwd())
|
||||||
|
#sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
||||||
|
|
||||||
|
import salome
|
||||||
|
salome.salome_init()
|
||||||
|
|
||||||
|
import geometry, mesh
|
||||||
|
|
||||||
|
#alpha = [ 0.1, 0.15, 0.2 ]
|
||||||
|
coef = float(sys.argv[1])
|
||||||
|
|
||||||
|
#for coef in alpha:
|
||||||
|
print("alpha = {}".format(coef))
|
||||||
|
print("Building geometry ...")
|
||||||
|
|
||||||
|
Pore, bc = geometry.create(coef)
|
||||||
|
geometry.geompy.addToStudy(Pore, 'Pore {}'.format(coef))
|
||||||
|
|
||||||
|
print("Building mesh ...")
|
||||||
|
|
||||||
|
PoreMesh = mesh.create(Pore, bc)
|
||||||
|
isDone = PoreMesh.Compute()
|
||||||
|
|
||||||
|
status = "Succesfully" if isDone else "Mesh is not computed"
|
||||||
|
print(status)
|
||||||
|
|
||||||
|
#try:
|
||||||
|
# dirname = os.path.dirname(__file__)
|
||||||
|
# filename = os.path.join(dirname, '../build/mesh.unv')
|
||||||
|
# PoreMesh.ExportUNV( filename )
|
||||||
|
# pass
|
||||||
|
#except:
|
||||||
|
# print('ExportUNV() failed. Invalid file name?')
|
||||||
|
|
||||||
|
if salome.sg.hasDesktop():
|
||||||
|
salome.sg.updateObjBrowser()
|
21
src/genmesh.py
Normal file
21
src/genmesh.py
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
import os
|
||||||
|
import subprocess
|
||||||
|
import multiprocessing
|
||||||
|
|
||||||
|
path = os.getcwd()
|
||||||
|
cube = os.path.join(path, "cube/main.py")
|
||||||
|
print(cube)
|
||||||
|
alpha = [0.1, 0.15]
|
||||||
|
processes = []
|
||||||
|
|
||||||
|
def genmesh(coef):
|
||||||
|
subprocess.run(["salome", "-t", "{} {}".format(cube, str(coef))])
|
||||||
|
|
||||||
|
for c in alpha:
|
||||||
|
print("starting process")
|
||||||
|
p = multiprocessing.Process(target=genmesh, args=(c,))
|
||||||
|
processes.append(p)
|
||||||
|
p.start()
|
||||||
|
|
||||||
|
for process in processes:
|
||||||
|
process.join()
|
Loading…
Reference in New Issue
Block a user