C/C++ example for GET_RFLEX_NODEACC

 

#include "stdafx.h"

#include "DllFunc.h"

#include <stdio.h>

FILE* NodeACCwrite;

 

RecurDynV8R3_UserSubRoutineWizard10_API void __cdecl modal_force_ext

(int id, double time, double upar[], int npar, int ifbody, int nodarr[], int nonde, int jflag, int iflag, double result[])

{

   using namespace rd_syscall;

   // Parameter Information

   //   id     : Modal force sequential identification. (Input)

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

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

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

   //   ifbody : RFLEX Body sequential ID. (Input)

   //   nodarr : Node ID array of input node set. (Input)

   //   nonde  : Number of node of node set. (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 nodal force vector. Acting point of the nodal force is each center of each node.

   //            Reference frame of each force vector must be the ground inertia marker. (Output, Size: nonde * 6)

 

   // User Statement

   int errflg =0 , ifinish = 0;

   int nodeseq = 0;

   double acc[6],tacc[3],racc[3];

 

   if (iflag)

   {

      for(int k = 0 ; k <nonde ; k++)

      {

         NodeACCwrite=fopen("RFlexNodeAcc_C.txt","w");

         fprintf(NodeACCwrite,"RFlex Node%d Acceleration \n",nodarr[k]);

 

         for (int i = 0; i<6 ;i++) { acc[i]=0.0; }

         for (int i = 0; i<3 ;i++) { tacc[i]=0.0; racc[i]=0.0; }

 

         get_rflex_nodeseqid(ifbody,nodarr[k],&nodeseq,&errflg);

         get_rflex_nodeacc(ifbody,nodeseq,NULL,0,acc,&errflg);

         get_rflex_nodetacc(ifbody,nodeseq,NULL,0,tacc,&errflg);

         get_rflex_noderacc(ifbody,nodeseq,NULL,0,racc,&errflg);

 

         fprintf(NodeACCwrite,"USING GET_RFLEX_NODEACC \n");

         fprintf(NodeACCwrite,"INITIAL TRANSLATIONAL ACCELERATION \n");

         fprintf(NodeACCwrite,"TAX = %20.10e\n",acc[0]);

         fprintf(NodeACCwrite,"TAY = %20.10e\n",acc[1]);

         fprintf(NodeACCwrite,"TAZ = %20.10e\n\n",acc[2]);

         fprintf(NodeACCwrite,"INITIAL ROTATIONAL ACCELERATION \n");

         fprintf(NodeACCwrite,"RAX = %20.10e\n",acc[3]);

         fprintf(NodeACCwrite,"RAY = %20.10e\n",acc[4]);

         fprintf(NodeACCwrite,"RAZ = %20.10e\n\n",acc[5]);

 

         fprintf(NodeACCwrite,"USING GET_RFLEX_NODETACC \n");

         fprintf(NodeACCwrite,"INITIAL TRANSLATIONAL ACCELERATION \n");

         fprintf(NodeACCwrite,"TAX = %20.10e\n",tacc[0]);

         fprintf(NodeACCwrite,"TAY = %20.10e\n",tacc[1]);

         fprintf(NodeACCwrite,"TAZ = %20.10e\n\n",tacc[2]);

 

         fprintf(NodeACCwrite,"USING GET_RFLEX_NODERACC \n");

         fprintf(NodeACCwrite,"INITIAL ROTATIONAL ACCELERATION \n");

         fprintf(NodeACCwrite,"RAX = %20.10e\n",racc[0]);

         fprintf(NodeACCwrite,"RAY = %20.10e\n",racc[1]);

         fprintf(NodeACCwrite,"RAZ = %20.10e\n\n",racc[2]);

 

      }

   }

   for(int i=0;i<6*nonde;i++)

   {

      result[i] = 0.0;

   }

}