Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

p4est solver on a spherical mesh #25

Merged
merged 8 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
6 changes: 5 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "TrixiAtmo"
uuid = "c9ed1054-d170-44a9-8ee2-d5566f5d1389"
authors = ["Benedict Geihe <bgeihe@uni-koeln.de>", "Tristan Montoya <montoya.tristan@gmail.com>", "Hendrik Ranocha <hendrik.ranocha@uni-mainz.de>", "Michael Schlottke-Lakemper <michael@sloede.com>"]
authors = ["Benedict Geihe <bgeihe@uni-koeln.de>", "Tristan Montoya <montoya.tristan@gmail.com>", "Hendrik Ranocha <hendrik.ranocha@uni-mainz.de>", "Andrés Rueda-Ramírez <aruedara@uni-koeln.de>", "Michael Schlottke-Lakemper <michael@sloede.com>"]
version = "0.1.0-DEV"

[deps]
Expand All @@ -9,6 +9,8 @@ MuladdMacro = "46d2c3a1-f734-5fdb-9937-b9b9aeba4221"
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
Static = "aedffcd0-7271-4cad-89d0-dc628f76c6d3"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
StaticArrayInterface = "0d7ed370-da01-4f52-bd93-41d350b8b718"
StrideArrays = "d1fa6d79-ef01-42a6-86c9-f7c551f8593b"
Trixi = "a7f1ee26-1774-49b1-8366-f1abc58fbfcb"

[compat]
Expand All @@ -17,5 +19,7 @@ MuladdMacro = "0.2.2"
Reexport = "1.0"
Static = "0.8, 1"
StaticArrays = "1"
StaticArrayInterface = "1.5.1"
StrideArrays = "0.1.28"
Trixi = "0.7, 0.8"
julia = "1.9"
4 changes: 4 additions & 0 deletions src/TrixiAtmo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,16 @@ using Trixi
using MuladdMacro: @muladd
using StaticArrays: SVector
using Static: True, False
using StrideArrays: PtrArray
using StaticArrayInterface: static_size
using LinearAlgebra: norm
using Reexport: @reexport
@reexport using StaticArrays: SVector

include("auxiliary/auxiliary.jl")
include("equations/equations.jl")
include("meshes/meshes.jl")
include("solvers/solvers.jl")

export CompressibleMoistEulerEquations2D

Expand Down
2 changes: 2 additions & 0 deletions src/meshes/meshes.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export P4estMeshCubedSphere2D
include("p4est_cubed_sphere.jl")
312 changes: 312 additions & 0 deletions src/meshes/p4est_cubed_sphere.jl

Large diffs are not rendered by default.

258 changes: 258 additions & 0 deletions src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,258 @@
@muladd begin
#! format: noindent

# New p4est element container that allows the use of a PtrArray for the contravariant_vectors
mutable struct P4estElementContainerPtrArray{NDIMS, RealT <: Real, uEltype <: Real,
NDIMSP1,
NDIMSP2, NDIMSP3,
ContravariantVectors <:
AbstractArray{RealT, NDIMSP3}} <:
Trixi.AbstractContainer
# Physical coordinates at each node
node_coordinates::Array{RealT, NDIMSP2} # [orientation, node_i, node_j, node_k, element]
# Jacobian matrix of the transformation
# [jacobian_i, jacobian_j, node_i, node_j, node_k, element] where jacobian_i is the first index of the Jacobian matrix,...
jacobian_matrix::Array{RealT, NDIMSP3}
# Contravariant vectors, scaled by J, in Kopriva's blue book called Ja^i_n (i index, n dimension)
contravariant_vectors::ContravariantVectors # [dimension, index, node_i, node_j, node_k, element]
# 1/J where J is the Jacobian determinant (determinant of Jacobian matrix)
inverse_jacobian::Array{RealT, NDIMSP1} # [node_i, node_j, node_k, element]
# Buffer for calculated surface flux
surface_flux_values::Array{uEltype, NDIMSP2} # [variable, i, j, direction, element]

# internal `resize!`able storage
_node_coordinates::Vector{RealT}
_jacobian_matrix::Vector{RealT}
_contravariant_vectors::Vector{RealT}
_inverse_jacobian::Vector{RealT}
_surface_flux_values::Vector{uEltype}
end

@inline function nelements(elements::P4estElementContainerPtrArray)
amrueda marked this conversation as resolved.
Show resolved Hide resolved
size(elements.node_coordinates, ndims(elements) + 2)

Check warning on line 32 in src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl

View check run for this annotation

Codecov / codecov/patch

src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl#L31-L32

