From ad58943477cfa91fd268dbcce5b0bc510a5155c9 Mon Sep 17 00:00:00 2001 From: Timo Koch <timo.koch@iws.uni-stuttgart.de> Date: Mon, 11 Jul 2022 19:45:05 +0200 Subject: [PATCH] [fcstaggered] Enable parallel gridvolvar update --- .../staggered/gridvolumevariables.hh | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/dumux/discretization/facecentered/staggered/gridvolumevariables.hh b/dumux/discretization/facecentered/staggered/gridvolumevariables.hh index b1d746eff1..ef0dcd4017 100644 --- a/dumux/discretization/facecentered/staggered/gridvolumevariables.hh +++ b/dumux/discretization/facecentered/staggered/gridvolumevariables.hh @@ -27,6 +27,8 @@ #include <vector> #include <type_traits> +#include <dumux/parallel/parallel_for.hh> + // make the local view function available whenever we use this class #include <dumux/discretization/localview.hh> #include <dumux/discretization/facecentered/staggered/elementsolution.hh> @@ -78,20 +80,16 @@ public: template<class GridGeometry, class SolutionVector> void update(const GridGeometry& gridGeometry, const SolutionVector& sol) { - const auto numScv = gridGeometry.numScv(); - volumeVariables_.resize(numScv); - - for (const auto& element : elements(gridGeometry.gridView())) + volumeVariables_.resize(gridGeometry.numScv()); + Dumux::parallelFor(gridGeometry.gridView().size(0), [&, &problem = problem()](const std::size_t eIdx) { - auto fvGeometry = localView(gridGeometry); - fvGeometry.bindElement(element); - - for (auto&& scv : scvs(fvGeometry)) - { - const auto elemSol = elementSolution(element, sol, gridGeometry); - volumeVariables_[scv.index()].update(elemSol, problem(), element, scv); - } - } + const auto element = gridGeometry.element(eIdx); + const auto fvGeometry = localView(gridGeometry).bindElement(element); + const auto elemSol = elementSolution(element, sol, gridGeometry); + + for (const auto& scv : scvs(fvGeometry)) + volumeVariables_[scv.index()].update(elemSol, problem, element, scv); + }); } const VolumeVariables& volVars(const std::size_t scvIdx) const -- GitLab