From: Stephen Sinclair <radarsat1@gmail.com>
Date: Sun, 24 Oct 2021 10:08:10 +0000
Subject: Add serialization support for rolling fc problems.

---
 io/src/serialization/SiconosFullNumerics.hpp       | 41 ++++++++++++++++++++++
 .../GlobalRollingFrictionContact.hpp               |  1 +
 .../src/simulationTools/RollingFrictionContact.hpp | 17 +++++++++
 3 files changed, 59 insertions(+)

diff --git a/io/src/serialization/SiconosFullNumerics.hpp b/io/src/serialization/SiconosFullNumerics.hpp
index 69d2f12..4eb3519 100644
--- a/io/src/serialization/SiconosFullNumerics.hpp
+++ b/io/src/serialization/SiconosFullNumerics.hpp
@@ -107,6 +107,47 @@ void siconos_io(Archive& ar, GlobalFrictionContactProblem& p, const unsigned int
 }
 REGISTER_BOOST_SERIALIZATION(GlobalFrictionContactProblem);
 
+template <class Archive>
+void siconos_io(Archive& ar, RollingFrictionContactProblem& p, const unsigned int file_version)
+{
+  SERIALIZE(p, (dimension)(numberOfContacts), ar);
+
+  if (Archive::is_loading::value)
+  {
+    p.q = (double *) malloc(p.dimension * p.numberOfContacts * sizeof(double));
+    p.mu = (double *) malloc(p.numberOfContacts * sizeof(double));
+    p.mu_r = (double *) malloc(p.numberOfContacts * sizeof(double));
+    p.M = NM_new();
+  }
+
+  SERIALIZE(p, (M), ar);
+  SERIALIZE_C_ARRAY(p.dimension * p.numberOfContacts, p, q, ar);
+  SERIALIZE_C_ARRAY(p.dimension, p, mu_r, ar);
+}
+REGISTER_BOOST_SERIALIZATION(RollingFrictionContactProblem);
+
+template <class Archive>
+void siconos_io(Archive& ar, GlobalRollingFrictionContactProblem& p, const unsigned int file_version)
+{
+  SERIALIZE(p, (dimension)(numberOfContacts), ar);
+
+  if (Archive::is_loading::value)
+  {
+    p.q = (double *) malloc(p.dimension * p.numberOfContacts * sizeof(double));
+    p.b = (double *) malloc(p.dimension * p.numberOfContacts * sizeof(double));
+    p.mu_r = (double *) malloc(p.numberOfContacts * sizeof(double));
+    p.M = NM_new();
+    p.H = NM_new();
+  }
+
+  SERIALIZE(p, (M), ar);
+  SERIALIZE(p, (H), ar);
+  SERIALIZE_C_ARRAY(p.dimension * p.numberOfContacts, p, q, ar);
+  SERIALIZE_C_ARRAY(p.dimension * p.numberOfContacts, p, b, ar);
+  SERIALIZE_C_ARRAY(p.dimension, p, mu_r, ar);
+}
+REGISTER_BOOST_SERIALIZATION(GlobalRollingFrictionContactProblem);
+
 template <class Archive>
 void siconos_io(Archive& ar, SparseBlockStructuredMatrix& v, unsigned int version)
 {
diff --git a/kernel/src/simulationTools/GlobalRollingFrictionContact.hpp b/kernel/src/simulationTools/GlobalRollingFrictionContact.hpp
index 0099855..de62c88 100644
--- a/kernel/src/simulationTools/GlobalRollingFrictionContact.hpp
+++ b/kernel/src/simulationTools/GlobalRollingFrictionContact.hpp
@@ -145,6 +145,7 @@ public:
   }
 
   /** get the value of the component number i of mu, the vector of the friction coefficients
+   *  \param i the component number (starting from 0)
    *  \return the friction coefficient for the ith contact
    */
   inline double getMur(unsigned int i) const
diff --git a/kernel/src/simulationTools/RollingFrictionContact.hpp b/kernel/src/simulationTools/RollingFrictionContact.hpp
index 2fc4b32..2cbb6b8 100644
--- a/kernel/src/simulationTools/RollingFrictionContact.hpp
+++ b/kernel/src/simulationTools/RollingFrictionContact.hpp
@@ -148,6 +148,23 @@ public:
     return (*_mu)[i];
   }
 
+  /** get a pointer to mu, the list of the friction coefficients
+   *  \return pointer on a std::vector<double>
+   */
+  inline SP::MuStorage mur() const
+  {
+    return _muR;
+  }
+
+  /** get the value of the component number i of mu, the vector of the friction coefficients
+   *  \param i the component number (starting from 0)
+   *  \return the friction coefficient for the ith contact
+   */
+  inline double getMur(unsigned int i) const
+  {
+    return (*_muR)[i];
+  }
+
   /** update mu vector
    */
   void updateMu();
