Skip to content

Commit

Permalink
Add gc call and removed write_vtk
Browse files Browse the repository at this point in the history
  • Loading branch information
zjwegert committed Apr 4, 2024
1 parent 849b5a8 commit a18b6c9
Show file tree
Hide file tree
Showing 30 changed files with 127 additions and 103 deletions.
6 changes: 1 addition & 5 deletions docs/src/reference/io.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
# IO

## Optimiser history and visualisation
## Optimiser history
```@docs
LevelSetTopOpt.write_history
```

```@docs
LevelSetTopOpt.write_vtk
```

## Object IO in serial
```@docs
LevelSetTopOpt.save
Expand Down
10 changes: 6 additions & 4 deletions scripts/MPI/3d_elastic_compliance_ALM.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ function main(mesh_partition,distribute,el_size)
η_coeff = 2
α_coeff = 4
vf = 0.4
path = dirname(dirname(@__DIR__))*"/results/3d_elastic_compliance_ALM"
path = dirname(dirname(@__DIR__))*"/results/3d_elastic_compliance_ALM/"
iter_mod = 10
i_am_main(ranks) && mkdir(path)

## FE Setup
model = CartesianDiscreteModel(ranks,mesh_partition,dom,el_size);
Expand Down Expand Up @@ -98,15 +100,15 @@ function main(mesh_partition,distribute,el_size)
)

## Optimiser
i_am_main(ranks) && mkdir(path)
optimiser = AugmentedLagrangian(pcfs,stencil,vel_ext,φh;
γ,γ_reinit,verbose=i_am_main(ranks),constraint_names=[:Vol])
for (it, uh, φh) in optimiser
write_vtk(Ω,path*"/struc_$it",it,["phi"=>φh,"H(phi)"=>(H φh),"|nabla(phi)|"=>(norm (φh)),"uh"=>uh])
data = ["φ"=>φh,"H(φ)"=>(H φh),"|∇(φ)|"=>(norm (φh)),"uh"=>uh]
iszero(it % iter_mod) && writevtk(Ω,path*"out$it",cellfields=data)
write_history(path*"/history.txt",optimiser.history;ranks=ranks)
end
it = get_history(optimiser).niter; uh = get_state(pcfs)
write_vtk(Ω,path*"/struc_$it",it,["phi"=>φh,"H(phi)"=>(H φh),"|nabla(phi)|"=>(norm (φh)),"uh"=>uh];iter_mod=1)
writevtk(Ω,path*"out$it",cellfields=["φ"=>φh,"H(φ)"=>(H φh),"|∇(φ)|"=>(norm (φh)),"uh"=>uh])
end

with_mpi() do distribute
Expand Down
10 changes: 6 additions & 4 deletions scripts/MPI/3d_hyperelastic_compliance_ALM.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ function main(mesh_partition,distribute,el_size)
η_coeff = 2
α_coeff = 4
vf = 0.4
path = dirname(dirname(@__DIR__))*"/results/3d_hyperelastic_compliance_ALM"
path = dirname(dirname(@__DIR__))*"/results/3d_hyperelastic_compliance_ALM/"
iter_mod = 10
i_am_main(ranks) && mkdir(path)

## FE Setup
model = CartesianDiscreteModel(ranks,mesh_partition,dom,el_size)
Expand Down Expand Up @@ -104,15 +106,15 @@ function main(mesh_partition,distribute,el_size)
)

## Optimiser
i_am_main(ranks) && mkdir(path)
optimiser = AugmentedLagrangian(pcfs,stencil,vel_ext,φh;
γ,γ_reinit,verbose=i_am_main(ranks),constraint_names=[:Vol])
for (it, uh, φh) in optimiser
write_vtk(Ω,path*"/struc_$it",it,["phi"=>φh,"H(phi)"=>(H φh),"|nabla(phi)|"=>(norm (φh)),"uh"=>uh])
data = ["φ"=>φh,"H(φ)"=>(H φh),"|∇(φ)|"=>(norm (φh)),"uh"=>uh]
iszero(it % iter_mod) && writevtk(Ω,path*"out$it",cellfields=data)
write_history(path*"/history.txt",optimiser.history;ranks=ranks)
end
it = get_history(optimiser).niter; uh = get_state(pcfs)
write_vtk(Ω,path*"/struc_$it",it,["phi"=>φh,"H(phi)"=>(H φh),"|nabla(phi)|"=>(norm (φh)),"uh"=>uh];iter_mod=1)
writevtk(Ω,path*"out$it",cellfields=["φ"=>φh,"H(φ)"=>(H φh),"|∇(φ)|"=>(norm (φh)),"uh"=>uh])
end

with_mpi() do distribute
Expand Down
10 changes: 6 additions & 4 deletions scripts/MPI/3d_hyperelastic_compliance_neohook_ALM.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ function main(mesh_partition,distribute,el_size)
η_coeff = 2
α_coeff = 4
vf = 0.4
path = dirname(dirname(@__DIR__))*"/results/3d_hyperelastic_compliance_neohook_ALM"
path = dirname(dirname(@__DIR__))*"/results/3d_hyperelastic_compliance_neohook_ALM/"
iter_mod = 10
i_am_main(ranks) && mkdir(path)

## FE Setup
model = CartesianDiscreteModel(ranks,mesh_partition,dom,el_size)
Expand Down Expand Up @@ -118,15 +120,15 @@ function main(mesh_partition,distribute,el_size)
)

## Optimiser
i_am_main(ranks) && mkdir(path)
optimiser = AugmentedLagrangian(pcfs,stencil,vel_ext,φh;
γ,γ_reinit,verbose=i_am_main(ranks),constraint_names=[:Vol])
for (it, uh, φh) in optimiser
write_vtk(Ω,path*"/struc_$it",it,["phi"=>φh,"H(phi)"=>(H φh),"|nabla(phi)|"=>(norm (φh)),"uh"=>uh])
data = ["φ"=>φh,"H(φ)"=>(H φh),"|∇(φ)|"=>(norm (φh)),"uh"=>uh]
iszero(it % iter_mod) && writevtk(Ω,path*"out$it",cellfields=data)
write_history(path*"/history.txt",optimiser.history;ranks=ranks)
end
it = get_history(optimiser).niter; uh = get_state(pcfs)
write_vtk(Ω,path*"/struc_$it",it,["phi"=>φh,"H(phi)"=>(H φh),"|nabla(phi)|"=>(norm (φh)),"uh"=>uh];iter_mod=1)
writevtk(Ω,path*"out$it",cellfields=["φ"=>φh,"H(φ)"=>(H φh),"|∇(φ)|"=>(norm (φh)),"uh"=>uh])
end

with_mpi() do distribute
Expand Down
10 changes: 6 additions & 4 deletions scripts/MPI/3d_inverse_homenisation_ALM.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ function main(mesh_partition,distribute,el_size)
η_coeff = 2
α_coeff = 4
vf = 0.5
path = dirname(dirname(@__DIR__))*"/results/3d_inverse_homenisation_ALM"
i_am_main(ranks) && mkdir(path)
path = dirname(dirname(@__DIR__))*"/results/3d_inverse_homenisation_ALM/"
iter_mod = 10
i_am_main(ranks) && mkdir(path)

## FE Setup
model = CartesianDiscreteModel(ranks,mesh_partition,dom,el_size,isperiodic=(true,true,true))
Expand Down Expand Up @@ -106,11 +107,12 @@ function main(mesh_partition,distribute,el_size)
optimiser = AugmentedLagrangian(pcfs,stencil,vel_ext,φh;
γ,γ_reinit,verbose=i_am_main(ranks),constraint_names=[:Vol])
for (it, uh, φh) in optimiser
write_vtk(Ω,path*"/struc_$it",it,["phi"=>φh,"H(phi)"=>(H φh),"|nabla(phi)|"=>(norm (φh))])
data = ["φ"=>φh,"H(φ)"=>(H φh),"|∇(φ)|"=>(norm (φh))]
iszero(it % iter_mod) && writevtk(Ω,path*"out$it",cellfields=data)
write_history(path*"/history.txt",optimiser.history;ranks=ranks)
end
it = get_history(optimiser).niter; uh = get_state(pcfs)
write_vtk(Ω,path*"/struc_$it",it,["phi"=>φh,"H(phi)"=>(H φh),"|nabla(phi)|"=>(norm (φh))];iter_mod=1)
writevtk(Ω,path*"out$it",cellfields=["φ"=>φh,"H(φ)"=>(H φh),"|∇(φ)|"=>(norm (φh))])
end

with_mpi() do distribute
Expand Down
8 changes: 5 additions & 3 deletions scripts/MPI/3d_inverter_ALM.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ function main(mesh_partition,distribute,el_size)
δₓ=0.5
ks = 0.01
g = VectorValue(1,0,0)
path = dirname(dirname(@__DIR__))*"/results/3d_inverter_ALM"
path = dirname(dirname(@__DIR__))*"/results/3d_inverter_ALM/"
iter_mod = 10
i_am_main(ranks) && mkdir(path)

## FE Setup
Expand Down Expand Up @@ -120,11 +121,12 @@ function main(mesh_partition,distribute,el_size)
optimiser = AugmentedLagrangian(pcfs,stencil,vel_ext,φh;
γ,γ_reinit,verbose=i_am_main(ranks),constraint_names=[:Vol,:UΓ_out])
for (it, uh, φh) in optimiser
write_vtk(Ω,path*"/struc_$it",it,["phi"=>φh,"H(phi)"=>(H φh),"|nabla(phi)|"=>(norm (φh)),"uh"=>uh])
data = ["φ"=>φh,"H(φ)"=>(H φh),"|∇(φ)|"=>(norm (φh)),"uh"=>uh]
iszero(it % iter_mod) && writevtk(Ω,path*"out$it",cellfields=data)
write_history(path*"/history.txt",optimiser.history;ranks=ranks)
end
it = get_history(optimiser).niter; uh = get_state(pcfs)
write_vtk(Ω,path*"/struc_$it",it,["phi"=>φh,"H(phi)"=>(H φh),"|nabla(phi)|"=>(norm (φh)),"uh"=>uh];iter_mod=1)
writevtk(Ω,path*"out$it",cellfields=["φ"=>φh,"H(φ)"=>(H φh),"|∇(φ)|"=>(norm (φh)),"uh"=>uh])
end

with_mpi() do distribute
Expand Down
8 changes: 5 additions & 3 deletions scripts/MPI/3d_inverter_HPM.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ function main(mesh_partition,distribute,el_size)
δₓ=0.5
ks = 0.01
g = VectorValue(1,0,0)
path = dirname(dirname(@__DIR__))*"/results/3d_inverter_HPM"
path = dirname(dirname(@__DIR__))*"/results/3d_inverter_HPM/"
iter_mod = 10
i_am_main(ranks) && mkdir(path)

## FE Setup
Expand Down Expand Up @@ -121,11 +122,12 @@ function main(mesh_partition,distribute,el_size)
optimiser = HilbertianProjection(pcfs,stencil,vel_ext,φh;γ,γ_reinit,ls_enabled,α_min=0.7,
ls_γ_max=0.05,verbose=i_am_main(ranks),constraint_names=[:Vol,:UΓ_out])
for (it, uh, φh) in optimiser
write_vtk(Ω,path*"/struc_$it",it,["phi"=>φh,"H(phi)"=>(H φh),"|nabla(phi)|"=>(norm (φh)),"uh"=>uh])
data = ["φ"=>φh,"H(φ)"=>(H φh),"|∇(φ)|"=>(norm (φh)),"uh"=>uh]
iszero(it % iter_mod) && writevtk(Ω,path*"out$it",cellfields=data)
write_history(path*"/history.txt",optimiser.history;ranks=ranks)
end
it = get_history(optimiser).niter; uh = get_state(pcfs)
write_vtk(Ω,path*"/struc_$it",it,["phi"=>φh,"H(phi)"=>(H φh),"|nabla(phi)|"=>(norm (φh)),"uh"=>uh];iter_mod=1)
writevtk(Ω,path*"out$it",cellfields=["φ"=>φh,"H(φ)"=>(H φh),"|∇(φ)|"=>(norm (φh)),"uh"=>uh])
end

with_mpi() do distribute
Expand Down
8 changes: 5 additions & 3 deletions scripts/MPI/3d_nonlinear_thermal_compliance_ALM.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ function main(mesh_partition,distribute,el_size)
η_coeff = 2
α_coeff = 4
vf = 0.4
path = dirname(dirname(@__DIR__))*"/results/3d_nonlinear_thermal_compliance_ALM"
path = dirname(dirname(@__DIR__))*"/results/3d_nonlinear_thermal_compliance_ALM/"
iter_mod = 10
i_am_main(ranks) && mkdir(path)

## FE Setup
Expand Down Expand Up @@ -108,11 +109,12 @@ function main(mesh_partition,distribute,el_size)
optimiser = AugmentedLagrangian(pcfs,stencil,vel_ext,φh;
γ,γ_reinit,verbose=i_am_main(ranks),constraint_names=[:Vol])
for (it, uh, φh) in optimiser
write_vtk(Ω,path*"/struc_$it",it,["phi"=>φh,"H(phi)"=>(H φh),"|nabla(phi)|"=>(norm (φh)),"uh"=>uh])
data = ["φ"=>φh,"H(φ)"=>(H φh),"|∇(φ)|"=>(norm (φh)),"uh"=>uh]
iszero(it % iter_mod) && writevtk(Ω,path*"out$it",cellfields=data)
write_history(path*"/history.txt",optimiser.history;ranks=ranks)
end
it = get_history(optimiser).niter; uh = get_state(pcfs)
write_vtk(Ω,path*"/struc_$it",it,["phi"=>φh,"H(phi)"=>(H φh),"|nabla(phi)|"=>(norm (φh)),"uh"=>uh];iter_mod=1)
writevtk(Ω,path*"out$it",cellfields=["φ"=>φh,"H(φ)"=>(H φh),"|∇(φ)|"=>(norm (φh)),"uh"=>uh])
end

with_mpi() do distribute
Expand Down
6 changes: 4 additions & 2 deletions scripts/MPI/3d_thermal_compliance_ALM.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ function main(mesh_partition,distribute,el_size,coef,step)
α_coeff = 4
vf = 0.4
path = dirname(dirname(@__DIR__))*"/results/3d_thermal_compliance_ALM_Nx$(el_size[1])_Coef$(coef)_Step$(step)"
iter_mod = 10
i_am_main(ranks) && mkdir(path)

## FE Setup
Expand Down Expand Up @@ -111,11 +112,12 @@ function main(mesh_partition,distribute,el_size,coef,step)
optimiser = AugmentedLagrangian(pcfs,stencil,vel_ext,φh;
γ,γ_reinit,verbose=i_am_main(ranks),constraint_names=[:Vol])
for (it, uh, φh) in optimiser
write_vtk(Ω,path*"/struc_$it",it,["phi"=>φh,"H(phi)"=>(H φh),"|nabla(phi)|"=>(norm (φh)),"uh"=>uh])
data = ["φ"=>φh,"H(φ)"=>(H φh),"|∇(φ)|"=>(norm (φh)),"uh"=>uh]
iszero(it % iter_mod) && writevtk(Ω,path*"out$it",cellfields=data)
write_history(path*"/history.txt",optimiser.history;ranks=ranks)
end
it = get_history(optimiser).niter; uh = get_state(pcfs)
write_vtk(Ω,path*"/struc_$it",it,["phi"=>φh,"H(phi)"=>(H φh),"|nabla(phi)|"=>(norm (φh)),"uh"=>uh];iter_mod=1)
writevtk(Ω,path*"out$it",cellfields=["φ"=>φh,"H(φ)"=>(H φh),"|∇(φ)|"=>(norm (φh)),"uh"=>uh])
end

with_mpi() do distribute
Expand Down
6 changes: 4 additions & 2 deletions scripts/MPI/elastic_compliance_ALM.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ function main(mesh_partition,distribute,el_size)
α_coeff = 4
vf = 0.4
path = dirname(dirname(@__DIR__))*"/results/elastic_compliance_ALM_MPI"
iter_mod = 10
i_am_main(ranks) && mkdir(path)

## FE Setup
Expand Down Expand Up @@ -100,11 +101,12 @@ function main(mesh_partition,distribute,el_size)
optimiser = AugmentedLagrangian(pcfs,stencil,vel_ext,φh;
γ,γ_reinit,verbose=i_am_main(ranks),constraint_names=[:Vol])
for (it, uh, φh) in optimiser
write_vtk(Ω,path*"/struc_$it",it,["phi"=>φh,"H(phi)"=>(H φh),"|nabla(phi)|"=>(norm (φh)),"uh"=>uh])
data = ["φ"=>φh,"H(φ)"=>(H φh),"|∇(φ)|"=>(norm (φh)),"uh"=>uh]
iszero(it % iter_mod) && writevtk(Ω,path*"out$it",cellfields=data)
write_history(path*"/history.txt",optimiser.history;ranks=ranks)
end
it = get_history(optimiser).niter; uh = get_state(pcfs)
write_vtk(Ω,path*"/struc_$it",it,["phi"=>φh,"H(phi)"=>(H φh),"|nabla(phi)|"=>(norm (φh)),"uh"=>uh];iter_mod=1)
writevtk(Ω,path*"out$it",cellfields=["φ"=>φh,"H(φ)"=>(H φh),"|∇(φ)|"=>(norm (φh)),"uh"=>uh])
end

with_mpi() do distribute
Expand Down
6 changes: 4 additions & 2 deletions scripts/MPI/inverse_homenisation_ALM.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ function main(mesh_partition,distribute,el_size)
α_coeff = 4
vf = 0.5
path = dirname(dirname(@__DIR__))*"/results/inverse_homenisation_ALM_MPI"
iter_mod = 10
i_am_main(ranks) && mkdir(path)

## FE Setup
Expand Down Expand Up @@ -101,11 +102,12 @@ function main(mesh_partition,distribute,el_size)
optimiser = AugmentedLagrangian(pcfs,stencil,vel_ext,φh;
γ,γ_reinit,verbose=i_am_main(ranks),constraint_names=[:Vol])
for (it, uh, φh) in optimiser
write_vtk(Ω,path*"/struc_$it",it,["phi"=>φh,"H(phi)"=>(H φh),"|nabla(phi)|"=>(norm (φh))])
data = ["φ"=>φh,"H(φ)"=>(H φh),"|∇(φ)|"=>(norm (φh))]
iszero(it % iter_mod) && writevtk(Ω,path*"out$it",cellfields=data)
write_history(path*"/history.txt",optimiser.history;ranks=ranks)
end
it = get_history(optimiser).niter; uh = get_state(pcfs)
write_vtk(Ω,path*"/struc_$it",it,["phi"=>φh,"H(phi)"=>(H φh),"|nabla(phi)|"=>(norm (φh))];iter_mod=1)
writevtk(Ω,path*"out$it",cellfields=["φ"=>φh,"H(φ)"=>(H φh),"|∇(φ)|"=>(norm (φh))])
end

with_mpi() do distribute
Expand Down
6 changes: 4 additions & 2 deletions scripts/MPI/thermal_compliance_ALM.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ function main(mesh_partition,distribute)
α_coeff = 4
vf = 0.4
path = dirname(dirname(@__DIR__))*"/results/thermal_compliance_ALM_MPI"
iter_mod = 10
i_am_main(ranks) && mkdir(path)

## FE Setup
Expand Down Expand Up @@ -86,11 +87,12 @@ function main(mesh_partition,distribute)
optimiser = AugmentedLagrangian(pcfs,stencil,vel_ext,φh;γ,γ_reinit,
verbose=i_am_main(ranks),constraint_names=[:Vol])
for (it, uh, φh) in optimiser
write_vtk(Ω,path*"/struc_$it",it,["phi"=>φh,"H(phi)"=>(H φh),"|nabla(phi)|"=>(norm (φh)),"uh"=>uh])
data = ["φ"=>φh,"H(φ)"=>(H φh),"|∇(φ)|"=>(norm (φh)),"uh"=>uh]
iszero(it % iter_mod) && writevtk(Ω,path*"out$it",cellfields=data)
write_history(path*"/history.txt",optimiser.history;ranks=ranks)
end
it = get_history(optimiser).niter; uh = get_state(pcfs)
write_vtk(Ω,path*"/struc_$it",it,["phi"=>φh,"H(phi)"=>(H φh),"|nabla(phi)|"=>(norm (φh)),"uh"=>uh];iter_mod=1)
writevtk(Ω,path*"out$it",cellfields=["φ"=>φh,"H(φ)"=>(H φh),"|∇(φ)|"=>(norm (φh)),"uh"=>uh])
end

with_mpi() do distribute
Expand Down
6 changes: 4 additions & 2 deletions scripts/MPI/thermal_compliance_ALM_PETSc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ function main(mesh_partition,distribute,el_size)
α_coeff = 4
vf = 0.4
path = dirname(dirname(@__DIR__))*"/results/thermal_compliance_ALM_MPI+PETSc"
iter_mod = 10
i_am_main(ranks) && mkdir(path)

## FE Setup
Expand Down Expand Up @@ -100,11 +101,12 @@ function main(mesh_partition,distribute,el_size)
optimiser = AugmentedLagrangian(pcfs,stencil,vel_ext,φh;γ,γ_reinit,
verbose=i_am_main(ranks),constraint_names=[:Vol])
for (it, uh, φh) in optimiser
write_vtk(Ω,path*"/struc_$it",it,["phi"=>φh,"H(phi)"=>(H φh),"|nabla(phi)|"=>(norm (φh)),"uh"=>uh])
data = ["φ"=>φh,"H(φ)"=>(H φh),"|∇(φ)|"=>(norm (φh)),"uh"=>uh]
iszero(it % iter_mod) && writevtk(Ω,path*"out$it",cellfields=data)
write_history(path*"/history.txt",optimiser.history;ranks=ranks)
end
it = get_history(optimiser).niter; uh = get_state(pcfs)
write_vtk(Ω,path*"/struc_$it",it,["phi"=>φh,"H(phi)"=>(H φh),"|nabla(phi)|"=>(norm (φh)),"uh"=>uh];iter_mod=1)
writevtk(Ω,path*"out$it",cellfields=["φ"=>φh,"H(φ)"=>(H φh),"|∇(φ)|"=>(norm (φh)),"uh"=>uh])
end

with_mpi() do distribute
Expand Down
8 changes: 5 additions & 3 deletions scripts/Serial/elastic_compliance_ALM.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ function main()
α_coeff = 4
vf = 0.4
g = VectorValue(0,-1)
path = dirname(dirname(@__DIR__))*"/results/elastic_compliance_ALM"
path = dirname(dirname(@__DIR__))*"/results/elastic_compliance_ALM/"
iter_mod = 10
mkdir(path)

## FE Setup
Expand Down Expand Up @@ -85,11 +86,12 @@ function main()
optimiser = AugmentedLagrangian(pcfs,stencil,vel_ext,φh;
γ,γ_reinit,verbose=true,constraint_names=[:Vol])
for (it,uh,φh) in optimiser
write_vtk(Ω,path*"/struc_$it",it,["phi"=>φh,"H(phi)"=>(H φh),"|nabla(phi)|"=>(norm (φh)),"uh"=>uh])
data = ["φ"=>φh,"H(φ)"=>(H φh),"|∇(φ)|"=>(norm (φh)),"uh"=>uh]
iszero(it % iter_mod) && writevtk(Ω,path*"out$it",cellfields=data)
write_history(path*"/history.txt",optimiser.history)
end
it = get_history(optimiser).niter; uh = get_state(pcfs)
write_vtk(Ω,path*"/struc_$it",it,["phi"=>φh,"H(phi)"=>(H φh),"|nabla(phi)|"=>(norm (φh)),"uh"=>uh];iter_mod=1)
writevtk(Ω,path*"out$it",cellfields=["φ"=>φh,"H(φ)"=>(H φh),"|∇(φ)|"=>(norm (φh)),"uh"=>uh])
end

main()
8 changes: 5 additions & 3 deletions scripts/Serial/elastic_compliance_HPM.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ function main()
α_coeff = 4
vf = 0.4
g = VectorValue(0,-1)
path = dirname(dirname(@__DIR__))*"/results/elastic_compliance_HPM"
path = dirname(dirname(@__DIR__))*"/results/elastic_compliance_HPM/"
iter_mod = 10
mkdir(path)

## FE Setup
Expand Down Expand Up @@ -86,11 +87,12 @@ function main()
optimiser = HilbertianProjection(pcfs,stencil,vel_ext,φh;
γ,γ_reinit,verbose=true,constraint_names=[:Vol])
for (it,uh,φh) in optimiser
write_vtk(Ω,path*"/struc_$it",it,["phi"=>φh,"H(phi)"=>(H φh),"|nabla(phi)|"=>(norm (φh)),"uh"=>uh])
data = ["φ"=>φh,"H(φ)"=>(H φh),"|∇(φ)|"=>(norm (φh)),"uh"=>uh]
iszero(it % iter_mod) && writevtk(Ω,path*"out$it",cellfields=data)
write_history(path*"/history.txt",optimiser.history)
end
it = get_history(optimiser).niter; uh = get_state(pcfs)
write_vtk(Ω,path*"/struc_$it",it,["phi"=>φh,"H(phi)"=>(H φh),"|nabla(phi)|"=>(norm (φh)),"uh"=>uh];iter_mod=1)
writevtk(Ω,path*"out$it",cellfields=["φ"=>φh,"H(φ)"=>(H φh),"|∇(φ)|"=>(norm (φh)),"uh"=>uh])
end

main();
Loading

0 comments on commit a18b6c9

Please sign in to comment.