From 2009d5dfb8116e98f087d068aab5c47572324b90 Mon Sep 17 00:00:00 2001 From: Mathis Kelm Date: Wed, 29 Sep 2021 13:48:30 +0200 Subject: [PATCH 1/2] [test] Check if grid can communicate in tests --- test/io/gridmanager/gridmanagertests.hh | 10 +++++++--- test/porousmediumflow/co2/problem.hh | 10 +++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/test/io/gridmanager/gridmanagertests.hh b/test/io/gridmanager/gridmanagertests.hh index 9ba89f6aa4..58f61d7bf5 100644 --- a/test/io/gridmanager/gridmanagertests.hh +++ b/test/io/gridmanager/gridmanagertests.hh @@ -31,6 +31,7 @@ #include #include +#include namespace Dumux { @@ -287,9 +288,12 @@ private: if (gridView.comm().size() > 1) { VertexHandleNonZeroMin dataHandle(boundaryMarker, gridView); - gridView.communicate(dataHandle, - Dune::InteriorBorder_All_Interface, - Dune::ForwardCommunication); + if constexpr (Detail::canCommunicate) + gridView.communicate(dataHandle, + Dune::InteriorBorder_All_Interface, + Dune::ForwardCommunication); + else + DUNE_THROW(Dune::InvalidStateException, "Cannot call getBoundaryMarkers_ on multiple processes for a grid that cannot communicate codim-" << GridView::dimension << "-entities"); } } }; diff --git a/test/porousmediumflow/co2/problem.hh b/test/porousmediumflow/co2/problem.hh index 6ab508f783..3e6db0df59 100644 --- a/test/porousmediumflow/co2/problem.hh +++ b/test/porousmediumflow/co2/problem.hh @@ -37,6 +37,7 @@ #include #include #include +#include #include "co2tables.hh" @@ -235,9 +236,12 @@ public: { VectorCommDataHandleSum, GridView::dimension> sumVolumeHandle(this->gridGeometry().vertexMapper(), vtkBoxVolume_); - gridView.communicate(sumVolumeHandle, - Dune::InteriorBorder_InteriorBorder_Interface, - Dune::ForwardCommunication); + if constexpr (Detail::canCommunicate) + gridView.communicate(sumVolumeHandle, + Dune::InteriorBorder_InteriorBorder_Interface, + Dune::ForwardCommunication); + else + DUNE_THROW(Dune::InvalidStateException, "Cannot call addFieldsToWriter on multiple processes for a grid that cannot communicate codim-" << GridView::dimension << "-entities."); } } } -- GitLab From 9ec0238bb0325a56273f9490757aa325b49349dc Mon Sep 17 00:00:00 2001 From: Mathis Kelm Date: Wed, 29 Sep 2021 13:53:38 +0200 Subject: [PATCH 2/2] [assembly] Check if grid can communicate when computing colours --- dumux/assembly/partialreassembler.hh | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/dumux/assembly/partialreassembler.hh b/dumux/assembly/partialreassembler.hh index 88c436fa7d..de2099e710 100644 --- a/dumux/assembly/partialreassembler.hh +++ b/dumux/assembly/partialreassembler.hh @@ -34,6 +34,7 @@ #include #include #include +#include #include "entitycolor.hh" @@ -184,9 +185,12 @@ public: // the red vertex for yellow border vertices VectorCommDataHandleMin, dim> minHandle(vertexMapper, vertexColor_); - gridView.communicate(minHandle, - Dune::InteriorBorder_InteriorBorder_Interface, - Dune::ForwardCommunication); + if constexpr (Detail::canCommunicate) + gridView.communicate(minHandle, + Dune::InteriorBorder_InteriorBorder_Interface, + Dune::ForwardCommunication); + else + DUNE_THROW(Dune::InvalidStateException, "Cannot call computeColors on multiple processes for a grid that cannot communicate codim-" << dim << "-entities."); // mark yellow elements for (const auto& element : elements(gridView)) @@ -238,9 +242,12 @@ public: // demote the border orange vertices VectorCommDataHandleMax, dim> maxHandle(vertexMapper, vertexColor_); - gridView.communicate(maxHandle, - Dune::InteriorBorder_InteriorBorder_Interface, - Dune::ForwardCommunication); + if constexpr (Detail::canCommunicate) + gridView.communicate(maxHandle, + Dune::InteriorBorder_InteriorBorder_Interface, + Dune::ForwardCommunication); + else + DUNE_THROW(Dune::InvalidStateException, "Cannot call computeColors on multiple processes for a grid that cannot communicate codim-" << dim << "-entities."); // promote the remaining orange vertices to red for (unsigned int i=0; i < vertexColor_.size(); ++i) { -- GitLab