#include "stdafx.h" #include "DllFunc.h" #include "math.h"
using namespace rd_syscall;
double Stress144[11]; double Strain144[11];
ModalForce_API void __cdecl modal_force (int id, double time, double upar[], int npar, int ifbody, double pos[12], double vel[6], double acc[6], int nmode, int nnode, int nModalLoad, double *ModalLoads, int jflag, int iflag, double *result) { // User Statement int i; int ierr; int itemp,Node144SeqID; int *ModeIds=NULL; double *StressShape144=NULL; double *StrainShape144=NULL; double *MCoord=NULL;
// Allocate memory ModeIds=new int[nmode]; StressShape144=new double[nmode*6]; StrainShape144=new double[nmode*6]; MCoord=new double[nmode];
// Saved Node Seq. ID get_rflex_nodeseqid(ifbody,144,&Node144SeqID,&ierr);
// Get Stress/Strain shape data and Modal coordinate data get_rflex_modeid(ifbody,ModeIds,&ierr); get_rflex_mcoor(ifbody,MCoord,&ierr); for(i=0;i<nmode;i++) { // Stress shape get_rflex_stressshape(ifbody,ModeIds[i],Node144SeqID,1, &StressShape144[i*6],&ierr); // Strain shape get_rflex_strainshape(ifbody,ModeIds[i],Node144SeqID,1, &StrainShape144[i*6],&ierr); }
// Initialization for(i=0;i<6;i++) { Stress144[i]=0.0; Strain144[i]=0.0; }
// Computing Stress/Strain for(i=0;i<nmode;i++) { Stress144[0]+= StressShape144[i*6+0]*MCoord[i]; Stress144[1]+= StressShape144[i*6+1]*MCoord[i]; Stress144[2]+= StressShape144[i*6+2]*MCoord[i]; Stress144[3]+= StressShape144[i*6+3]*MCoord[i]; Stress144[4]+= StressShape144[i*6+4]*MCoord[i]; Stress144[5]+= StressShape144[i*6+5]*MCoord[i]; Strain144[0]+= StrainShape144[i*6+0]*MCoord[i]; Strain144[1]+= StrainShape144[i*6+1]*MCoord[i]; Strain144[2]+= StrainShape144[i*6+2]*MCoord[i]; Strain144[3]+= StrainShape144[i*6+3]*MCoord[i]; Strain144[4]+= StrainShape144[i*6+4]*MCoord[i]; Strain144[5]+= StrainShape144[i*6+5]*MCoord[i]; }
for(int i=0;i<6+nmode;i++) result[i]=0.0; delete [] ModeIds; delete [] StressShape144; delete [] StrainShape144; delete [] MCoord; }
ModalForce_API void __cdecl request_usub(double time, double upar[], int npar, int iflag, double result[8]) { result[1]=Stress144[0]; result[2]=Strain144[0]; }
|