C/C++ example for axial force user subroutine

 

#include "stdafx.h"

#include "DllFunc.h"

 

AxialForce_API void __cdecl axial_force(double time, double upar[], int npar, int jflag, 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)

           //   jflag   : When RD/Solver evaluates a Jacobian, the flag is true. (Input)

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

           //   result  : Returned axial force or torque value. (Output)

 

           // User Statement

           // Local Varialbe Definition

           int mkid[3], errflg, akispl_id;

           double disp, value[3];

 

           // Assign Impact Parameters

           mkid[0] = (int) upar[0];

           mkid[1] = (int) upar[1];

           mkid[2] = (int) upar[2];

           akispl_id = (int) upar[3];

 

           // Call the Auxiliary subroutines for Calculation

           sysfnc("DX", mkid, 3, &disp, &errflg);

           rd_akispl(disp, 0, akispl_id, 0, value, &errflg);

 

           // Assign the Returned Value

           *result = value[0];

}