Skip to content
This repository was archived by the owner on Jul 19, 2023. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/DiffEqOperators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ end
export MatrixFreeOperator
export AnalyticalJacVecOperator, JacVecOperator, getops
export AbstractDerivativeOperator, DerivativeOperator,
CenteredDifference, UpwindDifference
CenteredDifference, UpwindDifference, NonLinearDiffusion
export DirichletBC, Dirichlet0BC, NeumannBC, Neumann0BC, RobinBC, GeneralBC, MultiDimBC, PeriodicBC,
MultiDimDirectionalBC, ComposedMultiDimBC
export compose, decompose, perpsize
Expand Down
26 changes: 26 additions & 0 deletions src/derivative_operators/derivative_operator.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,32 @@ struct DerivativeOperator{T<:Real,N,Wind,T2,S1,S2<:SArray,T3,F} <: AbstractDeriv
coeff_func :: F
end

struct NonLinearDiffusion end

function NonLinearDiffusion(second_differential_order::Int, first_differential_order::Int, approx_order::Int,
p::AbstractVector{T}, q::AbstractVector{T}, dx::Union{T,AbstractVector{T}, Real},
nknots::Int) where {T<:Real,N}
#p is given by bc1*k , k being the diffusion coefficient
#q is given by bc2*u , u being the desired function
#first differential is the inner one, second is the outer differential
@assert approx_order>1 "approximation_order must be greater than 1."
discretization = zeros(nknots)

if first_differential_order > 0
discretization += (CenteredDifference(first_differential_order,approx_order,dx,nknots)*q).*(CenteredDifference(second_differential_order,approx_order,dx,nknots)*p)
else
discretization += q[2:(nknots + 1)].*(CenteredDifference(second_differential_order,approx_order,dx,nknots)*p)
end

for l = 1:(second_differential_order - 1)
discretization += binomial(second_differential_order,l)*(CenteredDifference(l + first_differential_order,approx_order,dx,nknots)*q).*(CenteredDifference(second_differential_order - l,approx_order,dx,nknots)*p)
end

discretization += (CenteredDifference(first_differential_order + second_differential_order,approx_order,dx,nknots)*q).*p[2:(nknots + 1)]
return discretization

end

struct CenteredDifference{N} end

function CenteredDifference{N}(derivative_order::Int,
Expand Down