Skip to content

Commit 4651400

Browse files
committed
updated ExampleA09 (still no allocations even if EG is determined at runtime, thanks j-fu), trybrute parameter of gFindLocal! is now used
1 parent a2e7bd6 commit 4651400

File tree

3 files changed

+38
-43
lines changed

3 files changed

+38
-43
lines changed

examples/ExampleA09_PoissonLowLevel.jl

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,7 @@ function assemble_rhs!(b::AbstractVector, FES::FESpace; f = nothing)
141141
end
142142

143143
xgrid = FES.xgrid
144-
# EG = xgrid[UniqueCellGeometries][1]
145-
EG = Triangle2D
144+
EG = xgrid[UniqueCellGeometries][1]
146145
FEType = eltype(FES)
147146

148147
## quadrature formula
@@ -161,34 +160,37 @@ function assemble_rhs!(b::AbstractVector, FES::FESpace; f = nothing)
161160
L2G::L2GTransformer{Float64, Int32, EG} = L2GTransformer(EG, xgrid, ON_CELLS)
162161

163162
## ASSEMBLY LOOP
164-
bloc = zeros(Float64, ndofs4cell)
165-
ncells::Int = num_cells(xgrid)
166-
dof_j::Int = 0
167-
x::Vector{Float64} = zeros(Float64, 2)
168-
cellvolumes = xgrid[CellVolumes]
169-
170-
@time for cell = 1 : ncells
171-
for j = 1 : ndofs4cell
172-
## right-hand side
173-
temp = 0
174-
for qp = 1 : nweights
175-
## get global x for quadrature point
176-
update_trafo!(L2G, cell)
177-
eval_trafo!(x, L2G, xref[qp])
178-
179-
## (f, v_j)
180-
temp += weights[qp] * idvals[1, j, qp] * fdata(x)[1]
163+
function barrier(L2G::L2GTransformer{Tv,Ti,Tg,Tc}) where {Tv,Ti,Tg,Tc}
164+
165+
bloc = zeros(Float64, ndofs4cell)
166+
ncells::Int = num_cells(xgrid)
167+
dof_j::Int = 0
168+
x::Vector{Float64} = zeros(Float64, 2)
169+
cellvolumes = xgrid[CellVolumes]
170+
171+
@time for cell = 1 : ncells
172+
for j = 1 : ndofs4cell
173+
## right-hand side
174+
temp = 0
175+
for qp = 1 : nweights
176+
## get global x for quadrature point
177+
update_trafo!(L2G, cell)
178+
eval_trafo!(x, L2G, xref[qp])
179+
## (f, v_j)
180+
temp += weights[qp] * idvals[1, j, qp] * fdata(x)[1]
181181
end
182-
bloc[j] = temp
183-
end
184-
185-
for j = 1 : ndofs4cell
186-
dof_j = CellDofs[j, cell]
187-
b[dof_j] += bloc[j] * cellvolumes[cell]
182+
bloc[j] = temp
183+
end
184+
185+
for j = 1 : ndofs4cell
186+
dof_j = CellDofs[j, cell]
187+
b[dof_j] += bloc[j] * cellvolumes[cell]
188+
end
189+
190+
fill!(bloc, 0)
188191
end
189-
190-
fill!(bloc, 0)
191192
end
193+
barrier(L2G)
192194
end
193195

194196
function solve_poisson_lowlevel!(Solution; μ = 1)

src/interpolations.jl

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,8 @@ function ExtendableGrids.interpolate!(
483483
source::FEVectorBlock{T2,Tv,Ti};
484484
operator = Identity,
485485
postprocess = NoAction(),
486-
xtrafo = nothing, items = [],
486+
xtrafo = nothing,
487+
items = [],
487488
not_in_domain_value = 1e30,
488489
start_cell = 1,
489490
only_localsearch = false,
@@ -530,9 +531,9 @@ function ExtendableGrids.interpolate!(
530531
end
531532
if xtrafo !== nothing
532533
xtrafo(x_source, x)
533-
cell = gFindLocal!(xref, CF, x_source; icellstart = lastnonzerocell, eps = eps)
534+
cell = gFindLocal!(xref, CF, x_source; icellstart = lastnonzerocell, eps = eps, trybrute = !only_localsearch)
534535
else
535-
cell = gFindLocal!(xref, CF, x; icellstart = lastnonzerocell, eps = eps)
536+
cell = gFindLocal!(xref, CF, x; icellstart = lastnonzerocell, eps = eps, trybrute = !only_localsearch)
536537
end
537538
evaluate!(result,PE,xref,cell)
538539
return nothing
@@ -542,15 +543,9 @@ function ExtendableGrids.interpolate!(
542543
function point_evaluation_arbitrarygrids!(result, x)
543544
if xtrafo !== nothing
544545
xtrafo(x_source, x)
545-
cell = gFindLocal!(xref, CF, x_source; icellstart = lastnonzerocell, eps = eps)
546-
if cell == 0 && !only_localsearch
547-
cell = gFindBruteForce!(xref, CF, x_source)
548-
end
546+
cell = gFindLocal!(xref, CF, x_source; icellstart = lastnonzerocell, eps = eps, trybrute = !only_localsearch)
549547
else
550-
cell = gFindLocal!(xref, CF, x; icellstart = lastnonzerocell, eps = eps)
551-
if cell == 0 && !only_localsearch
552-
cell = gFindBruteForce!(xref, CF, x)
553-
end
548+
cell = gFindLocal!(xref, CF, x; icellstart = lastnonzerocell, eps = eps, trybrute = !only_localsearch)
554549
end
555550
if cell == 0
556551
fill!(result, not_in_domain_value)

src/userdata.jl

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,12 +156,10 @@ function nodevalues(xgrid::ExtendableGrid{Tv,Ti}, UD::AbstractUserDataType; T =
156156
UD.x = zeros(T,size(xCoordinates,1))
157157
end
158158
nodevals = zeros(T,UD.argsizes[1],nnodes)
159+
if is_itemdependent(UD)
160+
@warn "item dependence ignored in nodevalues for DataFunction"
161+
end
159162
for j = 1 : nnodes
160-
if is_itemdependent(UD)
161-
UD.citem[1] = cell
162-
UD.citem[2] = cell
163-
UD.citem[3] = xCellRegions[cell]
164-
end
165163
if is_xdependent(UD)
166164
UD.x .= view(xCoordinates,:,j)
167165
end

0 commit comments

Comments
 (0)