21 my_mesh = cdmath.Mesh(a, b, nx)
22 conc = cdmath.Field("Concentration", cdmath.CELLS, my_mesh, 1)
25 sigma = math.sqrt(0.2)
26 for i in range(my_mesh.getNumberOfCells()):
27 x = my_mesh.getCell(i).x()
28 conc[i] = 0.5 / (sigma * math.sqrt(2 * pi)) * math.exp(-0.5 * math.pow((x / sigma), 2))
35 print("MED post-treatment of the solution at T=" + str(time) + "…")
36 output_filename = "EqTr1D"
37 conc.setTime(time, it)
38 conc.writeMED(output_filename)
39 conc.writeVTK(output_filename)
40 conc.writeCSV(output_filename)
44 while (it < ntmax and time <= tmax):
45 print("-- Iter: " + str(it) + ", Time: " + str(time) + ", dt: " + str(dt))
46 conc[0] = conc[0] - u * dt / dx * (conc[0] - conc[my_mesh.getNumberOfCells() - 1])
47 for j in range(1, my_mesh.getNumberOfCells()):
48 conc[j] = conc[j] - u * dt / dx * (conc[j] - conc[j - 1])
52 if (it % output_freq == 0):
53 conc.setTime(time, it)
54 conc.writeMED(output_filename, False)
55 conc.writeVTK(output_filename, False)
56 conc.writeCSV(output_filename)
59 print("CDMATH calculation done.")
63 if __name__ == """__main__""":