Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion deprecated/flux.jl
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ function calc_flux!(::Val{0}, ::Val{2}, face::Face, DVM_data::DVM_Data, faceid::
# @show ps_data.neighbor.data[faceid][2].midpoint
# end
fw_test = zeros(DIM + 2)
for i = 1:2^(DIM-1)
for i = 1:(2^(DIM-1))
nps_data = ps_data.neighbor.data[faceid][i]
vs_data_n = nps_data.vs_data
ds = nps_data.ds[dir]
Expand Down
98 changes: 53 additions & 45 deletions lib/P4estTypes/src/connectivity.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ the roots of `Pxest` quadtrees or octrees. The parameter `X` is 4 if the
roots are quads (2D aka p4est) and 8 if they are hexes (3D aka p8est).

# Fields

$(DocStringExtensions.FIELDS)

# Usage
Expand All @@ -15,23 +16,23 @@ $(DocStringExtensions.FIELDS)
Construct a connectivity mesh for the roots of a forest-of-quadtrees using
p4est's built-in mesh connectivities. Valid values for `name` are

- `:unitsquare`: the unit square.
- `:periodic`: all-periodic unit square.
- `:rotwrap`: periodic unit square (the left and right faces are identified,
and bottom and top opposite).
- `:corner`: three-tree mesh around a corner.
- `:pillow`: two trees on top of each other.
- `:moebius`: a five-tree moebius band.
- `:star`: six-tree star.
- `:cubed`: six sides of a unit cube.
- `:disk_nonperiodic`: five-tree flat spherical disk.
- `:icosahedron`: for mapping the sphere using an icosahedron (see
`@doc P4estTypes.P4est.p4est_connectivity_new_icosahedron` for more info).
- `:shell2d`: 2D spherical shell.
- `:disk2d`: maps a 2D disk.


---
- `:unitsquare`: the unit square.
- `:periodic`: all-periodic unit square.
- `:rotwrap`: periodic unit square (the left and right faces are identified,
and bottom and top opposite).
- `:corner`: three-tree mesh around a corner.
- `:pillow`: two trees on top of each other.
- `:moebius`: a five-tree moebius band.
- `:star`: six-tree star.
- `:cubed`: six sides of a unit cube.
- `:disk_nonperiodic`: five-tree flat spherical disk.
- `:icosahedron`: for mapping the sphere using an icosahedron (see
`@doc P4estTypes.P4est.p4est_connectivity_new_icosahedron` for more info).
- `:shell2d`: 2D spherical shell.
- `:disk2d`: maps a 2D disk.

* * *

Connectivity{4}(:disk, periodic_x::Bool, periodic_y::Bool)

Create a connectivity structure for a five-tree flat spherical disk. The
Expand All @@ -40,26 +41,28 @@ the x and y directions, respectively.

See `@doc P4estTypes.P4est.p4est_connectivity_new_disk` for detailed information.

---
* * *

Connectivity{8}(name::Symbol)

Construct a connectivity mesh for the roots of a forest-of-octrees using
p8est's built-in mesh connectivities. Valid values for `name` are

- `:unitcube`: the unit cube.
- `:periodic`: an all-periodic unit cube.
- `:rotcubes`: contains a few cubes (these are rotated against each other to
stress the topology routines).
- `:rotwrap`: a mostly periodic unit cube (see
`@doc P4estTypes.P4est.p8est_connectivity_new_rotwrap`).
- `:shell`: a spherical shell (see
`@doc P4estTypes.P4est.p8est_connectivity_new_shell`).
- `:sphere`: a solid sphere (see
`@doc P4estTypes.P4est.p8est_connectivity_new_sphere`).
- `:twocubes`: two cubes.
- `:twowrap`: two cubes where the two far ends are identified periodically.

---
- `:unitcube`: the unit cube.
- `:periodic`: an all-periodic unit cube.
- `:rotcubes`: contains a few cubes (these are rotated against each other to
stress the topology routines).
- `:rotwrap`: a mostly periodic unit cube (see
`@doc P4estTypes.P4est.p8est_connectivity_new_rotwrap`).
- `:shell`: a spherical shell (see
`@doc P4estTypes.P4est.p8est_connectivity_new_shell`).
- `:sphere`: a solid sphere (see
`@doc P4estTypes.P4est.p8est_connectivity_new_sphere`).
- `:twocubes`: two cubes.
- `:twowrap`: two cubes where the two far ends are identified periodically.

* * *

Connectivity{8}(:torus, nsegments)

Create a connectivity structure that builds a revolution torus. Here
Expand All @@ -68,7 +71,8 @@ Create a connectivity structure that builds a revolution torus. Here
See `@doc P4estTypes.P4est.p8est_connectivity_new_torus` for detailed
information.

---
* * *

Connectivity{8}(:torus, nsegments)

Create a connectivity structure that builds a revolution torus. Here
Expand All @@ -77,7 +81,8 @@ Create a connectivity structure that builds a revolution torus. Here
See `@doc P4estTypes.P4est.p8est_connectivity_new_torus` for detailed
information.

---
* * *

Connectivity{X}(:twotrees, l_face, r_face, orientation) where {X}

Create a connectivity structure (`X=4` for quadtrees and `X=8` for octrees) for
Expand All @@ -86,20 +91,22 @@ two trees being rotated with respect to each other in a user-defined way. Here
respectively. The argument `orientation` gives the orientation code of the
trees with respect to each other.

---
* * *

Connectivity{X}(vertices, elements) where {X}

Creates a connectivity from the given list of vertices and element-to-vertex
connectivity. The parameter set to `X=4` is for quads and `X=8` for hexes.

- `vertices`: should be a number-of-vertices by 3 matrix where the columns
correspond to x, y, and z coordinates (typically the `z` coordinate will be
zero for a 2D forest).
- `elements`: should be a number-of-vertices by 4 or 8 matrix where the columns
vertex indices used to define each element. Note that z-ordering should be
used, and it should use zero-indexing.
- `vertices`: should be a number-of-vertices by 3 matrix where the columns
correspond to x, y, and z coordinates (typically the `z` coordinate will be
zero for a 2D forest).
- `elements`: should be a number-of-vertices by 4 or 8 matrix where the columns
vertex indices used to define each element. Note that z-ordering should be
used, and it should use zero-indexing.

* * *

---
Connectivity{X}(filename::String) where {X}

Create a connectivity from an ABAQUS input at `filename`. The parameter set to
Expand All @@ -110,9 +117,10 @@ See `@doc P4estTypes.P4est.p4est_connectivity_read_inp` and
files.

# See also
- [`brick`](@ref): a function to create a rectangular [`Connectivity`](@ref).
- [`connectivity`](@ref): a function to get the connectivity of a [`Pxest`](@ref).
- [`refine`](@ref): a function to create a refined [`Connectivity`](@ref).

- [`brick`](@ref): a function to create a rectangular [`Connectivity`](@ref).
- [`connectivity`](@ref): a function to get the connectivity of a [`Pxest`](@ref).
- [`refine`](@ref): a function to create a refined [`Connectivity`](@ref).
"""
mutable struct Connectivity{X,P}
"""The pointer (of type `P`) can be a pointer to either a
Expand Down
4 changes: 3 additions & 1 deletion lib/P4estTypes/src/ghost.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ for a `Pxest{X}`. Also stores the corresponding local domain quadrants,
mirrors, that are in other rank's ghost layers.

# Fields

$(DocStringExtensions.FIELDS)

# See also
- [`ghostlayer`](@ref): a function used to construct a `GhostLayer`

- [`ghostlayer`](@ref): a function used to construct a `GhostLayer`
"""
mutable struct GhostLayer{X,P}
"""The pointer (of type `P`) can be a pointer to either a
Expand Down
4 changes: 3 additions & 1 deletion lib/P4estTypes/src/lnodes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
Stores a parallel numbering of Lobatto nodes for a `Pxest{X}`.

# Fields

$(DocStringExtensions.FIELDS)

# See also
- [`lnodes`](@ref): a function used to construct `LNodes`

- [`lnodes`](@ref): a function used to construct `LNodes`
"""
mutable struct LNodes{X,P}
"""The pointer (of type `P`) can be a pointer to either a
Expand Down
24 changes: 14 additions & 10 deletions lib/P4estTypes/src/pxest.jl
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ and `X=8` indicates an octant; quadrant is used both as the general
term and the term for the 2D object).

