Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reordering of nodal Dirichlet conditions fails #1116

Open
termi-official opened this issue Dec 4, 2024 · 1 comment
Open

Reordering of nodal Dirichlet conditions fails #1116

termi-official opened this issue Dec 4, 2024 · 1 comment
Labels

Comments

@termi-official
Copy link
Member

termi-official commented Dec 4, 2024

MWE on master

using Ferrite
grid = generate_grid(Line, (1,));

ip = Lagrange{RefLine,1}()

dh = DofHandler(grid)
add!(dh, :u, ip)
close!(dh);

ch = ConstraintHandler(dh);
∂Ω = [1] # Triggers error in renumbering
# ∂Ω = getfacetset(grid, "left") # Works
dbc = Dirichlet(:u, ∂Ω, (x, t) -> 0)
add!(ch, dbc);
close!(ch)

perm = [2,1]
Ferrite.renumber!(dh,ch,perm)

(Edit by @KnutAM moving ip above dh)

@KnutAM
Copy link
Member

KnutAM commented Dec 4, 2024

Seems like that in

struct Dirichlet # <: Constraint
f::Function # f(x) or f(x,t) -> value(s)
facets::OrderedSet{T} where {T <: Union{Int, FacetIndex, FaceIndex, EdgeIndex, VertexIndex}}
field_name::Symbol
components::Vector{Int} # components of the field
local_facet_dofs::Vector{Int}
local_facet_dofs_offset::Vector{Int}
end

local_facet_dofs = nodeidxs and local_facet_dofs_offset = globaldofs in
# for nodes
function _update!(
inhomogeneities::Vector{T}, f::Function, ::AbstractVecOrSet{Int}, field::Symbol, nodeidxs::Vector{Int}, globaldofs::Vector{Int},
components::Vector{Int}, dh::AbstractDofHandler, facetvalues::BCValues,
dofmapping::Dict{Int, Int}, dofcoefficients::Vector{Union{Nothing, DofCoefficients{T}}}, time::Real
) where {T}

Without looking closer I guess the solution would be to update local_facet_dofs_offset in Dirichlet conditions applied to nodes. However, this seems like a bit unfortunate dual use of the Dirichlet condition...

As we also discussed potential generalisations @fredrikekre, perhaps one could keep having Dirichlet as the interface, but have specialized structs add!ed to the ConstraintHandler depending on the case (here e.g. DirichletFacet and DirichletNodal). For non-identity mappings, we could then "easily" dispatch and add different structs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants