Skip to content

Commit 9755a09

Browse files
authored
Hotfix for #1065 (#1070)
* Hotfix for #1065 * Add missing Project.toml
1 parent 9b9efbe commit 9755a09

4 files changed

Lines changed: 17 additions & 25 deletions

File tree

Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ version = "0.4.4-dev"
44
authors = ["erik.faulhaber <44124897+efaulhaber@users.noreply.github.com>"]
55

66
[deps]
7+
Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697"
78
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
89
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
910
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
@@ -41,6 +42,7 @@ OrdinaryDiffEqCore = "bbf590c4-e513-4bbe-9b18-05decba2e5d8"
4142
TrixiParticlesOrdinaryDiffEqExt = ["OrdinaryDiffEq", "OrdinaryDiffEqCore"]
4243

4344
[compat]
45+
Accessors = "0.1.43"
4446
Adapt = "4"
4547
CSV = "0.10"
4648
DataFrames = "1.6"

src/TrixiParticles.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ module TrixiParticles
22

33
using Reexport: @reexport
44

5+
using Accessors: @set
56
using Adapt: Adapt
67
using Base: @propagate_inbounds
78
using CSV: CSV

src/general/semidiscretization.jl

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -272,11 +272,7 @@ function semidiscretize(semi, tspan; reset_threads=true)
272272
# Therefore, we have to re-link them, which yields yet another `Semidiscretization`.
273273
# Note that this re-creates systems containing links, so it only works as long
274274
# as systems don't link to other systems containing links.
275-
semi_new = Semidiscretization(set_system_links.(semi_.systems, Ref(semi_)),
276-
semi_.ranges_u, semi_.ranges_v,
277-
semi_.neighborhood_searches,
278-
semi_.parallelization_backend,
279-
semi_.update_callback_used, semi_.integrate_tlsph)
275+
semi_new = @set semi_.systems = set_system_links.(semi_.systems, Ref(semi_))
280276

281277
@info "To move data to the GPU, `semidiscretize` creates a deep copy of the passed " *
282278
"`Semidiscretization`. Use `semi = ode.p` to access simulation data."
@@ -822,26 +818,10 @@ end
822818
# After `adapt`, the system type information may change.
823819
# This means that systems linking to other systems still point to old systems.
824820
# Therefore, we have to re-link them based on the stored system index.
825-
set_system_links(system, semi) = system
826-
827821
function set_system_links(system::OpenBoundarySystem, semi)
828822
fluid_system = semi.systems[system.fluid_system_index[]]
829823

830-
return OpenBoundarySystem(system.boundary_model,
831-
system.initial_condition,
832-
fluid_system, # link to fluid system
833-
system.fluid_system_index,
834-
system.smoothing_kernel,
835-
system.smoothing_length,
836-
system.mass,
837-
system.volume,
838-
system.boundary_candidates,
839-
system.fluid_candidates,
840-
system.boundary_zone_indices,
841-
system.boundary_zones,
842-
system.buffer,
843-
system.pressure_acceleration_formulation,
844-
system.shifting_technique,
845-
system.calculate_flow_rate,
846-
system.cache)
824+
return @set system.fluid_system = fluid_system
847825
end
826+
827+
set_system_links(system, semi) = system

src/io/write_vtk.jl

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,17 @@ function trixi2vtk(system_, dvdu_ode_, vu_ode_, semi_, t, periodic_box;
158158
vtk_save(pvd)
159159
end
160160

161+
function transfer2cpu(semi::Semidiscretization)
162+
# First move all data to the CPU
163+
semi = Adapt.adapt(Array, semi)
164+
165+
# Now, set the parallelization backend to `PolyesterBackend` to make sure that
166+
# `@threaded` loops still work as expected with this semidiscretization.
167+
return @set semi.parallelization_backend = PolyesterBackend()
168+
end
169+
161170
function transfer2cpu(v_::AbstractGPUArray, u_, semi_)
162-
semi = Adapt.adapt(Array, semi_)
171+
semi = transfer2cpu(semi_)
163172
v, u = transfer2cpu(v_, u_)
164173

165174
return v, u, semi

0 commit comments

Comments
 (0)