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

Add possibility to add bcs on edges/vertices #291

Closed
wants to merge 13 commits into from

Conversation

lijas
Copy link
Collaborator

@lijas lijas commented May 17, 2020

Useful for for example "simply supported" bcs.
Also useful for shell elements which only has edges.

See Cantilever.ipynb for example usage

@codecov-io
Copy link

codecov-io commented May 17, 2020

Codecov Report

Merging #291 into master will decrease coverage by 0.56%.
The diff coverage is 81.81%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #291      +/-   ##
==========================================
- Coverage   85.97%   85.40%   -0.57%     
==========================================
  Files          21       21              
  Lines        1961     2001      +40     
==========================================
+ Hits         1686     1709      +23     
- Misses        275      292      +17     
Impacted Files Coverage Δ
src/interpolations.jl 89.80% <0.00%> (-1.75%) ⬇️
src/Dofs/MixedDofHandler.jl 75.24% <8.33%> (-3.22%) ⬇️
src/Grid/grid.jl 82.39% <79.31%> (-1.35%) ⬇️
src/Dofs/ConstraintHandler.jl 90.29% <100.00%> (+0.49%) ⬆️
src/Dofs/DofHandler.jl 83.33% <100.00%> (-0.42%) ⬇️
src/FEValues/face_values.jl 100.00% <100.00%> (ø)
src/Grid/grid_generators.jl 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 20d14ac...ef6504d. Read the comment docs.

@@ -145,7 +157,7 @@ function _add!(ch::ConstraintHandler, dbc::Dirichlet, bcfaces::Set{Tuple{Int,Int
# loop over all the faces in the set and add the global dofs to `constrained_dofs`
constrained_dofs = Int[]
#_celldofs = fill(0, ndofs_per_cell(ch.dh))
for (cellidx, faceidx) in bcfaces
for (cellidx, faceidx) in bcfaces
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for (cellidx, faceidx) in bcfaces
for (cellidx, faceidx) in bcfaces

@@ -157,7 +157,7 @@ function assemble_up!(Ke, fe, cell, cellvalues_u, cellvalues_p, facevalues_u, gr
## We loop over all the faces in the cell, then check if the face
## is in our `"traction"` faceset.
@inbounds for face in 1:nfaces(cell)
if onboundary(cell, face) && (cellid(cell), face) ∈ getfaceset(grid, "traction")
if onboundary(cell, face) && FaceIndex(cellid(cell), face) ∈ getfaceset(grid, "traction")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, I guess this is pretty breaking. Perhaps we can leave FaceIndex as const FaceIndex = Tuple{Int, Int} but use struct for the others?

"output_type": "stream",
"text": [
" \u001b[1m------------------------------------------------------------------\u001b[22m\n",
" Time Allocations \n",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did this table go away?

@@ -229,6 +241,7 @@ function _update!(values::Vector{Float64}, f::Function, faces::Set{Tuple{Int,Int
_celldofs = fill(0, ndofs_per_cell(dh, _tmp_cellid))

for (cellidx, faceidx) in faces

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

@@ -395,22 +409,30 @@ end

#Function for adding constraint when using multiple celltypes
function add!(ch::ConstraintHandler, fh::FieldHandler, dbc::Dirichlet)
dbc.faces isa Set{Tuple{Int}} && error("Can only apply boundary conditions to faces (not nodes).")

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

@codecov-commenter
Copy link

codecov-commenter commented May 25, 2020

Codecov Report

Merging #291 into master will decrease coverage by 0.46%.
The diff coverage is 83.63%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #291      +/-   ##
==========================================
- Coverage   85.97%   85.51%   -0.47%     
==========================================
  Files          21       21              
  Lines        1961     2002      +41     
==========================================
+ Hits         1686     1712      +26     
- Misses        275      290      +15     
Impacted Files Coverage Δ
src/Dofs/MixedDofHandler.jl 75.24% <8.33%> (-3.22%) ⬇️
src/interpolations.jl 90.44% <33.33%> (-1.12%) ⬇️
src/Grid/grid.jl 83.21% <83.33%> (-0.53%) ⬇️
src/Dofs/ConstraintHandler.jl 90.29% <100.00%> (+0.49%) ⬆️
src/Dofs/DofHandler.jl 83.33% <100.00%> (-0.42%) ⬇️
src/FEValues/face_values.jl 100.00% <100.00%> (ø)
src/Grid/grid_generators.jl 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 20d14ac...e749c82. Read the comment docs.

@lijas
Copy link
Collaborator Author

lijas commented Feb 28, 2021

I added a simple example with shell elements, which is the strongest motivation why one needs to be able to add BCs on edges/vertices. I am planning to write some text for the example so that it can be added to the other tutorials.

I would also like some feedback on the structure of the code. Currently in the add!-function for the ConstraintHandler, I changed it so that it creates BCValues for either faces, edges or vertices:

function add!(ch::ConstraintHandler, dbc::Dirichlet)
...
functype = getgeometryfunction(eltype(dbc.bcset)) # eltype(dbc.bcset) is either FaceIndex, EdgeIndex or VertexIndes
bcvalue = BCValues(interpolation, JuAFEM.default_interpolation(celltype), functype)
_add!(ch, dbc, dbc.bcset, interpolation, field_dim, field_offset(ch.dh, dbc.field_name), bcvalue, functype)

where

getgeometryfunction(::Type{FaceIndex}) = JuAFEM.faces
getgeometryfunction(::Type{EdgeIndex}) = JuAFEM.edges
getgeometryfunction(::Type{VertexIndex}) = JuAFEM.vertices

Do you think it is clear what getgeometryfunction is doing? Is there a better name? Or should we skip it all together and just do

if eltype(dbc.bcset) isa FaceIndex
    functype = JuAFEM.faces
elseif eltype(dbc.bcset) isa EdgeIndex
   functype = JuAFEM.edges
elseif eltype(dbc.bcset) isa VertexIndex
   functype = JuAFEM.vertices
end
bcvalue = BCValues(interpolation, JuAFEM.default_interpolation(celltype), functype)
_add!(ch, dbc, dbc.faces, interpolation, field_dim, field_offset(ch.dh, dbc.field_name), bcvalue, functype)

Any feedback would be appriciated..

@KristofferC
Copy link
Collaborator

I think doing the explicit if makes sense for now. If the same type of code occurs in other places, it could be changed out to dispatch.

@lijas
Copy link
Collaborator Author

lijas commented Mar 31, 2021

Close due to #343

@lijas lijas closed this Mar 31, 2021
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

Successfully merging this pull request may close these issues.

4 participants