scicos.c File Reference

#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "machine.h"
#include "dynamic_link.h"
#include "scicos-def.h"
#include "stack-def.h"
#include "sciprint.h"
#include "scicos.h"
#include "import.h"
#include "blocks.h"
#include "core_math.h"
#include "dynamic_menus.h"
#include "syncexec.h"
#include "math_graphics.h"
#include "MALLOC.h"
#include "cvode.h"
#include "cvode_dense.h"
#include "ida.h"
#include "ida_dense.h"
#include "nvector_serial.h"
#include "sundials_dense.h"
#include "sundials_types.h"
#include "sundials_math.h"
#include "ida_impl.h"

Include dependency graph for scicos.c:

Go to the source code of this file.

Data Structures

struct  IERSCODE_struct
struct  UserData

Defines

#define abs(x)   ((x) >= 0 ? (x) : -(x))
#define max(a, b)   ((a) >= (b) ? (a) : (b))
#define min(a, b)   ((a) <= (b) ? (a) : (b))
#define freeall
#define freeallx
#define freeouttbptr
#define ONE   RCONST(1.0)
#define ZERO   RCONST(0.0)
#define T0   RCONST(0.0)

Functions

IERSCODE_struct C2F (ierscode)
static int check_flag (void *flagvalue, char *funcname, int opt)
void cosini (double *)
void idoit (double *)
void cosend (double *)
void cdoit (double *)
void doit (double *)
void ddoit (double *)
void edoit (double *, integer *)
void odoit (double *, double *, double *, double *)
void ozdoit (double *, double *, double *, integer *)
void zdoit (double *, double *, double *, double *)
void reinitdoit (double *, realtype *)
void cossimdaskr (double *)
void cossim (double *)
void callf (double *, double *, double *, double *, double *, integer *)
int simblk (realtype t, N_Vector yy, N_Vector yp, void *f_data)
int simblkdaskr (realtype tres, N_Vector yy, N_Vector yp, N_Vector resval, void *rdata)
int grblkdaskr (realtype t, N_Vector yy, N_Vector yp, realtype *gout, void *g_data)
int grblk (realtype t, N_Vector yy, realtype *gout, void *g_data)
void addevs (double, integer *, integer *)
void putevs (double *, integer *, integer *)
void FREE_blocks ()
int setmode (double *, double *, double *, integer *, double)
void Jdoit (double *, double *, double *, double *, int *)
int Jacobians (long int Neq, realtype, N_Vector, N_Vector, N_Vector, realtype, void *, DenseMat, N_Vector, N_Vector, N_Vector)
void Multp (double *, double *, double *, int, int, int, int)
void Set_Jacobian_flag (int flag)
double Get_Jacobian_parameter (void)
double Get_Scicos_SQUR (void)
void F2C() sciblk ()
void sciblk2 ()
void sciblk4 ()
void GetDynFunc ()
void C2F() iislink ()
integer C2F() cvstr ()
integer C2F() dset ()
integer C2F() dcopy ()
integer C2F() iset ()
integer C2F() realtime ()
integer C2F() realtimeinit ()
integer C2F() sxevents ()
integer C2F() stimer ()
integer C2F() xscion ()
int scilab_timer_check ()
COSDEBUGCOUNTER_struct C2F (cosdebugcounter)
IMPORT_SCICOS SOLVER_struct C2F (cmsolver)
IMPORT_SCICOS CURBLK_struct C2F (curblk)
IMPORT_SCICOS RTFACTOR_struct C2F (rtfactor)
IMPORT_SCICOS SCSPTR_struct C2F (scsptr)
IMPORT_SCICOS DBCOS_struct C2F (dbcos)
IMPORT_SCICOS COSTOL_struct C2F (costol)
IMPORT_SCICOS COSHLT_struct C2F (coshlt)
IMPORT_SCICOS COSDEBUG_struct C2F (cosdebug)
void call_debug_scicos (double *, double *, double *, double *, double *, integer *, integer, integer, integer)
int C2F() scicos (double *x_in, integer *xptr_in, double *z__, void **work, integer *zptr, integer *modptr_in, void **oz, integer *ozsz, integer *oztyp, integer *ozptr, integer *iz, integer *izptr, double *t0_in, double *tf_in, double *tevts_in, integer *evtspt_in, integer *nevts, integer *pointi_in, void **outtbptr_in, integer *outtbsz_in, integer *outtbtyp_in, outtb_el *outtb_elem_in, integer *nelem1, integer *nlnk1, integer *funptr, integer *funtyp_in, integer *inpptr_in, integer *outptr_in, integer *inplnk_in, integer *outlnk_in, double *rpar, integer *rpptr, integer *ipar, integer *ipptr, void **opar, integer *oparsz, integer *opartyp, integer *opptr, integer *clkptr_in, integer *ordptr_in, integer *nordptr1, integer *ordclk_in, integer *cord_in, integer *ncord1, integer *iord_in, integer *niord1, integer *oord_in, integer *noord1, integer *zord_in, integer *nzord1, integer *critev_in, integer *nblk1, integer *ztyp, integer *zcptr_in, integer *subscr, integer *nsubs, double *simpar, integer *flag__, integer *ierr_out)
integer C2F() funnum (char *fname)
int get_phase_simulation ()
void do_cold_restart ()
double get_scicos_time ()
int get_block_number ()
void set_block_error (int err)
void end_scicos_sim ()
void set_pointer_xproperty (int *pointer)

