Skip to content

Commit

Permalink
Merge pull request #40 from zjwegert/src_refactor_and_docs
Browse files Browse the repository at this point in the history
Documenter and refactor
  • Loading branch information
zjwegert authored Mar 12, 2024
2 parents 43aecae + 192d8ee commit d8b96d2
Show file tree
Hide file tree
Showing 119 changed files with 5,243 additions and 1,181 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/TagBot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: TagBot
on:
issue_comment:
types:
- created
workflow_dispatch:
jobs:
TagBot:
if: github.event_name == 'workflow_dispatch' || github.actor == 'JuliaTagBot'
runs-on: ubuntu-latest
steps:
- uses: JuliaRegistries/TagBot@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
ssh: ${{ secrets.DOCUMENTER_KEY }}
55 changes: 55 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: CI
on: [push, pull_request]
jobs:
test:
name: Tests ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
version:
- '1.9'
os:
- ubuntu-latest
arch:
- x64
steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: actions/cache@v1
env:
cache-name: cache-artifacts
with:
path: ~/.julia/artifacts
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
restore-keys: |
${{ runner.os }}-test-${{ env.cache-name }}-
${{ runner.os }}-test-
${{ runner.os }}-
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v1
with:
file: ./lcov.info

# docs:
# name: Documentation
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v2
# - uses: julia-actions/setup-julia@v1
# with:
# version: '1.9'
# - run: |
# julia --project=docs -e '
# using Pkg
# Pkg.develop(PackageSpec(path=pwd()))
# Pkg.instantiate()'
# - run: julia --project=docs docs/make.jl
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }}
70 changes: 70 additions & 0 deletions .github/workflows/ci_mpi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: CI_MPI
on: [push, pull_request]
jobs:
test:
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
runs-on: ${{ matrix.os }}
env:
P4EST_ROOT_DIR: "/opt/p4est/2.2/"
JULIA_PETSC_LIBRARY: "/opt/petsc/3.18/lib/libpetsc"
strategy:
fail-fast: false
matrix:
version:
- '1.9'
os:
- ubuntu-latest
arch:
- x64
steps:
- uses: actions/checkout@v2
- name: Cache p4est
id: cache-p4est
uses: actions/cache@v2
with:
path: ${{env.P4EST_ROOT_DIR}}
key: ${{ runner.os }}-build-${{ env.P4EST_ROOT_DIR }}-
restore-keys: |
${{ runner.os }}-build-${{ env.P4EST_ROOT_DIR }}-
${{ runner.os }}-build-
${{ runner.os }}-
- uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- name: Install p4est/petsc dependencies
run: |
sudo apt-get update
sudo apt-get install -y wget gfortran g++ openmpi-bin libopenmpi-dev
- name: Install petsc
run: |
CURR_DIR=$(pwd)
PACKAGE=petsc
VERSION=3.18
INSTALL_ROOT=/opt
PETSC_INSTALL=$INSTALL_ROOT/$PACKAGE/$VERSION
TAR_FILE=$PACKAGE-$VERSION.tar.gz
URL="https://ftp.mcs.anl.gov/pub/petsc/release-snapshots/"
ROOT_DIR=/tmp
SOURCES_DIR=$ROOT_DIR/$PACKAGE-$VERSION
BUILD_DIR=$SOURCES_DIR/build
wget -q $URL/$TAR_FILE -O $ROOT_DIR/$TAR_FILE
mkdir -p $SOURCES_DIR
tar xzf $ROOT_DIR/$TAR_FILE -C $SOURCES_DIR --strip-components=1
cd $SOURCES_DIR
./configure --prefix=$PETSC_INSTALL --with-cc=mpicc --with-cxx=mpicxx --with-fc=mpif90 \
--download-mumps --download-scalapack --download-parmetis --download-metis \
--download-ptscotch --with-debugging --with-x=0 --with-shared=1 \
--with-mpi=1 --with-64-bit-indices
make
make install
- uses: julia-actions/julia-buildpkg@latest
- run: echo $PWD
- run: julia --project=. -e 'using Pkg; Pkg.instantiate();'
- run: julia --project=. -e 'using Pkg; Pkg.add("MPIPreferences")'
- run: julia --project=. -e 'using MPIPreferences; MPIPreferences.use_system_binary()'
- run: julia --project=. -e 'using Pkg; Pkg.build(); Pkg.precompile()'
- run: julia --project=. --color=yes --check-bounds=yes test/mpi/runtests.jl
- uses: codecov/codecov-action@v1
with:
file: lcov.info
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ results/*
# environment.
Manifest.toml
LocalPreferences.toml
LSTO_Distributed.so
LevelSetTopOpt.so
2 changes: 1 addition & 1 deletion Deprecated/Deprecated_root_files/Utilities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Base.@kwdef struct SmoothErsatzMaterialInterpolation{M<:AbstractFloat}
end

write_vtk(Ω,path,φh,uh,H) = writevtk(Ω,path,cellfields=["phi"=>φh,
"H(phi)"=>(H φh),"|nabla(phi))|"=>(norm (φh)),"uh"=>uh])
"H(phi)"=>(H φh),"|nabla(phi)|"=>(norm (φh)),"uh"=>uh])

# Update layout of ghost nodes to match columns of stiffness matrix
function correct_ghost_layout(xh::DistributedCellField,cols)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ function main(mesh_partition,distribute)
# path = dirname(dirname(@__DIR__))*"/results/AutoDiffTesting_Parallel";
# writevtk(Ω,path,cellfields=["phi"=>φh,
# "H(phi)"=>(interp.H ∘ φh),
# "|nabla(phi))|"=>(norm ∘ ∇(φh)),
# "|nabla(phi)|"=>(norm ∘ ∇(φh)),
# "uh"=>uh,
# "J′_analytic"=>FEFunction(U_reg,dF_analytic),
# "J′_autodiff"=>FEFunction(U_reg,dF),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ function main(mesh_partition,distribute)
path = dirname(dirname(@__DIR__))*"/results/InvHomLE_AutoDiffTesting_Parallel";
writevtk(Ω,path,cellfields=["phi"=>φh,
"H(phi)"=>(interp.H φh),
"|nabla(phi))|"=>(norm (φh)),
"|nabla(phi)|"=>(norm (φh)),
"uh1"=>uh[1],
"uh2"=>uh[2],
"uh3"=>uh[3],
Expand Down
6 changes: 3 additions & 3 deletions Deprecated/Deprecated_scripts/AD_AM_testing.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Gridap, GridapDistributed, GridapPETSc, PartitionedArrays, LSTO_Distributed
using Gridap, GridapDistributed, GridapPETSc, PartitionedArrays, LevelSetTopOpt

"""
...
Expand Down Expand Up @@ -122,13 +122,13 @@ function main()
# print_history(it,["J"=>Ji])
# write_history(history,path*"/history.csv")
# uhi = get_state(pcfs)
# write_vtk(Ω,path*"/struc_$it",it,["phi"=>φh,"H(phi)"=>(H ∘ φh),"|nabla(phi))|"=>(norm ∘ ∇(φh))];iter_mod=1)
# write_vtk(Ω,path*"/struc_$it",it,["phi"=>φh,"H(phi)"=>(H ∘ φh),"|nabla(phi)|"=>(norm ∘ ∇(φh))];iter_mod=1)
# end
# it,Ji,_,_ = last(optimiser.history)
# print_history(it,["J"=>Ji])
# write_history(optimiser.history,path*"/history.csv")
# uhi = get_state(pcfs)
# write_vtk(Ω,path*"/struc_$it",it,["phi"=>φh,"H(phi)"=>(H ∘ φh),"|nabla(phi))|"=>(norm ∘ ∇(φh))];iter_mod=1)
# write_vtk(Ω,path*"/struc_$it",it,["phi"=>φh,"H(phi)"=>(H ∘ φh),"|nabla(phi)|"=>(norm ∘ ∇(φh))];iter_mod=1)

@show J_val

Expand Down
2 changes: 1 addition & 1 deletion Deprecated/Deprecated_scripts/inverter_AD_testing.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Gridap, GridapDistributed, GridapPETSc, PartitionedArrays, LSTO_Distributed
using Gridap, GridapDistributed, GridapPETSc, PartitionedArrays, LevelSetTopOpt

"""
(Serial) Inverter mechanism with augmented Lagrangian method in 2D.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Gridap, GridapDistributed, GridapPETSc, PartitionedArrays, LSTO_Distributed
using Gridap, GridapDistributed, GridapPETSc, PartitionedArrays, LevelSetTopOpt

"""
(Serial) Inverter mechanism with augmented Lagrangian method in 2D.
Expand Down Expand Up @@ -99,14 +99,14 @@ function main()
print_history(it,["J"=>Ji,"C"=>Ci,"L"=>Li,"λ"=>λi,"Λ"=>Λi])
write_history(history,path*"/history.csv")
# uhi = get_state(pcfs)
# write_vtk(Ω,path*"/struc_$it",it,["phi"=>φh,"H(phi)"=>(H ∘ φh),"|nabla(phi))|"=>(norm ∘ ∇(φh)),"uh"=>uhi];iter_mod=1)
# write_vtk(Ω,path*"/struc_$it",it,["phi"=>φh,"H(phi)"=>(H ∘ φh),"|nabla(phi)|"=>(norm ∘ ∇(φh)),"uh"=>uhi];iter_mod=1)
end
it,Ji,Ci,Li = last(optimiser.history)
λi = optimiser.λ; Λi = optimiser.Λ
print_history(it,["J"=>Ji,"C"=>Ci,"L"=>Li,"λ"=>λi,"Λ"=>Λi])
write_history(optimiser.history,path*"/history.csv")
uhi = get_state(pcfs)
write_vtk(Ω,path*"/struc_$it",it,["phi"=>φh,"H(phi)"=>(H φh),"|nabla(phi))|"=>(norm (φh)),"uh"=>uhi];iter_mod=1)
write_vtk(Ω,path*"/struc_$it",it,["phi"=>φh,"H(phi)"=>(H φh),"|nabla(phi)|"=>(norm (φh)),"uh"=>uhi];iter_mod=1)
end

main();
2 changes: 1 addition & 1 deletion Deprecated/auto_diff_elastic_compliance_serial.jl
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ hilb_rel_error = (abs(dϕh_Ω-v_J_Ω))/abs(v_J_Ω)
path = dirname(dirname(@__DIR__))*"/results/AutoDiffTesting";
writevtk(Ω,path,cellfields=["phi"=>φh,
"H(phi)"=>(interp.H φh),
"|nabla(phi))|"=>(norm (φh)),
"|nabla(phi)|"=>(norm (φh)),
"uh"=>uh,
"J′_abs_error"=>abs_error,
"J′_rel_error"=>rel_error,
Expand Down
2 changes: 1 addition & 1 deletion Deprecated/elastic_compliance_for_jordi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function main(mesh_partition,distribute)
φh = interpolate(x->-sqrt((x[1]-0.5)^2+(x[2]-0.5)^2+(x[3]-0.5)^2)+0.25,V_φ)
J,v_J,uh = elastic_compliance(φh,g,C,solve_data,interp,t)
display("Objective = $J")
writevtk(Ω,path,cellfields=["phi"=>φh,"H(phi)"=>(interp.H φh),"|nabla(phi))|"=>(norm (φh)),"uh"=>uh])
writevtk(Ω,path,cellfields=["phi"=>φh,"H(phi)"=>(interp.H φh),"|nabla(phi)|"=>(norm (φh)),"uh"=>uh])
end
t
end
Expand Down
2 changes: 1 addition & 1 deletion Deprecated/test_periodic_finitediff.jl
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,4 @@ v = get_free_dof_values(vh)
advect!(φ,v,model,Δ,γ,50)
reinit!(φ,model,Δ,0.5,2000,reinit_tol)

writevtk(Ω,(@__DIR__)*"\\Results\\test_reinit_2d_plus_advect",cellfields=["phi"=>φh,"H(phi)"=>(interp.H φh),"|nabla(phi))|"=>(norm (φh))]);
writevtk(Ω,(@__DIR__)*"\\Results\\test_reinit_2d_plus_advect",cellfields=["phi"=>φh,"H(phi)"=>(interp.H φh),"|nabla(phi)|"=>(norm (φh))]);
2 changes: 1 addition & 1 deletion Deprecated/tests_solver.jl
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ function main(mesh_partition,distribute)
solver = ElasticitySolver(solve_data.V)
J,v_J,uh = elastic_compliance(φh,g,C,solve_data,interp,t,solver)
display("Objective = $J")
writevtk(Ω,path,cellfields=["phi"=>φh,"H(phi)"=>(interp.H φh),"|nabla(phi))|"=>(norm (φh)),"uh"=>uh])
writevtk(Ω,path,cellfields=["phi"=>φh,"H(phi)"=>(interp.H φh),"|nabla(phi)|"=>(norm (φh)),"uh"=>uh])
end
t
end
Expand Down
2 changes: 1 addition & 1 deletion Deprecated/tests_solver2_mpi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import GridapDistributed.DistributedDiscreteModel
import GridapDistributed.DistributedMeasure
import GridapDistributed.DistributedTriangulation

using LSTO_Distributed
using LevelSetTopOpt

function isotropic_3d(E::M,nu::M) where M<:AbstractFloat
λ = E*nu/((1+nu)*(1-2nu)); μ = E/(2*(1+nu))
Expand Down
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name = "LSTO_Distributed"
name = "LevelSetTopOpt"
uuid = "27dd0110-1916-4fd6-8b4b-1bc109db1170"
authors = ["Zach Wegert <[email protected]>", "JordiManyer <[email protected]>"]
version = "0.1.0"
Expand All @@ -24,7 +24,7 @@ PartitionedArrays = "5a9dfac6-5c52-46f7-8278-5e2210713be9"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
SparseMatricesCSR = "a0a7dd2c-ebf4-11e9-1f05-cf50bc540ca1"
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[extras]
MPIPreferences = "3da0fdf6-3ccc-4f1b-acd9-58baa6c99267"
Loading

0 comments on commit d8b96d2

Please sign in to comment.