KiranRamesh-Aero / UnsteadyFlowSolvers.jl

Solvers for problems involving unsteady fluid flow
MIT License
22 stars 22 forks source link

makeVortPlots2D() no vorticity plots #47

Open phgelado opened 2 years ago

phgelado commented 2 years ago

Issue: makeVortPlots2D() returns No "Step Files" directory, found by Aidan M.C.

phgelado commented 2 years ago

In -> https://github.com/KiranUofG/UnsteadyFlowSolvers.jl/blob/master/src/plots/plots2D.jl

Line number 32.

try
        cd("Step Files")
    catch
        println(" Error: No 'Step Files' directory. Make sure 'wflag' is enabled before running simulation.")
        return
    end
phgelado commented 2 years ago

In -> https://github.com/KiranUofG/UnsteadyFlowSolvers.jl/blob/master/src/lowOrder2D/postprocess.jl

Line 34 ->

function writeStamp(dirname::String, t::Float64, surf::TwoDSurf, curfield::TwoDFlowField)

    try
        cd("Step Files")
    catch
        mkdir("Step Files")
        cd("Step Files")
    end
phgelado commented 2 years ago

There are two writeStamp functions, one starts in line 34, a second one starts in line 115

KiranRamesh-Aero commented 2 years ago

Looks like line 34 is for single surface, and line 115 for multiple surfaces. The "Step files" part of the code is missing from 115 and needs to be added in.

phgelado commented 2 years ago

Amended the function, added an if to the catch case to avoid creating multiple nested Step Files directories and a missing cd("..").

function writeStamp(dirname::String, t::Float64, surf::Vector{TwoDSurf}, curfield::TwoDFlowField)

    try
        cd("Step Files")
    catch
        if occursin("Step Files",pwd()) == false
            mkdir("Step Files")
            cd("Step Files")
        end
    end

    dirvec = readdir()
    if dirname in dirvec
        rm(dirname, recursive=true)
    end
    mkdir(dirname)
    cd(dirname)

    nsurf = length(surf)
    for i = 1:nsurf
        f = open("timeKinem-$i", "w")
        println(f, "#time \t", "alpha (deg) \t", "h/c \t", "u/uref \t")
        DelimitedFiles.writedlm(f, [t, surf[i].kinem.alpha, surf[i].kinem.h, surf[i].kinem.u]')
        close(f)

        f = open("FourierCoeffs-$i", "w")
        println(f, "#Fourier coeffs (0-n) \t", "d/dt (Fourier coeffs)  ")
        matfour = zeros(surf[i].naterm+1, 2)
        matfour[:,1] = [surf[i].a0[1];surf[i].aterm[:]]
        matfour[:,2] = [surf[i].a0dot[1];surf[i].adot[:]]
        DelimitedFiles.writedlm(f, matfour)
        close(f)

        # f = open("forces", "w")
        # write(f, ["#cl \t", "cd \t", "cm \t", "Gamma \t", "cn \t", "cs \t", "cnc \t",
        #           "cnnc \t", "nonl \t", "cm_n \t", "cm_pvt \t", "nonl_m  "])
        # cl, cd, cm, gamma, cn, cs, cnc, cncc, nonl, cm_n, cm_pvt, nonl_m = calc_forces_more(surf)
        # writedlm(f, [cl, cd, cm, gamma, cn, cs, cnc, cnnc, nonl, cm_n, cm_pvt, nonl_m])
        # close(f)
    end

    f = open("tev", "w")
    println(f, "#strength \t", "x-position \t", "z-position  ")
    tevmat = zeros(length(curfield.tev), 3)
    for i = 1:length(curfield.tev)
        tevmat[i,:] = [curfield.tev[i].s curfield.tev[i].x curfield.tev[i].z]
    end
    DelimitedFiles.writedlm(f, tevmat)
    close(f)

    f = open("lev", "w")
    println(f, "#strength \t", "x-position \t", "z-position  ")
    levmat = zeros(length(curfield.lev), 3)
    levcount = 0
    for i = 1:length(curfield.lev)
        if curfield.lev[i].vc != 0.
            levcount += 1
            levmat[levcount,:] = [curfield.lev[i].s curfield.lev[i].x curfield.lev[i].z]
        end
    end

    levmat = levmat[1:levcount,:]
    DelimitedFiles.writedlm(f, levmat)
    close(f)

    for is = 1:nsurf
        f = open("boundv-$is", "w")
        println(f, "#strength \t", "x-position \t", "z-position  ")
        bvmat = zeros(length(surf[is].bv), 3)
        for i = 1:length(surf[is].bv)
            bvmat[i,:] = [surf[is].bv[i].s surf[is].bv[i].x surf[is].bv[i].z]
        end
        DelimitedFiles.writedlm(f, bvmat)
        close(f)
    end

    cd("..")
    cd("..")
end