/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  v2006                                 |
|   \\  /    A nd           | Website:  www.openfoam.com                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    object      dynamicMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

motionSolverLibs    (    "librigidBodyDynamicsCOM.so"
    "libforcesCOM.so"
    "librigidBodyMeshMotionCOM.so");

dynamicFvMesh       dynamicOversetFvMesh;

motionSolver        rigidBodyMotion;

report          off;
//g		( 0 0 -9.81 );

solver
{
    type NewmarkCOM;
//    gamma   0.75;    // Velocity integration coefficient
//    beta    0.390625;    // Position integration coefficient
}
Iteration_number_for_MB	1;

OutputFiles	(bodypart);	// save the center of rotation.

golocalCoordinateSystem	(1 0 0  0 1 0  0 0 1);

bodies
{
    bodypart
    {
        type            rigidBody;
        parent          root;
        mass            1.226;	// = 0.8 * 1583 g
        inertia         (4442884e-9 0 -12750e-9  1726110e-9 0  4355676e-9); // (5553605.2e-9 0 -15938.1e-9  2157638.0e-9 0  5444595.5e-9);
        centreOfMass    (0.0017 0 0.0041); 
        transform       $golocalCoordinateSystem $centreOfMass;
        joint
        {
            type            composite;
            joints
            (
                {	type Pxyz;	}
                {       type Rxyz;      }
            );
        }
        patches         (robobody);
        innerDistance   100;   
        outerDistance   200;
    }

    pera1part
    {

        type            rigidBody;
        parent          root;
        mass            0.0185;	// = 1/2 * 37.1 g
        centreOfMass    (-0.0510 0.0906 0);    
        inertia         (31066e-9 -7265e-9 0  22678e-9 0  18484e-9);	//(62132e-9 -14530e-9 0  45355e-9 0  36967e-9);
        transform       $golocalCoordinateSystem $centreOfMass;	// (x axis, y axis, z axis)
        joint
        {
            type            composite;
            joints
            (
                {	type Pxyz;	}
                {       type Rxyz;      }
            );
        }
        patches        (pera1);
        innerDistance   100;
        outerDistance   200;
    }

    pera2part
    {

        type            rigidBody;
        parent          root;
        mass            0.0185;	// = 1/2 * 37.1 g
        centreOfMass    (-0.0511 -0.0906 0);	   
        inertia         (31081e-9 7266e-9 0  22692e-9 0  18497e-9);	//(62162e-9 14531e-9 0  45383e-9 0  36994e-9);
        transform       $golocalCoordinateSystem $centreOfMass;	// (x axis, y axis, z axis)
        joint
        {
            type            composite;
            joints
            (
                {	type Pxyz;	}
                {       type Rxyz;      }
            );
        }
        patches        (pera2);
        innerDistance   100;
        outerDistance   200;
    }
}

translational_spring_body   ( 10000 10 0 );	// ( 1.0e+2 1 0 ); spring coefficient, Damper coefficient, dummy
coil_spring_body   ( 10 1.0e-2 0 );		// spring coefficient, Damper coefficient, dummy


translational_spring   ( 1.0e+4 1.0 0 );	// ( 1.0e+2 1 0 ); spring coefficient, Damper coefficient, dummy

restraints
{

    body_rootC
    {
        type           	rigidbodyConnectionCOM;
        body            bodypart;
	reaction	root;	
	connection_point (0.0017 0 0.0041);
        gain    	$translational_spring_body;
    }
    body_root
    {
        type           	coilSpringDamperCOM;
        body            bodypart;
	reaction	root;	
        gain    	$coil_spring_body;
    }



    body_pera1Ca
    {
        type           	rigidbodyConnectionCOM;
        body            pera1part;
	reaction	bodypart;	
	connection_point (-0.05 0.09 0);
        gain    	$translational_spring;
    }
    body_pera1Cb
    {
        type           	rigidbodyConnectionCOM;
        body            pera1part;
	reaction	bodypart;	
	connection_point (-0.06732 0.1 0);	// +(-0.01732 0.01 0)
        gain    	$translational_spring;
    }

    body_pera2Ca
    {
        type           	rigidbodyConnectionCOM;
        body            pera2part;
	reaction	bodypart;	
	connection_point (-0.05 -0.09 0);
        gain    	$translational_spring;
    }
    body_pera2Cb
    {
        type           	rigidbodyConnectionCOM;
        body            pera2part;
	reaction	bodypart;	
	connection_point (-0.06732 -0.1 0);	// +(-0.01732 -0.01 0)
        gain    	$translational_spring;
    }


    pera1rotation
    {
        type           	angularVelocityControlCOM;
        body            pera1part;
	reaction	bodypart;	
        rotational_axis (0.866025 -0.5 0);// rotational axis viewing from reference coordinate system 
	angular_velocity	6.28243;	// rad / s
	relaxation_time	0.001;		// if( t < T ) torque *= t/T 
        gain    	( 0.1 1.0e-5 1 );// Pgain [Nm/(rad/s)], Dgain [Nm/(rad/s^2)], [W=Nm/s]
    }

    pera2rotation
    {
        type           	angularVelocityControlCOM;
        body            pera2part;
	reaction	bodypart;	
        rotational_axis (0.866025 0.5 0);// rotational axis viewing from reference coordinate system 
	angular_velocity	-6.28243;	// rad / s
	relaxation_time	0.001;		// if( t < T ) torque *= t/T 
        gain    	( 0.1 1.0e-5 1 );// Pgain [Nm/(rad/s)], Dgain [Nm/(rad/s^2)], [W=Nm/s]
    }

}


// ************************************************************************* //
