Skip to content

Commit 9a04bfd

Browse files
author
chmerdon
committed
some improvements
1 parent b740dbf commit 9a04bfd

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

examples/Example227_ObstacleProblemLVPP.jl

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#=
22
3-
# 225 : Obstacle Problem LVPP
3+
# 227 : Obstacle Problem LVPP
44
([source code](@__SOURCE_URL__))
55
66
This example computes the solution ``u`` of the nonlinear obstacle problem that seeks
@@ -65,16 +65,23 @@ function χ(x)
6565
end
6666
end
6767

68+
## transformation of latent variable ψ to constrained variable u
6869
function ∇R!(result, input, qpinfo)
6970
return result[1] = χ(qpinfo.x) + exp(input[1])
7071
end
7172

73+
## boundary data for latent variable ψ (such that ̃u := χ + ∇R(ψ) satisfies Dirichlet boundary conditions)
74+
function bnd_ψ!(result, qpinfo)
75+
return result[1] = log(-χ(qpinfo.x))
76+
end
77+
7278
function main(;
7379
nrefs = 5,
7480
α0 = 1.0,
7581
order = 1,
7682
parallel = false,
7783
npart = 8,
84+
tol = 1.0e-12,
7885
Plotter = nothing,
7986
kwargs...
8087
)
@@ -114,6 +121,7 @@ function main(;
114121
assign_operator!(PD, BilinearOperator([id(u)], [(id(ψ))]; transposed_copy = 1, store = true, parallel = parallel, kwargs...))
115122
assign_operator!(PD, NonlinearOperator(∇R!, [id(ψ)], [id(ψ)]; parallel = parallel, factor = -1, kwargs...))
116123
assign_operator!(PD, HomogeneousBoundaryData(u; regions = 1:4, kwargs...))
124+
assign_operator!(PD, InterpolateBoundaryData(ψ, bnd_ψ!; regions = 1:4, kwargs...))
117125
assign_operator!(PD, LinearOperator(b, [u]; kwargs...))
118126

119127
## solve
@@ -138,7 +146,7 @@ function main(;
138146
## compute distance
139147
dist = norm(view(sol[u]) .- view(sol_prev[u]))
140148
@info "dist = $dist, niterations = $(niterations - 1)"
141-
if dist < 1.0e-10
149+
if dist < tol
142150
converged = true
143151
else
144152
# increase proximal parameter

0 commit comments

Comments
 (0)