diff --git a/ProcessLib/SourceTerms/Python/CreatePythonSourceTerm.cpp b/ProcessLib/SourceTerms/Python/CreatePythonSourceTerm.cpp
index 602d5a8b6fa9c7fb63a97ef70dcd8ee9995cd87f..d1e0ba6ded7f73c073187e707e77718079f1abdd 100644
--- a/ProcessLib/SourceTerms/Python/CreatePythonSourceTerm.cpp
+++ b/ProcessLib/SourceTerms/Python/CreatePythonSourceTerm.cpp
@@ -73,7 +73,8 @@ std::unique_ptr<SourceTerm> createPythonSourceTerm(
     return std::make_unique<ProcessLib::SourceTerms::Python::PythonSourceTerm>(
         std::move(dof_table),
         ProcessLib::SourceTerms::Python::PythonSourceTermData{
-            source_term, global_component_id, source_term_mesh},
+            source_term, global_component_id, source_term_mesh,
+            source_term_mesh.getID()},
         integration_order, shapefunction_order, global_dim, flush_stdout);
 }
 
diff --git a/ProcessLib/SourceTerms/Python/PythonSourceTerm.h b/ProcessLib/SourceTerms/Python/PythonSourceTerm.h
index 06899e6a1905a445232f99afb5321000bf4f684d..dd9c8299a1b7ae1c4285251bf7864c1f131dc771 100644
--- a/ProcessLib/SourceTerms/Python/PythonSourceTerm.h
+++ b/ProcessLib/SourceTerms/Python/PythonSourceTerm.h
@@ -39,7 +39,7 @@ struct PythonSourceTermData final
     const MeshLib::Mesh& source_term_mesh;
 
     //! Mesh ID of the entire domain.
-    std::size_t const source_term_mesh_id = source_term_mesh.getID();
+    std::size_t const source_term_mesh_id;
 };
 
 //! A source term whose values are computed by a Python script.