diff --git a/dumux/assembly/partialreassembler.hh b/dumux/assembly/partialreassembler.hh index 88c436fa7d00e364938a57c1c87dfccfa0941a71..de2099e710ced5c0781125df70a3fe492bd70fe9 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) { diff --git a/test/io/gridmanager/gridmanagertests.hh b/test/io/gridmanager/gridmanagertests.hh index 9ba89f6aa448142a0466e03568be6ab962886a64..58f61d7bf59773b7a930630e8f6fd042fccb3cc1 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 6ab508f783691c2dc8d087a5dbfb092606e7e9af..3e6db0df59f257f6aaea2fc6411cc2f3783fbd49 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."); } } }