# -----------------------------------------------------------------------------
-from MEDLoader import MEDLoader, MEDCouplingFieldDouble, ON_NODES, DataArrayDouble
+from MEDLoader import MEDLoader, MEDCouplingFieldDouble, ON_NODES, DataArrayDouble, MEDFileMesh
def createZfield2(fichierMaillage):
"""
Add a field on nodes, named "BOTTOM", of type double, containing z coordinates of nodes.
createZfield2 is used after interpolZ. createZfield1 is base on MEDLoader interface.
There is an alternate method based on Med file, equivalent (createZfield1).
- The file <fichierMaillage>F.med produced by interpolz must exist, and is modified.
fichierMaillage : 2D (x,y) med file produced by SMESH and used by interpolZ.
- return <fichierMaillage>L.med : med file containing the field "BOTTOM"
+ return <fichierMaillage>F.med : med file containing the field "BOTTOM"
"""
noms = string.split(fichierMaillage,'.')
basename = string.join(noms[:-1], '.')
fichierZMaillage = basename + 'Z.med'
- fichierLMaillage = basename + 'L.med'
- print fichierLMaillage
+ fichierFMaillage = basename + 'F.med'
+ print fichierFMaillage
mymesh = MEDLoader.ReadUMeshFromFile(fichierZMaillage,0)
fieldOnNodes=MEDCouplingFieldDouble.New(ON_NODES)
fieldOnNodes.setName("BOTTOM")
fieldOnNodes.setMesh(mymesh)
fieldOnNodes.setArray(mymesh.getCoords()[:,2])
-
- MEDLoader.WriteField(fichierLMaillage,fieldOnNodes,True)
+ mm=MEDFileMesh.New(fichierZMaillage)
+ mm.write(fichierFMaillage,2)
+ MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fichierFMaillage,fieldOnNodes)
# -----------------------------------------------------------------------------
([maillagePlat], status) = smesh.CreateMeshesFromMED(fichierMaillage)
groups = maillagePlat.GetGroups()
+ grpns = [grp for grp in groups if grp.GetType() == SMESH.NODE]
+ if len(grpns) == 0:
+ print "Problem! There are no groups of nodes in the mesh!"
+ print "Please create at least the groups of nodes corresponding to each region of the HYDRO case"
+ return {}
+
+
for grp in groups:
if grp.GetType() == SMESH.NODE:
grpName = grp.GetName()