Skip to content

Commit ef6ef7d

Browse files
committed
LVDIM: Use least-squares approximating polynomial.
1 parent aaa3514 commit ef6ef7d

File tree

2 files changed

+22
-23
lines changed

2 files changed

+22
-23
lines changed

src/api.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ function volume_potential(; pde, target, source::Quadrature, compression, correc
290290
loc = target === source ? :inside : correction.target_location
291291
μ = _green_multiplier(loc)
292292
green_multiplier = fill(μ, length(target))
293-
shift = Val(false)
293+
shift = Val(true)
294294
δV = local_vdim_correction(
295295
pde,
296296
eltype(V),

src/vdim.jl

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -193,33 +193,32 @@ function local_vdim_correction(
193193
iszero(center) || error("SHIFT is not implemented for non-zero center")
194194
= [f((q.coords - c) / r) for f in p, q in view(source, jglob)]
195195
S = change_of_basis(multiindices, p, c, r)
196-
F = lu(L̃)
197-
@debug (vander_cond = max(vander_cond, cond(L̃))) maxlog = 0
198-
@debug (shift_norm = max(shift_norm, norm(S))) maxlog = 0
199-
@debug (vander_norm = max(vander_norm, norm(L̃))) maxlog = 0
196+
Linv = pinv(transpose(L̃))
197+
wei = R * transpose(S) * Linv
200198
else
201199
L = [f(q.coords) for f in p, q in view(source, jglob)]
202-
F = lu(L)
203-
@debug (vander_cond = max(vander_cond, cond(L))) maxlog = 0
204-
@debug (shift_norm = max(shift_norm, 1)) maxlog = 0
205-
@debug (vander_norm = max(vander_norm, norm(L))) maxlog = 0
200+
Linv = pinv(transpose(L))
201+
wei = R * Linv
206202
end
207203
# correct each target near the current element
208-
for i in 1:length(near_list[n])
209-
b = @views R[i, :]
210-
wei = SHIFT ? F \ (S * b) : F \ b # weights for the current element and target i
211-
rhs_norm = max(rhs_norm, norm(b))
212-
res_norm = if SHIFT
213-
max(res_norm, norm(L̃ * wei - S * b))
214-
else
215-
max(res_norm, norm(L * wei - b))
216-
end
217-
for k in 1:nq
218-
push!(Is, near_list[n][i])
219-
push!(Js, jglob[k])
220-
push!(Vs, wei[k])
221-
end
204+
push!(Is, repeat(near_list[n], inner = nq)...)
205+
push!(Js, repeat(jglob, outer = length(near_list[n]))...)
206+
push!(Vs, transpose(wei)...)
207+
if isdefined(Main, :Infiltrator)
208+
Main.infiltrate(@__MODULE__, Base.@locals, @__FILE__, @__LINE__)
222209
end
210+
#for i in 1:length(near_list[n])
211+
# #for k in 1:nq
212+
# # push!(Is, near_list[n][i])
213+
# # push!(Js, jglob[k])
214+
# # push!(Vs, wei[i, k])
215+
# #end
216+
# for k in 1:nq
217+
# push!(Is, near_list[n][i])
218+
# push!(Js, jglob[k])
219+
# push!(Vs, wei[i, k])
220+
# end
221+
#end
223222
end
224223
end
225224
@debug """Condition properties of vdim correction:

0 commit comments

Comments
 (0)