[*]I am currently trying to write a converter fro GridPro format to MED, using the Python API.
I managed writing node and cell information, using
mesh.setCoords(coordsArr)
for the nodes and
mesh.insertNextCell(mc.NORM_HEXA8, 8, conn)
for the cells
This is reasonably well documented in
http://docs.salome-platform.org/latest/ ... mples.html
However, now it comes to the boundary conditions, things get rather obscure.
It seems I need to create a 'family' of my boundary cells specified to be 'ON-FACE'. I understand the principles, but the way to do this using the Python API is not clear.
Does somebody have an example for a simple case how to do this, for example for a box grid as used in the
shear driven cavity case?
Thanks in advance !
specifying boundary condition in MED file using Python API
Forum rules
Please read the forum usage recommendations before posting.
Please read the forum usage recommendations before posting.
-
- Posts: 4208
- Joined: Mon Feb 20, 2012 3:25 pm
Re: specifying boundary condition in MED file using Python A
Hello,
I am not familiar with the MEDCoupling Python API (I am more familiar with the MED C API).
If your geometry is relatively simple, you could import it under SALOME, and use geometric filters to select mesh boundary faces on which to apply/define groups (saved internally as families, which are basically "group classes").
For something more automatic regarding SALOME scripting, you have better chances on the SALOME forum at salome-platform.org (you may also specify that for Code_Saturne, you need face/element families, not node families).
Regards,
Yvan
I am not familiar with the MEDCoupling Python API (I am more familiar with the MED C API).
If your geometry is relatively simple, you could import it under SALOME, and use geometric filters to select mesh boundary faces on which to apply/define groups (saved internally as families, which are basically "group classes").
For something more automatic regarding SALOME scripting, you have better chances on the SALOME forum at salome-platform.org (you may also specify that for Code_Saturne, you need face/element families, not node families).
Regards,
Yvan
Re: specifying boundary condition in MED file using Python A
Hello Yvan thanks for your quick reply to my post. I finally found out how to set the BCs:
First extrude the surface mesh fro the volume mesh
surfaceMesh,desc,descIndx,revDesc,revDescIndx=volumeMesh.buildDescendingConnectivity()
Next, identify the cell ids in this surface mesh and store them in a vector (faceIds)
Finally create a MedFile with the two meshes
mm = ml.MEDFileUMesh()
mm.setMeshes([volumeMesh, surfaceMesh])
and set the groups that reference the identified cells
group=ml.DataArrayInt(faceIds)
group.setName(self.bcMappings[bcMap])
# add to the list of groups
groups.append(group)
mm.setGroupsAtLevel(-1, groups)
This seems to work well, but I'lI have to do some further testing on complex meshed before making available the converter
First extrude the surface mesh fro the volume mesh
surfaceMesh,desc,descIndx,revDesc,revDescIndx=volumeMesh.buildDescendingConnectivity()
Next, identify the cell ids in this surface mesh and store them in a vector (faceIds)
Finally create a MedFile with the two meshes
mm = ml.MEDFileUMesh()
mm.setMeshes([volumeMesh, surfaceMesh])
and set the groups that reference the identified cells
group=ml.DataArrayInt(faceIds)
group.setName(self.bcMappings[bcMap])
# add to the list of groups
groups.append(group)
mm.setGroupsAtLevel(-1, groups)
This seems to work well, but I'lI have to do some further testing on complex meshed before making available the converter