Skip to content

Commit

Permalink
Bump meshes (#44)
Browse files Browse the repository at this point in the history
* Rename coordinates to coords in Meshes v0.43

* Vec2 -> Vec

* Adapt to Point access change

* Bump patch
  • Loading branch information
henry2004y authored May 26, 2024
1 parent 499acce commit d9b814d
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 23 deletions.
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "FieldTracer"
uuid = "05065131-34d1-456a-ba22-faf972bb2934"
authors = ["Hongyang Zhou <[email protected]>"]
version = "0.1.12"
version = "0.1.13"

[deps]
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Expand All @@ -10,7 +10,7 @@ MuladdMacro = "46d2c3a1-f734-5fdb-9937-b9b9aeba4221"
Requires = "ae029012-a4dd-5104-9daa-d747884805df"

[compat]
Meshes = "0.30, 0.31, 0.32, 0.33, 0.34, 0.35, 0.36, 0.37, 0.38, 0.39, 0.40, 0.41, 0.42, 0.43"
Meshes = "0.43"
MuladdMacro = "0.2"
Requires = "1.1"
julia = "1.6"
Expand Down
8 changes: 4 additions & 4 deletions src/structured2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -288,12 +288,12 @@ end
function trace2d_euler(fieldx, fieldy, startx, starty, grid::CartesianGrid;
kwargs...)

gridmin = coordinates(minimum(grid))
gridmax = coordinates(maximum(grid))
gridmin = coords(minimum(grid))
gridmax = coords(maximum(grid))
Δx = spacing(grid)

gridx = range(gridmin[1], gridmax[1], step=Δx[1])
gridy = range(gridmin[2], gridmax[2], step=Δx[2])
gridx = range(gridmin.x.val, gridmax.x.val, step=Δx[1].val)
gridy = range(gridmin.y.val, gridmax.y.val, step=Δx[2].val)

trace2d_euler(fieldx, fieldy, startx, starty, gridx, gridy; kwargs...)
end
20 changes: 10 additions & 10 deletions src/structured3d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -324,13 +324,13 @@ See also [`trace3d_rk4`](@ref).
function trace3d_euler(fieldx::F, fieldy::F, fieldz::F, startx::T, starty::T, startz::T,
grid::CartesianGrid; kwargs...) where {F, T}

gridmin = coordinates(minimum(grid))
gridmax = coordinates(maximum(grid))
gridmin = coords(minimum(grid))
gridmax = coords(maximum(grid))
Δx = spacing(grid)

gridx = range(gridmin[1], gridmax[1], step=Δx[1])
gridy = range(gridmin[2], gridmax[2], step=Δx[2])
gridz = range(gridmin[3], gridmax[3], step=Δx[3])
gridx = range(gridmin.x.val, gridmax.x.val, step=Δx[1].val)
gridy = range(gridmin.y.val, gridmax.y.val, step=Δx[2].val)
gridz = range(gridmin.z.val, gridmax.z.val, step=Δx[3].val)

trace3d_euler(fieldx, fieldy, fieldz, startx, starty, startz, gridx, gridy, gridz;
kwargs...)
Expand All @@ -345,13 +345,13 @@ See also [`trace3d_euler`](@ref).
function trace3d_rk4(fieldx::F, fieldy::F, fieldz::F, startx::T, starty::T, startz::T,
grid::CartesianGrid; kwargs...) where {F, T}

gridmin = coordinates(minimum(grid))
gridmax = coordinates(maximum(grid))
gridmin = coords(minimum(grid))
gridmax = coords(maximum(grid))
Δx = spacing(grid)

gridx = range(gridmin[1], gridmax[1], step=Δx[1])
gridy = range(gridmin[2], gridmax[2], step=Δx[2])
gridz = range(gridmin[3], gridmax[3], step=Δx[3])
gridx = range(gridmin.x.val, gridmax.x.val, step=Δx[1].val)
gridy = range(gridmin.y.val, gridmax.y.val, step=Δx[2].val)
gridz = range(gridmin.z.val, gridmax.z.val, step=Δx[3].val)

trace3d_rk4(fieldx, fieldy, fieldz, startx, starty, startz, gridx, gridy, gridz;
kwargs...)
Expand Down
12 changes: 6 additions & 6 deletions src/unstructured2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function trace(mesh::SimpleMesh, vx::Vector{TV}, vy::Vector{TV},
cellIDNew = 0

for it in 1:maxIter
Pfar = Pnow + Vec2(TX(vx[cellID]*Δ), TX(vy[cellID]*Δ))
Pfar = Pnow + Vec(TX(vx[cellID]*Δ), TX(vy[cellID]*Δ))
element = getelement(mesh, cellID)

if mesh[cellID] isa Quadrangle
Expand All @@ -39,20 +39,20 @@ function trace(mesh::SimpleMesh, vx::Vector{TV}, vy::Vector{TV},
j = i % nEdge + 1
P = Segment(element.vertices[i], element.vertices[j]) ray
if P isa Point
P⁺ = P + Vec2(TX(vx[cellID]*ϵ), TX(vy[cellID]*ϵ))
P⁺ = P + Vec(TX(vx[cellID]*ϵ), TX(vy[cellID]*ϵ))
cellIDNew = getCellID(mesh, P⁺)
break
elseif P isa Segment
P⁺ = element.vertices[j] + Vec2(TX(vx[cellID]*ϵ), TX(vy[cellID]*ϵ))
P⁺ = element.vertices[j] + Vec(TX(vx[cellID]*ϵ), TX(vy[cellID]*ϵ))
cellIDNew = getCellID(mesh, P⁺)
break
end
end

Pnow = P⁺

xStream[iS][it+1] = Pnow.coords[1]
yStream[iS][it+1] = Pnow.coords[2]
xStream[iS][it+1] = Pnow.coords.x.val
yStream[iS][it+1] = Pnow.coords.y.val
nIter[iS] = it+1

if cellIDNew == 0 # hit the boundary
Expand All @@ -72,7 +72,7 @@ function trace(mesh::SimpleMesh, vx::Vector{TV}, vy::Vector{TV},
end

"Return cell ID on the unstructured mesh."
function getCellID(mesh::SimpleMesh, point::Point2)
function getCellID(mesh::SimpleMesh, point::Point)
for (i, element) in enumerate(elements(mesh))
if point element
return i
Expand Down
2 changes: 1 addition & 1 deletion test/test_unstructured.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function test_trace_unstructured2D()
coords[:,8] = [3, 3]
coords[:,9] = [4, 3]

points = Point2[coords[:,i] for i in 1:size(coords,2)]
points = [Point(coords[:,i]...) for i in 1:size(coords,2)]
tris = connect.([(2,3,9), (5,8,7), (5,2,8), (2,9,8)], Triangle)
quads = connect.([(1,2,5,4),(4,5,7,6)], Quadrangle)
mesh = SimpleMesh(points, [tris; quads])
Expand Down

2 comments on commit d9b814d

@henry2004y
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/107700

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.1.13 -m "<description of version>" d9b814d12d29e5009fac5e60cf349fc3c4ddbf61
git push origin v0.1.13

Please sign in to comment.