Skip to content

Commit

Permalink
Clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
orlox committed Oct 16, 2024
1 parent d00b451 commit 691f42e
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 30 deletions.
1 change: 0 additions & 1 deletion examples/Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[deps]
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
GLMakie = "e9467ef8-e4e7-5192-8a1a-b1aee30e663a"
Jems = "80e28b2b-5ac7-4db2-b78d-9e35bb8cec21"
LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f"
MathTeXEngine = "0a4f8689-d25c-4efe-a92b-7142dfc1aa53"
Expand Down
38 changes: 20 additions & 18 deletions src/DualSupport/CellDualData.jl
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,15 @@ end
Updates all data of the CellDualData object to the given value.
"""
function update_cell_dual_data_value!(cd::CellDualData, value)
@inbounds cd.diff_cache_cell.dual_data[1] = value
@inbounds cd.diff_cache_m1.dual_data[1] = value
@inbounds cd.diff_cache_00.dual_data[1] = value
@inbounds cd.diff_cache_p1.dual_data[1] = value
#cd.diff_cache_cell.dual_data[1] = value
#cd.diff_cache_m1.dual_data[1] = value
#cd.diff_cache_00.dual_data[1] = value
#cd.diff_cache_p1.dual_data[1] = value
cd.diff_cache_cell.dual_data[1] = value
cd.diff_cache_m1.dual_data[1] = value
cd.diff_cache_00.dual_data[1] = value
cd.diff_cache_p1.dual_data[1] = value
# These are some attempts at speeding this up
#@inbounds cd.diff_cache_cell.dual_data[1] = value
#@inbounds cd.diff_cache_m1.dual_data[1] = value
#@inbounds cd.diff_cache_00.dual_data[1] = value
#@inbounds cd.diff_cache_p1.dual_data[1] = value
end

"""
Expand All @@ -96,16 +97,17 @@ Updates all data of the CellDualData object to the data of a given dual number.
function update_cell_dual_data!(cd::CellDualData{SIZE1, SIZE2, TNUMBER}, dual::TDSC) where {SIZE1, SIZE2, TNUMBER, TDSC}
update_cell_dual_data_value!(cd, dual.value)
nvars = SIZE1-1
@inbounds @views cd.diff_cache_cell.dual_data[2:1+nvars] .= dual.partials
@inbounds @views cd.diff_cache_m1.dual_data[2:1+nvars] .= dual.partials
@inbounds @views cd.diff_cache_00.dual_data[2+nvars:1+2*nvars] .= dual.partials
@inbounds @views cd.diff_cache_p1.dual_data[2+2*nvars:1+3*nvars] .= dual.partials
#for i in 1:nvars
# cd.diff_cache_cell.dual_data[1+i] = dual.partials[i]
# cd.diff_cache_m1.dual_data[1+i] = dual.partials[i]
# cd.diff_cache_00.dual_data[1+nvars+i] = dual.partials[i]
# cd.diff_cache_p1.dual_data[1+2*nvars+i] = dual.partials[i]
#end
for i in 1:nvars
cd.diff_cache_cell.dual_data[1+i] = dual.partials[i]
cd.diff_cache_m1.dual_data[1+i] = dual.partials[i]
cd.diff_cache_00.dual_data[1+nvars+i] = dual.partials[i]
cd.diff_cache_p1.dual_data[1+2*nvars+i] = dual.partials[i]
end
#these are some attempts at speeding this up
#@inbounds @views cd.diff_cache_cell.dual_data[2:1+nvars] .= dual.partials
#@inbounds @views cd.diff_cache_m1.dual_data[2:1+nvars] .= dual.partials
#@inbounds @views cd.diff_cache_00.dual_data[2+nvars:1+2*nvars] .= dual.partials
#@inbounds @views cd.diff_cache_p1.dual_data[2+2*nvars:1+3*nvars] .= dual.partials
end

function get_value(cd::CellDualData)
Expand Down
27 changes: 16 additions & 11 deletions src/DualSupport/FaceDualData.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,23 +43,28 @@ function Base.convert(::Type{FaceDualData{SIZE1, SIZE2, TN1}}, x::TN2) where {SI
end

function update_face_dual_data_value!(fd::FaceDualData, value)
@inbounds fd.diff_cache_face.dual_data[1] = value
@inbounds fd.diff_cache_m1.dual_data[1] = value
@inbounds fd.diff_cache_00.dual_data[1] = value
fd.diff_cache_face.dual_data[1] = value
fd.diff_cache_m1.dual_data[1] = value
fd.diff_cache_00.dual_data[1] = value
# these are some attempts at speeding this up
#@inbounds fd.diff_cache_face.dual_data[1] = value
#@inbounds fd.diff_cache_m1.dual_data[1] = value
#@inbounds fd.diff_cache_00.dual_data[1] = value
end

function update_face_dual_data!(fd::FaceDualData{SIZE1, SIZE2, TNUMBER}, dual::TDSC) where {SIZE1, SIZE2, TNUMBER, TDSC}
update_face_dual_data_value!(fd, dual.value)
twonvars = (SIZE1-1)
nvars = twonvars÷2
#for i in 1:twonvars
# fd.diff_cache_face.dual_data[1+i] = dual.partials[i]
# fd.diff_cache_m1.dual_data[1+i] = dual.partials[i]
# fd.diff_cache_00.dual_data[1+nvars+i] = dual.partials[i]
#end
@inbounds @views fd.diff_cache_face.dual_data[2:1+twonvars] .= dual.partials
@inbounds @views fd.diff_cache_m1.dual_data[2:1+twonvars] .= dual.partials
@inbounds @views fd.diff_cache_00.dual_data[2+nvars:1+nvars+twonvars] .= dual.partials
for i in 1:twonvars
fd.diff_cache_face.dual_data[1+i] = dual.partials[i]
fd.diff_cache_m1.dual_data[1+i] = dual.partials[i]
fd.diff_cache_00.dual_data[1+nvars+i] = dual.partials[i]
end
# these are some attempts at speeding this up
#@inbounds @views fd.diff_cache_face.dual_data[2:1+twonvars] .= dual.partials
#@inbounds @views fd.diff_cache_m1.dual_data[2:1+twonvars] .= dual.partials
#@inbounds @views fd.diff_cache_00.dual_data[2+nvars:1+nvars+twonvars] .= dual.partials
end

function get_value(fd::FaceDualData)
Expand Down

0 comments on commit 691f42e

Please sign in to comment.