Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikekre committed Sep 26, 2024
1 parent 237c1cb commit 6c767fe
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
10 changes: 5 additions & 5 deletions docs/src/literate-howto/threaded_assembly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -218,14 +218,14 @@ using OhMyThreads, TaskLocalValues

function assemble_global!(
K::SparseMatrixCSC, f::Vector, dh::DofHandler, colors,
cellvalues_template::CellValues; ntasks = Threads.nthreads()
cellvalues::CellValues; ntasks = Threads.nthreads()
)
## Body force and material stiffness
b = Vec{3}((0.0, 0.0, -1.0))
C = create_material_stiffness()
## Scratch data
scratch_template = ScratchData(
CellCache(dh), cellvalues_template,
scratch = ScratchData(
CellCache(dh), cellvalues,
zeros(ndofs_per_cell(dh), ndofs_per_cell(dh)), zeros(ndofs_per_cell(dh)),
start_assemble(K, f)
)
Expand All @@ -239,8 +239,8 @@ function assemble_global!(
## Tell the @tasks loop to use the scheduler defined above
@set scheduler = scheduler
## Obtain a task local scratch and unpack it
@local scratch = task_local(scratch_template)
(; cell_cache, cellvalues, Ke, fe, assembler) = scratch
@local scratch = task_local(scratch)
local (; cell_cache, cellvalues, Ke, fe, assembler) = scratch
## Reinitialize the cell cache and then the cellvalues
reinit!(cell_cache, cellidx)
reinit!(cellvalues, cell_cache)
Expand Down
1 change: 1 addition & 0 deletions src/interpolations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ nedges(::Interpolation{RefShape}) where RefShape = nedges(RefShape)
nfaces(::Interpolation{RefShape}) where RefShape = nfaces(RefShape)

Base.copy(ip::Interpolation) = ip
task_local(ip::Interpolation) = ip

"""
Ferrite.getrefdim(::Interpolation)
Expand Down
7 changes: 7 additions & 0 deletions src/iterators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,13 @@ function reinit!(cc::CellCache, i::Int)
return cc
end

function task_local(cc::CellCache)
return CellCache(
cc.flags, cc.grid, cc.cellid, task_local(cc.nodes), task_local(cc.coords), cc.dh,
task_local(cc.dofs)
)
end

# reinit! FEValues with CellCache
reinit!(cv::CellValues, cc::CellCache) = reinit!(cv, cc.coords)
reinit!(fv::FacetValues, cc::CellCache, f::Int) = reinit!(fv, cc.coords, f) # TODO: Deprecate?
Expand Down

0 comments on commit 6c767fe

Please sign in to comment.