Back to index

salome-med  6.5.0
Functions | Variables
batchmode_medcorba_test1 Namespace Reference

Functions

def AnalyzeField
def getMeshObjectFromStudy
def getFieldDoubleObjectFromStudy
def getFieldIntObjectFromStudy
def getMedObjectFromStudy

Variables

list filePath = os.environ["MED_ROOT_DIR"]
 studyCurrent = batchmode_salome.myStudyName
 studyCurrentId = batchmode_salome.myStudyId
tuple med_comp = batchmode_salome.lcc.FindOrLoadComponent("FactoryServer", "MED")

Function Documentation

Definition at line 43 of file batchmode_medcorba_test1.py.

00043 
00044 def AnalyzeField(field):
00045     name = field.getName()
00046     desc = field.getDescription()
00047     nbComp = field.getNumberOfComponents()
00048     itNum = field.getIterationNumber()
00049     ordNum = field.getOrderNumber()
00050 
00051     print "Analysis of the field ",name," with the description ",desc
00052     print "iteration number ",itNum," order Number ",ordNum
00053     print "It has ",nbComp," component(s)"
00054 
00055     fieldValue = field.getValue(SALOME_MED.MED_FULL_INTERLACE)
00056     fieldSupport = field.getSupport()
00057     fieldMesh = fieldSupport.getMesh()
00058     fieldEntity = fieldSupport.getEntity()
00059     bool = fieldSupport.isOnAllElements()
00060 
00061     if bool:
00062         print "The support of this field is on all entities ",fieldEntity," of the mesh ",fieldMesh.getName()
00063         if fieldEntity == SALOME_MED.MED_NODE:
00064             nbValByComp = fieldMesh.getNumberOfNodes()
00065         else:
00066             nbValByComp = fieldMesh.getNumberOfElements(fieldEntity,SALOME_MED.MED_ALL_ELEMENTS)
00067         print "and its dimension (number of values by component of the field) is ",nbValByComp
00068     else:
00069         print "The support of this field is partially on entities ",fieldEntity," of the mesh ",fieldMesh.getName()
00070         nbValByComp = fieldSupport.getNumberOfElements(SALOME_MED.MED_ALL_ELEMENTS)
00071         print "and its dimension (number of values by component of the field) is ",nbValByComp
00072 
00073     for i in range(nbComp):
00074         compName = field.getComponentName(i+1)
00075         compUnit = field.getComponentUnit(i+1)
00076         print "The ",(i+1),"-th  component ",compName," with the unit ",compUnit
00077 
00078     for i in range(nbValByComp):
00079         print "  * ",fieldValue[i*nbComp:(i+1)*nbComp]
00080 
00081 #==============================================================================

def batchmode_medcorba_test1.getFieldDoubleObjectFromStudy (   number,
  subnumber 
)

Definition at line 98 of file batchmode_medcorba_test1.py.

00098 
00099 def getFieldDoubleObjectFromStudy(number,subnumber):
00100     mySO = batchmode_salome.myStudy.FindObject("MEDFIELD")
00101     mysub = mySO.FindSubObject(number)[1]
00102     if mysub:
00103         mysubsub = mysub.FindSubObject(subnumber)[1]
00104         if mysubsub:
00105             Builder = batchmode_salome.myStudy.NewBuilder()
00106             anAttr = Builder.FindOrCreateAttribute(mysubsub, "AttributeIOR")
00107             obj = batchmode_salome.orb.string_to_object(anAttr.Value())
00108             anAttr = Builder.FindOrCreateAttribute(mysubsub, "AttributeName")
00109             myObj = obj._narrow(SALOME_MED.FIELDDOUBLE)
00110             return myObj
00111         else:
00112             print "ERROR: No FieldDouble Object stored in this Study"
00113             return None
00114     else:
00115         print "ERROR: No FieldDouble Object stored in this Study"
00116         return None
00117 
00118 
00119 #==============================================================================

def batchmode_medcorba_test1.getFieldIntObjectFromStudy (   number,
  subnumber 
)

Definition at line 120 of file batchmode_medcorba_test1.py.