Added lines #L31 - L32 were not covered by tests
end
@inline Base.ndims(::P4estElementContainerPtrArray{NDIMS}) where {NDIMS} = NDIMS
@inline function Base.eltype(::P4estElementContainerPtrArray{NDIMS, RealT, uEltype}) where {

Check warning on line 35 in src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl

View check run for this annotation

Codecov / codecov/patch

src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl#L34-L35

Added lines #L34 - L35 were not covered by tests
NDIMS,
RealT,
uEltype
}
uEltype

Check warning on line 40 in src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl

View check run for this annotation

Codecov / codecov/patch

src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl#L40

Added line #L40 was not covered by tests
end

# Create element container and initialize element data.
# This function dispatches on the dimensions of the mesh and the equation (AbstractEquations{3})
function Trixi.init_elements(mesh::Union{P4estMesh{2, RealT},

Check warning on line 45 in src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl

View check run for this annotation

Codecov / codecov/patch

src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl#L45

Added line #L45 was not covered by tests
T8codeMesh{2, RealT}},
equations::AbstractEquations{3},
basis,
::Type{uEltype}) where {RealT <: Real,
uEltype <: Real}
nelements = Trixi.ncells(mesh)

Check warning on line 51 in src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl

View check run for this annotation

Codecov / codecov/patch

src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl#L51

Added line #L51 was not covered by tests

NDIMS = 2 #Dimension of the manifold
ndims_spa = size(mesh.tree_node_coordinates, 1)

Check warning on line 54 in src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl

View check run for this annotation

Codecov / codecov/patch

src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl#L53-L54

Added lines #L53 - L54 were not covered by tests

_node_coordinates = Vector{RealT}(undef,

Check warning on line 56 in src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl

View check run for this annotation

Codecov / codecov/patch

src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl#L56

Added line #L56 was not covered by tests
ndims_spa * nnodes(basis)^NDIMS * nelements)
node_coordinates = Trixi.unsafe_wrap(Array, pointer(_node_coordinates),

Check warning on line 58 in src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl

View check run for this annotation

Codecov / codecov/patch

src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl#L58

Added line #L58 was not covered by tests
(ndims_spa,
ntuple(_ -> nnodes(basis), NDIMS)...,

Check warning on line 60 in src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl

View check run for this annotation

Codecov / codecov/patch

src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl#L60

Added line #L60 was not covered by tests
nelements))

_jacobian_matrix = Vector{RealT}(undef,

Check warning on line 63 in src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl

View check run for this annotation

Codecov / codecov/patch

src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl#L63

Added line #L63 was not covered by tests
ndims_spa * NDIMS * nnodes(basis)^NDIMS *
nelements)
jacobian_matrix = Trixi.unsafe_wrap(Array, pointer(_jacobian_matrix),

Check warning on line 66 in src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl

View check run for this annotation

Codecov / codecov/patch

src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl#L66

Added line #L66 was not covered by tests
(ndims_spa, NDIMS,
ntuple(_ -> nnodes(basis), NDIMS)...,

Check warning on line 68 in src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl

View check run for this annotation

Codecov / codecov/patch

src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl#L68

Added line #L68 was not covered by tests
nelements))

_contravariant_vectors = Vector{RealT}(undef,

Check warning on line 71 in src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl

View check run for this annotation

Codecov / codecov/patch

src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl#L71

Added line #L71 was not covered by tests
ndims_spa^2 * nnodes(basis)^NDIMS *
nelements)
contravariant_vectors = PtrArray(pointer(_contravariant_vectors),

Check warning on line 74 in src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl

View check run for this annotation

Codecov / codecov/patch

src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl#L74

Added line #L74 was not covered by tests
(Trixi.StaticInt(ndims_spa), ndims_spa,
ntuple(_ -> nnodes(basis), NDIMS)...,

Check warning on line 76 in src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl

View check run for this annotation

Codecov / codecov/patch

src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl#L76

Added line #L76 was not covered by tests
nelements))

_inverse_jacobian = Vector{RealT}(undef, nnodes(basis)^NDIMS * nelements)
inverse_jacobian = Trixi.unsafe_wrap(Array, pointer(_inverse_jacobian),
(ntuple(_ -> nnodes(basis), NDIMS)...,

Check warning on line 81 in src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl

View check run for this annotation

Codecov / codecov/patch

src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl#L79-L81

Added lines #L79 - L81 were not covered by tests
nelements))

