Skip to content

Commit

Permalink
some more testing and changes
Browse files Browse the repository at this point in the history
  • Loading branch information
zjwegert committed Sep 16, 2024
1 parent 05bcc73 commit a25cfe1
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function GridapTopOpt.evolve!(s::UnfittedFEEvolution,φh,vel,γ)
NT, h, c, dΩ = params.NT, params.h, params.c, params.
# ode_solver = s.ode_solver
Tf = γ*NT
velh = FEFunction(V_φ,vel)
velh = FEFunction(V_φ,vel) # <- needs to be normalised by Hilbertian projection norm

# This is temp as can't update γ in ode_solver yet
ode_ls = LUSolver()
Expand Down Expand Up @@ -92,7 +92,7 @@ function GridapTopOpt.reinit!(s::UnfittedFEEvolution,φh,args...)
reinit_nls = s.reinit_nls

γd = 20
cₐ = 0.5 # <- 3 in connor's paper
cₐ = 3.0 # 0.5 # <- 3 in connor's paper
ϵ = 1e-20

# Tmp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,40 @@ reffe_scalar = ReferenceFE(lagrangian,Float64,order)
V_φ = TestFESpace(model,reffe_scalar)
Ut_φ = TransientTrialFESpace(V_φ,t -> (x->-1))

φh = interpolate(x->cos(2π*x[1])*cos(2π*x[2])-0.11,V_φ)
α = 2.0*h
a_hilb(p,q) = ^2*(p)(q) + p*q)dΩ;
vel_ext = VelocityExtension(a_hilb,V_φ,V_φ)

ls_evo = UnfittedFEEvolution(Ut_φ, V_φ, dΩ, h; NT = 5, c = 0.1)
# φh = interpolate(x->-sqrt((x[1]-0.5)^2+(x[2]-0.5)^2)+0.25,V_φ) # <- Already SDF
φh = interpolate(x->cos(2π*x[1])*cos(2π*x[2])-0.11,V_φ)

reinit!(ls_evo,φh)
velh = interpolate(x->-1,V_φ)
function compute_test_velh(φh)
geo = DiscreteGeometry(φh,model)
cutgeo = cut(model,geo)
Ωin = Triangulation(cutgeo,PHYSICAL_IN).a
diff_Ωin = DifferentiableTriangulation(Ωin)
dΩin = Measure(diff_Ωin,2*order)
j_in(φ) = (φ)dΩin
dj_in = gradient(j_in,φh)
dj_vec_in = assemble_vector(dj_in,V_φ)
project!(vel_ext,dj_vec_in)
vel = dj_vec_in/sqrt(dj_vec_in'*vel_ext.K*dj_vec_in)
return FEFunction(V_φ,vel)
end

ls_evo = UnfittedFEEvolution(Ut_φ, V_φ, dΩ, h; NT = 5, c = 0.1,
reinit_nls = NLSolver(ftol=1e-12, iterations = 50, show_trace=true))
reinit!(ls_evo,φh) # <- inital sdf

velh = compute_test_velh(φh)
# velh = interpolate(x->-1,V_φ)
evolve!(ls_evo,φh,get_free_dof_values(velh),0.01)
reinit!(ls_evo,φh)

# You can compare the zero-iso curve for advected circle via
# φh_expected_contour = interpolate(x->-sqrt((x[1]-0.5)^2+(x[2]-0.5)^2)+0.25+ls_evo.params.NT*0.01,V_φ)

writevtk(
Ω,"results/test_evolve",
cellfields=["φh"=>φh,"|∇φh|"=>norm (φh)]
cellfields=["φh"=>φh,"|∇φh|"=>norm (φh),"velh"=>velh]#,"φh_expected_contour"=>φh_expected_contour]
)

0 comments on commit a25cfe1

Please sign in to comment.