# Fields

$(DocStringExtensions.FIELDS)
"""
struct QuadrantWrapper{X,P}
Expand Down Expand Up @@ -308,6 +309,7 @@ end
Stores the quadrants in a tree of a Pxest{X}.

# Fields

$(DocStringExtensions.FIELDS)
"""
struct Tree{X,P,Q} <: AbstractArray{QuadrantWrapper,1}
Expand Down Expand Up @@ -357,19 +359,21 @@ So, each rank will only have access to the quadrants it owns.) Second, using
forest via callback functions.

# Fields

$(DocStringExtensions.FIELDS)

# See also
- [`pxest`](@ref): a function that constructs a `Pxest` from a [`Connectivity`](@ref).
- [`iterateforest`](@ref): a function to iterate over the volumes, faces, edges, and
corners of the forest.
- [`refine!`](@ref): refine the quadrants of the forest.
- [`coarsen!`](@ref): coarsen the quadrants of the forest.
- [`balance!`](@ref): two-to-one balance the quadrants of the forest.
- [`partition!`](@ref): partition the quadrants of the forest.
- [`ghostlayer`](@ref): get the ghost layer of quadrants for the forest.
- [`lnodes`](@ref): get a global node numbering.
- [`P4estTypes.savevtk`](@ref): save a VTK representation of the forest.

