Page 1 of 1

specifying boundary condition in MED file using Python API

Posted: Thu Dec 31, 2015 7:40 pm
by martin.spel@rtech.fr
[*]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 !

Re: specifying boundary condition in MED file using Python A

Posted: Fri Jan 01, 2016 10:19 pm
by Yvan Fournier
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

Re: specifying boundary condition in MED file using Python A

Posted: Sun Jan 03, 2016 8:15 pm
by martin.spel@rtech.fr
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