Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
fail-fast: false
matrix:
version:
- '1.11'
- '1.10'
os:
- ubuntu-latest
Expand Down
6 changes: 3 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "FiniteElementContainers"
uuid = "d08262e4-672f-4e7f-a976-f2cea5767631"
authors = ["Craig M. Hamel <[email protected]> and contributors"]
version = "0.5.6"
version = "0.5.7"

[deps]
Atomix = "a9b6321e-bd34-4604-b9c9-b65b8de01458"
Expand Down Expand Up @@ -32,11 +32,11 @@ ComponentArrays = "0.15"
DocStringExtensions = "0.9"
Exodus = "0.13"
IterativeSolvers = "0.9"
JET = "0.8"
JET = "0.9"
KernelAbstractions = "0.9"
LinearAlgebra = "1"
Parameters = "0.12"
ReferenceFiniteElements = "0.11"
ReferenceFiniteElements = "0.12"
SparseArrays = "1"
StaticArrays = "1"
StructArrays = "0.6"
Expand Down
8 changes: 3 additions & 5 deletions src/Meshes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,9 @@ function num_dimensions end
$(TYPEDSIGNATURES)
Dummy method to be overriden for specific mesh file format
"""
function num_nodes end
"""
$(TYPEDSIGNATURES)
Dummy method to be overriden for specific mesh file format
"""
function num_nodes(mesh::AbstractMesh)
@assert false "This method needs to overriden in extensions!"
end

"""
$(TYPEDSIGNATURES)
Expand Down
26 changes: 13 additions & 13 deletions src/function_spaces/FunctionSpaces.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,19 @@ reference_element(fspace::FunctionSpace) = fspace.ref_fe
"""
$(TYPEDSIGNATURES)
"""
num_dimensions(fspace::FunctionSpace) = ReferenceFiniteElements.num_dimensions(fspace.ref_fe.ref_fe_type)
num_dimensions(fspace::FunctionSpace) = ReferenceFiniteElements.dimension(fspace.ref_fe.element)
"""
$(TYPEDSIGNATURES)
"""
num_elements(fspace::FunctionSpace) = num_elements(fspace.conn)
"""
$(TYPEDSIGNATURES)
"""
num_nodes_per_element(fspace::FunctionSpace) = ReferenceFiniteElements.num_nodes_per_element(fspace.ref_fe)
num_nodes_per_element(fspace::FunctionSpace) = ReferenceFiniteElements.num_vertices(fspace.ref_fe)
"""
$(TYPEDSIGNATURES)
"""
num_q_points(fspace::FunctionSpace) = ReferenceFiniteElements.num_q_points(fspace.ref_fe)
num_q_points(fspace::FunctionSpace) = ReferenceFiniteElements.num_quadrature_points(fspace.ref_fe)
"""
$(TYPEDSIGNATURES)
"""
Expand All @@ -52,27 +52,27 @@ num_dofs_per_node(::FunctionSpace{ND, RefFE, Conn}) where {ND, RefFE, Conn} = ND
$(TYPEDSIGNATURES)
"""
quadrature_points(fspace::FunctionSpace, q::Int) =
ReferenceFiniteElements.quadrature_points(fspace.ref_fe, q)
ReferenceFiniteElements.quadrature_point(fspace.ref_fe, q)
"""
$(TYPEDSIGNATURES)
"""
quadrature_weights(fspace::FunctionSpace, q::Int) =
ReferenceFiniteElements.quadrature_weights(fspace.ref_fe, q)
ReferenceFiniteElements.quadrature_weight(fspace.ref_fe, q)
"""
$(TYPEDSIGNATURES)
"""
shape_function_values(fspace::FunctionSpace, q::Int) =
ReferenceFiniteElements.shape_function_values(fspace.ref_fe, q)
ReferenceFiniteElements.shape_function_value(fspace.ref_fe, q)
"""
$(TYPEDSIGNATURES)
"""
shape_function_gradients(fspace::FunctionSpace, q::Int) =
ReferenceFiniteElements.shape_function_gradients(fspace.ref_fe, q)
ReferenceFiniteElements.shape_function_gradient(fspace.ref_fe, q)
"""
$(TYPEDSIGNATURES)
"""
shape_function_hessians(fspace::FunctionSpace, q::Int) =
ReferenceFiniteElements.shape_function_hessians(fspace.ref_fe, q)
ReferenceFiniteElements.shape_function_hessian(fspace.ref_fe, q)

#####################################################
"""
Expand Down Expand Up @@ -141,7 +141,7 @@ end
"""
$(TYPEDSIGNATURES)
"""
volume(fspace::FunctionSpace, ::ReferenceFiniteElements.ReferenceFEType, X::NodalField, q::Int, e::Int) =
volume(fspace::FunctionSpace, ::ReferenceFiniteElements.AbstractElementType, X::NodalField, q::Int, e::Int) =
fspace[X, q, e].JxW
# volume(fspace::FunctionSpace, X::NodalField, q::Int, e::Int) = fspace[X, q, e].JxW

