Beginning of implementation
~~~~~~~~~~~~~~~~~~~~~~~~~~~
-To implement this exercice we use the python language script and import the MEDCoupling and MEDLoader parts of the MED module::
+To implement this exercice we use the python language script and import the medcoupling module. We need also mathematical functions, so we import the python math module::
- from MEDCoupling import *
- from MEDLoader import *
-
- from math import *
+ import medcoupling as mc
+ from math import *
Then we must instantiate a meshing object::
- mesh=MEDCouplingUMesh.New()
+ mesh=mc.MEDCouplingUMesh.New()
mesh.setMeshDimension(2)
mesh.allocateCells(numberOfCells)
mesh.setName("MaFleur")
for i in range(6):
...
- myCoords=DataArrayDouble.New()
+ myCoords=mc.DataArrayDouble.New()
myCoords.setValues(coordinates,numberOfNodes,2)
mesh.setCoords(myCoords)
connectivity.append(...)
connectivity.append(...)
for i in range(6):
- mesh.insertNextCell(NORM_TRI3,3,connectivity[3*i:3*(i+1)])
+ mesh.insertNextCell(mc.NORM_TRI3,3,connectivity[3*i:3*(i+1)])
pass
start = i%6+1
connectivity.append(...)
for i in range(6):
- mesh.insertNextCell(NORM_POLYGON,6,connectivity[6*i:6*(i+1)])
+ mesh.insertNextCell(mc.NORM_POLYGON,6,connectivity[6*i:6*(i+1)])
pass
mesh.checkConsistencyLight()
You have to create a med file with the MED driver::
medFileName = "MEDCoupling_Fleur.med"
- MEDLoader.WriteUMesh(medFileName,mesh,True)
+ mc.WriteUMesh(medFileName,mesh,True)
Visualize the mesh with SMESH module of Salome
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~