diff --git a/julia/TUG/src/DynamicSimulation.jl b/julia/TUG/src/DynamicSimulation.jl index f9cb461..5c2a854 100644 --- a/julia/TUG/src/DynamicSimulation.jl +++ b/julia/TUG/src/DynamicSimulation.jl @@ -26,14 +26,18 @@ struct DynamicSimulation{T} <: AbstractSimulation{T} iterations::Int timestep::T + workerPool::WorkerPool + function DynamicSimulation( grid::Grid{T}, bc::Boundary{T}, approach::APPROACH, timestep::T, + workers::Vector{Int}=workers(), )::DynamicSimulation{T} where {T} timestep, iterations = adjustTimestep(grid, approach, timestep, 1, false) - new{T}(grid, Vector{Grid{T}}(), bc, approach, iterations, timestep) + workerPool = WorkerPool(workers) + new{T}(grid, Vector{Grid{T}}(), bc, approach, iterations, timestep, workerPool) end end @@ -66,7 +70,8 @@ Runs the simulation for all grid states in parallel. Nothing, but updates all grids in the simulation according to the defined approach and iterations. """ function next(simulation::DynamicSimulation{T})::Nothing where {T} - pmap(grid -> runSimulationForGrid(simulation, grid), simulation.grids) + pmap(grid -> runSimulationForGrid(simulation, grid), simulation.workerPool, simulation.grids) + return end """