C/C++ example for motion user subroutine

 

#include "stdafx.h"

#include "DllFunc.h"

 

Motion_API void __cdecl motion_usub

           (double time, double upar[], int npar, int iord, int iflag, double* result)

{

           using namespace rd_syscall;

           // Parameter Information

           //   time    :  Simulation time of RD/Solver. (Input)

           //   upar    :  Parameters defined by user. (Input)

           //   npar    :  Number of user parameters. (Input)

           //   iord    :  Integrator order. (Input)

           //   iflag   :  When RD/Solver initializes arrays, the flag is true. (Input)

           //   result  :  Returned value. (Output)

 

           // User Statement

           // Local Variable Definition

           double shift, omega;

           double value;

           double coef[3];

           int errflg;

 

           // Assign Impact Parameter

           shift=upar[0];

           omega=upar[1];

           coef[0]=upar[2];

           coef[1]=upar[3];

           coef[2]=upar[4];

 

           // Call the RD_FORCOS to collect Information for Calculation

           rd_forcos(time, shift, omega, coef, 3, iord, &value, &errflg);

 

           // Return the value

           *result=value;

}