Skip to content

Commit

Permalink
Added type parameter to FacetoFaceGlue, namely Dc of the triangulation
Browse files Browse the repository at this point in the history
from which it is setup
  • Loading branch information
amartinhuertas committed Feb 23, 2022
1 parent d931bc4 commit af7d095
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
6 changes: 3 additions & 3 deletions src/Geometry/AppendedTriangulations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ function get_grid(t::AppendedTriangulation)
lazy_append(a,b)
end

function get_glue(t::AppendedTriangulation,::Val{D}) where D
function get_glue(t::AppendedTriangulation,::Val{D}) where D
a = get_glue(t.a,Val(D))
b = get_glue(t.b,Val(D))
if a==nothing || b==nothing
Expand All @@ -129,11 +129,11 @@ function get_glue(t::AppendedTriangulation,::Val{D}) where D
lazy_append(a,b)
end

function lazy_append(a::FaceToFaceGlue,b::FaceToFaceGlue)
function lazy_append(a::FaceToFaceGlue{Dc},b::FaceToFaceGlue{Dc}) where {Dc}
tface_to_mface = lazy_append(a.tface_to_mface,b.tface_to_mface)
tface_to_mface_map = lazy_append(a.tface_to_mface_map,b.tface_to_mface_map)
mface_to_tface = nothing
FaceToFaceGlue(tface_to_mface,tface_to_mface_map,mface_to_tface)
FaceToFaceGlue(Dc,tface_to_mface,tface_to_mface_map,mface_to_tface)
end

function get_cell_shapefuns(trian::AppendedTriangulation)
Expand Down
2 changes: 1 addition & 1 deletion src/Geometry/BoundaryTriangulations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ function get_glue(trian::BoundaryTriangulation,::Val{D},::Val{D}) where D
face_s_q = lazy_map(linear_combination,face_to_q_vertex_coords,face_to_shapefuns)
tface_to_mface_map = face_s_q
mface_to_tface = nothing
FaceToFaceGlue(tface_to_mface,tface_to_mface_map,mface_to_tface)
FaceToFaceGlue(num_cell_dims(trian),tface_to_mface,tface_to_mface_map,mface_to_tface)
end

function get_facet_normal(trian::BoundaryTriangulation)
Expand Down
20 changes: 14 additions & 6 deletions src/Geometry/Triangulations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,18 @@ get_cell_reffe(trian::Triangulation) = get_cell_reffe(get_grid(trian))
is_first_order(trian::Triangulation) = is_first_order(get_grid(trian))

# This is the most used glue, but others are possible, see e.g. SkeletonGlue.
struct FaceToFaceGlue{A,B,C}
# Dc is the topological dimension of the cells of the Triangulation{Dc} from
# which the FaceToFaceGlue object is created
struct FaceToFaceGlue{Dc,A,B,C}
tface_to_mface::A
tface_to_mface_map::B
mface_to_tface::C
function FaceToFaceGlue(Dc::Integer,
tface_to_mface::A,
tface_to_mface_map::B,
mface_to_tface::C) where {A,B,C}
new{Dc,A,B,C}(tface_to_mface,tface_to_mface_map,mface_to_tface)
end
end

function is_change_possible(strian::Triangulation,ttrian::Triangulation)
Expand Down Expand Up @@ -155,7 +163,7 @@ function get_glue(trian::BodyFittedTriangulation{Dt},::Val{Dt}) where Dt
nmfaces = num_faces(trian.model,Dt)
mface_to_tface = PosNegPartition(tface_to_mface,Int32(nmfaces))
end
FaceToFaceGlue(tface_to_mface,tface_to_mface_map,mface_to_tface)
FaceToFaceGlue(Dt,tface_to_mface,tface_to_mface_map,mface_to_tface)
end

#function get_glue(trian::BodyFittedTriangulation{Dt},::Val{Dm}) where {Dt,Dm}
Expand Down Expand Up @@ -389,7 +397,7 @@ function _compose_glues(rglue,dglue)
nothing
end

function _compose_glues(rglue::FaceToFaceGlue,dglue::FaceToFaceGlue)
function _compose_glues(rglue::FaceToFaceGlue{Dc},dglue::FaceToFaceGlue) where Dc
rface_to_mface = rglue.tface_to_mface
dface_to_rface = dglue.tface_to_mface
dface_to_mface = collect(lazy_map(Reindex(rface_to_mface),dface_to_rface))
Expand All @@ -398,7 +406,7 @@ function _compose_glues(rglue::FaceToFaceGlue,dglue::FaceToFaceGlue)
dface_to_mface_map1 = lazy_map(Reindex(rface_to_mface_map),dface_to_rface)
dface_to_mface_map = lazy_map(,dface_to_mface_map1,dface_to_rface_map)
mface_to_dface = nothing
FaceToFaceGlue(dface_to_mface,dface_to_mface_map,mface_to_dface)
FaceToFaceGlue(Dc,dface_to_mface,dface_to_mface_map,mface_to_dface)
end

struct GenericTriangulation{Dc,Dp,A,B,C} <: Triangulation{Dc,Dp}
Expand Down Expand Up @@ -463,7 +471,7 @@ function get_glue(t::TriangulationView,::Val{d}) where d
view(parent,t.cell_to_parent_cell)
end

function Base.view(glue::FaceToFaceGlue,ids::AbstractArray)
function Base.view(glue::FaceToFaceGlue{Dc},ids::AbstractArray) where Dc
tface_to_mface = lazy_map(Reindex(glue.tface_to_mface),ids)
tface_to_mface_map = lazy_map(Reindex(glue.tface_to_mface_map),ids)
if glue.mface_to_tface === nothing
Expand All @@ -472,7 +480,7 @@ function Base.view(glue::FaceToFaceGlue,ids::AbstractArray)
nmfaces = length(glue.mface_to_tface)
mface_to_tface = PosNegPartition(tface_to_mface,Int32(nmfaces))
end
FaceToFaceGlue(tface_to_mface,tface_to_mface_map,mface_to_tface)
FaceToFaceGlue(Dc,tface_to_mface,tface_to_mface_map,mface_to_tface)
end

function get_facet_normal(trian::TriangulationView)
Expand Down

0 comments on commit af7d095

Please sign in to comment.