From b05324b0c2b2662b2aeeff8771941a7af6fa85c0 Mon Sep 17 00:00:00 2001 From: Erik Faulhaber <44124897+efaulhaber@users.noreply.github.com> Date: Thu, 13 Jun 2024 18:48:24 +0200 Subject: [PATCH 1/3] Make `copy_to_coupled_boundary!` threaded --- src/semidiscretization/semidiscretization_coupled.jl | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/semidiscretization/semidiscretization_coupled.jl b/src/semidiscretization/semidiscretization_coupled.jl index c5c21584dca..be2973ffb0d 100644 --- a/src/semidiscretization/semidiscretization_coupled.jl +++ b/src/semidiscretization/semidiscretization_coupled.jl @@ -125,7 +125,7 @@ end """ ndofsglobal(semi::SemidiscretizationCoupled) - + Return the global number of degrees of freedom associated with each scalar variable across all MPI ranks, and summed up over all coupled systems. This is the same as [`ndofs`](@ref) for simulations running in serial or parallelized via threads. It will in general be different for simulations @@ -605,10 +605,11 @@ function copy_to_coupled_boundary!(boundary_condition::BoundaryConditionCoupled{ i_cell_start, i_cell_step = index_to_start_step_2d(indices[1], axes(mesh_other, 1)) j_cell_start, j_cell_step = index_to_start_step_2d(indices[2], axes(mesh_other, 2)) - i_cell = i_cell_start - j_cell = j_cell_start + @threaded for i in 1:length(cells) + cell = cells[i] + i_cell = i_cell_start + (i - 1) * i_cell_step + j_cell = j_cell_start + (i - 1) * j_cell_step - for cell in cells i_node = i_node_start j_node = j_node_start element_id = linear_indices[i_cell, j_cell] @@ -630,9 +631,6 @@ function copy_to_coupled_boundary!(boundary_condition::BoundaryConditionCoupled{ i_node += i_node_step j_node += j_node_step end - - i_cell += i_cell_step - j_cell += j_cell_step end end From f36fe6957ded3608be5e1b28723dd5b1d1536ebe Mon Sep 17 00:00:00 2001 From: Erik Faulhaber <44124897+efaulhaber@users.noreply.github.com> Date: Mon, 17 Jun 2024 09:24:05 +0200 Subject: [PATCH 2/3] Update src/semidiscretization/semidiscretization_coupled.jl Co-authored-by: Hendrik Ranocha --- src/semidiscretization/semidiscretization_coupled.jl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/semidiscretization/semidiscretization_coupled.jl b/src/semidiscretization/semidiscretization_coupled.jl index 9ed6c36b50a..cafc3a472f3 100644 --- a/src/semidiscretization/semidiscretization_coupled.jl +++ b/src/semidiscretization/semidiscretization_coupled.jl @@ -603,7 +603,10 @@ function copy_to_coupled_boundary!(boundary_condition::BoundaryConditionCoupled{ i_cell_start, i_cell_step = index_to_start_step_2d(indices[1], axes(mesh_other, 1)) j_cell_start, j_cell_step = index_to_start_step_2d(indices[2], axes(mesh_other, 2)) - @threaded for i in 1:length(cells) + # we need indices starting at 1 for the handling of `i_cell` etc. + Base.require_one_based_indexing(cells) + + @threaded for i in eachindex(cells) cell = cells[i] i_cell = i_cell_start + (i - 1) * i_cell_step j_cell = j_cell_start + (i - 1) * j_cell_step From b58a7624ecad201f3342ac5bba2d81b68241209e Mon Sep 17 00:00:00 2001 From: Erik Faulhaber <44124897+efaulhaber@users.noreply.github.com> Date: Mon, 17 Jun 2024 09:40:32 +0200 Subject: [PATCH 3/3] Reformat --- src/semidiscretization/semidiscretization_coupled.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/semidiscretization/semidiscretization_coupled.jl b/src/semidiscretization/semidiscretization_coupled.jl index cafc3a472f3..4843f211089 100644 --- a/src/semidiscretization/semidiscretization_coupled.jl +++ b/src/semidiscretization/semidiscretization_coupled.jl @@ -603,9 +603,9 @@ function copy_to_coupled_boundary!(boundary_condition::BoundaryConditionCoupled{ i_cell_start, i_cell_step = index_to_start_step_2d(indices[1], axes(mesh_other, 1)) j_cell_start, j_cell_step = index_to_start_step_2d(indices[2], axes(mesh_other, 2)) - # we need indices starting at 1 for the handling of `i_cell` etc. + # We need indices starting at 1 for the handling of `i_cell` etc. Base.require_one_based_indexing(cells) - + @threaded for i in eachindex(cells) cell = cells[i] i_cell = i_cell_start + (i - 1) * i_cell_step