de.grogra.numeric.cvode
Class CVODE

java.lang.Object
  extended by de.grogra.numeric.cvode.CVODE

public class CVODE
extends java.lang.Object

This class provides native access to the CVODE library using JNA. Note that not all functions have been made accessible, but only those necessary to implement CVodeAdapter. For reference check CVODE documentation at: https://computation.llnl.gov/casc/sundials/documentation/cv_guide/cv_guide.html A native library "cvode" must be created that contains CVODE. To create this library, download SUNDIALS and execute:

   ./configure CFLAGS="-fPIC"
   make
 
Then copy all produced objects files (*.o) into a directory and link them to a shared library with (for Linux):
   gcc -shared -Wl,-soname=libcvode.so -o libcvode.so -static-libgcc *.o
 
To tell JNA where to find the shared library during development, add an option
-Djna.library.path=/path/to/library
to the VM arguments. To enable crash protection, also add
-Djna.protected
to the VM arguments.

Author:
Reinhard Hemmerling

Field Summary
static int CV_ADAMS
           
static int CV_BAD_DKY
           
static int CV_BAD_K
           
static int CV_BAD_T
           
static int CV_BDF
           
static int CV_CONV_FAILURE
           
static int CV_ERR_FAILURE
           
static int CV_FIRST_RHSFUNC_ERR
           
static int CV_FUNCTIONAL
           
static int CV_ILL_INPUT
           
static int CV_LINIT_FAIL
           
static int CV_LSETUP_FAIL
           
static int CV_LSOLVE_FAIL
           
static int CV_MEM_FAIL
           
static int CV_MEM_NULL
           
static int CV_NEWTON
           
static int CV_NO_MALLOC
           
static int CV_NORMAL
           
static int CV_ONE_STEP
           
static int CV_REPTD_RHSFUNC_ERR
           
static int CV_RHSFUNC_FAIL
           
static int CV_ROOT_RETURN
           
static int CV_RTFUNC_FAIL
           
static int CV_SUCCESS
           
static int CV_TOO_CLOSE
           
static int CV_TOO_MUCH_ACC
           
static int CV_TOO_MUCH_WORK
           
static int CV_TSTOP_RETURN
           
static int CV_UNREC_RHSFUNC_ERR
           
static int CV_WARNING
           
 
Constructor Summary
CVODE()
           
 
Method Summary
static int CVDense(com.sun.jna.Pointer cvode_mem, int N)
           
static int CVode(com.sun.jna.Pointer cvode_mem, double tout, N_Vector yout, com.sun.jna.ptr.DoubleByReference tret, int itask)
           
static com.sun.jna.Pointer CVodeCreate(int lmm, int iter)
          The function CVodeCreate instantiates a CVODE solver object and specifies the solution method.
static void CVodeFree(com.sun.jna.ptr.PointerByReference cvode_mem)
           
static java.lang.String CVodeGetReturnFlagName(int flag)
           
static int CVodeGetRootInfo(com.sun.jna.Pointer cvode_mem, int[] rootsfound)
           
static int CVodeInit(com.sun.jna.Pointer cvode_mem, CVRhsFn f, double t0, N_Vector y0)
           
static int CVodeRootInit(com.sun.jna.Pointer cvode_mem, int nrtfn, CVRootFn g)
           
static int CVodeSStolerances(com.sun.jna.Pointer cvode_mem, double reltol, double abstol)
           
static int CVodeSVtolerances(com.sun.jna.Pointer cvode_mem, double reltol, N_Vector abstol)
           
static void N_VDestroy_Serial(N_Vector v)
           
static N_Vector N_VNew_Serial(com.sun.jna.NativeLong vec_length)
           
static void N_VPrint_Serial(N_Vector v)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CV_ADAMS

public static final int CV_ADAMS
See Also:
Constant Field Values

CV_BAD_DKY

public static final int CV_BAD_DKY
See Also:
Constant Field Values

CV_BAD_K

public static final int CV_BAD_K
See Also:
Constant Field Values

CV_BAD_T

public static final int CV_BAD_T
See Also:
Constant Field Values

CV_BDF

public static final int CV_BDF
See Also:
Constant Field Values

CV_CONV_FAILURE

public static final int CV_CONV_FAILURE
See Also:
Constant Field Values

CV_ERR_FAILURE

public static final int CV_ERR_FAILURE
See Also:
Constant Field Values

CV_FIRST_RHSFUNC_ERR

public static final int CV_FIRST_RHSFUNC_ERR
See Also:
Constant Field Values

CV_FUNCTIONAL

public static final int CV_FUNCTIONAL
See Also:
Constant Field Values

CV_ILL_INPUT

