Classical method
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-First instanciate a meshing object. Therefore, we need to define :
+First instantiate a meshing object. Therefore, we need to define :
* its name
* its dimension
* its number of cells
-.. note:: All this initialisation are necessary. If one lacks, you will have a segmentation fault!.
+.. note:: All this initialisation is necessary. If one is missing, you'll have a segmentation fault!.
::
mesh.insertNextCell(NORM_HEXA8,8,connectivity[8*i:8*(i+1)])
pass
- # Finishing insertion
- mesh.finishInsertingCells()
- mesh.checkCoherency()
+ # Check mesh consistency:
+ mesh.checkConsistencyLight()
Method by extrusion
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
for i in range(NbCell2D):
m1.insertNextCell(NORM_QUAD4,4,Connectivities[4*i:4*(i+1)])
- m1.finishInsertingCells()
m1.changeSpaceDimension(3)
Definition of 1D mesh
m2.insertNextCell(NORM_SEG2,2,conn[0:2])
m2.insertNextCell(NORM_SEG2,2,conn[2:4])
m2.insertNextCell(NORM_SEG2,2,conn[4:6])
- m2.finishInsertingCells()
myCoords1D=DataArrayDouble.New()
myCoords1D.setValues(coords,4,1)
m2.setCoords(myCoords1D)
* its values
-The field will be a sin function dependant of distance of the barycenter of each cell from origin. So we need to create a barycenter field on the 3D mesh::
+The field will be a sin function dependent of distance of the barycenter of each cell from origin. So we need to create a barycenter field on the 3D mesh::
# Creation of field : with following definition
# => Definition of the mesh support
field = MEDCouplingFieldDouble.New(ON_CELLS)
field.setMesh(mesh)
field.setName("field")
- field.setNature(Integral)
+ field.setNature(ExtensiveMaximum)
# Computing and setting field values
myCoords=DataArrayDouble.New()
sampleTab=[]
- bar = mesh.getBarycenterAndOwner()
+ bar = mesh.computeCellCenterOfMass()
print bar.getNbOfElems()
for i in range(nbOfCells):
x = bar.getIJ(...)
Multi mesh Case
````````````````
-In spite of a MEDCoupling mesh has only one dimension, it's possible to genrate a file with multi dimension.
+In spite of a MEDCoupling mesh has only one dimension, it's possible to generate a file with multi dimension.
Therefore, you need to create as meshes as necessary dimensions.
You have to give the connectivity of the faces on the bottom face of the 3D cube: the list of the nodes which belong to the face.
mesh2D = mesh.buildFacePartOfMySelfNode(nodes,True)
#print mesh2D
mesh2D.setName("3Dcube")
- mesh2D.checkCoherency()
+ mesh2D.checkConsistencyLight()
medFileName = "MEDCoupling_cube3D.med"
meshes=[mesh2D,mesh]