Dirichlet = 1 Neuman = 0 BCs.data = np.array([[0, Dirichlet, 0, 0], [0, Dirichlet, 1, 0], [1, Dirichlet, 1, 0], [3, Dirichlet, 0, 0], [3, Dirichlet, 1, 0], [2, Neuman , 1, -P]]) #--------------------------------------------------------------- print("--> Solving...\n") # Global solver time assesment start = time.time() U, R, K = solver.run(mesh, BCs, MaterialSets, Procedures) end = time.time() print("Total time: {}s".format(end-start)) print("\n-- Post-processing...\n") U_print = U.copy() print(" . solution U:\n{}\n".format(U)) print(" . reaction forces R:\n{}\n".format(R)) meshio.write(mesh_file+".vtk", mesh)
# Load info print("Applying BCs...\n") BCs = BC_engine.BoundaryConditions() BCs.data = np.array([[0, 0, 0, -P], [ int(mesh.Nodes - 1), 1, 0, -P / (E * A * alfa) * np.exp(-alfa * L) ]]) print("-------------------------------------------------------") print(" SOLVING") print("-------------------------------------------------------\n") # Solving (U, R, K) = solver.run(mesh, BCs, MaterialSets, parameters) print("------------------------ END --------------------------\n") # Error analysis eps_h = float(0.5 * U.T @ K @ U) e[k, i, j] = np.sqrt((eps[i] - eps_h) / eps[i]) # Plotting if elem_plot == True: plt.figure(j + k * i_max * j_max + i * j_max + 1) plt.plot(mesh.points[:, 0], U, '-xb') true_sol = -P / (E * A * alfa) * np.exp( -alfa * mesh.points[:, 0]) plt.plot(mesh.points[:, 0], true_sol, '-+r')