From 25c93dea86efa791b201dee7a05ac34d5239c9e5 Mon Sep 17 00:00:00 2001 From: Dennis Ogiermann Date: Fri, 5 Jul 2024 16:01:18 +0200 Subject: [PATCH] Widen accepted vector types in FEValues (#1017) --- src/FEValues/FunctionValues.jl | 6 +++--- src/FEValues/GeometryMapping.jl | 6 +++--- src/FEValues/InterfaceValues.jl | 6 +++--- src/FEValues/common_values.jl | 14 +++++++------- src/FEValues/face_integrals.jl | 12 ++++++------ 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/FEValues/FunctionValues.jl b/src/FEValues/FunctionValues.jl index cdc7f99b95..67cdf5ad44 100644 --- a/src/FEValues/FunctionValues.jl +++ b/src/FEValues/FunctionValues.jl @@ -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 diff --git a/src/FEValues/GeometryMapping.jl b/src/FEValues/GeometryMapping.jl index 79abf87415..4497c7733a 100644 --- a/src/FEValues/GeometryMapping.jl +++ b/src/FEValues/GeometryMapping.jl @@ -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 diff --git a/src/FEValues/InterfaceValues.jl b/src/FEValues/InterfaceValues.jl index 32f3ad1e02..53c5ecb33a 100644 --- a/src/FEValues/InterfaceValues.jl +++ b/src/FEValues/InterfaceValues.jl @@ -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. @@ -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 @@ -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 diff --git a/src/FEValues/common_values.jl b/src/FEValues/common_values.jl index 6da4252dd7..b68cb751d8 100644 --- a/src/FEValues/common_values.jl +++ b/src/FEValues/common_values.jl @@ -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. @@ -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 diff --git a/src/FEValues/face_integrals.jl b/src/FEValues/face_integrals.jl index f6e48fe3c5..d2d26bc6bc 100644 --- a/src/FEValues/face_integrals.jl +++ b/src/FEValues/face_integrals.jl @@ -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)] @@ -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