diff --git a/test/freeflow/navierstokes/channel/3d/main.cc b/test/freeflow/navierstokes/channel/3d/main.cc
index 3bcce44c679384e2165e22b79b6a20171d2a384b..f3103220bb7c8a17c750d1a654beab20bce6927f 100644
--- a/test/freeflow/navierstokes/channel/3d/main.cc
+++ b/test/freeflow/navierstokes/channel/3d/main.cc
@@ -68,7 +68,7 @@ int main(int argc, char** argv)
     using Grid = GetPropType<TypeTag, Properties::Grid>;
     Dumux::GridManager<Grid> gridManager;
 
-#if HAVE_DUNE_SUBGRID
+#if HAVE_DUNE_SUBGRID && GRID_DIM == 3
     const bool isStaircaseGeometry = getParam<bool>("Problem.IsStaircaseGeometry", false);
 
     auto selector = [&](const auto& element)
diff --git a/test/freeflow/navierstokes/channel/3d/problem.hh b/test/freeflow/navierstokes/channel/3d/problem.hh
index 5d95ea95b0152010a49e886137636b049ad86b3a..eded38ba4cf985a6754800457acf225aded961f8 100644
--- a/test/freeflow/navierstokes/channel/3d/problem.hh
+++ b/test/freeflow/navierstokes/channel/3d/problem.hh
@@ -31,7 +31,7 @@
 #include <dune/common/float_cmp.hh>
 #include <dune/grid/yaspgrid.hh>
 
-#if HAVE_DUNE_SUBGRID
+#if HAVE_DUNE_SUBGRID && GRID_DIM == 3
 #include <dune/subgrid/subgrid.hh>
 #endif
 
@@ -71,7 +71,7 @@ struct Grid<TypeTag, TTag::ThreeDChannelTest>
 
     using HostGrid = Dune::YaspGrid<dim, Dune::EquidistantOffsetCoordinates<GetPropType<TypeTag, Properties::Scalar>, dim> >;
 
-#if HAVE_DUNE_SUBGRID
+#if HAVE_DUNE_SUBGRID && GRID_DIM == 3
     using type = Dune::SubGrid<HostGrid::dimension, HostGrid>;
 #else
     using type = HostGrid;