8 salome.salome_init_without_session()
10 from salome.smesh import smeshBuilder
13 smesh = smeshBuilder.New()
15 data_dir = osp.abspath(osp.join(osp.dirname(inspect.getfile(lambda: None)), 'data'))
16 working_dir = tempfile.mkdtemp()
18 input_med = osp.join (data_dir, "test_homard_adapt.med")
19 output_med_1 = osp.join (working_dir, "test_1.00_Uniform_R_01.med")
20 output_med_2 = osp.join (working_dir, "test_1.00_Uniform_R_02.med")
21 log_file_1 = osp.join (working_dir, "test_1.00_Uniform_R_01.med.log")
22 log_file_2 = osp.join (working_dir, "test_1.00_Uniform_R_02.med.log")
24 # Case 1: input: med file
25 # output: med file, log file, published mesh
26 if osp.isfile(output_med_1):
27 os.remove(output_med_1)
28 if osp.isfile(log_file_1):
31 smeshhomard = smesh.Adaptation("Uniform")
32 smeshhomard.CreateCase("MAILL", input_med, working_dir)
33 smeshhomard.SetConfType(0)
34 smeshhomard.SetKeepMedOUT(True)
35 smeshhomard.SetPublishMeshOUT(True)
36 smeshhomard.SetMeshNameOUT("MAILL_Uniform_R_01")
37 smeshhomard.SetMeshFileOUT(output_med_1)
38 smeshhomard.SetKeepWorkingFiles(False)
39 smeshhomard.SetLogInFile(True)
40 smeshhomard.SetLogFile(log_file_1)
41 smeshhomard.SetRemoveLogOnSuccess(False)
42 smeshhomard.SetVerboseLevel(3)
43 if not smeshhomard.Compute(): raise Exception("Error when computing Mesh")
45 if osp.isfile(output_med_1):
46 os.remove(output_med_1)
48 print("Test Uniform refinement Case 1: Error: no output med file")
51 if osp.isfile(log_file_1):
54 print("Test Uniform refinement Case 1: Error: no log file")
57 # Case 2: input: mesh, boundaries
58 # output: published mesh
59 if osp.isfile(output_med_2):
60 os.remove(output_med_2)
61 if osp.isfile(log_file_2):
65 ([MAILL], status) = smesh.CreateMeshesFromMED( input_med )
67 #smeshhomard = smesh.Adaptation("Uniform")
68 Boun_1 = smeshhomard.CreateBoundaryCylinder("Boun_1", 0.5, 0.5, 0.5, 0, 0, 1, 0.25)
69 smeshhomard.CreateCaseOnMesh("MAILL", MAILL.GetMesh(), working_dir)
70 smeshhomard.SetConfType(0)
71 smeshhomard.AddBoundaryGroup("Boun_1", "BORD_EXT")
72 smeshhomard.AddBoundaryGroup("Boun_1", "MOITIE1")
73 smeshhomard.SetKeepMedOUT(False)
74 smeshhomard.SetPublishMeshOUT(True)
75 smeshhomard.SetMeshNameOUT("MAILL_Uniform_R_02")
76 smeshhomard.SetMeshFileOUT(output_med_2)
77 smeshhomard.SetKeepWorkingFiles(False)
78 smeshhomard.SetLogInFile(True)
79 smeshhomard.SetLogFile(log_file_2)
80 smeshhomard.SetRemoveLogOnSuccess(True)
81 smeshhomard.SetVerboseLevel(0)
82 if not smeshhomard.Compute(): raise Exception("Error when computing Mesh")
84 if osp.isfile(output_med_2):
85 print("Test Uniform refinement Case 2: Error: output med file has not been removed")
88 if osp.isfile(log_file_2):
89 print("Test Uniform refinement Case 2: Error: log file has not been removed")
92 shutil.rmtree(working_dir)
94 if salome.sg.hasDesktop():
95 salome.sg.updateObjBrowser()