00120 
00121 def getFieldIntObjectFromStudy(number,subnumber):
00122     mySO = batchmode_salome.myStudy.FindObject("MEDFIELD")
00123     mysub = mySO.FindSubObject(number)[1]
00124     if mysub:
00125         mysubsub = mysub.FindSubObject(subnumber)[1]
00126         if mysubsub:
00127             Builder = batchmode_salome.myStudy.NewBuilder()
00128             anAttr = Builder.FindOrCreateAttribute(mysubsub, "AttributeIOR")
00129             obj = batchmode_salome.orb.string_to_object(anAttr.Value())
00130             myObj = obj._narrow(SALOME_MED.FIELDINT)
00131             return myObj
00132         else:
00133             print "ERROR: No FieldInt Object stored in this Study"
00134             return None
00135     else:
00136         print "ERROR: No FieldInt Object stored in this Study"
00137         return None
00138 
00139 #==============================================================================

Definition at line 140 of file batchmode_medcorba_test1.py.

00140 
00141 def getMedObjectFromStudy(fileName=None):
00142     myObj=None; Builder = batchmode_salome.myStudy.NewBuilder()
00143     if fileName is not None:
00144         objNameInStudy = "MED_OBJECT_FROM_FILE_"+fileName
00145         mySO = batchmode_salome.myStudy.FindObject(objNameInStudy)
00146         if mySO is not None:
00147             anAttr = Builder.FindOrCreateAttribute(mySO, "AttributeIOR")
00148             obj = batchmode_salome.orb.string_to_object(anAttr.Value())
00149             if obj is not None:
00150                 myObj = obj._narrow(SALOME_MED.MED)
00151             else:
00152                 print "ERROR: ",myObj," has been found in the Study, but with the type different of SALOME_MED.MED!!!"
00153         else:
00154             print "ERROR: ",objNameInStudy," hasn't been found in the Study!!!"
00155     else:
00156         SObj_root = batchmode_salome.myStudy.FindObjectByPath("/Med/")
00157         if SObj_root is not None:
00158             iter = batchmode_salome.myStudy.NewChildIterator(SObj_root)
00159             try:
00160                 iter.Init(); 
00161                 while iter.More():
00162                     Obj = iter.Value()
00163                     if Obj is not None:
00164                         Ok, anAttr = Builder.FindAttribute(Obj, "AttributeIOR")
00165                         if Ok:
00166                             if len(anAttr.Value()) > 0:
00167                                 obj = batchmode_salome.orb.string_to_object(anAttr.Value())
00168                                 if obj is not None:
00169                                     myObj = obj._narrow(SALOME_MED.MED)
00170                                     if myObj is not None:
00171                                         break
00172                     iter.Next()
00173             except:
00174                 print "Exception!!!"
00175         else: print "Root object Med hasn't been found in the study!!!"
00176     return myObj
        

Definition at line 82 of file batchmode_medcorba_test1.py.

00082 
00083 def getMeshObjectFromStudy(number):
00084     mySO = batchmode_salome.myStudy.FindObject("MEDMESH")
00085     mysub = mySO.FindSubObject(number)[1]
00086     if mysub:
00087         Builder = batchmode_salome.myStudy.NewBuilder()
00088         anAttr = Builder.FindOrCreateAttribute(mysub, "AttributeIOR")
00089         obj = batchmode_salome.orb.string_to_object(anAttr.Value())
00090         myObj = obj._narrow(SALOME_MED.MESH)
00091         return myObj
00092     else:
00093         print "ERROR: No Mesh Object stored in this Study"
00094         return None
00095 
00096 
00097 #==============================================================================


Variable Documentation

tuple batchmode_medcorba_test1.filePath = os.environ["MED_ROOT_DIR"]

Definition at line 38 of file batchmode_medcorba_test1.py.

tuple batchmode_medcorba_test1.med_comp = batchmode_salome.lcc.FindOrLoadComponent("FactoryServer", "MED")

Definition at line 180 of file batchmode_medcorba_test1.py.

batchmode_medcorba_test1.studyCurrent = batchmode_salome.myStudyName

Definition at line 177 of file batchmode_medcorba_test1.py.

batchmode_medcorba_test1.studyCurrentId = batchmode_salome.myStudyId

Definition at line 178 of file batchmode_medcorba_test1.py.