1 # contains function to compute a mesh in parallel
6 notebook = salome_notebook.NoteBook()
13 from salome.geom import geomBuilder
14 from salome.smesh import smeshBuilder
19 geompy = geomBuilder.New()
27 # First creating all the boxes
28 # for i in range(nbox):
29 # for j in range(nbox):
30 # for k in range(nbox):
32 # x_orig = i*(boxsize+offset)
33 # y_orig = j*(boxsize+offset)
34 # z_orig = k*(boxsize+offset)
36 # tmp_box = geompy.MakeBoxDXDYDZ(boxsize, boxsize, boxsize)
38 # if not i == j == k == 0:
39 # box = geompy.MakeTranslation(tmp_box, x_orig,
44 # geompy.addToStudy(box, 'box_{}:{}:{}'.format(i, j, k))
49 #But simplify for 2 boxes to also Test possibility of rewritting the
50 # input mesh from other parallel tests. In that case this test will break
51 # because the input mesh will not match the exported/imported box geometry.
56 x_orig = i*(boxsize+offset)
57 y_orig = j*(boxsize+offset)
58 z_orig = k*(boxsize+offset)
60 tmp_box = geompy.MakeBoxDXDYDZ(boxsize, boxsize, boxsize)
62 if not i == j == k == 0:
63 box = geompy.MakeTranslation(tmp_box, x_orig,
68 geompy.addToStudy(box, 'box_{}:{}:{}'.format(i, j, k))
72 # Create fuse of all boxes
73 all_boxes = geompy.MakeCompound(boxes)
74 geompy.addToStudy(all_boxes, 'Compound_1')
76 # Removing duplicates faces and edges
77 all_boxes = geompy.MakeGlueFaces(all_boxes, 1e-07)
78 geompy.addToStudy(all_boxes, 'Glued_Faces_1')
80 rubik_cube = geompy.MakeGlueEdges(all_boxes, 1e-07)
81 geompy.addToStudy(rubik_cube, 'rubik_cube')
84 smesh = smeshBuilder.New()
85 print("Creating Parallel Mesh")
86 par_mesh = smesh.ParallelMesh(rubik_cube, name="par_mesh")
88 print("Creating hypoehtesis for netgen")
89 NETGEN_2D_Parameters_1 = smesh.CreateHypothesisByAverageLength( 'NETGEN_Parameters_2D',
90 'NETGENEngine', 34.641, 0 )
92 print("Adding hypothesis")
93 par_mesh.Add2DGlobalHypothesis(NETGEN_2D_Parameters_1)
95 print("Setting parallelism method")
96 par_mesh.SetParallelismMethod(smeshBuilder.MULTITHREAD)
98 print("Setting parallelism options")
99 param = par_mesh.GetParallelismSettings()
100 param.SetNbThreads(6)
102 print("Starting parallel compute")
103 is_done = par_mesh.Compute()
105 raise Exception("Error when computing Mesh")
107 print(" Triangle: ", par_mesh.NbTriangles())
108 print(" edge: ", par_mesh.NbEdges())
110 assert par_mesh.NbTetras() == 0
111 assert par_mesh.NbTriangles() > 0
112 assert par_mesh.NbEdges() > 0