Skip to content

Commit

Permalink
initalize inverse_jacobian on gpu
Browse files Browse the repository at this point in the history
  • Loading branch information
jkravs committed Jul 5, 2023
1 parent 8fc47fe commit 3eb35d0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
10 changes: 6 additions & 4 deletions src/solvers/dgsem_tree/containers_2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
#! format: noindent

# Container data structure (structure-of-arrays style) for DG elements
mutable struct ElementContainer2D{RealT <: Real, uEltype <: Real, surfaceFluxArray <: DenseArray{uEltype, 4}, _surfaceFluxArray <: DenseArray{uEltype, 1}} <: AbstractContainer
inverse_jacobian::Vector{RealT} # [elements]
mutable struct ElementContainer2D{RealT <: Real, uEltype <: Real, inverseJacobianArray <: DenseArray{RealT, 1},
surfaceFluxArray <: DenseArray{uEltype, 4},
_surfaceFluxArray <: DenseArray{uEltype, 1}} <: AbstractContainer
inverse_jacobian::inverseJacobianArray # [elements]
node_coordinates::Array{RealT, 4} # [orientation, i, j, elements]
surface_flux_values::surfaceFluxArray # [variables, i, direction, elements]
cell_ids::Vector{Int} # [elements]
Expand Down Expand Up @@ -55,7 +57,7 @@ function ElementContainer2D{RealT, uEltype}(capacity::Integer, n_variables,
arrType = get_array_type(backend)

# Initialize fields with defaults
inverse_jacobian = fill(nan_RealT, capacity)
inverse_jacobian = allocate(backend, RealT, capacity)

_node_coordinates = fill(nan_RealT, 2 * n_nodes * n_nodes * capacity)
node_coordinates = unsafe_wrap(Array, pointer(_node_coordinates),
Expand All @@ -67,7 +69,7 @@ function ElementContainer2D{RealT, uEltype}(capacity::Integer, n_variables,

cell_ids = fill(typemin(Int), capacity)

return ElementContainer2D{RealT, uEltype, arrType{uEltype, 4}, arrType{uEltype, 1}}(inverse_jacobian, node_coordinates,
return ElementContainer2D{RealT, uEltype, arrType{RealT, 1}, arrType{uEltype, 4}, arrType{uEltype, 1}}(inverse_jacobian, node_coordinates,
surface_flux_values, cell_ids,
_node_coordinates, _surface_flux_values)
end
Expand Down
5 changes: 1 addition & 4 deletions src/solvers/dgsem_tree/dg_2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1606,13 +1606,10 @@ function apply_jacobian_gpu!(du, mesh::TreeMesh{2},

kernel! = internal_apply_jacobian_gpu!(backend)

dev_inverse_jacobian = allocate(backend, eltype(inverse_jacobian), size(inverse_jacobian))
copyto!(backend, dev_inverse_jacobian, inverse_jacobian)

num_nodes = nnodes(dg)
num_elements = nelements(cache.elements)

kernel!(du, dev_inverse_jacobian, equations, num_nodes, ndrange=num_elements)
kernel!(du, inverse_jacobian, equations, num_nodes, ndrange=num_elements)

synchronize(backend)

Expand Down

0 comments on commit 3eb35d0

Please sign in to comment.