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_1 = osp.join(data_dir, "tutorial_4.00.med")
19 input_xao_1 = osp.join(data_dir, "tutorial_4.xao")
20 output_med_1 = osp.join(working_dir, "tutorial_4.00_Uniform_R.med")
21 log_file_1 = osp.join(working_dir, "tutorial_4.00_Uniform_R.log")
23 # Case 1: input: med file
24 # output: med file, log file, published mesh
25 if osp.isfile(output_med_1):
26 os.remove(output_med_1)
27 if osp.isfile(log_file_1):
30 cao_name = "CAO_PIQUAGE"
31 smeshhomard = smesh.Adaptation("Uniform")
32 smeshhomard.CreateBoundaryCAO(cao_name, input_xao_1)
33 smeshhomard.CreateCase("PIQUAGE", input_med_1, working_dir)
34 smeshhomard.AddBoundary(cao_name)
35 smeshhomard.SetConfType(0)
36 smeshhomard.SetKeepMedOUT(True)
37 smeshhomard.SetPublishMeshOUT(True)
38 smeshhomard.SetMeshNameOUT("PIQUAGE_Uniform_R_01")
39 smeshhomard.SetMeshFileOUT(output_med_1)
40 smeshhomard.SetKeepWorkingFiles(False)
41 smeshhomard.SetLogInFile(True)
42 smeshhomard.SetLogFile(log_file_1)
43 smeshhomard.SetRemoveLogOnSuccess(False)
44 smeshhomard.SetVerboseLevel(3)
45 if not smeshhomard.Compute(): raise Exception("Error when computing Mesh")
47 if osp.isfile(output_med_1):
48 os.remove(output_med_1)
50 print("Test Uniform refinement Case 1: Error: no output med file")
53 if osp.isfile(log_file_1):
56 print("Test Uniform refinement Case 1: Error: no log file")
59 # Case 2: input: mesh, boundaries
60 # output: published mesh
61 input_med_2 = osp.join(data_dir, "tutorial_5.00.med")
62 input_fr = osp.join(data_dir, "tutorial_5.fr.med")
63 output_med_2 = osp.join(working_dir, "tutorial_5.00_Uniform_R.med")
64 log_file_2 = osp.join(working_dir, "tutorial_5.00_Uniform_R.log")
66 if osp.isfile(output_med_2):
67 os.remove(output_med_2)
68 if osp.isfile(log_file_2):
72 ([MAILL], status) = smesh.CreateMeshesFromMED( input_med_2 )
74 smeshhomard = smesh.Adaptation("Uniform")
75 smeshhomard.CreateBoundaryDi("Boun_5_1", "MAIL_EXT", input_fr)
76 smeshhomard.CreateCaseOnMesh("COEUR_2D", MAILL.GetMesh(), working_dir)
77 smeshhomard.AddBoundary("Boun_5_1")
78 smeshhomard.SetConfType(1)
79 smeshhomard.SetKeepMedOUT(False)
80 smeshhomard.SetPublishMeshOUT(True)
81 smeshhomard.SetMeshNameOUT("COEUR_2D_Uniform_R")
82 smeshhomard.SetMeshFileOUT(output_med_2)
83 smeshhomard.SetKeepWorkingFiles(False)
84 smeshhomard.SetLogInFile(True)
85 smeshhomard.SetLogFile(log_file_2)
86 smeshhomard.SetRemoveLogOnSuccess(True)
87 smeshhomard.SetVerboseLevel(0)
88 if not smeshhomard.Compute(): raise Exception("Error when computing Mesh")
90 if osp.isfile(output_med_2):
91 print("Test Uniform refinement Case 2: Error: output med file has not been removed")
94 if osp.isfile(log_file_2):
95 print("Test Uniform refinement Case 2: Error: log file has not been removed")
98 shutil.rmtree(working_dir)
100 if salome.sg.hasDesktop():
101 salome.sg.updateObjBrowser()