1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
|
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();
|