NSSC/Exercise_04/print_HTP.jl

39 lines
955 B
Julia

using Fmt
function print_HTP(H::Matrix{Float64}, T::Vector{Float64}, P::Vector{Float64}, filename="output.txt")
# Print matrices to .txt-file (name of file = filename).
# H... overall assembled stiffness matrix
# T... nodal temperature vector
# P... nodal force vector
# Make sure, that your system of equations is sorted by
# ascending node numbers, i.e., N1 N2 ... N100.
open(filename, "w") do io
write(io, "Stiffness matrix H: \n")
for row in H
for col in row
outline = f"{$col:+8.4e},"
write(io, f"{$outline:11s}")
end
write(io, "\n")
end
write(io, "Temperature T: \n")
for row in T
for col in row
outline = f"{$col:+8.4e},"
write(io, f"{$outline:11s} \n")
end
end
write(io, "Force vector P: \n")
for row in P
for col in row
outline = f"{$col:+8.4e},"
write(io, f"{$outline:11s} \n")
end
end
end
end