-
Notifications
You must be signed in to change notification settings - Fork 92
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
ConstraintHandler
for discontinuous interpolations
#729
ConstraintHandler
for discontinuous interpolations
#729
Conversation
Codecov ReportPatch coverage:
❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more. Additional details and impacted files@@ Coverage Diff @@
## master #729 +/- ##
==========================================
- Coverage 92.27% 92.22% -0.05%
==========================================
Files 30 30
Lines 4594 4607 +13
==========================================
+ Hits 4239 4249 +10
- Misses 355 358 +3
☔ View full report in Codecov by Sentry. |
ee8a98c
to
2b6f9b1
Compare
Setup: julia> using Ferrite
julia> grid = generate_grid(Quadrilateral, (3, 3));
julia> ip = DiscontinuousLagrange{2, RefCube, 1}()
DiscontinuousLagrange{RefQuadrilateral, 1}()
julia> dh = DofHandler(grid);
julia> add!(dh, :u, 1,ip);
(generic function with 10 methods)
julia> close!(dh);;
julia> ch = ConstraintHandler(dh);
julia> ∂Ω = ∪(
getfaceset(grid, "left"),
getfaceset(grid, "right"),
getfaceset(grid, "top"),
getfaceset(grid, "bottom"),
);
julia> dbc = Dirichlet(:u, ∂Ω, (x, t) -> 0)
Dirichlet(var"#5#6"(), Set(FaceIndex[FaceIndex((3, 2)), FaceIndex((7, 3)), FaceIndex((8, 3)), FaceIndex((1, 4)), FaceIndex((3, 1)), FaceIndex((9, 3)), FaceIndex((2, 1)), FaceIndex((4, 4)), FaceIndex((7, 4)), FaceIndex((6, 2)), FaceIndex((9, 2)), FaceIndex((1, 1))]), :u, Int64[], Int64[], Int64[])
julia> add!(ch, dbc);
julia> close!(ch)
ConstraintHandler:
BCs:
Field: u, Components: [1]
Master branch: julia> ch.prescribed_dofs
Int64[] This PR: julia> ch.prescribed_dofs
20-element Vector{Int64}:
1
2
4
5
⋮
34
35
36 |
I wonder if we can define What happens for the piecewise constant (order 0) interpolations? I suppose for those one need to impose the boundary condition by integrating the jump, just as is done for element-element couplings? |
Indeed, the |
Note that this one is also designed for the distributed assembly stuff to sync process boundaries - I just started chery picking stuff from the PR to make the review easier.
If we have no basis function on the interior of the boundary of the element, then AFAIK we cannot use the strong Dirichlet enforcement anymore and fall back to penalty approaches. |
Right, but penalty approach (integrating the jump from the element to the prescribed value(?)) would work also for higher order elements, right? This PR is for supporting strong Dirichlet when possible then, which should simply not be supported for order 0. |
Indeed. It currently prescribes no dofs for order 0.
Maybe we can do something like: function _local_face_dofs_for_bc(interpolation, field_dim, components, offset, boundaryfunc::F=facedof_indices) where F
@assert issorted(components)
local_face_dofs = Int[]
local_face_dofs_offset = Int[1]
getorder(interpolation) == 0 && return [], [1 for _ in 1:nfaces(interpolation)+1]
for (_, face) in enumerate(boundaryfunc(IsDiscontinuous(interpolation) ? get_continuous_interpolation(interpolation) : interpolation))
for fdof in face, d in 1:field_dim
if d in components
push!(local_face_dofs, (fdof-1)*field_dim + d + offset)
end
end
push!(local_face_dofs_offset, length(local_face_dofs) + 1)
end
return local_face_dofs, local_face_dofs_offset
end |
Yea this case is quite tricky. Users may accidentally prescribe different values on different faces in the corners of a domain which leads to weird ambiguities. It also raises the question at which point of the boundary should a constraint be evaluated. We should just throw a warning in this case and do nothing - which should be reflected in the tests, because this feels like there are possibilities to introduce unexpected regressions.
I should also note that the |
I was thinking maybe we could add something like |
Ferrite.jl/src/interpolations.jl Line 53 in 0ec0e49
|
Remove `IsDiscontinuous` and `get_continuous_interpolation`. Remove extra whitespace.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, perhaps add a simple test?
Sure, thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add tests for the periodic case as regression tests, too? Also, I think the devdocs are missing.
I'm not sure what regression tests can be written for the periodic case as I haven't changed its code, it throws the same mirroring error both before and after this PR. |
I haven't tested it with a problem, but it seems to work upon checking debugging mode.