diff --git a/tbox/_src/tboxw.i b/tbox/_src/tboxw.i
index c058293a7c3e98b0064ca54b5b59e80836a59063..8f2c75bb2992ad3b81321d6c894916e5f138aab4 100644
--- a/tbox/_src/tboxw.i
+++ b/tbox/_src/tboxw.i
@@ -142,6 +142,7 @@ namespace std {
 %include "wGroups.h"
 %warnfilter(+509);
 %shared_ptr(tbox::MshDeform);
+%immutable tbox::MshDeform::msh; // read-only variable (no setter)
 %include "wMshDeform.h" // included after std templates because it needs them
 %shared_ptr(tbox::MshCrack);
 %include "wMshCrack.h"
diff --git a/tbox/src/wMshDeform.cpp b/tbox/src/wMshDeform.cpp
index 9e06c9c62e1ab11ded9b076c5b544c8e7aaf8e09..e3f4e39fb0ddf366faea9cc59a47a0bfefea15cf 100644
--- a/tbox/src/wMshDeform.cpp
+++ b/tbox/src/wMshDeform.cpp
@@ -32,9 +32,10 @@ using namespace tbox;
 
 MshDeform::MshDeform(std::shared_ptr<MshData> _msh,
                      std::shared_ptr<tbox::LinearSolver> _linsol,
-                     int _nDim, int nthrds) : wSharedObject(), msh(_msh), linsol(_linsol),
+                     int _nDim, int nthrds) : wSharedObject(), linsol(_linsol),
                                               nDim(_nDim), nthreads(nthrds),
-                                              field(false), fixed(false), moving(false)
+                                              field(false), fixed(false),
+                                              moving(false), msh(_msh)
 {
     // Check problem dimension
     if (nDim != 2 && nDim != 3)
diff --git a/tbox/src/wMshDeform.h b/tbox/src/wMshDeform.h
index 8f4a090c5c9a40d476be40a75f3a71ec67cd089a..839001d1343571b831197c40cf4896c713dd8d55 100644
--- a/tbox/src/wMshDeform.h
+++ b/tbox/src/wMshDeform.h
@@ -34,7 +34,6 @@ namespace tbox
 class TBOX_API MshDeform : public fwk::wSharedObject
 {
 private:
-    std::shared_ptr<MshData> msh;                      ///< mesh
     std::shared_ptr<tbox::LinearSolver> linsol;        ///< linear (inner) solver
     size_t mshSize;                                    ///< number of nodes in the mesh
     int nDim;                                          ///< dimension of the problem (2 or 3)
@@ -63,6 +62,8 @@ private:
     Eigen::MatrixXd buildK(tbox::Element const &e, Eigen::MatrixXd const &H);
 
 public:
+    std::shared_ptr<MshData> msh; ///< mesh
+
     MshDeform(std::shared_ptr<MshData> _msh, std::shared_ptr<tbox::LinearSolver> _linsol, int _nDim, int nthrds = 1);
     virtual ~MshDeform() { std::cout << "~MshDeform()\n"; }
 
diff --git a/tbox/src/wUnitTest.cpp b/tbox/src/wUnitTest.cpp
index 4aa67944c3db9497d80c830ba359f44918ec828d..7b886c29e77e50893e9d5c64991e1b34e538b72d 100644
--- a/tbox/src/wUnitTest.cpp
+++ b/tbox/src/wUnitTest.cpp
@@ -78,10 +78,10 @@ void UnitTest::gmshIO(GmshExport *writer, GmshImport *reader)
 /**
  * @brief Deform a mesh of dimension d
  */
-void UnitTest::mshDeform(MshData *msh, MshDeform *mshDef, int d)
+void UnitTest::mshDeform(MshDeform *mshDef, int d)
 {
     // Initialize memory (volume element only)
-    for (auto e : msh->elems)
+    for (auto e : mshDef->msh->elems)
         if ((d == 2 && e->type() == ELTYPE::TRI3) || (d == 3 && e->type() == ELTYPE::TETRA4))
             e->initValues(true);
     // Call deform
diff --git a/tbox/src/wUnitTest.h b/tbox/src/wUnitTest.h
index 1170fd8e832fb573077a11034b43ebd99b48c5e0..4a51567687dfde2e93d2978b576f44281b86c2ca 100644
--- a/tbox/src/wUnitTest.h
+++ b/tbox/src/wUnitTest.h
@@ -36,7 +36,7 @@ public:
     virtual ~UnitTest() {}
 
     void gmshIO(GmshExport *writer, GmshImport *reader);
-    void mshDeform(MshData *msh, MshDeform *mshDef, int d);
+    void mshDeform(MshDeform *mshDef, int d);
 };
 
 } // namespace tbox
diff --git a/tbox/tests/meshDeformation.py b/tbox/tests/meshDeformation.py
index 3de4d257b3c1256d229783ed0305725ca0c1d1ee..02c0c04dc7c5eb49449c10cf6311c43925e0d714 100644
--- a/tbox/tests/meshDeformation.py
+++ b/tbox/tests/meshDeformation.py
@@ -55,7 +55,7 @@ def main():
     # deform the mesh
     test = tbox.UnitTest()
     tms["deform"].start()
-    test.mshDeform(msh, mshDef, 2)
+    test.mshDeform(mshDef, 2)
     tms["deform"].stop()
     gmshWriter.save("beam_def")
 
diff --git a/tbox/tests/meshDeformation3.py b/tbox/tests/meshDeformation3.py
index cebff8c5ee5a6975b291be4e684d0926bd5657f3..61534871c7061797e911c81bb742a6d7e06d46b2 100644
--- a/tbox/tests/meshDeformation3.py
+++ b/tbox/tests/meshDeformation3.py
@@ -54,7 +54,7 @@ def main():
     # deform the mesh
     test = tbox.UnitTest()
     tms["deform"].start()
-    test.mshDeform(msh, mshDef, 3)
+    test.mshDeform(mshDef, 3)
     tms["deform"].stop()
     gmshWriter.save(msh.name+"_def")