feat: dynamic simulation accepts a vector of workers to compute on

[skip ci]
This commit is contained in:
nebmit 2023-12-05 09:29:36 +01:00
parent 39eacff904
commit 3f7163e0af
No known key found for this signature in database

View File

@ -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
"""