<commit_before>#!/usr/bin/env python

#
# Example of two cubes, one with a convex shape, one with a primitive
# shape.
#

from siconos.mechanics.contact_detection.tools import Contactor

from mechanics_io import Hdf5

import siconos.numerics as Numerics


edge_length = 0.1
plane_length = 2.0

velocity_init=-1.0
angular_velocity_init =0.0

# Creation of the hdf5 file for input/output
with Hdf5() as io:

    # # Definition of a cube as a convex shape
    io.addConvexShape('CubeCS1', [
        (-edge_length, edge_length, -edge_length),
        (-edge_length, -edge_length, -edge_length),
        (-edge_length, -edge_length, edge_length),
        (-edge_length, edge_length, edge_length),
        (edge_length, edge_length, edge_length),
        (edge_length, edge_length, -edge_length),
        (edge_length, -edge_length, -edge_length),
        (edge_length, -edge_length, edge_length)])

    io.addConvexShape('CubeCS2', [
        (-edge_length, edge_length, -edge_length),
        (-edge_length, -edge_length, -edge_length),
        (-edge_length, -edge_length, edge_length),
        (-edge_length, edge_length, edge_length),
        (edge_length, edge_length, edge_length),
        (edge_length, edge_length, -edge_length),
        (edge_length, -edge_length, -edge_length),
        (edge_length, -edge_length, edge_length)])

    # Alternative to the previous convex shape definition.
    io.addPrimitiveShape('CubePrim1', 'Box', (2*edge_length, 2*edge_length, 2*edge_length))

    io.addPrimitiveShape('CubePrim2', 'Box', (2*edge_length, 2*edge_length, 2*edge_length))
    
    # Alternative to the previous convex shape definition.
    io.addPrimitiveShape('SpherePrim1', 'Sphere', (edge_length,))

    io.addPrimitiveShape('SpherePrim2', 'Sphere', (edge_length,))



    # select contactor

    contactors = ['CubePrim1', 'CubePrim2']
    contactors = ['CubePrim1', 'CubeCS2']
    contactors = ['CubeCS1', 'CubeCS2']

    contactors = ['SpherePrim1', 'SpherePrim2'];     test = 'Sphere_Sphere'
    contactors = ['SpherePrim1', 'CubePrim2']
    
    # Definition of a non smooth law. As no group ids are specified it
    # is between contactors of group id 0.
    io.addNewtonImpactFrictionNSL('contact', mu=0.3,e=0.5)

    # The cube object made with an unique Contactor : the cube shape.
    # As a mass is given, it is a dynamic system involved in contact
    # detection and in the simulation.  With no group id specified the
    # Contactor belongs to group 0
    io.addObject('object1', [Contactor(contactors[0])], translation=[0, 0, 2],
                 velocity=[ 0, 0,- velocity_init, angular_velocity_init,
                           angular_velocity_init, angular_velocity_init],
                 mass=1)

    io.addObject('object2', [Contactor(contactors[1])], translation=[0, 0, 2+3*edge_length],
                 velocity=[0, 0,  velocity_init, angular_velocity_init,
                           angular_velocity_init, angular_velocity_init],
                 mass=1)

 
# Run the simulation from the inputs previously defined and add
# results to the hdf5 file. The visualisation of the output may be done
# with the vview command.


step=20000
hstep=0.001

