From 45e80d2f3102545ff584cd1005e8666169ded062 Mon Sep 17 00:00:00 2001 From: Timo Koch Date: Wed, 21 Sep 2022 23:07:47 +0200 Subject: [PATCH 1/2] [tpfa][multithreading] Update flux vars cache in parallel --- .../cellcentered/tpfa/gridfluxvariablescache.hh | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/dumux/discretization/cellcentered/tpfa/gridfluxvariablescache.hh b/dumux/discretization/cellcentered/tpfa/gridfluxvariablescache.hh index d73e499e0e..3d88f5271e 100644 --- a/dumux/discretization/cellcentered/tpfa/gridfluxvariablescache.hh +++ b/dumux/discretization/cellcentered/tpfa/gridfluxvariablescache.hh @@ -24,6 +24,8 @@ #ifndef DUMUX_DISCRETIZATION_CCTPFA_GRID_FLUXVARSCACHE_HH #define DUMUX_DISCRETIZATION_CCTPFA_GRID_FLUXVARSCACHE_HH +#include + // make the local view function available whenever we use this class #include #include @@ -101,19 +103,18 @@ public: fluxVarsCache_.resize(gridGeometry.numScvf()); - auto fvGeometry = localView(gridGeometry); - auto elemVolVars = localView(gridVolVars); - for (const auto& element : elements(gridGeometry.gridView())) + Dumux::parallelFor(gridGeometry.gridView().size(0), [&](const std::size_t eIdx) { // Prepare the geometries within the elements of the stencil - fvGeometry.bind(element); - elemVolVars.bind(element, fvGeometry, sol); + const auto element = gridGeometry.element(eIdx); + const auto fvGeometry = localView(gridGeometry).bind(element); + const auto elemVolVars = localView(gridVolVars).bind(element, fvGeometry, sol); for (auto&& scvf : scvfs(fvGeometry)) { filler.fill(*this, fluxVarsCache_[scvf.index()], element, fvGeometry, elemVolVars, scvf, forceUpdate); } - } + }); } } -- GitLab From b5272bbde9c51dae3e785c3daf69a3b5850f924d Mon Sep 17 00:00:00 2001 From: Timo Koch Date: Wed, 21 Sep 2022 23:23:19 +0200 Subject: [PATCH 2/2] [staggered][multithreading] Update flux vars cache in parallel --- .../staggered/gridfluxvariablescache.hh | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/dumux/discretization/facecentered/staggered/gridfluxvariablescache.hh b/dumux/discretization/facecentered/staggered/gridfluxvariablescache.hh index 5287ffb9d9..ad64caad40 100644 --- a/dumux/discretization/facecentered/staggered/gridfluxvariablescache.hh +++ b/dumux/discretization/facecentered/staggered/gridfluxvariablescache.hh @@ -24,6 +24,8 @@ #ifndef DUMUX_DISCRETIZATION_FACECENTERED_STAGGERED_GRID_FLUXVARSCACHE_HH #define DUMUX_DISCRETIZATION_FACECENTERED_STAGGERED_GRID_FLUXVARSCACHE_HH +#include + // make the local view function available whenever we use this class #include #include @@ -95,20 +97,19 @@ public: FluxVariablesCacheFiller filler(problem()); fluxVarsCache_.resize(gridGeometry.numScvf()); - for (const auto& element : elements(gridGeometry.gridView())) + + Dumux::parallelFor(gridGeometry.gridView().size(0), [&](const std::size_t eIdx) { // Prepare the geometries within the elements of the stencil - auto fvGeometry = localView(gridGeometry); - fvGeometry.bind(element); - - auto elemVolVars = localView(gridVolVars); - elemVolVars.bind(element, fvGeometry, sol); + const auto element = gridGeometry.element(eIdx); + const auto fvGeometry = localView(gridGeometry).bind(element); + const auto elemVolVars = localView(gridVolVars).bind(element, fvGeometry, sol); for (auto&& scvf : scvfs(fvGeometry)) { filler.fill(*this, fluxVarsCache_[scvf.index()], element, fvGeometry, elemVolVars, scvf, forceUpdate); } - } + }); } } -- GitLab