You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
function Ferrite.generate_grid(::Type{Line}, nel::NTuple{1,Int}, left::Vec{dim,T}=Vec{1}((-1.0,)), right::Vec{dim,T}=Vec{1}((1.0, ))) where {T,dim}
nel_x = nel[1]
n_nodes = nel_x + 1
# Generate nodes
coords = Vector{Float64}[]
for i in 1:dim
coords_x = collect(range(left[i], stop=right[i], length=n_nodes))
push!(coords, coords_x)
end
nodes = Node{dim,T}[]
for i in 1:n_nodes
push!(nodes, Node(Tuple(coords[j][i] for j in 1:dim)))
end
# Generate cells
cells = Line[]
for i in 1:nel_x
push!(cells, Line((i, i + 1)))
end
# Cell faces
boundary = Vector([FacetIndex(1, 1),
FacetIndex(nel_x, 2)])
# Cell face sets
facetsets = Dict("left" => Ferrite.OrderedSet{FacetIndex}([boundary[1]]),
"right" => Ferrite.OrderedSet{FacetIndex}([boundary[2]]))
return Grid(cells, nodes, facetsets=facetsets)
end
Compared to the original code, this can generate 2D and 3D lines based on the dimension of input left / right node, and the default is 1D line.
The text was updated successfully, but these errors were encountered:
Compared to the original code, this can generate 2D and 3D lines based on the dimension of input left / right node, and the default is 1D line.
The text was updated successfully, but these errors were encountered: