Skip to content

Commit

Permalink
Change output of split to tuple of ADSBinaryNode
Browse files Browse the repository at this point in the history
  • Loading branch information
LuEdRaMo committed Apr 8, 2024
1 parent 79807f3 commit 889f409
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
10 changes: 10 additions & 0 deletions src/adsbinarynode.jl
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,11 @@ function leftchild!(
parent.left = node
end

function leftchild!(parent::ADSBinaryNode{N, M, T}, node::ADSBinaryNode{N, M, T}) where {N, M, T <: Real}
# set `node` as left child of `parent`
parent.left = node
end

function rightchild!(

Check warning on line 158 in src/adsbinarynode.jl

View check run for this annotation

Codecov / codecov/patch

src/adsbinarynode.jl#L158

Added line #L158 was not covered by tests
parent::ADSBinaryNode{N, M, T}, s::ADSDomain{N, T}, t::T,
x::SVector{M, TaylorN{T}}, p::SVector{M, Taylor1{TaylorN{T}}}
Expand All @@ -159,6 +164,11 @@ function rightchild!(
parent.right = node

Check warning on line 164 in src/adsbinarynode.jl

View check run for this annotation

Codecov / codecov/patch

src/adsbinarynode.jl#L162-L164

Added lines #L162 - L164 were not covered by tests
end

function rightchild!(parent::ADSBinaryNode{N, M, T}, node::ADSBinaryNode{N, M, T}) where {N, M, T <: Real}
# set `node` as right child of `parent`
parent.right = node
end

# AbstractTrees interface
function children(node::ADSBinaryNode{N, M, T}) where {N, M, T <: Real}
if isnothing(node.left) && isnothing(node.right)
Expand Down
10 changes: 5 additions & 5 deletions src/adstaylorinteg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ end
# Split node's domain in half
# See section 3 of https://doi.org/10.1007/s10569-015-9618-3
function split(node::ADSBinaryNode{N, M, T}, x::SVector{M, TaylorN{T}},
p::SVector{M, Taylor1{TaylorN{T}}}) where {N, M, T <: Real}
p::SVector{M, Taylor1{TaylorN{T}}}, dt::T) where {N, M, T <: Real}
# Split direction
j = splitdirection(x)
# Split domain
Expand All @@ -146,7 +146,7 @@ function split(node::ADSBinaryNode{N, M, T}, x::SVector{M, TaylorN{T}},
Taylor1( map(z -> z(v_2), p[i].coeffs), order ) for i in eachindex(p)
)

return s1, x1, p1, s2, x2, p2
return ADSBinaryNode(s1, node.t+dt, x1, p1), ADSBinaryNode(s2, node.t+dt, x2, p2)
end

"""
Expand All @@ -164,11 +164,11 @@ function split!(node::ADSBinaryNode{N, M, T}, p::SVector{M, Taylor1{TaylorN{T}}}
# Split
if nsplits < maxsplits && any(mask .> stol)
# Split
s1, x1, p1, s2, x2, p2 = split(node, x, p)
lchildnode, rchildnode = split(node, x, p, dt)
# Left half
leftchild!(node, s1, node.t + dt, x1, p1)
leftchild!(node, lchildnode)
# Right half
rightchild!(node, s2, node.t + dt, x2, p2)
rightchild!(node, rchildnode)
# Update number of splits
nsplits += 1
# No split
Expand Down

0 comments on commit 889f409

Please sign in to comment.