Expand All @@ -151,7 +151,7 @@ $(TYPEDSIGNATURES)
function volume(fspace::FunctionSpace, X::NodalField, e::Int)
v = 0.0 # TODO place for unitful to not work
for q in 1:num_q_points(fspace)
v = v + volume(fspace, fspace.ref_fe.ref_fe_type, X, q, e)
v = v + volume(fspace, fspace.ref_fe.element, X, q, e)
end
return v
end
Expand All @@ -162,15 +162,15 @@ function volume(fspace::FunctionSpace, X::NodalField)
v = 0.0
for e in 1:num_elements(fspace)
for q in 1:num_q_points(fspace)
v = v + volume(fspace, fspace.ref_fe.ref_fe_type, X, q, e)
v = v + volume(fspace, fspace.ref_fe.element, X, q, e)
end
end
return v
end

function shape_function_gradient_and_volume(ref_fe::ReferenceFE, X_el, q::Int)
∇N_ξ = ReferenceFiniteElements.shape_function_gradients(ref_fe, q)
w = ReferenceFiniteElements.quadrature_weights(ref_fe, q)
∇N_ξ = ReferenceFiniteElements.shape_function_gradient(ref_fe, q)
w = ReferenceFiniteElements.quadrature_weight(ref_fe, q)
# return shape_function_gradient_and_volume(ref_fe.ref_fe_type, X_el, ∇N_ξ, w)
J = (X_el * ∇N_ξ)'
J_inv = inv(J)
Expand Down
8 changes: 4 additions & 4 deletions src/function_spaces/NonAllocatedFunctionSpace.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ function NonAllocatedFunctionSpace(
elem_id_map,
conn::SimpleConnectivity,
q_degree::Int,
elem_type::Type{<:ReferenceFiniteElements.ReferenceFEType}
elem_type::Type{<:ReferenceFiniteElements.AbstractElementType}
)

ND = num_dofs_per_node(dof_manager)
NN, NE = num_nodes_per_element(conn), num_elements(conn)
ids = reshape(dof_ids(dof_manager), ND, size(dof_manager, 2))
temp = reshape(ids[:, conn], ND * NN, NE)
dof_conn = Connectivity{ND * NN, NE, Matrix, eltype(temp)}(temp)
ref_fe = ReferenceFE(elem_type(Val(q_degree)))
ref_fe = ReferenceFE(elem_type{Lagrange, q_degree}())
return NonAllocatedFunctionSpace{ND, typeof(elem_id_map), typeof(conn), typeof(dof_conn), typeof(ref_fe)}(
elem_id_map, conn, dof_conn, ref_fe
)
Expand All @@ -44,7 +44,7 @@ function NonAllocatedFunctionSpace(
elem_id_map,
conn::VectorizedConnectivity,
q_degree::Int,
elem_type::Type{<:ReferenceFiniteElements.ReferenceFEType}
elem_type::Type{<:ReferenceFiniteElements.AbstractElementType}
)

