[io] enable to modify an existing nslaw in the scene to change the parameters of the nslaw
can be useful for multiple simulation sequence
@@ -1164,7 +1164,7 @@ class MechanicsHdf5(object):
collision_group2=0):
"""
Add a nonsmooth law for contact between 2 groups.
- Only NewtonImpactFrictionNSL are supported.
+ Only NewtonImpactRollingFrictionNSL are supported.
name is an user identifiant and must be unique,
mu is the coefficient of friction,
e is the coefficient of restitution on the contact normal,
@@ -1174,6 +1174,11 @@ class MechanicsHdf5(object):
if name not in self._nslaws_data:
nslaw = self._nslaws_data.create_dataset(name, (0,))
nslaw.attrs['type'] = 'NewtonImpactRollingFrictionNSL'
+ else:
+ nslaw=self._nslaws_data[name]
+ if nslaw.attrs['type'] != 'NewtonImpactRollingFrictionNSL':
+ self.print_verbose('[warning] a nslaw is already existing with the same name ', name ,' but not the same type')
+
nslaw.attrs['mu'] = mu
nslaw.attrs['mu_r'] = mu_r
nslaw.attrs['e'] = e
@@ -1194,6 +1199,11 @@ class MechanicsHdf5(object):
if name not in self._nslaws_data:
nslaw = self._nslaws_data.create_dataset(name, (0,))
nslaw.attrs['type'] = 'NewtonImpactFrictionNSL'
+ else:
+ nslaw=self._nslaws_data[name]
+ if nslaw.attrs['type'] != 'NewtonImpactFrictionNSL':
+ self.print_verbose('[warning] a nslaw is already existing with the same name ', name ,' but not the same type')
+
nslaw.attrs['mu'] = mu
nslaw.attrs['e'] = e
nslaw.attrs['gid1'] = collision_group1
@@ -1218,6 +1228,11 @@ class MechanicsHdf5(object):
if name not in self._nslaws_data:
nslaw = self._nslaws_data.create_dataset(name, (0,))
nslaw.attrs['type'] = 'NewtonImpactNSL'
+ else:
+ nslaw=self._nslaws_data[name]
+ if nslaw.attrs['type'] != 'NewtonImpactNSL':
+ self.print_verbose('[warning] a nslaw is already existing with the same name ', name ,' but not the same type')
+
nslaw.attrs['e'] = e
nslaw.attrs['gid1'] = collision_group1
nslaw.attrs['gid2'] = collision_group2
@@ -1241,6 +1256,11 @@ class MechanicsHdf5(object):
if name not in self._nslaws_data:
nslaw = self._nslaws_data.create_dataset(name, (0,))
nslaw.attrs['type'] = 'RelayNSL'
+ else:
+ nslaw=self._nslaws_data[name]
+ if nslaw.attrs['type'] != 'RelayNSL':
+ self.print_verbose('[warning] a nslaw is already existing with the same name', name ,' but not the same type')
+
nslaw.attrs['size'] = size
nslaw.attrs['lb'] = lb
nslaw.attrs['ub'] = ub
