From d510630628a3f9fbe07d18f1546cc91f1f0a4faa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Fuhrmann?= Date: Wed, 11 Sep 2024 10:25:04 +0200 Subject: [PATCH] further documentation work --- docs/make.jl | 2 +- docs/src/internal.md | 6 +++ docs/src/physics.md | 26 ++++++++++++ docs/src/system.md | 29 +------------- src/VoronoiFVM.jl | 12 +++++- src/vfvm_geometryitems.jl | 7 ---- src/vfvm_physics.jl | 84 +++++++++++++++++++++++++++++++++++++++ src/vfvm_system.jl | 79 +----------------------------------- 8 files changed, 130 insertions(+), 115 deletions(-) diff --git a/docs/make.jl b/docs/make.jl index e8f929649..0cada3881 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -19,7 +19,7 @@ function make(; with_examples = true, pages = [ "Home" => "index.md", - "changes.md", + "Changelog" => "changes.md", "method.md", "API Documentation" => [ "system.md", diff --git a/docs/src/internal.md b/docs/src/internal.md index 87e3c4004..46bb027a3 100644 --- a/docs/src/internal.md +++ b/docs/src/internal.md @@ -102,3 +102,9 @@ eval_jacobian! mass_matrix prepare_diffeq! ``` + +## Misc tools +```@docs +VoronoiFVM.doolittle_ludecomp! +VoronoiFVM.doolittle_lusolve! +``` diff --git a/docs/src/physics.md b/docs/src/physics.md index 258a7f22c..1fe78c525 100644 --- a/docs/src/physics.md +++ b/docs/src/physics.md @@ -5,8 +5,34 @@ VoronoiFVM.AbstractPhysics VoronoiFVM.Physics VoronoiFVM.Physics(;kwargs...) + Base.show(io::IO,physics::VoronoiFVM.AbstractPhysics) ``` +## Handling boundary conditions +Boundary conditions are handled in the `bcondition` callback passed to the system constructor. +For being called in this callback, the following functions are available + +```@docs +boundary_dirichlet!(y,u,bnode::AbstractGeometryItem,ispec,ireg,val) +boundary_dirichlet!(y,u,bnode::AbstractGeometryItem;kwargs...) +boundary_neumann!(y,u,bnode::AbstractGeometryItem,ispec,ireg,val) +boundary_neumann!(y,u,bnode::AbstractGeometryItem;kwargs...) +boundary_robin!(y,u,bnode::AbstractGeometryItem,ispec,ireg,fac,val) +boundary_robin!(y,u,bnode::AbstractGeometryItem;kwargs...) +ramp +``` + +### Outflow boundary conditions +These are characterized by the `boutflow` physics callback and +and the `outflowboundaries` keyword argument in the system +resp. physics constructor. See also the +[corresponding notebook](https://j-fu.github.io/VoronoiFVM.jl/dev/nbhtml/outflow/) + +```@docs +hasoutflownode +isoutflownode +outflownode +``` ## Edge and node data ```@docs diff --git a/docs/src/system.md b/docs/src/system.md index 390a388dd..d4f5e9165 100644 --- a/docs/src/system.md +++ b/docs/src/system.md @@ -38,33 +38,6 @@ VoronoiFVM.is_bulk_species ``` -## Handling boundary conditions -Boundary conditions are handled in the `bcondition` callback passed to the system constructor. -For being called in this callback, the following functions are available - -```@docs -boundary_dirichlet!(y,u,bnode,ispec,ireg,val) -boundary_dirichlet!(y,u,bnode;kwargs...) -boundary_neumann!(y,u,bnode,ispec,ireg,val) -boundary_neumann!(y,u,bnode;kwargs...) -boundary_robin!(y,u,bnode,ispec,ireg,fac,val) -boundary_robin!(y,u,bnode;kwargs...) -ramp -``` - -### Outflow boundary conditions -These are characterized by the `boutflow` physics callback and -and the `outflowboundaries` keyword argument in the system -resp. physics constructor. See also the -[corresponding notebook](https://j-fu.github.io/VoronoiFVM.jl/dev/nbhtml/outflow/) - -```@docs -hasoutflownode -isoutflownode -outflownode -``` - - ## Allocation warnings The code checks for allocations in the assembly loop. @@ -137,7 +110,7 @@ VoronoiFVM.System{Tv,Ti, Tm, TSpecMat<:AbstractMatrix, TSolArray<:AbstractMatrix ## Legacy API ```@docs -boundary_dirichlet!(system::VoronoiFVM.AbstractSystem, ispec, ibc, v) +boundary_dirichlet!(system::VoronoiFVM.AbstractSystem{Tv}, ispec, ibc, v) where {Tv} boundary_dirichlet!(system::VoronoiFVM.AbstractSystem; kwargs...) boundary_neumann!(system::VoronoiFVM.AbstractSystem, ispec, ibc, v) boundary_neumann!(system::VoronoiFVM.AbstractSystem; kwargs...) diff --git a/src/VoronoiFVM.jl b/src/VoronoiFVM.jl index b2cc69124..083a3875c 100644 --- a/src/VoronoiFVM.jl +++ b/src/VoronoiFVM.jl @@ -58,6 +58,17 @@ using Compat: @compat +""" + $(TYPEDEF) + +Abstract type for geometry items (node,bnode,edge, bedge) +""" +abstract type AbstractGeometryItem{Tc <: Number, Tp <: Number, Ti <: Integer} end +export AbstractGeometryItem + +abstract type AbstractSolutionArray{T,N} <: AbstractArray{T,N} end +export AbstractSolutionArray + include("vfvm_physics.jl") @compat public Physics @@ -66,7 +77,6 @@ export fbernoulli export fbernoulli_pm export inplace_linsolve! -abstract type AbstractSolutionArray{T,N} <: AbstractArray{T,N} end include("vfvm_history.jl") export NewtonSolverHistory, TransientSolverHistory, details diff --git a/src/vfvm_geometryitems.jl b/src/vfvm_geometryitems.jl index 06f07d428..d8ce655b2 100644 --- a/src/vfvm_geometryitems.jl +++ b/src/vfvm_geometryitems.jl @@ -1,10 +1,3 @@ -""" - $(TYPEDEF) - -Abstract type for geometry items (node,bnode,edge, bedge) -""" -abstract type AbstractGeometryItem{Tc <: Number, Tp <: Number, Ti <: Integer} end - """ time(edge_or_node) diff --git a/src/vfvm_physics.jl b/src/vfvm_physics.jl index 38ca78ae7..fff5fe3f7 100644 --- a/src/vfvm_physics.jl +++ b/src/vfvm_physics.jl @@ -482,3 +482,87 @@ isnontrivial(e::AbstractEvaluator) = e.isnontrivial function diffusion_flux(D::T) where {T} (y, u, args...) -> y[1] = D(u[1, 1] + u[1, 2]) * (u[1, 1] - u[1, 2]) end + +""" + boundary_dirichlet!(y,u,bnode,ispec,ireg,val) + +Set Dirichlet boundary condition for species ispec at boundary ibc. +""" +function boundary_dirichlet!(y, u, bnode::AbstractGeometryItem, ispec, ireg, val; penalty = bnode.Dirichlet) + if bnode.region == ireg + y[ispec] += penalty * (u[ispec] - val) + # just for call during initialization, so we can convert from dual number + bnode.dirichlet_value[ispec] = value(val) + end + nothing +end + +""" + boundary_dirichlet!(y,u,bnode; kwargs...) + +Keyword argument version: +- `species`: species number. Default: 1 +- `region`: boundary region number. By default, all boundary regions. +- `value`: value +""" +function boundary_dirichlet!(y, u, bnode::AbstractGeometryItem; species = 1, region = bnode.region, value = 0, penalty = bnode.Dirichlet) + boundary_dirichlet!(y, u, bnode, species, region, value; penalty) +end + +""" + ramp(t; kwargs...) +Ramp function for specifying time dependent boundary conditions + +Keyword arguments: +- `dt`: Tuple: start and end time of ramp. Default: `(0,0.1)` +- `du`: Tuple: values at start and end time. Default: `(0,0)` +""" +function ramp(t; dt = (0, 0.1), du = (0, 0)) + (t, ubegin, uend, tbegin, tend) = promote(Float64(t), du[1], du[2], dt[1], dt[2]) + if t < tbegin + return ubegin + elseif t < tend + return ubegin + (uend - ubegin) * (t - tbegin) / (tend - tbegin) + else + return uend + end +end + + +""" + boundary_neumann!(y,u,bnode,ispec,ireg,val) + +Set Neumann boundary condition for species ispec at boundary ibc. +""" +boundary_neumann!(y, u, bnode::AbstractGeometryItem, ispec, ireg, val) = bnode.region == ireg ? y[ispec] -= val : nothing + +""" + boundary_neumann!(y,u,bnode, args...; kwargs...) +Keyword argument version: +- `species`: species number. Default: 1 +- `region`: boundary region number. By default, all boundary regions. +- `value`: value +""" +function boundary_neumann!(y, u, bnode::AbstractGeometryItem, args...; species = 1, region = bnode.region, value = 0) + boundary_neumann!(y, u, bnode, species, region, value) +end + + +""" + boundary_robin!(y,u,bnode,ispec,ireg,fac,val) + +Set Robin boundary condition for species ispec at boundary ibc. +""" +boundary_robin!(y, u, bnode::AbstractGeometryItem, ispec, ireg, fac, val) = bnode.region == ireg ? y[ispec] += fac * u[ispec] - val : nothing + +""" + boundary_robin!(y,u,bnode, args...; kwargs...) +Keyword argument version: +- `species`: species number. Default: 1 +- `region`: boundary region number. By default, all boundary regions. +- `factor`: factor +- `value`: value +""" +function boundary_robin!(y, u, bnode::AbstractGeometryItem, args...; species = 1, region = bnode.region, factor = 0, value = 0) + boundary_robin!(y, u, bnode, species, region, factor, value) +end diff --git a/src/vfvm_system.jl b/src/vfvm_system.jl index e75fd511f..5e093b047 100644 --- a/src/vfvm_system.jl +++ b/src/vfvm_system.jl @@ -806,6 +806,7 @@ end """ boundary_dirichlet!(system; kwargs...) + Keyword argument version: - `species`: species number - `region`: region number @@ -818,49 +819,6 @@ function boundary_dirichlet!(system::AbstractSystem; species = 1, region = 1, va boundary_dirichlet!(system, species, region, value) end -""" - boundary_dirichlet!(y,u,bnode,ispec,ireg,val) - -Set Dirichlet boundary condition for species ispec at boundary ibc. -""" -function boundary_dirichlet!(y, u, bnode, ispec, ireg, val; penalty = bnode.Dirichlet) - if bnode.region == ireg - y[ispec] += penalty * (u[ispec] - val) - # just for call during initialization, so we can convert from dual number - bnode.dirichlet_value[ispec] = value(val) - end - nothing -end - -""" - boundary_dirichlet!(y,u,bnode, args...; kwargs...) -Keyword argument version: -- `species`: species number. Default: 1 -- `region`: boundary region number. By default, all boundary regions. -- `value`: value -""" -function boundary_dirichlet!(y, u, bnode, args...; species = 1, region = bnode.region, value = 0, penalty = bnode.Dirichlet) - boundary_dirichlet!(y, u, bnode, species, region, value; penalty) -end - -""" - ramp(t; kwargs...) -Ramp function for specifying time dependent boundary conditions - -Keyword arguments: -- `dt`: Tuple: start and end time of ramp. Default: `(0,0.1)` -- `du`: Tuple: values at start and end time. Default: `(0,0)` -""" -function ramp(t; dt = (0, 0.1), du = (0, 0)) - (t, ubegin, uend, tbegin, tend) = promote(Float64(t), du[1], du[2], dt[1], dt[2]) - if t < tbegin - return ubegin - elseif t < tend - return ubegin + (uend - ubegin) * (t - tbegin) / (tend - tbegin) - else - return uend - end -end ################################################################## """ @@ -889,23 +847,6 @@ Keyword argument version: """ boundary_neumann!(system::AbstractSystem; species = 0, region = 0, value = 0) = boundary_neumann!(system, species, region, value) -""" - boundary_neumann!(y,u,bnode,ispec,ireg,val) - -Set Neumann boundary condition for species ispec at boundary ibc. -""" -boundary_neumann!(y, u, bnode, ispec, ireg, val) = bnode.region == ireg ? y[ispec] -= val : nothing - -""" - boundary_neumann!(y,u,bnode, args...; kwargs...) -Keyword argument version: -- `species`: species number. Default: 1 -- `region`: boundary region number. By default, all boundary regions. -- `value`: value -""" -function boundary_neumann!(y, u, bnode, args...; species = 1, region = bnode.region, value = 0) - boundary_neumann!(y, u, bnode, species, region, value) -end ################################################################## """ @@ -938,24 +879,6 @@ function boundary_robin!(system::AbstractSystem; species = 0, region = 0, factor boundary_robin!(system, species, region, factor, value) end -""" - boundary_robin!(y,u,bnode,ispec,ireg,fac,val) - -Set Robin boundary condition for species ispec at boundary ibc. -""" -boundary_robin!(y, u, bnode, ispec, ireg, fac, val) = bnode.region == ireg ? y[ispec] += fac * u[ispec] - val : nothing - -""" - boundary_robin!(y,u,bnode, args...; kwargs...) -Keyword argument version: -- `species`: species number. Default: 1 -- `region`: boundary region number. By default, all boundary regions. -- `factor`: factor -- `value`: value -""" -function boundary_robin!(y, u, bnode, args...; species = 1, region = bnode.region, factor = 0, value = 0) - boundary_robin!(y, u, bnode, species, region, factor, value) -end ################################################################## """