Skip to content

Commit 0b7002d

Browse files
author
LasNikas
committed
implement suggestions
1 parent a9b4f32 commit 0b7002d

1 file changed

Lines changed: 52 additions & 52 deletions

File tree

src/general/interpolation.jl

Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -570,11 +570,14 @@ end
570570
computed_density[point] = NaN
571571
neighbor_count[point] = 0
572572

573-
set_nan!(cache, point, ref_system)
573+
foreach(Tuple(cache)) do field
574+
set_nan!(field, point)
575+
end
574576
else
575577
# Normalize all quantities by the shepard coefficient
576-
divide_by_shepard_coefficient!(cache, point, shepard_coefficient,
577-
ref_system)
578+
foreach(Tuple(cache)) do field
579+
divide_by_shepard_coefficient!(field, shepard_coefficient, point)
580+
end
578581
end
579582
end
580583

@@ -584,55 +587,6 @@ end
584587
neighbor_count=Array(neighbor_count), cache_...)
585588
end
586589

587-
function set_nan!(cache, point, ref_system::FluidSystem)
588-
for dim in 1:ndims(ref_system)
589-
cache.velocity[dim, point] = NaN
590-
end
591-
cache.pressure[point] = NaN
592-
cache.density[point] = NaN
593-
594-
return cache
595-
end
596-
597-
function set_nan!(cache, point, ref_system::SolidSystem)
598-
for dim in 1:ndims(ref_system)
599-
cache.velocity[dim, point] = NaN
600-
end
601-
cache.jacobian[point] = NaN
602-
cache.von_mises_stress[point] = NaN
603-
604-
for j in axes(cache.cauchy_stress, 2), i in axes(cache.cauchy_stress, 1)
605-
cache.cauchy_stress[i, j, point] = NaN
606-
end
607-
608-
return cache
609-
end
610-
611-
function divide_by_shepard_coefficient!(cache, point, shepard_coefficient,
612-
ref_system::FluidSystem)
613-
for dim in 1:ndims(ref_system)
614-
cache.velocity[dim, point] /= shepard_coefficient[point]
615-
end
616-
cache.pressure[point] /= shepard_coefficient[point]
617-
cache.density[point] /= shepard_coefficient[point]
618-
619-
return cache
620-
end
621-
622-
function divide_by_shepard_coefficient!(cache, point, shepard_coefficient,
623-
ref_system::SolidSystem)
624-
for dim in 1:ndims(ref_system)
625-
cache.velocity[dim, point] /= shepard_coefficient[point]
626-
end
627-
cache.jacobian[point] /= shepard_coefficient[point]
628-
cache.von_mises_stress[point] /= shepard_coefficient[point]
629-
630-
for j in axes(cache.cauchy_stress, 2), i in axes(cache.cauchy_stress, 1)
631-
cache.cauchy_stress[i, j, point] /= shepard_coefficient[point]
632-
end
633-
return cache
634-
end
635-
636590
@inline function create_cache_interpolation(ref_system::FluidSystem, n_points, semi)
637591
(; parallelization_backend) = semi
638592

@@ -704,3 +658,49 @@ end
704658

705659
return cache
706660
end
661+
662+
function set_nan!(field::AbstractVector, point)
663+
field[point] = NaN
664+
665+
return field
666+
end
667+
668+
function set_nan!(field::AbstractArray{T, 2}, point)
669+
for dim in axes(field, 1)
670+
field[dim, point] = NaN
671+
end
672+
673+
return field
674+
end
675+
676+
function set_nan!(field::AbstractArray{T, 3}, point)
677+
for j in axes(field, 2), i in axes(field, 1)
678+
field[i, j, point] = NaN
679+
end
680+
681+
return field
682+
end
683+
684+
function divide_by_shepard_coefficient!(field::AbstractVector, shepard_coefficient, point)
685+
field[point] /= shepard_coefficient[point]
686+
687+
return field
688+
end
689+
690+
function divide_by_shepard_coefficient!(field::AbstractArray{T, 2}, shepard_coefficient,
691+
point)
692+
for dim in axes(field, 1)
693+
field[dim, point] /= shepard_coefficient[point]
694+
end
695+
696+
return cache
697+
end
698+
699+
function divide_by_shepard_coefficient!(field::AbstractArray{T, 3}, shepard_coefficient,
700+
point)
701+
for j in axes(field, 2), i in axes(field, 1)
702+
field[i, j, point] /= shepard_coefficient[point]
703+
end
704+
705+
return field
706+
end

0 commit comments

Comments
 (0)