/*--------------------------------*- 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;
rho rhoInf;
rhoInf 1.293;
g               ( 0 0 -9.8065 );

solver
{
    type NewmarkCOM;
//    gamma   0.75;    // Velocity integration coefficient:	"gamma > 0.5" is unconditionary stable, but low accuracy.  
//    beta    0.390625;    // Position integration coefficient:	beta = (gamma+0.5)^2/4	
}
Iteration_number_for_MB	10;

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

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

bodies
{
    robobodypart
    {
        type            rigidBody;
        parent          root;

        mass            0.004784;
        inertia         (772.568e-9 0 404.418e-9  1678.532e-9 0  917.787e-9);
        centreOfMass    (0.010217 0 -0.011249);			/* global coordinate system */
        transform       $golocalCoordinateSystem $centreOfMass;
        joint
        {
            type            composite;
            joints
            (
                {
                    type Pxyz;
                }
                {
                    type Rxyz;
                }
            );
        }

        patches         (robobody);
        innerDistance   100;
        outerDistance   101;
    }

    wingRpart
    {
        type            rigidBody;
        parent          root;

        mass            0.002292;
        inertia         (735.715e-9 11.36e-9 -3.613e-9  87.972e-9 -5.523e-9  678.612e-9);
        centreOfMass    (0.000126 0.039424 -0.009838);			
        transform       $golocalCoordinateSystem $centreOfMass;
        joint
        {
            type            composite;
            joints
            (
                {
                    type Pxyz;
                }
                {
                    type Rxyz;
                }
            );
        }
        patches         (wingR);
        innerDistance   100;
        outerDistance   101;
    }

    wingLpart
    {
        type            rigidBody;
        parent          root;

        mass            0.002292;
        inertia         (735.715e-9 -11.36e-9 3.613e-9  87.972e-9 5.523e-9  678.612e-9);
        centreOfMass    (0.000126 -0.039424 -0.009838);		
        transform       $golocalCoordinateSystem $centreOfMass;
        joint
        {
            type            composite;
            joints
            (
                {
                    type Pxyz;
                }
                {
                    type Rxyz;
                }
            );
        }
        patches         (wingL);
        innerDistance   100;
        outerDistance   101;
    }
}

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

restraints
{
    body_rootC
    {
        type           	rigidbodyConnectionCOM;
        body            robobodypart;
	reaction	root;	
	connection_point (0.010217 0 -0.011249);
        gain    	( 1.0e+5 1.0e+2 0 );
    }
    body_root
    {
        type           	coilSpringDamperCOM;
        body            robobodypart;
	reaction	root;	
        gain    	$coil_spring;
    }





    wingjointRt
    {
        type           	rigidbodyConnectionCOM;
        body            wingRpart;
	reaction	robobodypart;	
	connection_point (0 0.01 0);
        gain    	$translational_spring;
    }
    wingjointLt
    {
        type           	rigidbodyConnectionCOM;
        body            wingLpart;
	reaction	robobodypart;	
	connection_point (0 -0.01 0);
        gain    	$translational_spring;
    }

	// wing motions
    wingRmotion
    {
        type           	rollpitchyawControlWaveCOM;
        body            wingRpart;
	reaction	robobodypart;
	z_angle		(  0.7854 40 0  0 0 0  0 0 0 );	// Amplitude [rad], frequency [Hz], Phase [rad], Shift [rad], dummy, dummy, dummy, dummy, dummy 
	y_angle		( -0.5236 40 0.7854  0 0 0  0 0 0 );	// Amplitude [rad], frequency [Hz], Phase [rad], Shift [rad], dummy, dummy, dummy, dummy, dummy 
	x_angle		( 0.0 0 0  0 0 0  0 0 0 );	// Amplitude [rad], frequency [Hz], Phase [rad], Shift [rad], dummy, dummy, dummy, dummy, dummy 
	rotation_order	0;	// 0 means Rz&Ry&Rx
	relaxation_time	0.0025;
        gain    	( 100 1.0e-2 10.0 );
    }
    wingLmotion
    {
        type           	rollpitchyawControlWaveCOM;
        body            wingLpart;
	reaction	robobodypart;
	z_angle		( -0.7854 40 0  0 0 0  0 0 0 );	// Amplitude [rad], frequency [Hz], Phase [rad], Shift [rad], dummy, dummy, dummy, dummy, dummy 
	y_angle		( -0.5236 40 0.7854  0 0 0  0 0 0 );	// Amplitude [rad], frequency [Hz], Phase [rad], Shift [rad], dummy, dummy, dummy, dummy, dummy 
	x_angle		( 0.0 0 0  0 0 0  0 0 0 );	// Amplitude [rad], frequency [Hz], Phase [rad], Shift [rad], dummy, dummy, dummy, dummy, dummy 
	rotation_order	0;	// 0 means Rz&Ry&Rx
	relaxation_time	0.0025;
        gain    	( 100 1.0e-2 10.0 );
    }
}

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