C/C++ example for IMPACT

 

#include "stdafx.h"

#include "DllFunc.h"

 

LINSPL_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 VARIABLE DEFINITION

   double value[3], mkid[5], DY,VY;

   int ID[2], errflg, i;

 

   // Assign Impact Parameters

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

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

 

   for(i=0;i<5;i++){

      mkid[i] = upar[i+2];

   }

 

   // Call the Auxiliary subroutines for calculation

   sysfnc("DY",ID,2,&DY,&ERRFLG);

   sysfnc("VY",ID,2,&VY,&ERRFLG);

   rd_impact(DY,VY,mkid[0],mkid[1],mkid[2], mkid[3],mkid[4],0,&value[0],&errflg);

 

   // Assign the returned Value

   *result = value[0];

}