public static final int CV_ILL_INPUT
See Also:
Constant Field Values

CV_LINIT_FAIL

public static final int CV_LINIT_FAIL
See Also:
Constant Field Values

CV_LSETUP_FAIL

public static final int CV_LSETUP_FAIL
See Also:
Constant Field Values

CV_LSOLVE_FAIL

public static final int CV_LSOLVE_FAIL
See Also:
Constant Field Values

CV_MEM_FAIL

public static final int CV_MEM_FAIL
See Also:
Constant Field Values

CV_MEM_NULL

public static final int CV_MEM_NULL
See Also:
Constant Field Values

CV_NEWTON

public static final int CV_NEWTON
See Also:
Constant Field Values

CV_NO_MALLOC

public static final int CV_NO_MALLOC
See Also:
Constant Field Values

CV_NORMAL

public static final int CV_NORMAL
See Also:
Constant Field Values

CV_ONE_STEP

public static final int CV_ONE_STEP
See Also:
Constant Field Values

CV_REPTD_RHSFUNC_ERR

public static final int CV_REPTD_RHSFUNC_ERR
See Also:
Constant Field Values

CV_RHSFUNC_FAIL

public static final int CV_RHSFUNC_FAIL
See Also:
Constant Field Values

CV_ROOT_RETURN

public static final int CV_ROOT_RETURN
See Also:
Constant Field Values

CV_RTFUNC_FAIL

public static final int CV_RTFUNC_FAIL
See Also:
Constant Field Values

CV_SUCCESS

public static final int CV_SUCCESS
See Also:
Constant Field Values

CV_TOO_CLOSE

public static final int CV_TOO_CLOSE
See Also:
Constant Field Values

CV_TOO_MUCH_ACC

public static final int CV_TOO_MUCH_ACC
See Also:
Constant Field Values

CV_TOO_MUCH_WORK

public static final int CV_TOO_MUCH_WORK
See Also:
Constant Field Values

CV_TSTOP_RETURN

public static final int CV_TSTOP_RETURN
See Also:
Constant Field Values

CV_UNREC_RHSFUNC_ERR

public static final int CV_UNREC_RHSFUNC_ERR
See Also:
Constant Field Values

CV_WARNING

public static final int CV_WARNING
See Also:
Constant Field Values
Constructor Detail

CVODE

public CVODE()
Method Detail

CVDense

public static int CVDense(com.sun.jna.Pointer cvode_mem,
                          int N)

CVode

public static int CVode(com.sun.jna.Pointer cvode_mem,
                        double tout,
                        N_Vector yout,
                        com.sun.jna.ptr.DoubleByReference tret,
                        int itask)

CVodeCreate

public static com.sun.jna.Pointer CVodeCreate(int lmm,
                                              int iter)
The function CVodeCreate instantiates a CVODE solver object and specifies the solution method. The recommended choices for (lmm, iter) are (CV_ADAMS, CV_FUNCTIONAL) for nonstiff problems and (CV_BDF, CV_NEWTON) for stiff problems.

Parameters:
lmm - specifies the linear multistep method and may be one of two possible values: CV_ADAMS or CV_BDF
iter - specifies the type of nonlinear solver iteration and may be either CV_NEWTON or CV_FUNCTIONAL
Returns:
If successful, CVodeCreate returns a pointer to the newly created CVODE memory block (of type void *). Otherwise, it returns NULL.

CVodeFree

public static void CVodeFree(com.sun.jna.ptr.PointerByReference cvode_mem)

CVodeGetReturnFlagName

public static java.lang.String CVodeGetReturnFlagName(int flag)

CVodeGetRootInfo

public static int CVodeGetRootInfo(com.sun.jna.Pointer cvode_mem,
                                   int[] rootsfound)

CVodeInit

public static int CVodeInit(com.sun.jna.Pointer cvode_mem,
                            CVRhsFn f,
                            double t0,
                            N_Vector y0)

CVodeRootInit

public static int CVodeRootInit(com.sun.jna.Pointer cvode_mem,
                                int nrtfn,
                                CVRootFn g)

CVodeSStolerances

public static int CVodeSStolerances(com.sun.jna.Pointer cvode_mem,
                                    double reltol,
                                    double abstol)

CVodeSVtolerances

public static int CVodeSVtolerances(com.sun.jna.Pointer cvode_mem,
                                    double reltol,
                                    N_Vector abstol)

N_VDestroy_Serial

public static void N_VDestroy_Serial(N_Vector v)

N_VNew_Serial

public static N_Vector N_VNew_Serial(com.sun.jna.NativeLong vec_length)

N_VPrint_Serial

public static void N_VPrint_Serial(N_Vector v)