- [`pxest`](@ref): a function that constructs a `Pxest` from a [`Connectivity`](@ref).
- [`iterateforest`](@ref): a function to iterate over the volumes, faces, edges, and
corners of the forest.
- [`refine!`](@ref): refine the quadrants of the forest.
- [`coarsen!`](@ref): coarsen the quadrants of the forest.
- [`balance!`](@ref): two-to-one balance the quadrants of the forest.
- [`partition!`](@ref): partition the quadrants of the forest.
- [`ghostlayer`](@ref): get the ghost layer of quadrants for the forest.
- [`lnodes`](@ref): get a global node numbering.
- [`P4estTypes.savevtk`](@ref): save a VTK representation of the forest.
"""
mutable struct Pxest{X,P,C} <: AbstractArray{Tree,1}
"""The pointer (of type `P`) can be a pointer to either a
Expand Down
3 changes: 2 additions & 1 deletion lib/P4estTypes/test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ mktempdir() do tmp_dir
@test success(pipeline(cmd, stderr = stderr, stdout = stdout))

@testset "$f" for f in testfiles
cmd = `$(mpiexec()) -n $nprocs $(Base.julia_cmd()) --startup-file=no --project=$tmp_project $(joinpath(test_dir, f))`
cmd =
`$(mpiexec()) -n $nprocs $(Base.julia_cmd()) --startup-file=no --project=$tmp_project $(joinpath(test_dir, f))`
@test success(pipeline(cmd, stderr = stderr, stdout = stdout))
end
end
10 changes: 5 additions & 5 deletions src/adaptive.jl
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ function replace_PS(::Val{1}, out_quad, in_quads, which_tree, DVM_data::DVM_Data
)
index = findfirst(x -> x === Odata, datas)
deleteat!(datas, index)
for i = 1:2^DIM
for i = 1:(2^DIM)
pw_in_quad = PointerWrapper(in_quads[i])
dp = PointerWrapper(P4est_PS_Data, pw_in_quad.p.user_data[])
ps_data = PS_copy(Odata)
Expand All @@ -96,7 +96,7 @@ function replace_PS(::Val{2^DIM}, out_quad, in_quads, which_tree, DVM_data::DVM_
pw_in_quad = PointerWrapper(in_quads[1])
dp = PointerWrapper(P4est_PS_Data, pw_in_quad.p.user_data[])
Odatas = Vector{PS_Data}(undef, 2^DIM)
for i = 1:2^DIM
for i = 1:(2^DIM)
pw_out_quad = PointerWrapper(out_quad[i])
Odatas[i] = unsafe_pointer_to_objref(
pointer(PointerWrapper(P4est_PS_Data, pw_out_quad.p.user_data[]).ps_data),
Expand All @@ -114,7 +114,7 @@ function replace_PS(::Val{2^DIM}, out_quad, in_quads, which_tree, DVM_data::DVM_
end
ps_data.ds .*= 2.0
index = findfirst(x -> x === Odatas[1], datas)
deleteat!(datas, index:index+2^DIM-1)
deleteat!(datas, index:(index+2^DIM-1))
insert!(datas, index, ps_data)
dp[] = P4est_PS_Data(pointer_from_objref(ps_data))
end
Expand Down Expand Up @@ -159,7 +159,7 @@ end
function coarsen_flag_PS(ps_datas::Vector{PS_Data}, levels::Vector{Int}, DVM_data::DVM_Data)
global_data = DVM_data.global_data
flag = Cint(1)
for i = 1:2^DIM
for i = 1:(2^DIM)
if boundary_flag(DVM_data, ps_datas[i])
return Cint(0)
end
Expand All @@ -181,7 +181,7 @@ function p4est_coarsen_flag(forest::Ptr{p4est_t}, which_tree, quadrants)
quadrants_wrap = unsafe_wrap(Vector{Ptr{p4est_quadrant_t}}, quadrants, 2^DIM)
levels = Vector{Int}(undef, 2^DIM)
ps_datas = Vector{PS_Data}(undef, 2^DIM)
for i = 1:2^DIM
for i = 1:(2^DIM)
qp = PointerWrapper(quadrants_wrap[i])
dp = PointerWrapper(P4est_PS_Data, qp.p.user_data[])
levels[i] = qp.level[]
Expand Down
4 changes: 2 additions & 2 deletions src/connectivity.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ function Cartesian_connectivity(Nx, Ny, xmin, xmax, ymin, ymax)
vertices_C = Array{NTuple{2,Float64}}(undef, Nx + 1, Ny + 1)
dx = (xmax - xmin) / Nx
dy = (ymax - ymin) / Ny
for j = 1:Ny+1
for i = 1:Nx+1
for j = 1:(Ny+1)
for i = 1:(Nx+1)
vertices_C[i, j] = (xmin + (i - 1) * dx, ymin + (j - 1) * dy)
end
end
Expand Down
2 changes: 1 addition & 1 deletion src/flux_interp_t.jl
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ function calc_flux!(::Val{0}, ::Val{2}, face::Face, DVM_data::DVM_Data, faceid::
rot = get_rot(faceid) # Left: -1, Right: 1
gas = DVM_data.global_data.gas
vs_data = ps_data.vs_data
for i = 1:2^(DIM-1)
for i = 1:(2^(DIM-1))
nps_data = ps_data.neighbor.data[faceid][i]
vs_data_n = nps_data.vs_data
ds = nps_data.ds[dir]
Expand Down
14 changes: 7 additions & 7 deletions src/ghost.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ end
function get_mirror_data_inner!(ps_data::PS_Data, vs_temp::AV)
vs_data = ps_data.vs_data
vs_num = vs_data.vs_num
vs_temp[1:NDF*vs_num] .= reshape(vs_data.df, vs_num * NDF)
vs_temp[1:(NDF*vs_num)] .= reshape(vs_data.df, vs_num * NDF)
end
function get_mirror_data(ps4est, global_data)
GC.@preserve ps4est global_data begin
Expand All @@ -46,10 +46,10 @@ function get_mirror_data(ps4est, global_data)
ap = Base.unsafe_wrap(Vector{Cdouble}, p, 3 * DIM + 3 + NDF * vs_num)
offset = 0
ap[1:(offset+=DIM)] .= ps_data.ds
ap[offset+1:(offset+=DIM)] .= ps_data.midpoint
ap[offset+1:(offset+=DIM+2)] .= ps_data.w
ap[(offset+1):(offset+=DIM)] .= ps_data.midpoint
ap[(offset+1):(offset+=DIM+2)] .= ps_data.w
ap[offset+=1] = ps_data.vs_data.vs_num
vs_temp = @view(ap[offset+1:(offset+=NDF*vs_num)])
vs_temp = @view(ap[(offset+1):(offset+=NDF*vs_num)])
get_mirror_data_inner!(ps_data, vs_temp)
mirror_data_pointers[i] = p
end
Expand Down Expand Up @@ -112,8 +112,8 @@ function get_mirror_structure(ps4est, global_data::Global_Data)
p = Ptr{Cdouble}(sc_malloc(-1, vs_num * (DIM + 2) * sizeof(Cdouble)))
ap = Base.unsafe_wrap(Vector{Cdouble}, p, vs_num * (DIM + 2))
weight_temp = @view(ap[1:vs_num])
level_temp = @view(ap[vs_num+1:vs_num*2])
midpoint_temp = @view(ap[vs_num*2+1:vs_num*(DIM+2)])
level_temp = @view(ap[(vs_num+1):(vs_num*2)])
midpoint_temp = @view(ap[(vs_num*2+1):(vs_num*(DIM+2))])
get_mirror_structure_inner!(ps_data, weight_temp, level_temp, midpoint_temp)
mirror_structure_pointers[i] = p
end
Expand Down Expand Up @@ -141,7 +141,7 @@ function update_mirror_data!(ps4est, DVM_data::DVM_Data)
mirror_data_pointers[i],
3 * DIM + 3 + NDF * vs_num,
)
vs_temp = @view(ap[3*DIM+3+1:end])
vs_temp = @view(ap[(3*DIM+3+1):end])
get_mirror_data_inner!(ps_data, vs_temp)
end
end
Expand Down
Loading