Skip to content

Commit

Permalink
further documentation work
Browse files Browse the repository at this point in the history
  • Loading branch information
j-fu committed Sep 11, 2024
1 parent c44f1a8 commit d510630
Show file tree
Hide file tree
Showing 8 changed files with 130 additions and 115 deletions.
2 changes: 1 addition & 1 deletion docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function make(; with_examples = true,

pages = [
"Home" => "index.md",
"changes.md",
"Changelog" => "changes.md",
"method.md",
"API Documentation" => [
"system.md",
Expand Down
6 changes: 6 additions & 0 deletions docs/src/internal.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,9 @@ eval_jacobian!
mass_matrix
prepare_diffeq!
```

## Misc tools
```@docs
VoronoiFVM.doolittle_ludecomp!
VoronoiFVM.doolittle_lusolve!
```
26 changes: 26 additions & 0 deletions docs/src/physics.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
29 changes: 1 addition & 28 deletions docs/src/system.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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...)
Expand Down
12 changes: 11 additions & 1 deletion src/VoronoiFVM.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
7 changes: 0 additions & 7 deletions src/vfvm_geometryitems.jl
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
84 changes: 84 additions & 0 deletions src/vfvm_physics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
79 changes: 1 addition & 78 deletions src/vfvm_system.jl
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,7 @@ end

"""
boundary_dirichlet!(system; kwargs...)
Keyword argument version:
- `species`: species number
- `region`: region number
Expand All @@ -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

##################################################################
"""
Expand Down Expand Up @@ -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

##################################################################
"""
Expand Down Expand Up @@ -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

##################################################################
"""
Expand Down

0 comments on commit d510630

Please sign in to comment.