diff --git a/dumux/geomechanics/el2p/el2plocaloperator.hh b/dumux/geomechanics/el2p/el2plocaloperator.hh
index acbdb1a7833d23f265d4e3f7103516a1bb5c7889..0b96068285f0f4bc33772ac23188f1dc9dd86c0c 100644
--- a/dumux/geomechanics/el2p/el2plocaloperator.hh
+++ b/dumux/geomechanics/el2p/el2plocaloperator.hh
@@ -287,8 +287,10 @@ public:
                 pw += x(pressLFS,i) * q[i];
                 sn += x(satLFS,i) * q[i];
                 ux += x(displacementLFS.child(0),i) * q[i];
-                uy += x(displacementLFS.child(1),i) * q[i];
-                uz += x(displacementLFS.child(2),i) * q[i];
+                if (dim > 1)
+                    uy += x(displacementLFS.child(1),i) * q[i];
+                if (dim > 2)
+                    uz += x(displacementLFS.child(2),i) * q[i];
              }
              RT_P sw = 1.0 - sn;
              RT_P pn = pw + MaterialLaw::pc(materialParams, sw);
@@ -323,8 +325,10 @@ public:
              primVars[wPhaseIdx] = pw;
              primVars[nPhaseIdx] = sn;
              primVars[Indices::uxIdx] = ux;
-             primVars[Indices::uyIdx] = uy;
-             primVars[Indices::uzIdx] = uz;
+             if (dim > 1)
+                 primVars[Indices::uyIdx] = uy;
+             if (dim > 2)
+                 primVars[Indices::uzIdx] = uz;
 
              VolumeVariables volVars;
              // evaluate volume variables for this quadrature point
