diff --git a/src/openmc_nek_driver.cpp b/src/openmc_nek_driver.cpp
index 5c9a3b28..c130162b 100644
--- a/src/openmc_nek_driver.cpp
+++ b/src/openmc_nek_driver.cpp
@@ -264,13 +264,16 @@ void OpenmcNekDriver::init_densities()
       // the correct index in the densities_ array. This mapping assumes that
       // each Nek element is fully contained within an OpenMC cell, i.e. Nek
       // elements are not split between multiple OpenMC cells.
-      for (const auto& c: openmc_driver_->cells_) {
-        const auto& global_elems = mat_to_elems_.at(c.material_index_);
+      for (int i = 0; i < openmc_driver_->cells_.size(); ++i) {
+        if (cell_fluid_mask_[i] == 1) {
+          auto& c = openmc_driver_->cells_[i];
+          const auto& global_elems = mat_to_elems_.at(c.material_index_);
 
-        for (int elem: global_elems) {
-          double rho = c.get_density();
-          densities_[elem] = rho;
-          densities_prev_[elem] = rho;
+          for (int elem: global_elems) {
+            double rho = c.get_density();
+            densities_[elem] = rho;
+            densities_prev_[elem] = rho;
+          }
         }
       }
     }