4 salome.salome_init_without_session()
7 from salome.smesh import smeshBuilder
10 smesh = smeshBuilder.New()
12 import os, inspect, tempfile, shutil
14 data_dir = os.path.abspath(os.path.dirname(inspect.getfile(lambda: None)))
15 working_dir = tempfile.mkdtemp()
17 input_med_1 = os.path.join (data_dir, "tutorial_4.00.med")
18 input_xao_1 = os.path.join (data_dir, "tutorial_4.xao")
19 output_med_1 = os.path.join (working_dir, "tutorial_4.00_Uniform_R.med")
20 log_file_1 = os.path.join (working_dir, "tutorial_4.00_Uniform_R.log")
22 # Case 1: input: med file
23 # output: med file, log file, published mesh
24 if os.path.isfile(output_med_1):
25 os.remove(output_med_1)
26 if os.path.isfile(log_file_1):
29 cao_name = "CAO_PIQUAGE"
30 smeshhomard = smesh.Adaptation("Uniform")
31 smeshhomard.CreateBoundaryCAO(cao_name, input_xao_1)
32 smeshhomard.CreateCase("PIQUAGE", input_med_1, working_dir)
33 smeshhomard.AddBoundary(cao_name)
34 smeshhomard.SetConfType(0)
35 smeshhomard.SetKeepMedOUT(True)
36 smeshhomard.SetPublishMeshOUT(True)
37 smeshhomard.SetMeshNameOUT("PIQUAGE_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 input_med_2 = os.path.join (data_dir, "tutorial_5.00.med")
61 input_fr = os.path.join (data_dir, "tutorial_5.fr.med")
62 output_med_2 = os.path.join (working_dir, "tutorial_5.00_Uniform_R.med")
63 log_file_2 = os.path.join (working_dir, "tutorial_5.00_Uniform_R.log")
65 if os.path.isfile(output_med_2):
66 os.remove(output_med_2)
67 if os.path.isfile(log_file_2):
71 ([MAILL], status) = smesh.CreateMeshesFromMED( input_med_2 )
73 smeshhomard = smesh.Adaptation("Uniform")
74 smeshhomard.CreateBoundaryDi("Boun_5_1", "MAIL_EXT", input_fr)
75 smeshhomard.CreateCaseOnMesh("COEUR_2D", MAILL.GetMesh(), working_dir)
76 smeshhomard.AddBoundary("Boun_5_1")
77 smeshhomard.SetConfType(1)
78 smeshhomard.SetKeepMedOUT(False)
79 smeshhomard.SetPublishMeshOUT(True)
80 smeshhomard.SetMeshNameOUT("COEUR_2D_Uniform_R")
81 smeshhomard.SetMeshFileOUT(output_med_2)
82 smeshhomard.SetKeepWorkingFiles(False)
83 smeshhomard.SetLogInFile(True)
84 smeshhomard.SetLogFile(log_file_2)
85 smeshhomard.SetRemoveLogOnSuccess(True)
86 smeshhomard.SetVerboseLevel(0)
89 if os.path.isfile(output_med_2):
90 print("Test Uniform refinement Case 2: Error: output med file has not been removed")
93 if os.path.isfile(log_file_2):
94 print("Test Uniform refinement Case 2: Error: log file has not been removed")
97 shutil.rmtree(working_dir)
99 if salome.sg.hasDesktop():
100 salome.sg.updateObjBrowser()