Skip to content

Commit

Permalink
Widen accepted vector types in FEValues (#1017)
Browse files Browse the repository at this point in the history
  • Loading branch information
termi-official committed Jul 5, 2024
1 parent 2c8b751 commit 25c93de
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 22 deletions.
6 changes: 3 additions & 3 deletions src/FEValues/FunctionValues.jl
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,13 @@ function FunctionValues{DiffOrder}(::Type{T}, ip::Interpolation, qr::QuadratureR
return fv
end

function precompute_values!(fv::FunctionValues{0}, qr_points::Vector{<:Vec})
function precompute_values!(fv::FunctionValues{0}, qr_points::AbstractVector{<:Vec})
reference_shape_values!(fv.Nξ, fv.ip, qr_points)
end
function precompute_values!(fv::FunctionValues{1}, qr_points::Vector{<:Vec})
function precompute_values!(fv::FunctionValues{1}, qr_points::AbstractVector{<:Vec})
reference_shape_gradients_and_values!(fv.dNdξ, fv.Nξ, fv.ip, qr_points)
end
function precompute_values!(fv::FunctionValues{2}, qr_points::Vector{<:Vec})
function precompute_values!(fv::FunctionValues{2}, qr_points::AbstractVector{<:Vec})
reference_shape_hessians_gradients_and_values!(fv.d2Ndξ2, fv.dNdξ, fv.Nξ, fv.ip, qr_points)
end

Expand Down
6 changes: 3 additions & 3 deletions src/FEValues/GeometryMapping.jl
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,13 @@ function GeometryMapping{2}(::Type{T}, ip::ScalarInterpolation, qr::QuadratureRu
return gm
end

function precompute_values!(gm::GeometryMapping{0}, qr_points::Vector{<:Vec})
function precompute_values!(gm::GeometryMapping{0}, qr_points::AbstractVector{<:Vec})
reference_shape_values!(gm.M, gm.ip, qr_points)
end
function precompute_values!(gm::GeometryMapping{1}, qr_points::Vector{<:Vec})
function precompute_values!(gm::GeometryMapping{1}, qr_points::AbstractVector{<:Vec})
reference_shape_gradients_and_values!(gm.dMdξ, gm.M, gm.ip, qr_points)
end
function precompute_values!(gm::GeometryMapping{2}, qr_points::Vector{<:Vec})
function precompute_values!(gm::GeometryMapping{2}, qr_points::AbstractVector{<:Vec})
reference_shape_hessians_gradients_and_values!(gm.d2Mdξ2, gm.dMdξ, gm.M, gm.ip, qr_points)
end

Expand Down
6 changes: 3 additions & 3 deletions src/FEValues/InterfaceValues.jl
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ end
end

@doc raw"""
transform_interface_points!(dst::Vector{Vec{3, Float64}}, points::Vector{Vec{3, Float64}}, interface_transformation::InterfaceOrientationInfo)
transform_interface_points!(dst::AbstractVector{Vec{3, Float64}}, points::AbstractVector{Vec{3, Float64}}, interface_transformation::InterfaceOrientationInfo)
Transform the points from face A to face B using the orientation information of the interface and store it in the vector dst.
For 3D, the faces are transformed into regular polygons such that the rotation angle is the shift in reference node index × 2π ÷ number of edges in face.
Expand Down Expand Up @@ -549,7 +549,7 @@ y | \
"""
transform_interface_points!

function transform_interface_points!(dst::Vector{Vec{3, Float64}}, points::Vector{Vec{3, Float64}}, interface_transformation::InterfaceOrientationInfo{RefShapeA, RefShapeB}) where {RefShapeA <: AbstractRefShape{3}, RefShapeB <: AbstractRefShape{3}}
function transform_interface_points!(dst::AbstractVector{Vec{3, Float64}}, points::AbstractVector{Vec{3, Float64}}, interface_transformation::InterfaceOrientationInfo{RefShapeA, RefShapeB}) where {RefShapeA <: AbstractRefShape{3}, RefShapeB <: AbstractRefShape{3}}
facet_a = interface_transformation.facet_a
facet_b = interface_transformation.facet_b

Expand All @@ -562,7 +562,7 @@ function transform_interface_points!(dst::Vector{Vec{3, Float64}}, points::Vecto
return nothing
end

function transform_interface_points!(dst::Vector{Vec{2, Float64}}, points::Vector{Vec{2, Float64}}, interface_transformation::InterfaceOrientationInfo{RefShapeA, RefShapeB}) where {RefShapeA <: AbstractRefShape{2}, RefShapeB <: AbstractRefShape{2}}
function transform_interface_points!(dst::AbstractVector{Vec{2, Float64}}, points::AbstractVector{Vec{2, Float64}}, interface_transformation::InterfaceOrientationInfo{RefShapeA, RefShapeB}) where {RefShapeA <: AbstractRefShape{2}, RefShapeB <: AbstractRefShape{2}}
facet_a = interface_transformation.facet_a
facet_b = interface_transformation.facet_b
flipped = interface_transformation.flipped
Expand Down
14 changes: 7 additions & 7 deletions src/FEValues/common_values.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ function ValuesUpdateFlags(ip_fun::Interpolation, ::Val{update_gradients}, ::Val
end

"""
reinit!(cv::CellValues, cell::AbstractCell, x::Vector)
reinit!(cv::CellValues, x::Vector)
reinit!(fv::FacetValues, cell::AbstractCell, x::Vector, face::Int)
reinit!(fv::FacetValues, x::Vector, face::Int)
reinit!(cv::CellValues, cell::AbstractCell, x::AbstractVector)
reinit!(cv::CellValues, x::AbstractVector)
reinit!(fv::FacetValues, cell::AbstractCell, x::AbstractVector, face::Int)
reinit!(fv::FacetValues, x::AbstractVector, face::Int)
Update the `CellValues`/`FacetValues` object for a cell or face with coordinates `x`.
The derivatives of the shape functions, and the new integration weights are computed.
Expand Down Expand Up @@ -347,19 +347,19 @@ end
_copy_or_nothing(x) = copy(x)
_copy_or_nothing(::Nothing) = nothing

function reference_shape_values!(values::AbstractMatrix, ip, qr_points::Vector{<:Vec})
function reference_shape_values!(values::AbstractMatrix, ip, qr_points::AbstractVector{<:Vec})
for (qp, ξ) in pairs(qr_points)
reference_shape_values!(@view(values[:, qp]), ip, ξ)
end
end

function reference_shape_gradients_and_values!(gradients::AbstractMatrix, values::AbstractMatrix, ip, qr_points::Vector{<:Vec})
function reference_shape_gradients_and_values!(gradients::AbstractMatrix, values::AbstractMatrix, ip, qr_points::AbstractVector{<:Vec})
for (qp, ξ) in pairs(qr_points)
reference_shape_gradients_and_values!(@view(gradients[:, qp]), @view(values[:, qp]), ip, ξ)
end
end

function reference_shape_hessians_gradients_and_values!(hessians::AbstractMatrix, gradients::AbstractMatrix, values::AbstractMatrix, ip, qr_points::Vector{<:Vec})
function reference_shape_hessians_gradients_and_values!(hessians::AbstractMatrix, gradients::AbstractMatrix, values::AbstractMatrix, ip, qr_points::AbstractVector{<:Vec})
for (qp, ξ) in pairs(qr_points)
reference_shape_hessians_gradients_and_values!(@view(hessians[:, qp]), @view(gradients[:, qp]), @view(values[:, qp]), ip, ξ)
end
Expand Down
12 changes: 6 additions & 6 deletions src/FEValues/face_integrals.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@ align to the facet's local axis.
function weighted_normal end

"""
create_facet_quad_rule(::Type{RefShape}, w::Vector{T}, p::Vector{Vec{N, T}})
create_facet_quad_rule(::Type{RefShape}, w::AbstractVectorä{T}, p::AbstractVectorä{Vec{N, T}})
create_facet_quad_rule(
::Type{RefShape},
quad_faces::Vector{Int}, w_quad::Vector{T}, p_quad::Vector{Vec{N, T}},
tri_faces::Vector{Int}, w_tri::Vector{T}, p_tri::Vector{Vec{N, T}}
quad_faces::AbstractVectorä{Int}, w_quad::AbstractVector{T}, p_quad::AbstractVector{Vec{N, T}},
tri_faces::AbstractVector{Int}, w_tri::AbstractVector{T}, p_tri::AbstractVector{Vec{N, T}}
)
Create a ["FacetQuadratureRule"](@ref) for the given cell type, weights and points. If the
cell has facets of different shapes (i.e. quadrilaterals and triangles) then each shape's
facets indices, weights and points are passed separately.
"""
function create_facet_quad_rule(::Type{RefShape}, w::Vector{T}, p::Vector{Vec{N, T}}) where {N, T, RefShape <: AbstractRefShape}
function create_facet_quad_rule(::Type{RefShape}, w::AbstractVector{T}, p::AbstractVector{Vec{N, T}}) where {N, T, RefShape <: AbstractRefShape}
facet_quad_rule = QuadratureRule{RefShape, Vector{T}, Vector{Vec{N+1, T}}}[]
for facet in 1:nfacets(RefShape)
new_points = [facet_to_element_transformation(p[i], RefShape, facet) for i in 1:length(w)]
Expand All @@ -48,8 +48,8 @@ end
# For cells with mixed faces
function create_facet_quad_rule(
::Type{RefShape},
quad_facets::Vector{Int}, w_quad::Vector{T}, p_quad::Vector{Vec{N, T}},
tri_facets::Vector{Int}, w_tri::Vector{T}, p_tri::Vector{Vec{N, T}}
quad_facets::AbstractVector{Int}, w_quad::AbstractVector{T}, p_quad::AbstractVector{Vec{N, T}},
tri_facets::AbstractVector{Int}, w_tri::AbstractVector{T}, p_tri::AbstractVector{Vec{N, T}}
) where {N, T, RefShape <: Union{RefPrism, RefPyramid}}
facet_quad_rule = Vector{QuadratureRule{RefShape, Vector{T}, Vector{Vec{N+1, T}}}}(undef, nfacets(RefShape))
for facet in quad_facets
Expand Down

0 comments on commit 25c93de

Please sign in to comment.