_surface_flux_values = Vector{uEltype}(undef,

Check warning on line 84 in src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl

View check run for this annotation

Codecov / codecov/patch

src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl#L84

Added line #L84 was not covered by tests
nvariables(equations) *
nnodes(basis)^(NDIMS - 1) * (NDIMS * 2) *
nelements)
surface_flux_values = Trixi.unsafe_wrap(Array, pointer(_surface_flux_values),

Check warning on line 88 in src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl

View check run for this annotation

Codecov / codecov/patch

src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl#L88

Added line #L88 was not covered by tests
(nvariables(equations),
ntuple(_ -> nnodes(basis), NDIMS - 1)...,

Check warning on line 90 in src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl

View check run for this annotation

Codecov / codecov/patch

src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl#L90

Added line #L90 was not covered by tests
NDIMS * 2, nelements))

elements = P4estElementContainerPtrArray{NDIMS, RealT, uEltype, NDIMS + 1,

Check warning on line 93 in src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl

View check run for this annotation

Codecov / codecov/patch

src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl#L93

Added line #L93 was not covered by tests
NDIMS + 2,
NDIMS + 3, typeof(contravariant_vectors)}(node_coordinates,
jacobian_matrix,
contravariant_vectors,
inverse_jacobian,
surface_flux_values,
_node_coordinates,
_jacobian_matrix,
_contravariant_vectors,
_inverse_jacobian,
_surface_flux_values)

init_elements_2d_manifold_in_3d!(elements, mesh, basis)

Check warning on line 106 in src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl

View check run for this annotation

Codecov / codecov/patch

src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl#L106

Added line #L106 was not covered by tests

return elements

Check warning on line 108 in src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl

View check run for this annotation

Codecov / codecov/patch

src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl#L108

Added line #L108 was not covered by tests
end

function init_elements_2d_manifold_in_3d!(elements,

Check warning on line 111 in src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl

View check run for this annotation

Codecov / codecov/patch

src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl#L111

Added line #L111 was not covered by tests
mesh::Union{P4estMesh{2}, T8codeMesh{2}},
basis::LobattoLegendreBasis)
(; node_coordinates, jacobian_matrix,

Check warning on line 114 in src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl

View check run for this annotation

Codecov / codecov/patch

src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl#L114

Added line #L114 was not covered by tests
contravariant_vectors, inverse_jacobian) = elements

calc_node_coordinates_2d_shell!(node_coordinates, mesh, basis)

Check warning on line 117 in src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl

View check run for this annotation

Codecov / codecov/patch

src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl#L117

Added line #L117 was not covered by tests

for element in 1:Trixi.ncells(mesh)

Check warning on line 119 in src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl

View check run for this annotation

Codecov / codecov/patch

src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl#L119

Added line #L119 was not covered by tests

# Compute Jacobian matrix as usual
Trixi.calc_jacobian_matrix!(jacobian_matrix, element, node_coordinates, basis)

Check warning on line 122 in src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl

View check run for this annotation

Codecov / codecov/patch

src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl#L122

Added line #L122 was not covered by tests

# Compute contravariant vectors
calc_contravariant_vectors_2d_shell!(contravariant_vectors,

Check warning on line 125 in src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl

View check run for this annotation

Codecov / codecov/patch

src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl#L125

Added line #L125 was not covered by tests
element,
jacobian_matrix,
node_coordinates,
basis)

# Compute the inverse Jacobian as the norm of the cross product of the covariant vectors
for j in eachnode(basis), i in eachnode(basis)
inverse_jacobian[i, j, element] = 1 /

Check warning on line 133 in src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl

View check run for this annotation

Codecov / codecov/patch

src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl#L132-L133

Added lines #L132 - L133 were not covered by tests
norm(Trixi.cross(jacobian_matrix[:, 1, i,
j,
element],
jacobian_matrix[:, 2, i,
j,
element]))
end
end

Check warning on line 141 in src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl

View check run for this annotation

Codecov / codecov/patch

src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl#L140-L141

Added lines #L140 - L141 were not covered by tests

return nothing

Check warning on line 143 in src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl

View check run for this annotation

Codecov / codecov/patch

src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl#L143

Added line #L143 was not covered by tests
end

# Interpolate tree_node_coordinates to each quadrant at the nodes of the specified basis
function calc_node_coordinates_2d_shell!(node_coordinates,

Check warning on line 147 in src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl

View check run for this annotation

Codecov / codecov/patch

src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl#L147

Added line #L147 was not covered by tests
mesh::Union{P4estMesh{2}, T8codeMesh{2}},
basis::LobattoLegendreBasis)
# Hanging nodes will cause holes in the mesh if its polydeg is higher
# than the polydeg of the solver.
@assert length(basis.nodes)>=length(mesh.nodes) "The solver can't have a lower polydeg than the mesh"