diff --git a/dumux/geomechanics/el2p/el2pmodel.hh b/dumux/geomechanics/el2p/el2pmodel.hh
index 01a3b4cea5fd2c7c2b136f8d54fd3ed9f5116d56..200ea61523c87071477e7da6f865a3d66baaa31f 100644
--- a/dumux/geomechanics/el2p/el2pmodel.hh
+++ b/dumux/geomechanics/el2p/el2pmodel.hh
@@ -498,14 +498,14 @@ public:
             // are defined to be positive and total stress is calculated by adding the pore pressure
             if(rockMechanicsSignConvention_){
                 totalStressX[eIdx][0] = initStressX[eIdx][0] + deltaEffStressX[eIdx][0]    + deltaEffPressure[eIdx];
-                totalStressX[eIdx][1] = initStressX[eIdx][1] + deltaEffStressX[eIdx][1];
-                totalStressX[eIdx][2] = initStressX[eIdx][2] + deltaEffStressX[eIdx][2];
                 if (dim >= 2) {
+                    totalStressX[eIdx][1] = initStressX[eIdx][1] + deltaEffStressX[eIdx][1];
                     totalStressY[eIdx][0] = initStressY[eIdx][0] + deltaEffStressY[eIdx][0];
                     totalStressY[eIdx][1] = initStressY[eIdx][1] + deltaEffStressY[eIdx][1]    + deltaEffPressure[eIdx];
-                    totalStressY[eIdx][2] = initStressY[eIdx][2] + deltaEffStressY[eIdx][2];
                 }
                 if (dim >= 3) {
+                    totalStressX[eIdx][2] = initStressX[eIdx][2] + deltaEffStressX[eIdx][2];
+                    totalStressY[eIdx][2] = initStressY[eIdx][2] + deltaEffStressY[eIdx][2];
                     totalStressZ[eIdx][0] = initStressZ[eIdx][0] + deltaEffStressZ[eIdx][0];
                     totalStressZ[eIdx][1] = initStressZ[eIdx][1] + deltaEffStressZ[eIdx][1];
                     totalStressZ[eIdx][2] = initStressZ[eIdx][2] + deltaEffStressZ[eIdx][2]    + deltaEffPressure[eIdx];
@@ -513,14 +513,14 @@ public:
             }
             else{
                 totalStressX[eIdx][0] = initStressX[eIdx][0] + deltaEffStressX[eIdx][0]    - deltaEffPressure[eIdx];
-                totalStressX[eIdx][1] = initStressX[eIdx][1] + deltaEffStressX[eIdx][1];
-                totalStressX[eIdx][2] = initStressX[eIdx][2] + deltaEffStressX[eIdx][2];
                 if (dim >= 2) {
+                    totalStressX[eIdx][1] = initStressX[eIdx][1] + deltaEffStressX[eIdx][1];
                     totalStressY[eIdx][0] = initStressY[eIdx][0] + deltaEffStressY[eIdx][0];
                     totalStressY[eIdx][1] = initStressY[eIdx][1] + deltaEffStressY[eIdx][1]    - deltaEffPressure[eIdx];
-                    totalStressY[eIdx][2] = initStressY[eIdx][2] + deltaEffStressY[eIdx][2];
                 }
                 if (dim >= 3) {
+                    totalStressX[eIdx][2] = initStressX[eIdx][2] + deltaEffStressX[eIdx][2];
+                    totalStressY[eIdx][2] = initStressY[eIdx][2] + deltaEffStressY[eIdx][2];
                     totalStressZ[eIdx][0] = initStressZ[eIdx][0] + deltaEffStressZ[eIdx][0];
                     totalStressZ[eIdx][1] = initStressZ[eIdx][1] + deltaEffStressZ[eIdx][1];
                     totalStressZ[eIdx][2] = initStressZ[eIdx][2] + deltaEffStressZ[eIdx][2]    - deltaEffPressure[eIdx];
diff --git a/test/geomechanics/el2p/el2pproblem.hh b/test/geomechanics/el2p/el2pproblem.hh
index f0c4518bf9c308fd8127b79aa9c357eee7a8baba..a2a580222270e6c6a5add28a4242e452db3368bf 100644
--- a/test/geomechanics/el2p/el2pproblem.hh
+++ b/test/geomechanics/el2p/el2pproblem.hh
@@ -282,7 +282,7 @@ public:
             GlobalPosition globalPos = vertex.geometry().corner(0);
 
             // initial approximate pressure distribution at start of initialization run
-            pInit_[vIdxGlobal] = -(1.013e5 + (depthBOR_ - globalPos[2]) * brineDensity_ * 9.81);
+            pInit_[vIdxGlobal] = -(1.013e5 + (depthBOR_ - globalPos[dimWorld-1]) * brineDensity_ * 9.81);
         }
     }
 
@@ -341,7 +341,7 @@ public:
     {
       GlobalPosition stress;
       Scalar porosity, rockDensity, gravity;
-      gravity = -this->gravity()[2];
+      gravity = -this->gravity()[dimWorld-1];
       porosity = this->spatialParams().porosity(globalPos);
       rockDensity = this->spatialParams().rockDensity(globalPos);
 
@@ -381,7 +381,7 @@ public:
     Scalar temperatureAtPos(const GlobalPosition &globalPos) const
     {
         Scalar T;
-        T = 283.15 + (depthBOR_ - globalPos[2]) * 0.03;
+        T = 283.15 + (depthBOR_ - globalPos[dimWorld-1]) * 0.03;
 
         return T;
     };
@@ -483,14 +483,14 @@ public:
         }
 
         // Lower boundary closed for brine and CO2 flux, uz is fixed.
-        if(globalPos[2] < eps_)
+        if(globalPos[dimWorld-1] < eps_)
         {
             values.setDirichlet(uzIdx);
         }
 
         // for the initialization run the pressure and saturation
         // values are only given at the top boundary.
-        if(globalPos[2] > this->bBoxMax()[2]-eps_)
+        if(globalPos[dimWorld-1] > this->bBoxMax()[dimWorld-1]-eps_)
         {
             values.setDirichlet(pressureIdx);
             values.setDirichlet(saturationIdx);
@@ -595,7 +595,7 @@ public:
         if(initializationRun_ == false){
         if(globalPos[0] > 490 && globalPos[0] < 510
                         && globalPos[1] > 490 && globalPos[1] < 510
-                        && globalPos[2] > 490 && globalPos[2] < 510)
+                        && globalPos[dimWorld-1] > 490 && globalPos[dimWorld-1] < 510)
         values[saturationIdx] = 1.e-5; // injection
         }
     }
@@ -799,8 +799,8 @@ public:
                 // compare coordinates of current vertex with position coordinates
                 if (globalPos[0] >= position[0] - eps_ && globalPos[0] <= position[0] + eps_
                                 && globalPos[1] >= position[1] - eps_ && globalPos[1]
-                                <= position[1] + eps_ && globalPos[2] >= position[2] - eps_
-                                && globalPos[2] <= position[2] + eps_)
+                                <= position[1] + eps_ && globalPos[dimWorld-1] >= position[dimWorld-1] - eps_
+                                && globalPos[dimWorld-1] <= position[dimWorld-1] + eps_)
                 {
                     // if coordinates are identical write the pressure value for this
                     // vertex (with index vIdxGlobal) into the values vector