1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
4 # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
5 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
7 # This library is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU Lesser General Public
9 # License as published by the Free Software Foundation; either
10 # version 2.1 of the License.
12 # This library is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # Lesser General Public License for more details.
17 # You should have received a copy of the GNU Lesser General Public
18 # License along with this library; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
28 filePath=os.environ["MED_ROOT_DIR"]
29 filePath=os.path.join(filePath, "share", "salome", "resources", "med")
35 from libSALOME_Swig import *
48 def changeBlankToUnderScore(stringWithBlank):
51 decompString = string.split(stringWithBlank,blank)
52 length = len(decompString)
53 stringWithUnderScore = decompString[0]
54 for i in range(1,length):
55 stringWithUnderScore += underscore
56 stringWithUnderScore += decompString[i]
57 return stringWithUnderScore
59 def getMedObjectFromStudy(file):
60 objNameInStudy = "MED_OBJECT_FROM_FILE_"+file
61 compNameInStudy= "MED"
62 listOfSO = salome.myStudy.FindObjectByName(objNameInStudy,compNameInStudy)
63 listLength = len(listOfSO)
64 if (listLength == 0) :
65 print objNameInStudy," cannot be found in the Study under the component ",compNameInStudy
67 elif (listLength > 1) :
68 print "there are more than one instance of ",objNameInStudy," in the Study under the component ",compNameInStudy
72 print objNameInStudy," cannot be found in the Study"
75 anAttr = mySO.FindAttribute("AttributeIOR")[1]
76 obj = salome.orb.string_to_object(anAttr.Value())
77 myObj = obj._narrow(SALOME_MED.MED)
79 print objNameInStudy," has been found in the Study but with the wrong type"
82 def getMeshObjectFromStudy(meshName):
83 objNameInStudy = "/Med/MEDMESH/"+meshName
84 mySO = salome.myStudy.FindObjectByPath(objNameInStudy)
86 print objNameInStudy," cannot be found in the Study"
89 anAttr = mySO.FindAttribute("AttributeIOR")[1]
90 obj = salome.orb.string_to_object(anAttr.Value())
91 myObj = obj._narrow(SALOME_MED.MESH)
93 print objNameInStudy," has been found in the Study but with the wrong type"
96 def getSupportObjectFromStudy(meshName,supportName):
97 meshNameStudy = changeBlankToUnderScore(meshName)
98 objNameInStudy = "/Med/MEDMESH/MEDSUPPORTS_OF_"+meshNameStudy+"/"+supportName
99 mySO = salome.myStudy.FindObjectByPath(objNameInStudy)
101 print objNameInStudy," cannot be found in the Study"
104 anAttr = mySO.FindAttribute("AttributeIOR")[1]
105 obj = salome.orb.string_to_object(anAttr.Value())
106 myObj = obj._narrow(SALOME_MED.SUPPORT)
108 print objNameInStudy," has been found in the Study but with the wrong type"
111 def getFieldObjectFromStudy(dt,it,fieldName,supportName,meshName):
112 meshNameStudy = changeBlankToUnderScore(meshName)
113 objNameInStudy = "/Med/MEDFIELD/"+fieldName+"/("+str(dt)+","+str(it)+")_ON_"+supportName+"_OF_"+meshNameStudy
114 mySO = salome.myStudy.FindObjectByPath(objNameInStudy)
116 print objNameInStudy," cannot be found in the Study"
119 anAttr = mySO.FindAttribute("AttributeIOR")[1]
120 obj = salome.orb.string_to_object(anAttr.Value())
121 myObj = obj._narrow(SALOME_MED.FIELDINT)
123 myObj = obj._narrow(SALOME_MED.FIELDDOUBLE)
125 print objNameInStudy," has been found in the Study but with the wrong type"
129 medFiles.append("ChampsDarcy.med")
130 medFiles.append("darcy_1.1_res.med")
131 medFiles.append("darcy_1.3_resCASTEM.med")
132 medFiles.append("darcy_1.3_resPORFLOW.med")
133 medFiles.append("darcy_1.3_resTRACES.med")
134 medFiles.append("darcy2_Castem_EFMH.med")
135 medFiles.append("darcy2_Castem_qua_EFMH.med")
136 medFiles.append("darcy2_Castem_qua_VF.med")
137 medFiles.append("Deff_fdt_5.8_castem_efmh_diff_conc_dom.med")
138 medFiles.append("Deff_fdt_5.8_castem_vf_diff_conc_dom.med")
139 medFiles.append("extendedtransport53_triangles.med")
140 medFiles.append("H_CastCast_EFMH_I129_COUPLEX1.med")
141 medFiles.append("H_CastCast_VF_I129_COUPLEX1.med")
142 medFiles.append("H_CastCast_VF_Se79_COUPLEX1.med")
143 medFiles.append("H_CastPorf_I129_COUPLEX1.med")
144 medFiles.append("H_CastPorf_Se79_COUPLEX1.med")
145 medFiles.append("H_PorfCast_EFMH_I129_COUPLEX1.med")
146 medFiles.append("H_PorfCast_EFMH_Se79_COUPLEX1.med")
147 medFiles.append("H_PorfPorf_I129_COUPLEX1.med")
148 medFiles.append("H_Traces_I129_COUPLEX1.med")
149 medFiles.append("H_Traces_Se79_COUPLEX1.med")
150 medFiles.append("maillage_5_5_5.med")
151 medFiles.append("maillage_chemvalIV_cas1_40elts.med")
152 medFiles.append("Old_ChampsDarcy.med")
153 medFiles.append("Old_darcy_1.1_res.med")
154 medFiles.append("Old_darcy_1.3_resCASTEM.med")
155 medFiles.append("Old_darcy_1.3_resPORFLOW.med")
156 medFiles.append("Old_darcy_1.3_resTRACES.med")
157 medFiles.append("Old_darcy2_Castem_EFMH.med")
158 medFiles.append("Old_darcy2_Castem_qua_EFMH.med")
159 medFiles.append("Old_darcy2_Castem_qua_VF.med")
160 medFiles.append("Old_Deff_fdt_5.8_castem_efmh_diff_conc_dom.med")
161 medFiles.append("Old_Deff_fdt_5.8_castem_vf_diff_conc_dom.med")
162 medFiles.append("Old_H_CastCast_EFMH_I129_COUPLEX1.med")
163 medFiles.append("Old_H_CastCast_VF_I129_COUPLEX1.med")
164 medFiles.append("Old_H_CastCast_VF_Se79_COUPLEX1.med")
165 medFiles.append("Old_H_CastPorf_I129_COUPLEX1.med")
166 medFiles.append("Old_H_CastPorf_Se79_COUPLEX1.med")
167 medFiles.append("Old_H_PorfCast_EFMH_I129_COUPLEX1.med")
168 medFiles.append("Old_H_PorfCast_EFMH_Se79_COUPLEX1.med")
169 medFiles.append("Old_H_PorfPorf_I129_COUPLEX1.med")
170 medFiles.append("Old_H_PorfPorf_Se79_COUPLEX1.med")
171 medFiles.append("Old_H_Traces_I129_COUPLEX1.med")
172 medFiles.append("Old_H_Traces_Se79_COUPLEX1.med")
173 medFiles.append("Old_maillage_chemvalIV_cas1_40elts.med")
175 nbOfFiles = len(medFiles)
177 med = salome.lcc.FindOrLoadComponent("FactoryServer", "MED")
179 for i in range(nbOfFiles):
180 medFile = medFiles[i]
181 print "Testing with the file ",medFile
182 medFile = os.path.join(filePath, medFile)
183 med.readStructFile(medFile,salome.myStudyName)
185 print "END of the Pyhton script ..... Ctrl D to exit"