Variables

static integer nblk
static integer nordptr
static integer nlnk
static integer ng
static integer ncord
static integer noord
static integer nzord
static integer niord
static integer nclock
static integer nordclk
static integer nmod
static integerneq
static double Atol
static double rtol
static double ttol
static double deltat
static double hmax
static integer hot
static integer c__90 = 90
static integer c__0 = 0
static integer c__91 = 91
static double c_b14 = 0.
static integer c__1 = 1
static integeriwa
static integerxptr
static integermodptr
static integerevtspt
static integerfuntyp
static integerinpptr
static integeroutptr
static integerinplnk
static integeroutlnk
static integerclkptr
static integerordptr
static integerordclk
static integercord
static integeriord
static integeroord
static integerzord
static integercritev
static integerzcptr
static integerpointi
static integerierr
static double * x
static double * xd
static double * tevts
static double * g
static integermod
static double * t0
static double * tf
static double scicos_time
static void ** outtbptr
static integerouttbsz
static integerouttbtyp
SCSREAL_COP * outtbdptr
SCSINT8_COP * outtbcptr
SCSINT16_COP * outtbsptr
SCSINT32_COP * outtblptr
SCSUINT8_COP * outtbucptr
SCSUINT16_COP * outtbusptr
SCSUINT32_COP * outtbulptr
static outtb_elouttb_elem
static int nelem
static scicos_blockBlocks
static integer phase
realtypepointer_xproperty
integer n_pointer_xproperty
static integerblock_error
static integer Jacobian_Flag
static integer AJacobian_block
static double CJJ
static double SQuround
static integer debug_block


Define Documentation

#define abs ( x   )     ((x) >= 0 ? (x) : -(x))

#define freeall

Value:

if (*neq>0) CVodeFree(&cvode_mem);\
              if (*neq>0) N_VDestroy_Serial(y);\
              if ( ng>0 ) FREE(jroot);\
              if ( ng>0 ) FREE(zcros);

Definition at line 106 of file scicos.c.

Referenced by cossim().

#define freeallx

Value:

if (*neq>0 && (Jacobian_Flag>0))  FREE(data->rwork);\
              if ( ng>0 ) FREE(data->gwork);\
              if (*neq>0) N_VDestroy_Serial(data->ewt);\
              if (*neq>0) FREE(data);\
              if (*neq>0) IDAFree(&ida_mem);\
              if (*neq>0) N_VDestroy_Serial(IDx);\
              if (*neq>0) N_VDestroy_Serial(yp);\
              if (*neq>0) N_VDestroy_Serial(yy);\
              if ( ng>0 ) FREE(jroot);\
              if ( ng>0 ) FREE(zcros);\
              if (nmod>0) FREE(Mode_save);

Definition at line 112 of file scicos.c.

Referenced by cossimdaskr().

#define freeouttbptr

Value:

FREE(outtbd);\
              FREE(outtbc);\
              FREE(outtbs);\
              FREE(outtbl);\
              FREE(outtbuc);\
              FREE(outtbus);\
              FREE(outtbul);

Definition at line 125 of file scicos.c.

Referenced by cosini().

#define max ( a,
b   )     ((a) >= (b) ? (a) : (b))

