Skip to content

Commit

Permalink
Fix vol
Browse files Browse the repository at this point in the history
  • Loading branch information
zjwegert committed Jun 10, 2024
1 parent 15aa1f9 commit 04498f9
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
14 changes: 7 additions & 7 deletions scripts/Embedded/2d_thermal.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function main()
## Optimisation functionals
J(u,φ,dΩ,dΓ_N,dΩ1,dΩ2,dΓ) = ((u)(u))dΩ1
dJ(q,u,φ,dΩ,dΓ_N,dΩ1,dΩ2,dΓ) = ((u)(u)*q)dΓ;
Vol(u,φ,dΩ,dΓ_N,dΩ1,dΩ2,dΓ) = (1/vol_D)dΩ1 - (vf)dΩ;
Vol(u,φ,dΩ,dΓ_N,dΩ1,dΩ2,dΓ) = (1/vol_D)dΩ1 - (vf/vol_D)dΩ;
dVol(q,u,φ,dΩ,dΓ_N,dΩ1,dΩ2,dΓ) = (-1/vol_D*q)dΓ

## IntegrandWithEmbeddedMeasure
Expand Down Expand Up @@ -78,17 +78,17 @@ function main()
optimiser = AugmentedLagrangian(pcfs,ls_evo,vel_ext,φh;
γ,γ_reinit,verbose=true,constraint_names=[:Vol])
for (it,uh,φh) in optimiser
dΩ1,_, = get_meas(φh)
_Ω1,_, = get_embedded_triangulations(embedded_meas)
if iszero(it % iter_mod)
writevtk(dΩ1.quad.trian,path*"Omega_out$it",cellfields=["φ"=>φh,"|∇(φ)|"=>(norm (φh)),"uh"=>uh])
writevtk(.quad.trian,path*"Gamma_out$it",cellfields=["normal"=>get_normal_vector(.quad.trian)])
writevtk(_Ω1,path*"Omega_out$it",cellfields=["φ"=>φh,"|∇(φ)|"=>(norm (φh)),"uh"=>uh])
writevtk(,path*"Gamma_out$it",cellfields=["normal"=>get_normal_vector()])
end
write_history(path*"/history.txt",optimiser.history)
end
it = get_history(optimiser).niter; uh = get_state(pcfs)
dΩ1,_, = get_meas(φh)
writevtk(dΩ1.quad.trian,path*"Omega_out$it",cellfields=["φ"=>φh,"|∇(φ)|"=>(norm (φh)),"uh"=>uh])
writevtk(.quad.trian,path*"Gamma_out$it",cellfields=["normal"=>get_normal_vector(.quad.trian)])
_Ω1,_, = get_embedded_triangulations(embedded_meas)
writevtk(_Ω1,path*"Omega_out$it",cellfields=["φ"=>φh,"|∇(φ)|"=>(norm (φh)),"uh"=>uh])
writevtk(,path*"Gamma_out$it",cellfields=["normal"=>get_normal_vector()])
end

main()
14 changes: 7 additions & 7 deletions scripts/Embedded/2d_thermal_optimised.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function main()
## Optimisation functionals
J(u,φ,dΩ,dΓ_N,dΩ1,dΩ2,dΓ) = ((u)(u))dΩ1
dJ(q,u,φ,dΩ,dΓ_N,dΩ1,dΩ2,dΓ) = ((u)(u)*q)dΓ;
Vol(u,φ,dΩ,dΓ_N,dΩ1,dΩ2,dΓ) = (1/vol_D)dΩ1 - (vf)dΩ;
Vol(u,φ,dΩ,dΓ_N,dΩ1,dΩ2,dΓ) = (1/vol_D)dΩ1 - (vf/vol_D)dΩ;
dVol(q,u,φ,dΩ,dΓ_N,dΩ1,dΩ2,dΓ) = (-1/vol_D*q)dΓ

## IntegrandWithEmbeddedMeasure
Expand Down Expand Up @@ -79,17 +79,17 @@ function main()
optimiser = AugmentedLagrangian(pcfs,ls_evo,vel_ext,φh;reinit_mod=5,
γ,γ_reinit,verbose=true,constraint_names=[:Vol])
for (it,uh,φh) in optimiser
dΩ1,_, = get_meas(φh)
_Ω1,_, = get_embedded_triangulations(embedded_meas)
if iszero(it % iter_mod)
writevtk(dΩ1.quad.trian,path*"Omega_out$it",cellfields=["φ"=>φh,"|∇(φ)|"=>(norm (φh)),"uh"=>uh])
writevtk(.quad.trian,path*"Gamma_out$it",cellfields=["normal"=>get_normal_vector(.quad.trian)])
writevtk(_Ω1,path*"Omega_out$it",cellfields=["φ"=>φh,"|∇(φ)|"=>(norm (φh)),"uh"=>uh])
writevtk(,path*"Gamma_out$it",cellfields=["normal"=>get_normal_vector()])
end
write_history(path*"/history.txt",optimiser.history)
end
it = get_history(optimiser).niter; uh = get_state(pcfs)
dΩ1,_, = get_meas(φh)
writevtk(dΩ1.quad.trian,path*"Omega_out$it",cellfields=["φ"=>φh,"|∇(φ)|"=>(norm (φh)),"uh"=>uh])
writevtk(.quad.trian,path*"Gamma_out$it",cellfields=["normal"=>get_normal_vector(.quad.trian)])
_Ω1,_, = get_embedded_triangulations(embedded_meas)
writevtk(_Ω1,path*"Omega_out$it",cellfields=["φ"=>φh,"|∇(φ)|"=>(norm (φh)),"uh"=>uh])
writevtk(,path*"Gamma_out$it",cellfields=["normal"=>get_normal_vector()])
end

main()
4 changes: 2 additions & 2 deletions scripts/Embedded/2d_thermal_optimised_MPI.jl
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ function main(parts,distribute)
optimiser = AugmentedLagrangian(pcfs,ls_evo,vel_ext,φh;reinit_mod=5,
γ,γ_reinit,verbose=i_am_main(ranks),constraint_names=[:Vol])
for (it,uh,φh) in optimiser
_Ω1,_,_Γ = get_embedded_triangulations(φh,embedded_meas)
_Ω1,_,_Γ = get_embedded_triangulations(embedded_meas)
if iszero(it % iter_mod)
writevtk(_Ω1,path*"Omega_out$it",cellfields=["φ"=>φh,"|∇(φ)|"=>(norm (φh)),"uh"=>uh])
writevtk(_Γ,path*"Gamma_out$it",cellfields=["normal"=>get_normal_vector(_Γ)])
end
write_history(path*"/history.txt",optimiser.history;ranks)
end
it = get_history(optimiser).niter; uh = get_state(pcfs)
_Ω1,_,_Γ = get_embedded_triangulations(φh,embedded_meas)
_Ω1,_,_Γ = get_embedded_triangulations(embedded_meas)
writevtk(_Ω1,path*"Omega_out$it",cellfields=["φ"=>φh,"|∇(φ)|"=>(norm (φh)),"uh"=>uh])
writevtk(_Γ,path*"Gamma_out$it",cellfields=["normal"=>get_normal_vector(_Γ)])
end
Expand Down
2 changes: 1 addition & 1 deletion scripts/Embedded/embedded_measures.jl
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ function get_embedded_measures(φ,s::EmbeddedMeasureCache)
return s.measures
end

function get_embedded_triangulations(φ,s::EmbeddedMeasureCache)
function get_embedded_triangulations(s::EmbeddedMeasureCache)
return s.trians
end

Expand Down

0 comments on commit 04498f9

Please sign in to comment.