with Hdf5(mode='r+',collision_margin=0.05) as io:

    # By default earth gravity is applied and the units are those
    # of the International System of Units.
    # Because of fixed collision margins used in the collision detection,
    # sizes of small objects may need to be expressed in cm or mm.

    io.run_debug(with_timer=False,
           time_stepping=None,
           space_filter=None,
           body_class=None,
           shape_class=None,
           face_class=None,
           edge_class=None,<commit_msg>[example] back to the standard mechanics.io<commit_after>#!/usr/bin/env python

#
# Example of two cubes, one with a convex shape, one with a primitive
# shape.
#

from siconos.mechanics.contact_detection.tools import Contactor

from siconos.io.mechanics_io import Hdf5

import siconos.numerics as Numerics


edge_length = 0.1
plane_length = 2.0

velocity_init=-1.0
angular_velocity_init =0.0

# Creation of the hdf5 file for input/output
with Hdf5() as io:

    # # Definition of a cube as a convex shape
    io.addConvexShape('CubeCS1', [
        (-edge_length, edge_length, -edge_length),
        (-edge_length, -edge_length, -edge_length),
        (-edge_length, -edge_length, edge_length),
        (-edge_length, edge_length, edge_length),
        (edge_length, edge_length, edge_length),
        (edge_length, edge_length, -edge_length),
        (edge_length, -edge_length, -edge_length),
        (edge_length, -edge_length, edge_length)])

    io.addConvexShape('CubeCS2', [
        (-edge_length, edge_length, -edge_length),
        (-edge_length, -edge_length, -edge_length),
        (-edge_length, -edge_length, edge_length),
        (-edge_length, edge_length, edge_length),
        (edge_length, edge_length, edge_length),
        (edge_length, edge_length, -edge_length),
        (edge_length, -edge_length, -edge_length),
        (edge_length, -edge_length, edge_length)])

    # Alternative to the previous convex shape definition.
    io.addPrimitiveShape('CubePrim1', 'Box', (2*edge_length, 2*edge_length, 2*edge_length))

    io.addPrimitiveShape('CubePrim2', 'Box', (2*edge_length, 2*edge_length, 2*edge_length))
    
    # Alternative to the previous convex shape definition.
    io.addPrimitiveShape('SpherePrim1', 'Sphere', (edge_length,))

    io.addPrimitiveShape('SpherePrim2', 'Sphere', (edge_length,))



    # select contactor

    contactors = ['CubePrim1', 'CubePrim2']
    contactors = ['CubePrim1', 'CubeCS2']
    contactors = ['CubeCS1', 'CubeCS2']

    contactors = ['SpherePrim1', 'SpherePrim2'];     test = 'Sphere_Sphere'
    contactors = ['SpherePrim1', 'CubePrim2']
    
    # Definition of a non smooth law. As no group ids are specified it
    # is between contactors of group id 0.
    io.addNewtonImpactFrictionNSL('contact', mu=0.3,e=0.5)

    # The cube object made with an unique Contactor : the cube shape.
    # As a mass is given, it is a dynamic system involved in contact
    # detection and in the simulation.  With no group id specified the
    # Contactor belongs to group 0
    io.addObject('object1', [Contactor(contactors[0])], translation=[0, 0, 2],
                 velocity=[ 0, 0,- velocity_init, angular_velocity_init,
                           angular_velocity_init, angular_velocity_init],
                 mass=1)

    io.addObject('object2', [Contactor(contactors[1])], translation=[0, 0, 2+3*edge_length],
                 velocity=[0, 0,  velocity_init, angular_velocity_init,
                           angular_velocity_init, angular_velocity_init],
                 mass=1)

 
# Run the simulation from the inputs previously defined and add
# results to the hdf5 file. The visualisation of the output may be done
# with the vview command.


step=20000
hstep=0.001

with Hdf5(mode='r+',collision_margin=0.05) as io:

    # By default earth gravity is applied and the units are those
    # of the International System of Units.
    # Because of fixed collision margins used in the collision detection,
    # sizes of small objects may need to be expressed in cm or mm.

    io.run(with_timer=False,
           time_stepping=None,
           space_filter=None,
           body_class=None,
           shape_class=None,
           face_class=None,
           edge_class=None,
{'fraction_non_alphanumeric': 0.10353162347253927, 'fraction_numerical': 0.018799516583859272, 'mean_word_length': 3.153931957612939, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6079363', 'n_tokens_mistral': 2412, 'n_tokens_neox': 2294, 'n_words': 644}