Giter Club home page Giter Club logo

Comments (5)

weymouth avatar weymouth commented on August 18, 2024

What have you tried? You should be able to just define each body with is open map and then add them together...

from waterlily.jl.

KunalGhoshGitHub avatar KunalGhoshGitHub commented on August 18, 2024

Firstly, thank you for your time.

Actually, I was experimenting with one of the examples given (TwoD_cylinderVIV.jl).

I tried to define two bars (sdf_1 and sdf_2) but I am unable to figure out how to give two separate map functions to them.

Here is the modified code:

required to keep things global

let
# parameters
amp=π/4
ϵ=0.5
thk=2ϵ+√2
Re = 250; U = 1
p = 5; L = 2^p
radius = L/2

T = 4*radius    # VIV period

# initial condition FSI
p0=radius/3; v0=0.1*L; a0=0; t0=0

# motion function uses global var to adjust
posx(t) = p0 + (t-t0)*v0

function sdf_1(x,t)
    √sum(abs2,(2*L >= x[1] .> L) ? ((1.0*x[2] - L)) : x ) - thk/2
end

function sdf_2(x,t)
    √sum(abs2,(2*L <= x[1] .< 3*L) ? (x[1] .- (2.0*x[2])) : x ) - thk/2
end

sdf_list = [sdf_1,sdf_2]

function map(x,t)
    α = amp*cos(t*U/L); R = SA[cos(α) sin(α); -sin(α) cos(α)]
    R * (x - SA[3L-L*sin(0*t*U/L),4L])
end

body = AutoBody(map) do x,t  # signed distance function
        minimum(sdf_list) do SDF
            SDF(x,t)
        end
    end

# generate sim
sim = Simulation((10L,10L), (U,0), radius; ν=U*radius/Re, body=body)

# get start time
duration=10; step=0.1; t₀=round(sim_time(sim))

@time @gif for tᵢ in range(t₀,t₀+duration;step)

    # update until time tᵢ in the background
    t = sum(sim.flow.Δt[1:end-1])
    while t < tᵢ*sim.L/sim.U

        # measure body
        measure!(sim,t)

        # update flow
        mom_step!(sim.flow,sim.pois)
        
        Δt = sim.flow.Δt[end]
        p0 += Δt*v0 
        t0 = t; t += Δt
    end

    # plot vorticity
    @inside sim.flow.σ[I] = WaterLily.curl(3,I,sim.flow.u)*sim.L/sim.U
    flood(sim.flow.σ; shift=(-0.5,-0.5),clims=(-5,5))
    body_plot!(sim); plot!(title="tU/L $tᵢ")
    
    # print time step
    println("tU/L=",round(tᵢ,digits=4),", Δt=",round(sim.flow.Δt[end],digits=3))
end

end

from waterlily.jl.

weymouth avatar weymouth commented on August 18, 2024

That's not a good example for applying two simple mappings. Take a look at #35. You just need to do something like:

using WaterLily,StaticArrays
function two_circles(n,m;Re=250,U=1)
    body1 = AutoBody((x,t)->√(x'*x) - m/8, map=(x,t)->x .- m/3 - SA_F32[t,0])
    body2 = AutoBody((x,t)->√(x'*x) - m/6, map=(x,t)->x .- 2m/3 + SA_F32[t,0])
    Simulation((n,m), (U,0), radius; ν=U*radius/Re, body=body1+body2)
end

I've created two maps with two different SDFs and maps. Then the body is just the sum of the two.

from waterlily.jl.

weymouth avatar weymouth commented on August 18, 2024

I assume you figured it out...

from waterlily.jl.

KunalGhoshGitHub avatar KunalGhoshGitHub commented on August 18, 2024

Respected sir,

Yes, sir, I had figured it out. Thank you for the help.

Thank you for your time and consideration.

Yours sincerely,
Kunal Ghosh

from waterlily.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.