From c55a12e8df93716c302c47d4b63fe41f6f7af140 Mon Sep 17 00:00:00 2001 From: Knut Andreas Meyer Date: Fri, 2 Aug 2024 13:57:36 +0200 Subject: [PATCH 1/5] Download mesh for comphom tutorial --- docs/download_resources.jl | 2 -- .../computational_homogenization.jl | 22 +++++++++++-------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/docs/download_resources.jl b/docs/download_resources.jl index 2dfbeffb2f..0c3149b2bd 100644 --- a/docs/download_resources.jl +++ b/docs/download_resources.jl @@ -5,8 +5,6 @@ const directory = joinpath(@__DIR__, "src", "tutorials") mkpath(directory) for (file, url) in [ - "periodic-rve.msh" => "https://raw.githubusercontent.com/Ferrite-FEM/Ferrite.jl/gh-pages/assets/periodic-rve.msh", - "periodic-rve-coarse.msh" => "https://raw.githubusercontent.com/Ferrite-FEM/Ferrite.jl/gh-pages/assets/periodic-rve-coarse.msh", "transient_heat.gif" => "https://raw.githubusercontent.com/Ferrite-FEM/Ferrite.jl/gh-pages/assets/transient_heat.gif", "transient_heat_colorbar.svg" => "https://raw.githubusercontent.com/Ferrite-FEM/Ferrite.jl/gh-pages/assets/transient_heat_colorbar.svg", "porous_media.gif" => "https://raw.githubusercontent.com/Ferrite-FEM/Ferrite.jl/gh-pages/assets/porous_media.gif", diff --git a/docs/src/literate-tutorials/computational_homogenization.jl b/docs/src/literate-tutorials/computational_homogenization.jl index 945c02fe06..8be7067faa 100644 --- a/docs/src/literate-tutorials/computational_homogenization.jl +++ b/docs/src/literate-tutorials/computational_homogenization.jl @@ -197,17 +197,21 @@ using FerriteGmsh #src notebook: use coarse mesh to decrease build time #src script: use the fine mesh #src markdown: use the coarse mesh to decrease build time, but make it look like the fine -#nb ## grid = togrid("periodic-rve.msh") -#nb grid = togrid("periodic-rve-coarse.msh") -#jl ## grid = togrid("periodic-rve-coarse.msh") -#jl grid = togrid("periodic-rve.msh") -#md grid = togrid("periodic-rve.msh") #- +import Downloads #hide +meshfile = "periodic-rve.msh" #src +#jl meshfile = "periodic-rve.msh" +#md meshfile = "periodic-rve-coarse.msh" #hide +#nb meshfile = "periodic-rve-coarse.msh" +isfile(meshfile) || Downloads.download( #hide + string("https://raw.githubusercontent.com/Ferrite-FEM/Ferrite.jl/gh-pages/assets/", meshfile), #hide + meshfile) #hide +grid = togrid(meshfile) #src +#nb grid = togrid(meshfile) #md grid = redirect_stdout(devnull) do #hide -#md togrid("periodic-rve-coarse.msh") #hide -#md end #hide - -grid = togrid("periodic-rve.msh") #src +#md togrid(meshfile) #hide +#md end #hide +#md grid # Next we construct the interpolation and quadrature rule, and combining them into # cellvalues as usual: From e5a7fd7ad2848773d3d8613902515557cf1fd7bf Mon Sep 17 00:00:00 2001 From: Knut Andreas Meyer Date: Fri, 2 Aug 2024 14:04:15 +0200 Subject: [PATCH 2/5] Fix notebook link --- docs/src/literate-tutorials/computational_homogenization.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/literate-tutorials/computational_homogenization.jl b/docs/src/literate-tutorials/computational_homogenization.jl index 8be7067faa..7dd71bd413 100644 --- a/docs/src/literate-tutorials/computational_homogenization.jl +++ b/docs/src/literate-tutorials/computational_homogenization.jl @@ -9,7 +9,7 @@ #- #md # !!! tip #md # This example is also available as a Jupyter notebook: -#md # [`computational_homogenization.ipynb`](@__NBVIEWER_ROOT_URL__/examples/computational_homogenization.ipynb). +#md # [`computational_homogenization.ipynb`](@__NBVIEWER_ROOT_URL__/tutorials/computational_homogenization.ipynb). #- # # ## Introduction From 99b2a9de89565b58e2694c1313be4c04c6318bb2 Mon Sep 17 00:00:00 2001 From: Knut Andreas Meyer Date: Fri, 2 Aug 2024 14:12:26 +0200 Subject: [PATCH 3/5] Fix test --- test/test_examples.jl | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/test/test_examples.jl b/test/test_examples.jl index d20001d18f..5758277c8e 100644 --- a/test/test_examples.jl +++ b/test/test_examples.jl @@ -41,12 +41,11 @@ end # end module TestComputationalHomogenization - include(joinpath(@__DIR__, "../docs/download_resources.jl")) mktempdir() do dir cd(dir) do - cp(joinpath(@__DIR__, "../docs/src/tutorials/periodic-rve.msh"), - joinpath(dir, "periodic-rve.msh") - ) + # Add already downloaded file to allow running test suite offline + mesh_file = joinpath(@__DIR__, "../docs/src/tutorials/periodic-rve.msh") + isfile(mesh_file) && cp(mesh_file, joinpath(dir, basename(mesh_file))) include(joinpath(@__DIR__, "../docs/src/literate-tutorials/computational_homogenization.jl")) end end From f36e8df3dd5836ca5e3e5035d234679dcdb52762 Mon Sep 17 00:00:00 2001 From: Knut Andreas Meyer Date: Sat, 3 Aug 2024 18:14:17 +0200 Subject: [PATCH 4/5] Download mesh for porous media --- docs/download_resources.jl | 1 - docs/src/literate-tutorials/porous_media.jl | 8 +++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/download_resources.jl b/docs/download_resources.jl index 0c3149b2bd..48d2671053 100644 --- a/docs/download_resources.jl +++ b/docs/download_resources.jl @@ -8,7 +8,6 @@ for (file, url) in [ "transient_heat.gif" => "https://raw.githubusercontent.com/Ferrite-FEM/Ferrite.jl/gh-pages/assets/transient_heat.gif", "transient_heat_colorbar.svg" => "https://raw.githubusercontent.com/Ferrite-FEM/Ferrite.jl/gh-pages/assets/transient_heat_colorbar.svg", "porous_media.gif" => "https://raw.githubusercontent.com/Ferrite-FEM/Ferrite.jl/gh-pages/assets/porous_media.gif", - "porous_media_0p25.inp" => "https://raw.githubusercontent.com/Ferrite-FEM/Ferrite.jl/gh-pages/assets/porous_media_0p25.inp", "reactive_surface.gif" => "https://raw.githubusercontent.com/Ferrite-FEM/Ferrite.jl/gh-pages/assets/reactive_surface.gif", "nsdiffeq.gif" => "https://raw.githubusercontent.com/Ferrite-FEM/Ferrite.jl/gh-pages/assets/nsdiffeq.gif", ] diff --git a/docs/src/literate-tutorials/porous_media.jl b/docs/src/literate-tutorials/porous_media.jl index 65c211dd43..26be7be1e8 100644 --- a/docs/src/literate-tutorials/porous_media.jl +++ b/docs/src/literate-tutorials/porous_media.jl @@ -249,8 +249,14 @@ end; # `get_ferrite_grid` function. We then create one cellset for each phase (solid and porous) # for each element type. These 4 sets will later be used in their own `SubDofHandler` function get_grid() + ## Try downloading the grid if not available already + gridfile = "porous_media_0p25.inp" + isfile(gridfile) || Downloads.download( + string("https://raw.githubusercontent.com/Ferrite-FEM/Ferrite.jl/gh-pages/assets/", gridfile), + gridfile) + ## Import grid from abaqus mesh - grid = get_ferrite_grid(joinpath(@__DIR__, "porous_media_0p25.inp")) + grid = get_ferrite_grid(gridfile) ## Create cellsets for each fieldhandler addcellset!(grid, "solid3", intersect(getcellset(grid, "solid"), getcellset(grid, "CPS3"))) From ad17cd4744a1a6c251a124dc8eb0b716a9dd89bd Mon Sep 17 00:00:00 2001 From: Knut Andreas Meyer Date: Sat, 3 Aug 2024 18:19:15 +0200 Subject: [PATCH 5/5] using Downloads in porous media example --- docs/src/literate-tutorials/porous_media.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/literate-tutorials/porous_media.jl b/docs/src/literate-tutorials/porous_media.jl index 26be7be1e8..7ca7e8afd3 100644 --- a/docs/src/literate-tutorials/porous_media.jl +++ b/docs/src/literate-tutorials/porous_media.jl @@ -96,7 +96,7 @@ #md # the final [section](@ref porous-media-plain-program) # # Required packages -using Ferrite, FerriteMeshParser, Tensors +using Ferrite, FerriteMeshParser, Tensors, Downloads # ### Elasticity # We start by defining the elastic material type, containing the elastic stiffness,