from math import sqrt
import cdmath
+import medcoupling as mc
print("Loading a triangular mesh of a 2D square")
filename = "./meshSquare"
M=cdmath.Mesh(filename+".med")
+#Extract groups in the mesh
print("Checking boundary group names")
boundaryFaceGroupNames=M.getNameOfFaceGroups()
boundaryNodeGroupNames=M.getNameOfNodeGroups()
temperature_field_nodes[i] = Tout
temperature_field_nodes.writeMED(filename, False)
+
+#### Delete mesh and still save field in a med file
+m = mc.MEDCouplingCMesh()
+x = mc.DataArrayDouble([0.,1.,2.])
+y = mc.DataArrayDouble([0.,1.,2.])
+m.setCoords(x, y)
+m = m.buildUnstructured()
+m.setName("mesh")
+
+f = mc.MEDCouplingFieldDouble(mc.ON_CELLS, mc.ONE_TIME)
+f.setMesh(m)
+f.setName("F")
+
+da = mc.DataArrayDouble([1,2,3,4])
+f.setArray(da)
+f.setTime(0.0,0,0)
+
+# Maillage d'abord:
+fName = "./michael.med"
+mc.WriteUMesh(fName, m, True)
+
+# Maintenant juste les champs:
+ff = mc.MEDFileField1TS()
+ff.setFieldNoProfileSBT(f)
+ff.write(fName, 0)
+
+# Tue le maillage
+m = 0
+del m
+import gc
+gc.collect() # Make sure Python interp has called mesh destructor ...
+
+# Ecrit encore du champ:
+da2 = da.deepCopy()
+f.setTime(1.0,1,0)
+da2 += 1
+print(da2.getValues())
+f.setArray(da2)
+
+ff = mc.MEDFileField1TS()
+ff.setFieldNoProfileSBT(f) # le maillage n'existe plus, tant pis :-)
+ff.write(fName, 0)
+ff.write(fName, 0) # 1 append