Check warning on line 152 in src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl

View check run for this annotation

Codecov / codecov/patch

src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl#L152

Added line #L152 was not covered by tests

calc_node_coordinates_2d_shell!(node_coordinates, mesh, basis.nodes)

Check warning on line 154 in src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl

View check run for this annotation

Codecov / codecov/patch

src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl#L154

Added line #L154 was not covered by tests
end

# Interpolate tree_node_coordinates to each quadrant at the specified nodes
function calc_node_coordinates_2d_shell!(node_coordinates,

Check warning on line 158 in src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl

View check run for this annotation

Codecov / codecov/patch

src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl#L158

Added line #L158 was not covered by tests
mesh::P4estMesh{2},
nodes::AbstractVector)
# We use `StrideArray`s here since these buffers are used in performance-critical
# places and the additional information passed to the compiler makes them faster
# than native `Array`s.
tmp1 = Trixi.StrideArray(undef, real(mesh),

Check warning on line 164 in src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl

View check run for this annotation

Codecov / codecov/patch

src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl#L164

Added line #L164 was not covered by tests
Trixi.StaticInt(size(mesh.tree_node_coordinates, 1)),
Trixi.static_length(nodes),
Trixi.static_length(mesh.nodes))
matrix1 = Trixi.StrideArray(undef, real(mesh),

Check warning on line 168 in src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl

View check run for this annotation

Codecov / codecov/patch

src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl#L168

Added line #L168 was not covered by tests
Trixi.static_length(nodes),
Trixi.static_length(mesh.nodes))
matrix2 = similar(matrix1)
baryweights_in = Trixi.barycentric_weights(mesh.nodes)

Check warning on line 172 in src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl

View check run for this annotation

Codecov / codecov/patch

src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl#L171-L172

Added lines #L171 - L172 were not covered by tests

# Macros from `p4est`
p4est_root_len = 1 << Trixi.P4EST_MAXLEVEL
p4est_root_len = 1 << Trixi.P4EST_MAXLEVEL
p4est_quadrant_len(l) = 1 << (Trixi.P4EST_MAXLEVEL - l)

Check warning on line 177 in src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl

View check run for this annotation

Codecov / codecov/patch

src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl#L175-L177

Added lines #L175 - L177 were not covered by tests

trees = Trixi.unsafe_wrap_sc(Trixi.p4est_tree_t, mesh.p4est.trees)

Check warning on line 179 in src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl

View check run for this annotation

Codecov / codecov/patch

src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl#L179

Added line #L179 was not covered by tests

for tree in eachindex(trees)
offset = trees[tree].quadrants_offset
quadrants = Trixi.unsafe_wrap_sc(Trixi.p4est_quadrant_t, trees[tree].quadrants)

Check warning on line 183 in src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl

View check run for this annotation

Codecov / codecov/patch

src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl#L181-L183

Added lines #L181 - L183 were not covered by tests

for i in eachindex(quadrants)
element = offset + i
quad = quadrants[i]

Check warning on line 187 in src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl

View check run for this annotation

Codecov / codecov/patch

src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl#L185-L187

Added lines #L185 - L187 were not covered by tests

quad_length = p4est_quadrant_len(quad.level) / p4est_root_len

Check warning on line 189 in src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl

View check run for this annotation

Codecov / codecov/patch

src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl#L189

Added line #L189 was not covered by tests

nodes_out_x = 2 * (quad_length * 1 / 2 * (nodes .+ 1) .+

Check warning on line 191 in src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl

View check run for this annotation

Codecov / codecov/patch

src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl#L191

Added line #L191 was not covered by tests
quad.x / p4est_root_len) .- 1
nodes_out_y = 2 * (quad_length * 1 / 2 * (nodes .+ 1) .+

Check warning on line 193 in src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl

View check run for this annotation

Codecov / codecov/patch

src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl#L193

Added line #L193 was not covered by tests
quad.y / p4est_root_len) .- 1
Trixi.polynomial_interpolation_matrix!(matrix1, mesh.nodes, nodes_out_x,

Check warning on line 195 in src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl

View check run for this annotation

Codecov / codecov/patch

src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl#L195

Added line #L195 was not covered by tests
baryweights_in)
Trixi.polynomial_interpolation_matrix!(matrix2, mesh.nodes, nodes_out_y,

Check warning on line 197 in src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl

View check run for this annotation

Codecov / codecov/patch

src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl#L197

Added line #L197 was not covered by tests
baryweights_in)

