Path: blob/main/src/solvers/dgsem_tree/container_parabolic_1d.jl
5591 views
mutable struct ParabolicContainer1D{uEltype <: Real}1u_transformed::Array{uEltype, 3}2gradients::Array{uEltype, 3}3flux_parabolic::Array{uEltype, 3}45# internal `resize!`able storage6_u_transformed::Vector{uEltype}7_gradients::Vector{uEltype}8_flux_parabolic::Vector{uEltype}910function ParabolicContainer1D{uEltype}(n_vars::Integer, n_nodes::Integer,11n_elements::Integer) where {uEltype <: Real}12return new(Array{uEltype, 3}(undef, n_vars, n_nodes, n_elements),13Array{uEltype, 3}(undef, n_vars, n_nodes, n_elements),14Array{uEltype, 3}(undef, n_vars, n_nodes, n_elements),15Vector{uEltype}(undef, n_vars * n_nodes * n_elements),16Vector{uEltype}(undef, n_vars * n_nodes * n_elements),17Vector{uEltype}(undef, n_vars * n_nodes * n_elements))18end19end2021function init_parabolic_container_1d(n_vars::Integer, n_nodes::Integer,22n_elements::Integer,23::Type{uEltype}) where {uEltype <: Real}24return ParabolicContainer1D{uEltype}(n_vars, n_nodes, n_elements)25end2627# Only one-dimensional `Array`s are `resize!`able in Julia.28# Hence, we use `Vector`s as internal storage and `resize!`29# them whenever needed. Then, we reuse the same memory by30# `unsafe_wrap`ping multi-dimensional `Array`s around the31# internal storage.32function Base.resize!(parabolic_container::ParabolicContainer1D, equations, dg, cache)33capacity = nvariables(equations) * nnodes(dg) * nelements(dg, cache)34resize!(parabolic_container._u_transformed, capacity)35resize!(parabolic_container._gradients, capacity)36resize!(parabolic_container._flux_parabolic, capacity)3738parabolic_container.u_transformed = unsafe_wrap(Array,39pointer(parabolic_container._u_transformed),40(nvariables(equations),41nnodes(dg),42nelements(dg, cache)))4344parabolic_container.gradients = unsafe_wrap(Array,45pointer(parabolic_container._gradients),46(nvariables(equations),47nnodes(dg),48nelements(dg, cache)))4950parabolic_container.flux_parabolic = unsafe_wrap(Array,51pointer(parabolic_container._flux_parabolic),52(nvariables(equations),53nnodes(dg),54nelements(dg, cache)))5556return nothing57end585960