Skip to content

Commit

Permalink
Move calculation of interface data to fill_mesh_info_fv!
Browse files Browse the repository at this point in the history
  • Loading branch information
bennibolm committed Feb 29, 2024
1 parent 4710d38 commit 62b47bb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 36 deletions.
20 changes: 20 additions & 0 deletions src/meshes/t8code_mesh.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1150,6 +1150,8 @@ function fill_mesh_info_fv!(mesh::T8codeMesh, interfaces, boundaries,
for ielement in 0:(num_elements_in_tree - 1)
element = t8_forest_get_element_in_tree(mesh.forest, itree, ielement)

level = t8_element_level(eclass_scheme, element)

num_faces = t8_element_num_faces(eclass_scheme, element)

# Loop over all faces of the current local element.
Expand Down Expand Up @@ -1213,6 +1215,24 @@ function fill_mesh_info_fv!(mesh::T8codeMesh, interfaces, boundaries,
boundaries.neighbor_ids[boundary_id] = current_index + 1
boundaries.faces[boundary_id] = iface + 1
boundaries.name[boundary_id] = boundary_names[iface + 1, itree + 1]
else # Interface or mortar.
neighbor_level = t8_element_level(neighbor_scheme, neighbor_leaves[1])

# Local interface: The second condition ensures we only visit the interface once.
if level == neighbor_level && current_index <= neighbor_ielements[1]
local_num_conform += 1
interfaces.neighbor_ids[1, local_num_conform] = current_index +
1
interfaces.neighbor_ids[2, local_num_conform] = neighbor_ielements[1] +
1

interfaces.faces[1, local_num_conform] = iface + 1
interfaces.faces[2, local_num_conform] = dual_faces[1]

# Local mortar.
elseif level < neighbor_level
error("Mortars are not supported yet!")
end
end

t8_free(dual_faces_ref[])
Expand Down
36 changes: 0 additions & 36 deletions src/solvers/fv_t8code/containers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -239,42 +239,6 @@ function init_fv_interfaces(mesh::T8codeMesh, equations,
interfaces = T8codeFVInterfaceContainer{uEltype}(u, neighbor_ids, faces,
_u, _neighbor_ids, _faces)

# I tried it to do it like for the existing T8codeMesh routines with
# init_interfaces!(interfaces, mesh)
# The problem was that I need the face id of both elements for every interface.
# That is not needed for DG code since it is handled with the indices there.

init_fv_interfaces!(interfaces, mesh, elements)

return interfaces
end

function init_fv_interfaces!(interfaces, mesh::T8codeMesh, elements)
# Note: In t8code, the routine 't8code_forest_iterate' is not implemented yet.

idx = 1
for element in 1:ncells(mesh)
(; face_connectivity, num_faces, face_midpoints, neighbor_faces) = elements[element]
for (face, neighbor) in enumerate(face_connectivity[1:num_faces])
if neighbor < element
continue
end

# face_midpoint = Trixi.get_variable_wrapped(face_midpoints, equations, face)
face_neighbor = neighbor_faces[face]
# face_midpoint_neighbor = Trixi.get_variable_wrapped(elements[neighbor].face_midpoints,
# equations,
# face_neighbor)
interfaces.neighbor_ids[1, idx] = element
interfaces.neighbor_ids[2, idx] = neighbor

interfaces.faces[1, idx] = face
interfaces.faces[2, idx] = face_neighbor

idx += 1
end
end

return interfaces
end

Expand Down

0 comments on commit 62b47bb

Please sign in to comment.