#define min ( a,
b   )     ((a) <= (b) ? (a) : (b))

#define ONE   RCONST(1.0)

Definition at line 135 of file scicos.c.

Referenced by cossimdaskr(), CVAdamsFinish(), CVAdamsStart(), CVAdjustAdams(), CVBDFStab(), CVChooseEta(), CVCompleteStep(), CVComputeEtaqm1(), CVComputeEtaqp1(), CVDecreaseBDF(), CVDenseDQJac(), CVDenseSetup(), CVDenseSolve(), CVDoErrorTest(), CVEwtSetSV(), CVHandleNFlag(), CVIncreaseBDF(), CVNewtonIteration(), CVNlsFunctional(), CVNlsNewton(), CVode(), CVodeGetDky(), CVodeGetErrWeights(), CVodeGetEstLocalErrors(), CVodeMalloc(), CVodeReInit(), CVodeSetMaxStep(), CVodeSetMinStep(), CVodeSetTolerances(), CVPredict(), CVPrepareNextStep(), CVRcheck1_orig(), CVRcheck2_orig(), CVRcheck3(), CVRcheck3_orig(), CVRestore(), CVRootfind(), CVRootfind_orig(), CVSet(), CVSetAdams(), CVSetBDF(), CVSetEta(), CVSetTqBDF(), CVsldet(), CVStep(), CVUpperBoundH0(), CVYddNorm(), denaddI(), denGETRF(), IDACalcIC(), IDACompleteStep(), IDADenseDQJac(), IDADenseSolve(), IDAEwtSetSV(), IDAfnorm(), IDAGetConsistentIC(), IDAGetErrWeights(), IDAGetEstLocalErrors(), IDAGetSolution(), IDAHandleNFlag(), IDALineSrch(), IDAMalloc(), IDANewtonIC(), IDANewtonIter(), IDANewy(), IDANewyyp(), IDANls(), IDAnlsIC(), IDAPredict(), IDARcheck1_orig(), IDARcheck2_orig(), IDAReInit(), IDARestore(), IDARootfind(), IDARootfind_origin(), IDASetCoeffs(), IDASetConstraints(), IDASetId(), IDASetMaxStep(), IDASetTolerances(), IDASolve(), IDAStep(), IDAStopTest1(), IDAStopTest2(), IDATestError(), Jacobians(), N_VCompare_Serial(), N_VConstrMask_Serial(), N_VInv_Serial(), N_VInvTest_Serial(), N_VLinearSum_Serial(), N_VScale_Serial(), RPowerI(), set_pointer_xproperty(), simblkdaskr(), and Vaxpy_Serial().

#define T0   RCONST(0.0)

Definition at line 137 of file scicos.c.

Referenced by cossim(), and cossimdaskr().

#define ZERO   RCONST(0.0)


Function Documentation

void addevs ( double  t,
integer evtnb,
integer ierr1 
)

Definition at line 4646 of file scicos.c.

References evtspt, i, j, pointi, and tevts.

Referenced by cossim(), cossimdaskr(), and ddoit().

04649 {
04650   static integer i, j;
04651 
04652   /* Function Body */
04653   *ierr1 = 0;
04654   if (evtspt[*evtnb] != -1) {
04655     if (evtspt[*evtnb] == 0) {
04656       tevts[*evtnb] = t;
04657     }else{
04658       if (*pointi != 0) {
04659         /* find parent of evtnb    */
04660         if (*pointi == *evtnb) {
04661           *pointi =evtspt[*evtnb]; /* remove from chain */
04662         }else{
04663           i= *pointi;
04664           while (*evtnb != evtspt[i]){
04665             i=evtspt[i];
04666           }
04667           evtspt[i]=evtspt[*evtnb]; /* remove old evtnb from chain */
04668         }
04669       }
04670       evtspt[*evtnb] = 0;
04671       tevts[*evtnb] = t;
04672     }
04673   } else {
04674     evtspt[*evtnb] = 0;
04675     tevts[*evtnb] = t;
04676   }
04677   if (*pointi == 0) {
04678     *pointi = *evtnb;
04679     return;
04680   }
04681   if (t < tevts[*pointi]) {
04682     evtspt[*evtnb] = *pointi;
04683     *pointi = *evtnb;
04684     return;
04685   }
04686   i = *pointi;
04687 
04688  L100:
04689   if (evtspt[i] == 0) {
04690     evtspt[i] = *evtnb;
04691     return;
04692   }
04693   if (t >= tevts[evtspt[i]]) {
04694     j = evtspt[i];
04695     if (evtspt[j] == 0) {
04696       evtspt[j] = *evtnb;
04697       return;
04698     }
04699     i = j;
04700     goto L100;
04701   } else {
04702     evtspt[*evtnb] = evtspt[i];
04703     evtspt[i] = *evtnb;
04704   }
04705 } /* addevs */

