Skip to content

Curl Operation #163

@anthony-meza

Description

@anthony-meza

"""
curl(u::MeshArray,v::MeshArray,Γ::NamedTuple)
Compute curl of a velocity field.
"""
function curl(u::MeshArray,v::MeshArray::NamedTuple)
uvcurl=similar.XC)
fac=exchange(1.0 ./Γ.RAZ,1)
(U,V)=exchange(u,v,1)
(DXC,DYC)=exchange.DXC,Γ.DYC,1)
[DXC.MA[i].=abs.(DXC.MA[i]) for i in eachindex(U.MA)]
[DYC.MA[i].=abs.(DYC.MA[i]) for i in eachindex(V.MA)]
for i in eachindex(U.MA)
ucur=U.MA[i][2:end,:]
vcur=V.MA[i][:,2:end]
tmpcurl=ucur[:,1:end-1]-ucur[:,2:end]
tmpcurl=tmpcurl-(vcur[1:end-1,:]-vcur[2:end,:])
tmpcurl=tmpcurl.*fac.MA[i][1:end-1,1:end-1]
##still needed:
##- deal with corners
##- if putCurlOnTpoints
tmpcurl=1/4*(tmpcurl[1:end-1,2:end]+tmpcurl[1:end-1,1:end-1]+
tmpcurl[2:end,2:end]+tmpcurl[2:end,1:end-1])
uvcurl[i]=tmpcurl
end
return uvcurl
end

Should U and V fields be weighted by some distance before computing the curl?

E.g.,

[DXC[i].=abs.(DXC[i]) for i in eachindex(U)]
[DYC[i].=abs.(DYC[i]) for i in eachindex(V)]

#not currently in code
U_DY = U .* DYC #weight by length of opposing side
V_DX = V .* DXC

###compute curl afterward###

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions