siconos.io.mechanics_hdf5 module

siconos.io.mechanics_hdf5.check_points_axes(name, joint_class, points, axes)[source]

Check that the number and shape of provided points and axes match what is expected for the given joint type.

Parameters:
  • name (str) – The name of the joint

  • joint_class (str) – The type of joint. Must be one of the keys in joint_points_axes.

  • points (np.ndarray, optional) – array of points

  • axes (np.ndarray, optional) – array of axes

siconos.io.mechanics_hdf5.group(h, name, must_exist=True)[source]
siconos.io.mechanics_hdf5.data(h, name, nbcolumns, use_compression=False)[source]
siconos.io.mechanics_hdf5.add_line(dataset, line)[source]
siconos.io.mechanics_hdf5.upgrade_io_format(filename)[source]
class siconos.io.mechanics_hdf5.MechanicsHdf5(io_filename=None, mode='w', io_filename_backup=None, use_compression=False, output_domains=False, verbose=True)[source]

Bases: object

a MechanicsHdf5 context manager, used to prepare a simulation description to be executed by MechanicsRunner.

Parameters:
  • io_filename (string, optional) – hdf5 file name, default = <caller>.hdf5, caller being the name without ext of the file that instanciates the Runner.

  • mode (string, optional) – h5 mode (w, r, append), default = ‘w’

  • io_filename_backup (string, optional) – name of a backup (copy) file for hdf5 outputs. Backup every <output_frequency> step. Default = <caller>_last.hdf5

  • use_compression (boolean, optional) – true to use compression for h5 file, default=False

  • output_domains (boolean, optional) – if trueoutputs info regarding contact point domains default=False

  • verbose (boolean, optional) – default=True

print_verbose(*args, **kwargs)[source]
print_io_mechanics(*args, **kwargs)[source]
dimension()[source]

dimension : get the dimension (2 or 3) of the scene

shapes()[source]
Shapesparameterized primitives or user defined

(convex set or meshes)

permanent_interactions()[source]

Permanent interactions.

radii_data()[source]

Radii of objects

p0s_data()[source]

Vector p0 for each object

static_data()[source]

Coordinates and orientations of static objects.

dynamic_data()[source]

Coordinates and orientations of dynamic objects.

velocities_data()[source]

Velocities of dynamic objects

contact_forces_data()[source]

Contact points information.

contact_info_data()[source]

Contact points information.

contact_work_data()[source]

Contact points information.

domains_data()[source]

Contact point domain information.

solver_data()[source]

Solver output

log_data()[source]

log output

instances()[source]

Scene objects.

nonsmooth_laws()[source]

Non smooth laws between group of contactors.

joints()[source]

Joints between dynamic objects or between an object and the scenery.

boundary_conditions()[source]

Boundary conditions applied to dynamic objects

add_plugin_source(name, filename)[source]

Add C source plugin

add_external_function(name, body_name, function_name, plugin_name, plugin_function_name)[source]
add_external_bc_function(name, body_name, bc_indices, plugin_name, plugin_function_name)[source]
add_mesh_from_string(name, shape_data, scale=None, insideMargin=None, outsideMargin=None)[source]

Add a mesh shape from a string. Accepted format : mesh encoded in VTK .vtp format

add_mesh_from_file(name, filename, scale=None, insideMargin=None, outsideMargin=None)[source]

Add a mesh shape from a file. Accepted format : .stl or mesh encoded in VTK .vtp format

add_height_map(name, heightmap, rectangle, insideMargin=None, outsideMargin=None)[source]

Add a heightmap represented as a SiconosMatrix

add_brep_from_string(name, shape_data)[source]

Add a brep contained in a string.

add_occ_shape(name, occ_shape)[source]

Adds an OpenCascade TopoDS_Shape to the hdf5 group ‘ref’

It takes an OpenCascade shape (e.g., a sphere, box, etc.), converts it into the STEP format, and stores it as a dataset

Parameters:

namestr

The name associated with the shape. This name will be used as the identifier for the shape in the internal storage. If the name already exists in the storage, the shape will not be added again.

occ_shapeTopoDS_Shape

The OpenCascade shape to be added, expected to be an instance of the TopoDS_Shape class.

add_shape_data_from_file(name, filename)[source]

Add shape data from a file.

add_interaction(name, body1_name, contactor1_name=None, body2_name=None, contactor2_name=None, distance_calculator='cadmbtb', offset1=0.0, offset2=0.0)[source]

Add permanent interactions between two objects contactors.

add_convex_shape(name, points, insideMargin=None, outsideMargin=None, avoid_internal_edge_contact=False)[source]

Add a convex shape defined by a list of points.

outsideMargin is the value of margin that substract from the actual contact distance

If insideMargin is positive, the convex hull is shrunken by that amount (each face is moved by “shrink” length units towards the center along its normal). This value is then added to outsideMargin to compensate the shrink. The convex hull appears for the user as in its original size.

add_primitive_shape(name, primitive, params, insideMargin=None, outsideMargin=None)[source]

Add a primitive shape.

Todo: Comments on insideMargin and outsideMargin that depends on the

primitive shape type.

add_object(name, shapes, translation=None, orientation=None, velocity=None, use_volume_centroid_as_initial_translation=False, material=None, boundary_conditions=None, nodal_forces=None, mass=None, center_of_mass=None, inertia=None, time_of_birth=-1, time_of_death=-1, fext=None, allow_self_collide=False)[source]

Add an object with associated shapes as a list of Volume or Contactor objects. Contact detection and processing is defined by the Contactor objects. The Volume objects are used for the computation of inertia and center of mass if not provided.

The body-fixed frame is assumed to be the global inertial frame. This means that 1. By default, the center of mass is located at the origin. The initial translation is applied from this point, so that x_g(0) = translation 2. the orientation is identical to the inertial frame. The initial orientation is applied to the inertial frame to obtain the body-fixed frame.

Each Contactor and Volume object may have a relative translation and a relative orientation expressed in the bodyframe coordinates.

Parameters:
  • name (string) – The name of the object.

  • shapes (iterable) – The list of associated Contactor or Volume objects.

  • translation (array_like of length 3 or 2 (dimension =2)) – Initial translation of the object (mandatory)

  • orientation (array_like of length 3 (Euler Angles) or 4) – (unit quaternion), or 1 (dimension =2) Initial orientiation of the object. By default, identity

  • velocity (array_like of length 6, or 3 (dimension =2)) –

    Initial velocity of the object. The default velocity is zero. dimension =3 :

    The components are those of the translation velocity along x, y and z axis and the rotation velocity around x, y and z axis.

    dimension =2 :

    The components are those of the translation velocity along x, y and the rotation velocity z axis.

  • material (array_like of length 3.) – (density, elastic Young modulus, poisson ratio) The material of the finite elements object. If material is given, mass is directly computed and the mass parameter is not used.

  • mass (float) – The mass of the object, if it is None the object is defined as a static object involved only in contact detection. The default value is None.

  • center_of_mass (array_like of length 3) – The position of the center of mass expressed in the body frame coordinates.

  • inertia (array_like of length 3 or 3x3 matrix.) – The principal moments of inertia (array of length 3) or a full 3x3 inertia matrix

  • use_volume_centroid_as_initial_translation (boolean.) – if True and if a Volume is given is the list of shape, the position of the volume centroid is used as initial translation.

add_objects(name, shapes, translations, orientations=None, velocities=None, mass=None, inertia=None, time_of_birth=-1, time_of_death=-1)[source]

Add an aggregate of objects (e.g., granular material) with shared properties.

All objects share the same shape, mass and inertia. Only translations, orientations and velocities are specific to each grain.

Parameters:
  • name (string) – The name of the aggregate.

  • shapes (Contactor or list of Contactors) – The shape(s) for all grains (only first contactor used for now).

  • translations (array_like (N, 2) or (N, 3)) – Initial translations for all N grains.

  • orientations (array_like (N,) for 2D or (N, 4) for 3D, optional) – Initial orientations. Default: zero rotation.

  • velocities (array_like (N, 3) for 2D or (N, 6) for 3D, optional) – Initial velocities. Default: zero.

  • mass (float, optional) – Mass for each grain (all grains have same mass).

  • inertia (array_like, optional) – Inertia for each grain (all grains have same inertia).

add_Newton_impact_rolling_friction_nsl(name, mu, mu_r, e=0, collision_group1=0, collision_group2=0)[source]

Add a nonsmooth law for contact between 2 groups. 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, gid1 and gid2 define the group identifiants.

add_Fremond_impact_friction_nsl(name, mu, e=0, collision_group1=0, collision_group2=0)[source]

Add a nonsmooth law for contact between 2 groups. Only NewtonImpactFrictionNSL 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, gid1 and gid2 define the group identifiants.

add_Newton_impact_friction_nsl(name, mu, e=0, collision_group1=0, collision_group2=0)[source]

Add a nonsmooth law for contact between 2 groups. Only NewtonImpactFrictionNSL 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, gid1 and gid2 define the group identifiants.

add_Newton_impact_nsl(name, e=0, collision_group1=-1, collision_group2=-1)[source]

Add a nonsmooth law for contact between 2 groups. Only NewtonImpactNSL are supported. name is a user identifier and must be unique, e is the coefficient of restitution on the contact normal, gid1 and gid2 define the group identifiers.

As opposed to add_Newton_impact_friction_nsl, the default groups are -1, making the NSL unassociated with point contacts. It can by used for joint stops however.

add_relay_nsl(name, lb, ub, size=1, collision_group1=-1, collision_group2=-1)[source]

Add a nonsmooth law for contact between 2 groups. Only NewtonImpactNSL are supported. name is a user identifier and must be unique, e is the coefficient of restitution on the contact normal, gid1 and gid2 define the group identifiers.

As opposed to add_Newton_impact_friction_nsl, the default groups are -1, making the NSL unassociated with point contacts. It can by used for joint stops however.

add_joint(name, object1, object2=None, points=[[0, 0, 0]], axes=[[0, 1, 0]], joint_class='PivotJointR', absolute=None, allow_self_collide=None, nslaws=None, stops=None, friction=None, coupled=None, references=None)[source]

add a joint between two objects

add_boundary_condition(name, object1, indices=None, bc_class='HarmonicBC', v=None, a=None, b=None, omega=None, phi=None)[source]

add boundarycondition to the object object1

implementation only works for HarmonicBC for the moment