From 43bd67ee9e4029c0ba49335a9cf4a811a79d397a Mon Sep 17 00:00:00 2001 From: kimauth Date: Sat, 7 Jan 2023 15:52:14 +0100 Subject: [PATCH 1/2] Remove grid representation from MixedDofHandler --- src/Dofs/MixedDofHandler.jl | 34 ++++++---------------------------- 1 file changed, 6 insertions(+), 28 deletions(-) diff --git a/src/Dofs/MixedDofHandler.jl b/src/Dofs/MixedDofHandler.jl index 9169b36b92..24d6ed76e5 100644 --- a/src/Dofs/MixedDofHandler.jl +++ b/src/Dofs/MixedDofHandler.jl @@ -49,8 +49,6 @@ Construct a `MixedDofHandler` based on `grid`. Supports: struct MixedDofHandler{dim,T,G<:AbstractGrid{dim}} <: AbstractDofHandler fieldhandlers::Vector{FieldHandler} cell_dofs::CellVector{Int} - cell_nodes::CellVector{Int} - cell_coords::CellVector{Vec{dim,T}} closed::ScalarWrapper{Bool} grid::G ndofs::ScalarWrapper{Int} @@ -58,7 +56,7 @@ end function MixedDofHandler(grid::Grid{dim,C,T}) where {dim,C,T} ncells = getncells(grid) - MixedDofHandler{dim,T,typeof(grid)}(FieldHandler[], CellVector(Int[],zeros(Int,ncells),zeros(Int,ncells)), CellVector(Int[],Int[],Int[]), CellVector(Vec{dim,T}[],Int[],Int[]), ScalarWrapper(false), grid, ScalarWrapper(-1)) + MixedDofHandler{dim,T,typeof(grid)}(FieldHandler[], CellVector(Int[],zeros(Int,ncells),zeros(Int,ncells)), ScalarWrapper(false), grid, ScalarWrapper(-1)) end getfieldnames(fh::FieldHandler) = [field.name for field in fh.fields] @@ -101,21 +99,15 @@ function celldofs(dh::MixedDofHandler, i::Int) return dh.cell_dofs[i] end -function cellcoords!(global_coords::Vector{Vec{dim,T}}, dh::MixedDofHandler, i::Int) where {dim,T} - @assert isclosed(dh) - @assert length(global_coords) == nnodes_per_cell(dh, i) - unsafe_copyto!(global_coords, 1, dh.cell_coords.values, dh.cell_coords.offset[i], length(global_coords)) - return global_coords +#TODO: perspectively remove in favor of `getcoordinates!(global_coords, grid, i)`? +function cellcoords!(global_coords::Vector{Vec{dim,T}}, dh::MixedDofHandler, i::Union{Int, <:AbstractCell}) where {dim,T} + cellcoords!(global_coords, dh.grid, i) end -function cellnodes!(global_nodes::Vector{Int}, dh::MixedDofHandler, i::Int) - @assert isclosed(dh) - @assert length(global_nodes) == nnodes_per_cell(dh, i) - unsafe_copyto!(global_nodes, 1, dh.cell_nodes.values, dh.cell_nodes.offset[i], length(global_nodes)) - return global_nodes +function cellnodes!(global_nodes::Vector{Int}, dh::MixedDofHandler, i::Union{Int, <:AbstractCell}) + cellnodes!(global_nodes, dh.grid, i) end - """ getfieldnames(dh::MixedDofHandler) getfieldnames(fh::FieldHandler) @@ -265,20 +257,6 @@ function __close!(dh::MixedDofHandler{dim}) where {dim} dh.ndofs[] = maximum(dh.cell_dofs.values) dh.closed[] = true - #Create cell_nodes and cell_coords (similar to cell_dofs) - push!(dh.cell_nodes.offset, 1) - push!(dh.cell_coords.offset, 1) - for cell in dh.grid.cells - for nodeid in cell.nodes - push!(dh.cell_nodes.values, nodeid) - push!(dh.cell_coords.values, dh.grid.nodes[nodeid].x) - end - push!(dh.cell_nodes.offset, length(dh.cell_nodes.values)+1) - push!(dh.cell_coords.offset, length(dh.cell_coords.values)+1) - push!(dh.cell_nodes.length, length(cell.nodes)) - push!(dh.cell_coords.length, length(cell.nodes)) - end - return dh, vertexdicts, edgedicts, facedicts end From aac45c1ac941ffd112f1963cc3ddef3b33c5d298 Mon Sep 17 00:00:00 2001 From: kimauth Date: Sat, 7 Jan 2023 16:30:10 +0100 Subject: [PATCH 2/2] redirect nnodes_per_cell(dh, cell) to grid --- src/Dofs/MixedDofHandler.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Dofs/MixedDofHandler.jl b/src/Dofs/MixedDofHandler.jl index 24d6ed76e5..95500226c6 100644 --- a/src/Dofs/MixedDofHandler.jl +++ b/src/Dofs/MixedDofHandler.jl @@ -71,7 +71,7 @@ Return the number of degrees of freedom for the cell with index `cell`. See also [`ndofs`](@ref). """ ndofs_per_cell(dh::MixedDofHandler, cell::Int=1) = dh.cell_dofs.length[cell] -nnodes_per_cell(dh::MixedDofHandler, cell::Int=1) = dh.cell_nodes.length[cell] +nnodes_per_cell(dh::MixedDofHandler, cell::Int=1) = nnodes_per_cell(dh.grid, cell) # TODO: deprecate, shouldn't belong to MixedDofHandler any longer """ celldofs!(global_dofs::Vector{Int}, dh::AbstractDofHandler, i::Int)