4.8.3.7. FORCOS
Language type |
Subroutine |
FORTRAN |
call rd_forcos(x, x0, w, upar, npar, order, value, errflg) or forcos(x, x0, w, upar, npar, order, value, errflg) |
C/C++ |
rd_forcos(x, x0, w, upar, npar, order, &value, &errflg) or forcos(x, x0, w, upar, npar, order, &value, &errflg) |
Variable Name |
Size |
Description |
x |
double |
The input variable for the defined Fourier Cosine series. |
x0 |
double |
The x-direction offset for the variable (x) in the Fourier Cosine series. |
w |
double |
The base frequency for the Fourier Cosine series (in radians). |
upar |
double* |
Argument list array. This array have to contain coefficient for the Fourier cosine series. |
npar |
int |
Number of arguments in the argument list array. |
order |
int |
The order can be 3 values. (order = 0, 1 or 2.) |
value |
double |
|
errflg |
int |
Error flag. If the result of this argument is zero, there’s no error |
C---- SUB. MOTION_USUB
SUBROUTINE MOTION_USUB
& (TIME,UPAR,NPAR,IORD,IFLAG,RESULT)
C---- TO EXPORT * SUBROUTINE
!DEC$ ATTRIBUTES DLLEXPORT,C::MOTION_USUB
C---- INCLUDE SYSTEM CALL
INCLUDE 'SYSCAL.F'
C---- DEFINE VARIABLES
C Parameter Information
C TIME : Simulation time of RD/Solver. (Input)
C UPAR : Parameters defined by user. (Input)
C NPAR : Number of user parameters. (Input)
C IORD : Integrator order. (Input)
C IFLAG : When RD/Solver initializes arrays, the flag is true. (Input)
C RESULT : Returned value. (Output)
DOUBLE PRECISION TIME, UPAR(*)
INTEGER NPAR, IORD
LOGICAL IFLAG
DOUBLE PRECISION RESULT[REFERENCE]
C---- USER STATEMENT
DOUBLE PRECISION SHIFT, OMEGA
DOUBLE PRECISION VALUE
DOUBLE PRECISION CORF(3)
LOGICAL ERRFLG
SHIFT = UPAR(1)
OMEGA = UPAR(2)
COEF(1) = UPAR(3)
COEF(2) = UPAR(4)
COEF(3) = UPAR(5)
CALL RD_FORCOS(TIME,SHIFT,OMEGA,COEF,3,IORD,VALUE,ERRFLG)
RESULT = VALUE
RETURN
END
#include "stdafx.h"
#include "DllFunc.h"
FORSIN_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;
}