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

Lack of functions for interface cell #23

Open
zkk960317 opened this issue Dec 8, 2024 · 2 comments
Open

Lack of functions for interface cell #23

zkk960317 opened this issue Dec 8, 2024 · 2 comments

Comments

@zkk960317
Copy link

When add Dirichlet boundary to nodes connected to interface cell, an error occurred shown that no function geometirc_interpolation and reference_coordinates

using Ferrite, FerriteInterfaceElements, SparseArrays

grid = generate_grid(Quadrilateral, (10, 10))
addcellset!(grid, "up", (x) -> 0.0 <= x[2])
addcellset!(grid, "down", (x) -> x[2] <= 0.0)
addcellset!(grid, "bulk", 1:getncells(grid))

grid = insert_interfaces(grid, ["up", "down"])
addnodeset!(grid, "loadPoint", (x) -> x[1] ≈ 1.0 && x[2] ≈ 0.0)

dh = DofHandler(grid)
set_bulk = getcellset(grid, "bulk")
set_interface = getcellset(grid, "interfaces")
ip_bulk = Lagrange{RefQuadrilateral,1}()^2
ip_interface = InterfaceCellInterpolation(Lagrange{RefLine,1}())^2
add!(SubDofHandler(dh, set_bulk), :u, ip_bulk)
add!(SubDofHandler(dh, set_interface), :u, ip_interface)
close!(dh);

ch = ConstraintHandler(dh)
add!(ch, Dirichlet(:u, getfacetset(grid, "left"), Returns(zeros(2))))
add!(ch, Dirichlet(:u, getnodeset(grid, "loadPoint"), Returns(1.0), [1]))
@time "ch" close!(ch)
ERROR: MethodError: no method matching geometric_interpolation(::Type{InterfaceCell{RefQuadrilateral, Line, 4}})

Closest candidates are:
  geometric_interpolation(::Type{QuadraticTetrahedron})
@lijas
Copy link
Collaborator

lijas commented Dec 8, 2024

Applying dirichlet constraints directly to nodes are always a bit iffy in Ferrite. First of all, your nodeset "loadpoint" has two nodes in it, one from each side of the interface.

julia> getnodeset(grid, "loadPoint")
OrderedCollections.OrderedSet{Int64} with 2 elements:
  66
  132

Which one do you want to apply the constraint to?

A work around is to apply the constraint to a vertex instead. A vertex is similar to a node, but the vertex is also associated with an element VertexIndex(Cellid, LocalVertexID) (which makes it a bit easier for the constraint handler to find the correct dof):

addvertexset!(grid, "loadPoint", (x) -> x[1] ≈ 1.0 && x[2] ≈ 0.0)
julia> getvertexset(grid, "loadPoint")
OrderedCollections.OrderedSet{VertexIndex} with 4 elements:
  VertexIndex((50, 3)) #Bottom bulk
  VertexIndex((60, 2)) #Top bulk
  VertexIndex((110, 1)) #Cohesive element
  VertexIndex((110, 3)) #cohesive element

Lets say we want to apply a constraint to the top bulk material, simply change the dirichlet to:

add!(ch, Dirichlet(:u, [getvertexset(grid, "loadPoint")[1]], Returns(1.0), [1]))

The best option would be to try to re-formulate the Dirichlet constraint to be applied to "facets" instead, because they are usually uniquely defined.

@zkk960317
Copy link
Author

@lijas Thank you very much for your help. My original intention was to apply dirichlet constraints to both nodes, so according to your prompt, the correct code should be:

add!(ch, Dirichlet(:u, collect(getvertexset(grid, "loadPoint"))[[1,2]], Returns(1.0), [1]))

This approach is feasible because the load applied to the interface cell can always be treated to the bulk cells.

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

No branches or pull requests

2 participants