-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f97976e
commit bcfec72
Showing
10 changed files
with
292 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
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 p4est | ||
run: | | ||
# Install p4est 2.2 from sources | ||
CURR_DIR=$(pwd) | ||
PACKAGE=p4est | ||
VERSION=2.2 | ||
INSTALL_ROOT=/opt | ||
P4EST_INSTALL=$INSTALL_ROOT/$PACKAGE/$VERSION | ||
TAR_FILE=$PACKAGE-$VERSION.tar.gz | ||
URL="https://github.com/p4est/p4est.github.io/raw/master/release" | ||
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=$P4EST_INSTALL --without-blas --without-lapack --enable-mpi -disable-dependency-tracking | ||
make --quiet | ||
make --quiet install | ||
rm -rf $ROOT_DIR/$TAR_FILE $SOURCES_DIR | ||
cd $CURR_DIR | ||
- 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
module LSTOMPITests | ||
|
||
using Test | ||
using MPI | ||
|
||
testdir = @__DIR__ | ||
istest(f) = endswith(f, ".jl") && !(f=="runtests.jl") | ||
testfiles = sort(filter(istest, readdir(testdir))) | ||
|
||
MPI.mpiexec() do cmd | ||
for file in testfiles | ||
path = joinpath(testdir,file) | ||
_cmd = `$(cmd) -np 4 --allow-run-as-root --oversubscribe $(Base.julia_cmd()) --project=. $path` | ||
@show _cmd | ||
run(_cmd) | ||
@test true | ||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
using Test | ||
include("seq/runtests.jl") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
module ThermalComplianceALMTests | ||
|
||
using Gridap, LevelSetTopOpt | ||
|
||
""" | ||
(Serial) Minimum thermal compliance with augmented Lagrangian method in 2D. | ||
Optimisation problem: | ||
Min J(Ω) = ∫ κ*∇(u)⋅∇(u) dΩ | ||
Ω | ||
s.t., Vol(Ω) = vf, | ||
⎡u∈V=H¹(Ω;u(Γ_D)=0), | ||
⎣∫ κ*∇(u)⋅∇(v) dΩ = ∫ v dΓ_N, ∀v∈V. | ||
""" | ||
function main() | ||
## Parameters| | ||
order = 1 | ||
xmax=ymax=1.0 | ||
prop_Γ_N = 0.2 | ||
prop_Γ_D = 0.2 | ||
dom = (0,xmax,0,ymax) | ||
el_size = (20,20) | ||
γ = 0.1 | ||
γ_reinit = 0.5 | ||
max_steps = floor(Int,minimum(el_size)/10) | ||
tol = 1/(5*order^2)/minimum(el_size) | ||
κ = 1 | ||
vf = 0.4 | ||
η_coeff = 2 | ||
α_coeff = 4 | ||
|
||
## FE Setup | ||
model = CartesianDiscreteModel(dom,el_size); | ||
el_Δ = get_el_Δ(model) | ||
f_Γ_D(x) = (x[1] ≈ 0.0 && (x[2] <= ymax*prop_Γ_D + eps() || | ||
x[2] >= ymax-ymax*prop_Γ_D - eps())) | ||
f_Γ_N(x) = (x[1] ≈ xmax && ymax/2-ymax*prop_Γ_N/2 - eps() <= x[2] <= | ||
ymax/2+ymax*prop_Γ_N/2 + eps()) | ||
update_labels!(1,model,f_Γ_D,"Gamma_D") | ||
update_labels!(2,model,f_Γ_N,"Gamma_N") | ||
|
||
## Triangulations and measures | ||
Ω = Triangulation(model) | ||
Γ_N = BoundaryTriangulation(model,tags="Gamma_N") | ||
dΩ = Measure(Ω,2*order) | ||
dΓ_N = Measure(Γ_N,2*order) | ||
vol_D = sum(∫(1)dΩ) | ||
|
||
## Spaces | ||
reffe_scalar = ReferenceFE(lagrangian,Float64,order) | ||
V = TestFESpace(model,reffe_scalar;dirichlet_tags=["Gamma_D"]) | ||
U = TrialFESpace(V,0.0) | ||
V_φ = TestFESpace(model,reffe_scalar) | ||
V_reg = TestFESpace(model,reffe_scalar;dirichlet_tags=["Gamma_N"]) | ||
U_reg = TrialFESpace(V_reg,0) | ||
|
||
## Create FE functions | ||
φh = interpolate(initial_lsf(4,0.2),V_φ) | ||
|
||
## Interpolation and weak form | ||
interp = SmoothErsatzMaterialInterpolation(η = η_coeff*maximum(el_Δ)) | ||
I,H,DH,ρ = interp.I,interp.H,interp.DH,interp.ρ | ||
|
||
a(u,v,φ,dΩ,dΓ_N) = ∫((I ∘ φ)*κ*∇(u)⋅∇(v))dΩ | ||
l(v,φ,dΩ,dΓ_N) = ∫(v)dΓ_N | ||
|
||
## Optimisation functionals | ||
J(u,φ,dΩ,dΓ_N) = ∫((I ∘ φ)*κ*∇(u)⋅∇(u))dΩ | ||
dJ(q,u,φ,dΩ,dΓ_N) = ∫(κ*∇(u)⋅∇(u)*q*(DH ∘ φ)*(norm ∘ ∇(φ)))dΩ; | ||
Vol(u,φ,dΩ,dΓ_N) = ∫(((ρ ∘ φ) - vf)/vol_D)dΩ; | ||
dVol(q,u,φ,dΩ,dΓ_N) = ∫(-1/vol_D*q*(DH ∘ φ)*(norm ∘ ∇(φ)))dΩ | ||
|
||
## Finite difference solver and level set function | ||
stencil = AdvectionStencil(FirstOrderStencil(2,Float64),model,V_φ,tol,max_steps) | ||
|
||
## Setup solver and FE operators | ||
state_map = AffineFEStateMap(a,l,U,V,V_φ,U_reg,φh,dΩ,dΓ_N) | ||
pcfs = PDEConstrainedFunctionals(J,[Vol],state_map,analytic_dJ=dJ,analytic_dC=[dVol]) | ||
|
||
## Hilbertian extension-regularisation problems | ||
α = α_coeff*maximum(el_Δ) | ||
a_hilb(p,q) =∫(α^2*∇(p)⋅∇(q) + p*q)dΩ; | ||
vel_ext = VelocityExtension(a_hilb,U_reg,V_reg) | ||
|
||
## Optimiser | ||
optimiser = AugmentedLagrangian(pcfs,stencil,vel_ext,φh; | ||
γ,γ_reinit,verbose=true,constraint_names=[:Vol]) | ||
|
||
# Do a few iterations | ||
vars, state = iterate(optimiser) | ||
vars, state = iterate(optimiser,state) | ||
end | ||
|
||
main() | ||
|
||
end # module |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module LSTOSequentialTests | ||
|
||
using Test | ||
|
||
@time @testset "Thermal Compliance - ALM" begin include("ThermalComplianceALMTests.jl") end | ||
|
||
end # module |