-
Notifications
You must be signed in to change notification settings - Fork 90
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
Changes to MixedDofHandler #279
Conversation
Codecov Report
@@ Coverage Diff @@
## master #279 +/- ##
==========================================
- Coverage 88.50% 86.93% -1.57%
==========================================
Files 22 21 -1
Lines 1897 1937 +40
==========================================
+ Hits 1679 1684 +5
- Misses 218 253 +35
Continue to review full report at Codecov.
|
docs/src/literate/heat_equation.jl
Outdated
# It is now time to loop over all the cells in our grid. We do this by iterating | ||
# over a `CellIterator`. The iterator caches some useful things for us, for example | ||
# the nodal coordinates for the cell, and the local degrees of freedom. | ||
#+ | ||
@inbounds for cell in CellIterator(dh) |
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.
Does CellIterator
not work for MixedDofHandler
?
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.
Not at the moment, but could quite easily fix that so it works for both dofhandler and mixeddofhandler.
Updates:
Todo: |
src/iterators.jl
Outdated
current_cellid::ScalarWrapper{Int} | ||
nodes::Vector{Int} | ||
coords::Vector{Vec{dim,T}} | ||
dh::DofHandler{dim,N,T,M} | ||
cellset::Vector{Int} | ||
dh::Union{DofHandler{dim,C,T}, MixedDofHandler{dim,C,T}} #Futre: remove DofHandler and rename MixedDofHandler->DofHandler |
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.
Specialize on this instead?
CellIterator{dim, C, T, DH<:AbstractDofHandler}
src/Grid/MixedGrid.jl
Outdated
@@ -1,5 +1,5 @@ | |||
|
|||
mutable struct MixedGrid{dim,C,T<:Real} <: JuAFEM.AbstractGrid | |||
#=mutable struct Grid{dim,C,T<:Real} <: JuAFEM.AbstractGrid |
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.
Delete this file
@@ -54,13 +54,14 @@ struct ConstraintHandler{DH<:AbstractDofHandler,T} | |||
free_dofs::Vector{Int} | |||
values::Vector{T} | |||
dofmapping::Dict{Int,Int} # global dof -> index into dofs and values | |||
bcvalues::Vector{BCValues{T}} |
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.
Store bcvalues in ConstraintHandler instead of getting it from DofHandler
@@ -386,68 +393,27 @@ function meandiag(K::AbstractMatrix) | |||
end | |||
|
|||
|
|||
|
|||
# TODO Remove - almost identical to the previous | |||
function _update!(values::Vector{Float64}, f::Function, faces::Set{Tuple{Int,Int}}, field::Symbol, local_face_dofs::Vector{Int}, local_face_dofs_offset::Vector{Int}, |
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.
Delete this function anduse the normal _update! function for both MixedDofHandler and DofHandler
All tests work for me and I think it is possible to merge now. |
Are the changes to the heat equation example still supposed to be in here? |
docs/src/literate/heat_equation.jl
Outdated
@@ -110,7 +110,7 @@ update!(ch, 0.0); | |||
# We define a function, `doassemble` to do the assembly, which takes our `cellvalues`, | |||
# the sparse matrix and our DofHandler as input arguments. The function returns the | |||
# assembled stiffness matrix, and the force vector. | |||
function doassemble(cellvalues::CellScalarValues{dim}, K::SparseMatrixCSC, dh::DofHandler) where {dim} | |||
function doassemble(cellvalues::CellScalarValues{dim,T}, K::SparseMatrixCSC, dh::JuAFEM.AbstractDofHandler) where {dim,T} |
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.
function doassemble(cellvalues::CellScalarValues{dim,T}, K::SparseMatrixCSC, dh::JuAFEM.AbstractDofHandler) where {dim,T} | |
function doassemble(cellvalues::CellScalarValues{dim}, K::SparseMatrixCSC, dh::JuAFEM.AbstractDofHandler) where {dim} |
seems unused
docs/src/literate/heat_equation.jl
Outdated
@@ -127,20 +127,28 @@ function doassemble(cellvalues::CellScalarValues{dim}, K::SparseMatrixCSC, dh::D | |||
f = zeros(ndofs(dh)) | |||
assembler = start_assemble(K, f) | |||
|
|||
#celldofs = zeros(Int, ndofs_per_cell(dh)) | |||
#cellcoords = zeros(Vec{dim,T}, JuAFEM.nnodes_per_cell(dh)) |
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.
rm?
docs/src/literate/heat_equation.jl
Outdated
# For each cell we also need to reinitialize the cached values in `cellvalues`. | ||
#+ | ||
reinit!(cellvalues, cell) | ||
reinit!(cellvalues, cellcoords) |
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.
Doesn't work with celldata
here?
docs/src/literate/heat_equation.jl
Outdated
# Always remember to reset the element stiffness matrix and | ||
# force vector since we reuse them for all elements. | ||
#+ | ||
fill!(Ke, 0) | ||
fill!(fe, 0) | ||
|
||
#JuAFEM.cellcoords!(cellcoords, dh, cellid) | ||
#JuAFEM.celldofs!(celldofs, dh, cellid) |
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.
rm?
docs/src/literate/heat_equation.jl
Outdated
@@ -166,7 +174,7 @@ function doassemble(cellvalues::CellScalarValues{dim}, K::SparseMatrixCSC, dh::D | |||
# The last step in the element loop is to assemble `Ke` and `fe` | |||
# into the global `K` and `f` with `assemble!`. | |||
#+ | |||
assemble!(assembler, celldofs(cell), fe, Ke) | |||
assemble!(assembler, _celldofs, fe, Ke) |
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.
change back?
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.
I can revert the entire heat_equation example
@@ -54,13 +54,14 @@ struct ConstraintHandler{DH<:AbstractDofHandler,T} | |||
free_dofs::Vector{Int} | |||
values::Vector{T} | |||
dofmapping::Dict{Int,Int} # global dof -> index into dofs and values | |||
bcvalues::Vector{BCValues{T}} |
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.
So each new bc will have it's own bcvalues? Isn't it more a property of the field/interpolation?
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.
MixedDofHandler stores bcvalues in the fieldHandler, and DofHandler stores bcvalues itself, so in able to be able to have the same functionality for both Dohandlers, I must save the bcvalues in ConstraintHandler (I think)
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.
Maybe it is better to store it in Dirichlet
This makes changes to the MixedDofHandler so it will work the same as regular DofHandler for one celltype. This makes it possible to later merge MixedDofHandler/MixedGrid with DofHandler/Grid, which I think is much cleaner than having two versions that basically do the same thing.
I dont think there will any loss in speed becuase of the way dofhandler stores celldofs, cellcoords and collnodes now.