Path: blob/main/src/solvers/dgsem_tree/container_parabolic_3d.jl
5591 views
mutable struct ParabolicContainer3D{uEltype <: Real}1u_transformed::Array{uEltype, 5}2gradients::NTuple{3, Array{uEltype, 5}}3flux_parabolic::NTuple{3, Array{uEltype, 5}}45# internal `resize!`able storage6_u_transformed::Vector{uEltype}7# Use Tuple for outer, fixed-size datastructure8_gradients::Tuple{Vector{uEltype}, Vector{uEltype}, Vector{uEltype}}9_flux_parabolic::Tuple{Vector{uEltype}, Vector{uEltype}, Vector{uEltype}}1011function ParabolicContainer3D{uEltype}(n_vars::Integer, n_nodes::Integer,12n_elements::Integer) where {uEltype <: Real}13return new(Array{uEltype, 5}(undef, n_vars, n_nodes, n_nodes, n_nodes, n_elements), # `u_transformed`14# `gradients`15(Array{uEltype, 5}(undef, n_vars, n_nodes, n_nodes, n_nodes, n_elements),16Array{uEltype, 5}(undef, n_vars, n_nodes, n_nodes, n_nodes, n_elements),17Array{uEltype, 5}(undef, n_vars, n_nodes, n_nodes, n_nodes, n_elements)),18# `flux_parabolic`19(Array{uEltype, 5}(undef, n_vars, n_nodes, n_nodes, n_nodes, n_elements),20Array{uEltype, 5}(undef, n_vars, n_nodes, n_nodes, n_nodes, n_elements),21Array{uEltype, 5}(undef, n_vars, n_nodes, n_nodes, n_nodes, n_elements)),22# `u_transformed`23Vector{uEltype}(undef, n_vars * n_nodes^3 * n_elements),24# `_gradients`25(Vector{uEltype}(undef, n_vars * n_nodes^3 * n_elements),26Vector{uEltype}(undef, n_vars * n_nodes^3 * n_elements),27Vector{uEltype}(undef, n_vars * n_nodes^3 * n_elements)),28# `_flux_parabolic`29(Vector{uEltype}(undef, n_vars * n_nodes^3 * n_elements),30Vector{uEltype}(undef, n_vars * n_nodes^3 * n_elements),31Vector{uEltype}(undef, n_vars * n_nodes^3 * n_elements)))32end33end3435function init_parabolic_container_3d(n_vars::Integer, n_nodes::Integer,36n_elements::Integer,37::Type{uEltype}) where {uEltype <: Real}38return ParabolicContainer3D{uEltype}(n_vars, n_nodes, n_elements)39end4041# Only one-dimensional `Array`s are `resize!`able in Julia.42# Hence, we use `Vector`s as internal storage and `resize!`43# them whenever needed. Then, we reuse the same memory by44# `unsafe_wrap`ping multi-dimensional `Array`s around the45# internal storage.46function Base.resize!(parabolic_container::ParabolicContainer3D, equations, dg, cache)47capacity = nvariables(equations) * nnodes(dg)^3 * nelements(dg, cache)48resize!(parabolic_container._u_transformed, capacity)49for dim in 1:350resize!(parabolic_container._gradients[dim], capacity)51resize!(parabolic_container._flux_parabolic[dim], capacity)52end5354parabolic_container.u_transformed = unsafe_wrap(Array,55pointer(parabolic_container._u_transformed),56(nvariables(equations),57nnodes(dg), nnodes(dg), nnodes(dg),58nelements(dg, cache)))5960gradients_1 = unsafe_wrap(Array,61pointer(parabolic_container._gradients[1]),62(nvariables(equations),63nnodes(dg), nnodes(dg), nnodes(dg),64nelements(dg, cache)))65gradients_2 = unsafe_wrap(Array,66pointer(parabolic_container._gradients[2]),67(nvariables(equations),68nnodes(dg), nnodes(dg), nnodes(dg),69nelements(dg, cache)))70gradients_3 = unsafe_wrap(Array,71pointer(parabolic_container._gradients[3]),72(nvariables(equations),73nnodes(dg), nnodes(dg), nnodes(dg),74nelements(dg, cache)))7576parabolic_container.gradients = (gradients_1, gradients_2, gradients_3)7778flux_parabolic_1 = unsafe_wrap(Array,79pointer(parabolic_container._flux_parabolic[1]),80(nvariables(equations),81nnodes(dg), nnodes(dg), nnodes(dg),82nelements(dg, cache)))83flux_parabolic_2 = unsafe_wrap(Array,84pointer(parabolic_container._flux_parabolic[2]),85(nvariables(equations),86nnodes(dg), nnodes(dg), nnodes(dg),87nelements(dg, cache)))88flux_parabolic_3 = unsafe_wrap(Array,89pointer(parabolic_container._flux_parabolic[3]),90(nvariables(equations),91nnodes(dg), nnodes(dg), nnodes(dg),92nelements(dg, cache)))9394parabolic_container.flux_parabolic = (flux_parabolic_1, flux_parabolic_2,95flux_parabolic_3)9697return nothing98end99100101