ND = num_dofs_per_node(dof_manager)
Expand All @@ -53,7 +53,7 @@ function NonAllocatedFunctionSpace(
ids = reshape(1:ND * num_nodes(dof_manager), ND, num_nodes(dof_manager))
temp = reshape(ids[:, conn], ND * NN, NE)
dof_conn = Connectivity{ND * NN, NE, Vector, eltype(temp)}(vec(temp))
ref_fe = ReferenceFE(elem_type(Val(q_degree)))
ref_fe = ReferenceFE(elem_type{Lagrange, q_degree}())

return NonAllocatedFunctionSpace{ND, typeof(elem_id_map), typeof(conn), typeof(dof_conn), typeof(ref_fe)}(
elem_id_map, conn, dof_conn, ref_fe
Expand Down
4 changes: 2 additions & 2 deletions src/function_spaces/Utils.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
elem_type_map = Dict{String, Type{<:ReferenceFiniteElements.ReferenceFEType}}(
elem_type_map = Dict{String, Type{<:ReferenceFiniteElements.AbstractElementType}}(
"HEX" => Hex8,
"HEX8" => Hex8,
"QUAD" => Quad4,
Expand Down Expand Up @@ -28,7 +28,7 @@ end

# TODO should we deprecate these?
function setup_reference_element(
type::Type{<:ReferenceFiniteElements.ReferenceFEType},
type::Type{<:ReferenceFiniteElements.AbstractElementType},
q_degree
)
ReferenceFiniteElements.ReferenceFE(type(Val(q_degree)))
Expand Down
17 changes: 9 additions & 8 deletions src/function_spaces/VectorizedPreAllocatedFunctionSpace.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ end
function setup_shape_function_values!(Ns, ref_fe)
for e in axes(Ns, 2)
for q in axes(Ns, 1)
Ns[q, e] = ReferenceFiniteElements.shape_function_values(ref_fe, q)
Ns[q, e] = ReferenceFiniteElements.shape_function_value(ref_fe, q)
end
end
end
Expand All @@ -39,7 +39,7 @@ function setup_shape_function_gradients!(∇N_Xs, Xs, conn, ref_fe)
for e in axes(∇N_Xs, 2)
X = Xs[:, conn[:, e]] # TODO clean this up
for q in axes(∇N_Xs, 1)
∇N_ξ = ReferenceFiniteElements.shape_function_gradients(ref_fe, q)
∇N_ξ = ReferenceFiniteElements.shape_function_gradient(ref_fe, q)
J = (X * ∇N_ξ)'
J_inv = inv(J)
∇N_Xs[q, e] = (J_inv * ∇N_ξ')'
Expand All @@ -52,9 +52,9 @@ function setup_shape_function_JxWs!(JxWs, Xs, conn, ref_fe)
for e in axes(JxWs, 2)
X = Xs[:, conn[:, e]] # TODO clean this up
for q in axes(JxWs, 1)
∇N_ξ = ReferenceFiniteElements.shape_function_gradients(ref_fe, q)
∇N_ξ = ReferenceFiniteElements.shape_function_gradient(ref_fe, q)
J = (X * ∇N_ξ)'
JxWs[q, e] = det(J) * ReferenceFiniteElements.quadrature_weights(ref_fe, q)
JxWs[q, e] = det(J) * ReferenceFiniteElements.quadrature_weight(ref_fe, q)
end
end
end
Expand All @@ -64,7 +64,7 @@ function VectorizedPreAllocatedFunctionSpace(
elem_id_map,
conn,
q_degree::Int,
elem_type::Type{<:ReferenceFiniteElements.ReferenceFEType},
elem_type::Type{<:ReferenceFiniteElements.AbstractElementType},
coords::VectorizedNodalField
)

Expand All @@ -73,9 +73,10 @@ function VectorizedPreAllocatedFunctionSpace(
ids = reshape(dof_ids(dof_manager), ND, size(dof_manager, 2))
temp = reshape(ids[:, conn], ND * NN, NE)
dof_conn = Connectivity{ND * NN, NE, Matrix, eltype(temp)}(temp)
ref_fe = ReferenceFE(elem_type(q_degree))
D = ReferenceFiniteElements.num_dimensions(ref_fe)
NQ = ReferenceFiniteElements.num_q_points(ref_fe)
# ref_fe = ReferenceFE(elem_type(q_degree))
ref_fe = ReferenceFE(elem_type{Lagrange, q_degree}())
D = ReferenceFiniteElements.dimension(ref_fe)
NQ = ReferenceFiniteElements.num_quadrature_points(ref_fe)
Ns = QuadratureField{NN, NQ, NE, Vector, SVector{NN, Float64}}(undef)
∇N_Xs = QuadratureField{NN * D, NQ, NE, Vector, SMatrix{NN, D, Float64, NN * D}}(undef)
JxWs = QuadratureField{1, NQ, NE, Vector, Float64}(undef)
Expand Down
10 changes: 5 additions & 5 deletions test/TestFormulations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -396,8 +396,8 @@ end
1.0 1.0;
0.0 1.0
]'
ref_fe = ReferenceFE(Quad4(1))
∇N_X = FiniteElementContainers.map_shape_function_gradients(X, shape_function_gradients(ref_fe, 1))
ref_fe = ReferenceFE(Quad4{Lagrange, 1}())
∇N_X = FiniteElementContainers.map_shape_function_gradients(X, shape_function_gradient(ref_fe, 1))
∇u_q = SMatrix{2, 2, Float64, 4}((1., 2., 3., 4.))
A_q = Tensor{4, 3, Float64, 81}(reshape(1:81, 9, 9)')
test_incompressible_plane_stress(∇N_X, ∇u_q, A_q)
Expand All @@ -412,8 +412,8 @@ end
1.0 1.0 1.0;
0.0 1.0 1.0;
]'
ref_fe = ReferenceFE(Hex8(1))
∇N_X = FiniteElementContainers.map_shape_function_gradients(X, shape_function_gradients(ref_fe, 1))
ref_fe = ReferenceFE(Hex8{Lagrange, 1}())
∇N_X = FiniteElementContainers.map_shape_function_gradients(X, shape_function_gradient(ref_fe, 1))
∇u_q = SMatrix{3, 3, Float64, 9}((1., 2., 3., 4., 5., 6., 7., 8., 9.))
test_three_dimensional(∇N_X, ∇u_q, A_q)
end
end
6 changes: 3 additions & 3 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ end
end

# getting an error from FileMesh.num_nodes for some reason. No method
# @testset ExtendedTestSet "JET" begin
# JET.test_package(FiniteElementContainers; target_defined_modules=true)
# end
@testset ExtendedTestSet "JET" begin
JET.test_package(FiniteElementContainers; target_defined_modules=true)
end
Loading