From bd0a0e8cf549a50d0b738c166eddb215049a7334 Mon Sep 17 00:00:00 2001 From: Lambert Theisen Date: Mon, 14 Oct 2024 10:34:08 +0200 Subject: [PATCH] try to add docs --- .github/workflows/doc.yml | 22 +++++++++++++++++ .github/workflows/test.yml | 2 +- Manifest.toml | 48 +++++++++++++++++++++++++++++++++++++- Project.toml | 1 + README.md | 9 ++++--- docs/.gitignore | 1 + docs/make.jl | 19 +++++++++++++++ docs/src/api.md | 14 +++++++++++ docs/src/assets/.gitkeep | 0 docs/src/index.md | 26 +++++++++++++++++++++ src/Solver.jl | 38 ++++++++++++++++++++++++++++++ 11 files changed, 175 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/doc.yml create mode 100644 docs/.gitignore create mode 100644 docs/make.jl create mode 100644 docs/src/api.md create mode 100644 docs/src/assets/.gitkeep create mode 100644 docs/src/index.md diff --git a/.github/workflows/doc.yml b/.github/workflows/doc.yml new file mode 100644 index 0000000..10e697c --- /dev/null +++ b/.github/workflows/doc.yml @@ -0,0 +1,22 @@ +name: Doc + +on: + push: + branches: + - master + pull_request: + +jobs: + docs: + name: Doc + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: julia-actions/setup-julia@v1 + with: + version: '1' + - uses: julia-actions/julia-buildpkg@v1 + - uses: julia-actions/julia-docdeploy@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 601e86a..0bcd31e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,4 +1,4 @@ -name: Run tests +name: Test on: push: diff --git a/Manifest.toml b/Manifest.toml index 9970aca..22c2a28 100644 --- a/Manifest.toml +++ b/Manifest.toml @@ -2,7 +2,12 @@ julia_version = "1.10.2" manifest_format = "2.0" -project_hash = "de4af1fb3390e68a97ccc9215147284c1486a39a" +project_hash = "851282b9d4540d4f1d1d921b1dd41c97e2e71062" + +[[deps.ANSIColoredPrinters]] +git-tree-sha1 = "574baf8110975760d391c710b6341da1afa48d8c" +uuid = "a4c015fc-c6ff-483c-b24f-f7ea428134e9" +version = "0.0.1" [[deps.AbstractFFTs]] deps = ["LinearAlgebra"] @@ -363,6 +368,12 @@ git-tree-sha1 = "2fb1e02f2b635d0845df5d7c167fec4dd739b00d" uuid = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae" version = "0.9.3" +[[deps.Documenter]] +deps = ["ANSIColoredPrinters", "AbstractTrees", "Base64", "CodecZlib", "Dates", "DocStringExtensions", "Downloads", "Git", "IOCapture", "InteractiveUtils", "JSON", "LibGit2", "Logging", "Markdown", "MarkdownAST", "Pkg", "PrecompileTools", "REPL", "RegistryInstances", "SHA", "TOML", "Test", "Unicode"] +git-tree-sha1 = "5a1ee886566f2fa9318df1273d8b778b9d42712d" +uuid = "e30172f5-a6a5-5a46-863b-614d45cd2de4" +version = "1.7.0" + [[deps.Downloads]] deps = ["ArgTools", "FileWatching", "LibCURL", "NetworkOptions"] uuid = "f43a241f-c20a-4ad4-852c-f6b1247861c6" @@ -572,6 +583,18 @@ git-tree-sha1 = "43ba3d3c82c18d88471cfd2924931658838c9d8f" uuid = "61579ee1-b43e-5ca0-a5da-69d92c66a64b" version = "9.55.0+4" +[[deps.Git]] +deps = ["Git_jll"] +git-tree-sha1 = "04eff47b1354d702c3a85e8ab23d539bb7d5957e" +uuid = "d7ba0133-e1db-5d97-8f8c-041e4b3a1eb2" +version = "1.3.1" + +[[deps.Git_jll]] +deps = ["Artifacts", "Expat_jll", "JLLWrappers", "LibCURL_jll", "Libdl", "Libiconv_jll", "OpenSSL_jll", "PCRE2_jll", "Zlib_jll"] +git-tree-sha1 = "ea372033d09e4552a04fd38361cd019f9003f4f4" +uuid = "f8c6e375-362e-5223-8a59-34ff63f689eb" +version = "2.46.2+0" + [[deps.Glib_jll]] deps = ["Artifacts", "Gettext_jll", "JLLWrappers", "Libdl", "Libffi_jll", "Libiconv_jll", "Libmount_jll", "PCRE2_jll", "Zlib_jll"] git-tree-sha1 = "7c82e6a6cd34e9d935e9aa4051b66c6ff3af59ba" @@ -631,6 +654,12 @@ git-tree-sha1 = "20b6765a3016e1fca0c9c93c80d50061b94218b7" uuid = "a51ab1cf-af8e-5615-a023-bc2c838bba6b" version = "69.1.0+0" +[[deps.IOCapture]] +deps = ["Logging", "Random"] +git-tree-sha1 = "b6d6bfdd7ce25b0f9b2f6b3dd56b2673a66c8770" +uuid = "b5f81e59-6552-4d32-b1f0-c071b021bf89" +version = "0.2.5" + [[deps.ImageAxes]] deps = ["AxisArrays", "ImageBase", "ImageCore", "Reexport", "SimpleTraits"] git-tree-sha1 = "2e4520d67b0cef90865b3ef727594d2a58e0e1f8" @@ -830,6 +859,11 @@ git-tree-sha1 = "50901ebc375ed41dbf8058da26f9de442febbbec" uuid = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f" version = "1.3.1" +[[deps.LazilyInitializedFields]] +git-tree-sha1 = "8f7f3cabab0fd1800699663533b6d5cb3fc0e612" +uuid = "0e77f7df-68c5-4e49-93ce-4cd80f5598bf" +version = "1.2.2" + [[deps.LazyArtifacts]] deps = ["Artifacts", "Pkg"] uuid = "4af54fe1-eca0-43a8-85a7-787d91b784e3" @@ -1000,6 +1034,12 @@ version = "0.4.2" deps = ["Base64"] uuid = "d6f4376e-aef5-505a-96c1-9c027394607a" +[[deps.MarkdownAST]] +deps = ["AbstractTrees", "Markdown"] +git-tree-sha1 = "465a70f0fc7d443a00dcdc3267a497397b8a3899" +uuid = "d0879d2d-cac2-40c8-9cee-1863dc0c7391" +version = "0.1.2" + [[deps.MathTeXEngine]] deps = ["AbstractTrees", "Automa", "DataStructures", "FreeTypeAbstraction", "GeometryBasics", "LaTeXStrings", "REPL", "RelocatableFolders", "UnicodeFun"] git-tree-sha1 = "96ca8a313eb6437db5ffe946c457a401bbb8ce1d" @@ -1406,6 +1446,12 @@ git-tree-sha1 = "45e428421666073eab6f2da5c9d310d99bb12f9b" uuid = "189a3867-3050-52da-a836-e630ba90ab69" version = "1.2.2" +[[deps.RegistryInstances]] +deps = ["LazilyInitializedFields", "Pkg", "TOML", "Tar"] +git-tree-sha1 = "ffd19052caf598b8653b99404058fce14828be51" +uuid = "2792f1a3-b283-48e8-9a74-f99dce5104f3" +version = "0.1.0" + [[deps.RelocatableFolders]] deps = ["SHA", "Scratch"] git-tree-sha1 = "ffdaf70d81cf6ff22c2b6e733c900c3321cab864" diff --git a/Project.toml b/Project.toml index 1f60678..dd229ba 100644 --- a/Project.toml +++ b/Project.toml @@ -7,6 +7,7 @@ version = "0.1.0" CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b" CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0" DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" +Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" GLMakie = "e9467ef8-e4e7-5192-8a1a-b1aee30e663a" Gridap = "56d4f2e9-7ea1-5844-9cf6-b9c51ca7ce8e" LineSearches = "d3d80556-e9d4-5f37-9878-2ab0fcc64255" diff --git a/README.md b/README.md index ca522f6..1ad2f13 100644 --- a/README.md +++ b/README.md @@ -6,12 +6,14 @@ Testing workflow badge -# GenMatFlow.jl +# GenMatFlow.jl: A Navier-Stokes-Fourier Solver for generalized material laws -- Navier-Stokes-Fourier Solver for generalized material laws, including: +- Different material laws, including: - Newtonian fluids: $\boldsymbol{\sigma} = \boldsymbol{D}(\boldsymbol{u}) = \frac12 (\boldsymbol{\nabla} \boldsymbol{u} + \boldsymbol{\nabla} \boldsymbol{u}^T)$ - Non-Newtonian fluids with power-law: $\boldsymbol{\sigma} = K {\left(2 \boldsymbol{D} \boldsymbol{\colon} \boldsymbol{D} \right)}^{\frac{1-n}{2}} \boldsymbol{D}(\boldsymbol{u})$ - Discretization using Finite Elements in [Gridap.jl](https://github.com/gridap/Gridap.jl) +- Solve nonlinear systems using Newtons method + ## Installation @@ -28,5 +30,6 @@ julia --project -e 'import Pkg; Pkg.instantiate()' - Run examples by navigating to the folder and execute the examples from the shell: ```bash -cd TODO +cd examples/validation-basak +include("basak.jl") ``` diff --git a/docs/.gitignore b/docs/.gitignore new file mode 100644 index 0000000..f65519e --- /dev/null +++ b/docs/.gitignore @@ -0,0 +1 @@ +build/** diff --git a/docs/make.jl b/docs/make.jl new file mode 100644 index 0000000..a9bd402 --- /dev/null +++ b/docs/make.jl @@ -0,0 +1,19 @@ +push!(LOAD_PATH,"../src/") +push!(LOAD_PATH,"src/") + +using GenMatFlow +using Documenter + +makedocs( + sitename="GenMatFlow.jl", + remotes = nothing, + pages = Any[ + "Home" => "index.md", + "API" => "api.md", + ] +) + +# optionally deploy docs to github pages +deploydocs( + repo = "github.com/lamBOOO/GenMatFlow.jl.git", +) diff --git a/docs/src/api.md b/docs/src/api.md new file mode 100644 index 0000000..0fe53b5 --- /dev/null +++ b/docs/src/api.md @@ -0,0 +1,14 @@ +# Developer Documentation + +## API + +```@autodocs +Modules = [GenMatFlow] +Private = true +Order = [:function, :type] +``` + +## Index + +```@index +``` diff --git a/docs/src/assets/.gitkeep b/docs/src/assets/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/docs/src/index.md b/docs/src/index.md new file mode 100644 index 0000000..e4cd5b3 --- /dev/null +++ b/docs/src/index.md @@ -0,0 +1,26 @@ +```@eval +using Markdown +# Read the README.md file as a string +readme = read("../../README.md", String) + +# Find the position of the first '#' character (first headline) +pos = findfirst(r"#", readme)[1] + +# Check if a '#' was found +if isnothing(pos) + error("No '#' found in README.md") +end + +print(readme) +print(pos) + +# Extract the content from the first headline onward +readme_content = readme[pos:end] + +# Parse the extracted content as Markdown and include it +Markdown.parse(readme_content) +``` + +## API + +- See [API reference](./api.md) diff --git a/src/Solver.jl b/src/Solver.jl index dfd62a2..7faa8d1 100644 --- a/src/Solver.jl +++ b/src/Solver.jl @@ -8,6 +8,44 @@ using LineSearches: BackTracking, StrongWolfe using Random Random.seed!(1234) +export simulate + +""" + simulate(;name="sim",Pr=1.0,Ra=1.0,n=1.0,n_elems=20,nlsolver_opts=(;show_trace=true,method=:newton,linesearch=BackTracking(),ftol=1E-8,xtol=1E-10),levels=(;T=5,psi=5,Sth=5,Sfl=5),T_diri_tags=["leftline","rightline","botleftpoint","botrightpoint","topleftpoint","toprightpoint"],T_diri_expressions=[0.0,1.0,0.0,1.0,0.0,1.0]) + +Simulate the flow in a square cavity with a moving lid and a temperature gradient. + +# Arguments +- `name::String`: Name of the simulation. +- `Pr::Float64`: Prandtl number. +- `Ra::Float64`: Rayleigh number. +- `n::Float64`: Power of the viscosity. +- `n_elems::Int`: Number of elements in each direction. +- `nlsolver_opts::Dict`: Options for the nonlinear solver. +- `levels::Dict`: Levels for the contour plots. +- `T_diri_tags::Array{String}`: Tags for the Dirichlet boundary conditions for the temperature. +- `T_diri_expressions::Array{Float64}`: Expressions for the Dirichlet boundary conditions for the temperature. + +# Returns +- `uh::FEFunction`: Velocity field. +- `ph::FEFunction`: Pressure field. +- `Th::FEFunction`: Temperature field. +- `psih::FEFunction`: Stream function. +- `Nu::Interpolable`: Nusselt number. +- `Sth::FEFunction`: Local heat entropy. +- `Sfl::FEFunction`: Local fluid entropy. +- `btrian::BoundaryTriangulation`: Boundary triangulation. +- `model::CartesianDiscreteModel`: Model. +- `Ωₕ::Triangulation`: Triangulation. +- `Pr::Float64`: Prandtl number. +- `Ra::Float64`: Rayleigh number. + +# Example +```julia +simulate(;name="sim",Pr=1.0,Ra=1.0,n=1.0,n_elems=20,nlsolver_opts=(;show_trace=true,method=:newton,linesearch=BackTracking(),ftol=1E-8,xtol=1E-10),levels=(;T=5,psi=5,Sth=5,Sfl=5),T_diri_tags=["leftline","rightline","botleftpoint","botrightpoint","topleftpoint","toprightpoint"],T_diri_expressions=[0.0,1.0,0.0,1.0,0.0,1.0]) +``` + +""" function simulate(; name="sim", Pr=1.0,