Skip to content

Commit

Permalink
Add collections file.
Browse files Browse the repository at this point in the history
  • Loading branch information
termi-official committed Sep 26, 2023
1 parent 31016f9 commit 8994736
Showing 1 changed file with 97 additions and 0 deletions.
97 changes: 97 additions & 0 deletions src/collections.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
"""
InterpolationCollection
A collection of compatible interpolations over some (possilby different) cells.
"""
abstract type InterpolationCollection end

"""
ScalarInterpolationCollection
A collection of compatible scalar-valued interpolations over some (possilby different) cells.
"""
abstract type ScalarInterpolationCollection <: InterpolationCollection end

"""
VectorInterpolationCollection
A collection of compatible vector-valued interpolations over some (possilby different) cells.
"""
abstract type VectorInterpolationCollection <: InterpolationCollection end


"""
LagrangeCollection{order} <: InterpolationCollection
A collection of fixed-order Lagrange interpolations across different cell types.
"""
struct LagrangeCollection{order <: Int} <: ScalarInterpolationCollection
end

getinterpolation(lc::LagrangeCollection{order}, cell::AbstractCell{ref_shape}) where {order, ref_shape} = Lagrange{ref_shape, order}()
getinterpolation(lc::LagrangeCollection{order}, ::Type{ref_shape}) where {order, ref_shape} = Lagrange{ref_shape, order}()


"""
VectorizedInterpolationCollection{order} <: InterpolationCollection
A collection of fixed-order vectorized Lagrange interpolations across different cell types.
"""
struct VectorizedInterpolationCollection{vdim <:Int, IPC <: ScalarInterpolationCollection} <: InterpolationCollection
base::IPC
end

getinterpolation(lc::VectorizedInterpolationCollection{vdim, IPC}, cell::AbstractCell{ref_shape}) where {vdim, IPC, ref_shape} = getinterpolation(base, cell)^vdim
getinterpolation(lc::VectorizedInterpolationCollection{vdim, IPC}, type::Type{ref_shape}) where {vdim, IPC, ref_shape} = getinterpolation(base, type)^vdim


"""
QuadratureRuleCollection
A collection of quadrature rules across different cell types.
"""
struct QuadratureRuleCollection{QRW, QRH, QRT}
qr_wedge::QRW
qr_hex::QRH
qr_tet::QRT
end

QuadratureRuleCollection(order::Int) = QuadratureRuleCollection(
QuadratureRule{RefWedge}(order),
QuadratureRule{RefHexahedron}(order),
QuadratureRule{RefTetrahedron}(order)
)

getquadraturerule(qrc::QuadratureRuleCollection{QRW, QRH, QRT}, cell::Hexahedron) where {QRW, QRH, QRT} = qcr.qr_hex
getquadraturerule(qrc::QuadratureRuleCollection{QRW, QRH, QRT}, cell::Wedge) where {QRW, QRH, QRT} = qcr.qr_wedge
getquadraturerule(qrc::QuadratureRuleCollection{QRW, QRH, QRT}, cell::Tetrahedron) where {QRW, QRH, QRT} = qcr.qr_tet

"""
CellValueCollection
Helper to construct and query the correct cell values on mixed grids.
"""
struct CellValueCollection{CVW, CVH, CVT}
cv_wedge::CVW
cv_hex::CVH
cv_tet::CVT
end

getcellvalues(cv::CellValueCollection{CVW, CVH, CVT}, cell::Hexahedron) where {CVW, CVH, CVT} = cv.cv_hex
getcellvalues(cv::CellValueCollection{CVW, CVH, CVT}, cell::Wedge) where {CVW, CVH, CVT} = cv.cv_wedge
getcellvalues(cv::CellValueCollection{CVW, CVH, CVT}, cell::Tetrahedron) where {CVW, CVH, CVT} = cv.cv_tet

"""
FaceValueCollection
Helper to construct and query the correct face values on mixed grids.
"""
struct FaceValueCollection{CVW, CVH, CVT}
cv_wedge::CVW
cv_hex::CVH
cv_tet::CVT
end

getcellvalues(cv::FaceValueCollection{CVW, CVH, CVT}, cell::Hexahedron) where {CVW, CVH, CVT} = cv.cv_hex
getcellvalues(cv::FaceValueCollection{CVW, CVH, CVT}, cell::Wedge) where {CVW, CVH, CVT} = cv.cv_wedge
getcellvalues(cv::FaceValueCollection{CVW, CVH, CVT}, cell::Tetrahedron) where {CVW, CVH, CVT} = cv.cv_tet

0 comments on commit 8994736

Please sign in to comment.