Trixi.multiply_dimensionwise!(view(node_coordinates, :, :, :, element),

Check warning on line 200 in src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl

View check run for this annotation

Codecov / codecov/patch

src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl#L200

Added line #L200 was not covered by tests
matrix1, matrix2,
view(mesh.tree_node_coordinates, :, :, :,
tree),
tmp1)
end
end

Check warning on line 206 in src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl

View check run for this annotation

Codecov / codecov/patch

src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl#L205-L206

Added lines #L205 - L206 were not covered by tests

return node_coordinates

Check warning on line 208 in src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl

View check run for this annotation

Codecov / codecov/patch

src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl#L208

Added line #L208 was not covered by tests
end

function calc_contravariant_vectors_2d_shell!(contravariant_vectors::AbstractArray{<:Any,

Check warning on line 211 in src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl

View check run for this annotation

Codecov / codecov/patch

src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl#L211

Added line #L211 was not covered by tests
5},
element,
jacobian_matrix, node_coordinates,
basis::LobattoLegendreBasis)
@unpack derivative_matrix = basis

Check warning on line 216 in src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl

View check run for this annotation

Codecov / codecov/patch

src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl#L216

Added line #L216 was not covered by tests

for j in eachnode(basis), i in eachnode(basis)
for n in 1:3

Check warning on line 219 in src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl

View check run for this annotation

Codecov / codecov/patch

src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl#L218-L219

Added lines #L218 - L219 were not covered by tests
# (n, m, l) cyclic
m = (n % 3) + 1
l = ((n + 1) % 3) + 1

Check warning on line 222 in src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl

View check run for this annotation

Codecov / codecov/patch

src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl#L221-L222

Added lines #L221 - L222 were not covered by tests

contravariant_vectors[n, 1, i, j, element] = (jacobian_matrix[m, 2, i, j,

Check warning on line 224 in src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl

View check run for this annotation

Codecov / codecov/patch

src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl#L224

Added line #L224 was not covered by tests
element] *
node_coordinates[l, i, j,
element]
-
jacobian_matrix[l, 2, i, j,
element] *
node_coordinates[m, i, j,
element])

contravariant_vectors[n, 2, i, j, element] = (jacobian_matrix[l, 1, i, j,

Check warning on line 234 in src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl

View check run for this annotation

Codecov / codecov/patch

src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl#L234

Added line #L234 was not covered by tests
element] *
node_coordinates[m, i, j,
element]
-
jacobian_matrix[m, 1, i, j,
element] *
node_coordinates[l, i, j,
element])

contravariant_vectors[n, 3, i, j, element] = (jacobian_matrix[m, 1, i, j,

Check warning on line 244 in src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl

View check run for this annotation

Codecov / codecov/patch

src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl#L244

Added line #L244 was not covered by tests
element] *
jacobian_matrix[l, 2, i, j,
element]
-
jacobian_matrix[m, 2, i, j,
element] *
jacobian_matrix[l, 1, i, j,
element])
end
end

Check warning on line 254 in src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl

View check run for this annotation

Codecov / codecov/patch

src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl#L253-L254

Added lines #L253 - L254 were not covered by tests

return contravariant_vectors

Check warning on line 256 in src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl

View check run for this annotation

Codecov / codecov/patch

src/solvers/dgsem_p4est/containers_2d_manifold_in_3d.jl#L256

Added line #L256 was not covered by tests
end
end # @muladd
8 changes: 8 additions & 0 deletions src/solvers/dgsem_p4est/dg.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Extract contravariant vector Ja^i (i = index) as SVector
# This function dispatches on the type of contravariant_vectors
static2val(::Trixi.StaticInt{N}) where {N} = Val{N}()
@inline function get_contravariant_vector(index, contravariant_vectors::PtrArray,

Check warning on line 4 in src/solvers/dgsem_p4est/dg.jl

View check run for this annotation

Codecov / codecov/patch

src/solvers/dgsem_p4est/dg.jl#L3-L4

Added lines #L3 - L4 were not covered by tests
indices...)
SVector(ntuple(@inline(dim->contravariant_vectors[dim, index, indices...]),

Check warning on line 6 in src/solvers/dgsem_p4est/dg.jl

View check run for this annotation

Codecov / codecov/patch

src/solvers/dgsem_p4est/dg.jl#L6

Added line #L6 was not covered by tests
static2val(static_size(contravariant_vectors, Trixi.StaticInt(1)))))
end
2 changes: 2 additions & 0 deletions src/solvers/solvers.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include("dgsem_p4est/dg.jl")
include("dgsem_p4est/containers_2d_manifold_in_3d.jl")