6 salome.salome_init_without_session()
9 from salome.smesh import smeshBuilder
12 smesh = smeshBuilder.New()
14 import os, inspect, tempfile, shutil
16 data_dir = os.path.abspath(os.path.dirname(inspect.getfile(lambda: None)))
17 working_dir = tempfile.mkdtemp()
19 input_med = os.path.join (data_dir, "test_homard_adapt.med")
20 output_med_1 = os.path.join (working_dir, "test_1.00_Uniform_R_01.med")
21 output_med_2 = os.path.join (working_dir, "test_1.00_Uniform_R_02.med")
22 log_file_1 = os.path.join (working_dir, "test_1.00_Uniform_R_01.med.log")
23 log_file_2 = os.path.join (working_dir, "test_1.00_Uniform_R_02.med.log")
25 # Case 1: input: med file
26 # output: med file, log file, published mesh
27 if os.path.isfile(output_med_1):
28 os.remove(output_med_1)
29 if os.path.isfile(log_file_1):
32 smeshhomard = smesh.Adaptation("Uniform")
33 smeshhomard.CreateCase("MAILL", input_med, working_dir)
34 smeshhomard.SetConfType(0)
35 smeshhomard.SetKeepMedOUT(True)
36 smeshhomard.SetPublishMeshOUT(True)
37 smeshhomard.SetMeshNameOUT("MAILL_Uniform_R_01")
38 smeshhomard.SetMeshFileOUT(output_med_1)
39 smeshhomard.SetKeepWorkingFiles(False)
40 smeshhomard.SetLogInFile(True)
41 smeshhomard.SetLogFile(log_file_1)
42 smeshhomard.SetRemoveLogOnSuccess(False)
43 smeshhomard.SetVerboseLevel(3)
46 if os.path.isfile(output_med_1):
47 os.remove(output_med_1)
49 print("Test Uniform refinement Case 1: Error: no output med file")
52 if os.path.isfile(log_file_1):
55 print("Test Uniform refinement Case 1: Error: no log file")
58 # Case 2: input: mesh, boundaries
59 # output: published mesh
60 if os.path.isfile(output_med_2):
61 os.remove(output_med_2)
62 if os.path.isfile(log_file_2):
66 ([MAILL], status) = smesh.CreateMeshesFromMED( input_med )
68 #smeshhomard = smesh.Adaptation("Uniform")
69 Boun_1 = smeshhomard.CreateBoundaryCylinder("Boun_1", 0.5, 0.5, 0.5, 0, 0, 1, 0.25)
70 smeshhomard.CreateCaseOnMesh("MAILL", MAILL.GetMesh(), working_dir)
71 smeshhomard.SetConfType(0)
72 smeshhomard.AddBoundaryGroup("Boun_1", "BORD_EXT")
73 smeshhomard.AddBoundaryGroup("Boun_1", "MOITIE1")
74 smeshhomard.SetKeepMedOUT(False)
75 smeshhomard.SetPublishMeshOUT(True)
76 smeshhomard.SetMeshNameOUT("MAILL_Uniform_R_02")
77 smeshhomard.SetMeshFileOUT(output_med_2)
78 smeshhomard.SetKeepWorkingFiles(False)
79 smeshhomard.SetLogInFile(True)
80 smeshhomard.SetLogFile(log_file_2)
81 smeshhomard.SetRemoveLogOnSuccess(True)
82 smeshhomard.SetVerboseLevel(0)
85 if os.path.isfile(output_med_2):
86 print("Test Uniform refinement Case 2: Error: output med file has not been removed")
89 if os.path.isfile(log_file_2):
90 print("Test Uniform refinement Case 2: Error: log file has not been removed")
93 shutil.rmtree(working_dir)
95 if salome.sg.hasDesktop():
96 salome.sg.updateObjBrowser()