Here is the caller graph for this function:

IMPORT_SCICOS COSDEBUG_struct C2F ( cosdebug   ) 

IMPORT_SCICOS COSHLT_struct C2F ( coshlt   ) 

IMPORT_SCICOS COSTOL_struct C2F ( costol   ) 

IMPORT_SCICOS DBCOS_struct C2F ( dbcos   ) 

IMPORT_SCICOS SCSPTR_struct C2F ( scsptr   ) 

IMPORT_SCICOS RTFACTOR_struct C2F ( rtfactor   ) 

IMPORT_SCICOS CURBLK_struct C2F ( curblk   ) 

IMPORT_SCICOS SOLVER_struct C2F ( cmsolver   ) 

COSDEBUGCOUNTER_struct C2F ( cosdebugcounter   ) 

IERSCODE_struct C2F ( ierscode   ) 

void call_debug_scicos ( double *  t,
double *  xtd,
double *  xt,
double *  residual,
double *  g,
integer flag,
integer  kf,
integer  flagi,
integer  deb_blk 
)

Definition at line 4477 of file scicos.c.

References C2F(), scicos_block::funpt, scicos_block::g, k, nclock, scicos_block::nevprt, ng, scicos_block::res, scicos_time, sciprint(), scicos_block::scsptr, scicos_block::x, scicos_block::xd, xptr, and zcptr.

Referenced by callf().

04480 {
04481   voidf loc ;
04482   int solver=C2F(cmsolver).solver,k;
04483   ScicosF4 loc4;
04484   C2F(cosdebugcounter).counter=C2F(cosdebugcounter).counter+1;
04485 
04486   C2F(scsptr).ptr=Blocks[deb_blk].scsptr;
04487   loc=Blocks[deb_blk].funpt;
04488   scicos_time=*t;
04489   Blocks[kf-1].nevprt=nclock;
04490   loc4 = (ScicosF4) loc;
04491   if(Blocks[kf-1].ng>0){
04492     Blocks[kf-1].g=&g[zcptr[kf]-1];
04493   }
04494   if(Blocks[kf-1].nx==0){
04495     (*loc4)(&Blocks[kf-1],*flag);
04496   }
04497   else {
04498     Blocks[kf-1].x=&xt[xptr[kf]-1];
04499     /* special case for type 10004 */
04500     if(Blocks[kf-1].type==10004) {
04501       Blocks[kf-1].xd=&xtd[xptr[kf]-1];
04502       Blocks[kf-1].res=&residual[xptr[kf]-1];
04503       (*loc4)(&Blocks[kf-1],*flag);
04504     }
04505     else {
04506       if(*flag==0 && solver==100) {
04507         Blocks[kf-1].res=&residual[xptr[kf]-1];
04508         Blocks[kf-1].xd=&residual[xptr[kf]-1];
04509         (*loc4)(&Blocks[kf-1],*flag);
04510         Blocks[kf-1].xd=&xtd[xptr[kf]-1];
04511         if(flagi!=7) {
04512           for (k=0;k<Blocks[kf-1].nx;k++) {
04513             Blocks[kf-1].res[k]=Blocks[kf-1].res[k]-Blocks[kf-1].xd[k];
04514           }
04515         }
04516         else {
04517           for (k=0;k<Blocks[kf-1].nx;k++) {
04518             Blocks[kf-1].xd[k]=Blocks[kf-1].res[k];
04519           }
04520         }
04521       }
04522       else {
04523         Blocks[kf-1].xd=&xtd[xptr[kf]-1];
04524         (*loc4)(&Blocks[kf-1],*flag);
04525       }
04526     }
04527   }
04528   if (*flag<0) sciprint("Error in the Debug block \r\n");
04529 }

Here is the call graph for this function:

Here is the caller graph for this function:

void callf ( double *  t,
double *  xtd,