mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -06:00
sundials: Added package for non linear equations and differential algebraic equations solving
git-svn-id: svn://ultimatepp.org/upp/trunk@14564 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
90561f5cd7
commit
59635c7080
154 changed files with 53353 additions and 0 deletions
215
bazaar/plugin/sundials/include/ida/ida.h
Normal file
215
bazaar/plugin/sundials/include/ida/ida.h
Normal file
|
|
@ -0,0 +1,215 @@
|
|||
/* -----------------------------------------------------------------
|
||||
* Programmer(s): Allan G. Taylor, Alan C. Hindmarsh, Radu Serban,
|
||||
* and Aaron Collier @ LLNL
|
||||
* -----------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
* -----------------------------------------------------------------
|
||||
* This is the header file for the main IDA solver.
|
||||
* -----------------------------------------------------------------*/
|
||||
|
||||
#ifndef _IDA_H
|
||||
#define _IDA_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sundials/sundials_nvector.h>
|
||||
#include <sundials/sundials_nonlinearsolver.h>
|
||||
#include <ida/ida_ls.h>
|
||||
|
||||
#ifdef __cplusplus /* wrapper to enable C++ usage */
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* -----------------
|
||||
* IDA Constants
|
||||
* ----------------- */
|
||||
|
||||
/* itask */
|
||||
#define IDA_NORMAL 1
|
||||
#define IDA_ONE_STEP 2
|
||||
|
||||
/* icopt */
|
||||
#define IDA_YA_YDP_INIT 1
|
||||
#define IDA_Y_INIT 2
|
||||
|
||||
/* return values */
|
||||
|
||||
#define IDA_SUCCESS 0
|
||||
#define IDA_TSTOP_RETURN 1
|
||||
#define IDA_ROOT_RETURN 2
|
||||
|
||||
#define IDA_WARNING 99
|
||||
|
||||
#define IDA_TOO_MUCH_WORK -1
|
||||
#define IDA_TOO_MUCH_ACC -2
|
||||
#define IDA_ERR_FAIL -3
|
||||
#define IDA_CONV_FAIL -4
|
||||
|
||||
#define IDA_LINIT_FAIL -5
|
||||
#define IDA_LSETUP_FAIL -6
|
||||
#define IDA_LSOLVE_FAIL -7
|
||||
#define IDA_RES_FAIL -8
|
||||
#define IDA_REP_RES_ERR -9
|
||||
#define IDA_RTFUNC_FAIL -10
|
||||
#define IDA_CONSTR_FAIL -11
|
||||
|
||||
#define IDA_FIRST_RES_FAIL -12
|
||||
#define IDA_LINESEARCH_FAIL -13
|
||||
#define IDA_NO_RECOVERY -14
|
||||
#define IDA_NLS_INIT_FAIL -15
|
||||
#define IDA_NLS_SETUP_FAIL -16
|
||||
#define IDA_NLS_FAIL -17
|
||||
|
||||
#define IDA_MEM_NULL -20
|
||||
#define IDA_MEM_FAIL -21
|
||||
#define IDA_ILL_INPUT -22
|
||||
#define IDA_NO_MALLOC -23
|
||||
#define IDA_BAD_EWT -24
|
||||
#define IDA_BAD_K -25
|
||||
#define IDA_BAD_T -26
|
||||
#define IDA_BAD_DKY -27
|
||||
#define IDA_VECTOROP_ERR -28
|
||||
|
||||
#define IDA_UNRECOGNIZED_ERROR -99
|
||||
|
||||
|
||||
/* ------------------------------
|
||||
* User-Supplied Function Types
|
||||
* ------------------------------ */
|
||||
|
||||
typedef int (*IDAResFn)(realtype tt, N_Vector yy, N_Vector yp,
|
||||
N_Vector rr, void *user_data);
|
||||
|
||||
typedef int (*IDARootFn)(realtype t, N_Vector y, N_Vector yp,
|
||||
realtype *gout, void *user_data);
|
||||
|
||||
typedef int (*IDAEwtFn)(N_Vector y, N_Vector ewt, void *user_data);
|
||||
|
||||
typedef void (*IDAErrHandlerFn)(int error_code,
|
||||
const char *module, const char *function,
|
||||
char *msg, void *user_data);
|
||||
|
||||
/* -------------------
|
||||
* Exported Functions
|
||||
* ------------------- */
|
||||
|
||||
/* Initialization functions */
|
||||
SUNDIALS_EXPORT void *IDACreate(void);
|
||||
|
||||
SUNDIALS_EXPORT int IDAInit(void *ida_mem, IDAResFn res, realtype t0,
|
||||
N_Vector yy0, N_Vector yp0);
|
||||
SUNDIALS_EXPORT int IDAReInit(void *ida_mem, realtype t0, N_Vector yy0,
|
||||
N_Vector yp0);
|
||||
|
||||
/* Tolerance input functions */
|
||||
SUNDIALS_EXPORT int IDASStolerances(void *ida_mem, realtype reltol,
|
||||
realtype abstol);
|
||||
SUNDIALS_EXPORT int IDASVtolerances(void *ida_mem, realtype reltol,
|
||||
N_Vector abstol);
|
||||
SUNDIALS_EXPORT int IDAWFtolerances(void *ida_mem, IDAEwtFn efun);
|
||||
|
||||
/* Initial condition calculation function */
|
||||
SUNDIALS_EXPORT int IDACalcIC(void *ida_mem, int icopt, realtype tout1);
|
||||
|
||||
/* Initial condition calculation optional input functions */
|
||||
SUNDIALS_EXPORT int IDASetNonlinConvCoefIC(void *ida_mem, realtype epiccon);
|
||||
SUNDIALS_EXPORT int IDASetMaxNumStepsIC(void *ida_mem, int maxnh);
|
||||
SUNDIALS_EXPORT int IDASetMaxNumJacsIC(void *ida_mem, int maxnj);
|
||||
SUNDIALS_EXPORT int IDASetMaxNumItersIC(void *ida_mem, int maxnit);
|
||||
SUNDIALS_EXPORT int IDASetLineSearchOffIC(void *ida_mem, booleantype lsoff);
|
||||
SUNDIALS_EXPORT int IDASetStepToleranceIC(void *ida_mem, realtype steptol);
|
||||
SUNDIALS_EXPORT int IDASetMaxBacksIC(void *ida_mem, int maxbacks);
|
||||
|
||||
/* Optional input functions */
|
||||
SUNDIALS_EXPORT int IDASetErrHandlerFn(void *ida_mem, IDAErrHandlerFn ehfun,
|
||||
void *eh_data);
|
||||
SUNDIALS_EXPORT int IDASetErrFile(void *ida_mem, FILE *errfp);
|
||||
SUNDIALS_EXPORT int IDASetUserData(void *ida_mem, void *user_data);
|
||||
SUNDIALS_EXPORT int IDASetMaxOrd(void *ida_mem, int maxord);
|
||||
SUNDIALS_EXPORT int IDASetMaxNumSteps(void *ida_mem, long int mxsteps);
|
||||
SUNDIALS_EXPORT int IDASetInitStep(void *ida_mem, realtype hin);
|
||||
SUNDIALS_EXPORT int IDASetMaxStep(void *ida_mem, realtype hmax);
|
||||
SUNDIALS_EXPORT int IDASetStopTime(void *ida_mem, realtype tstop);
|
||||
SUNDIALS_EXPORT int IDASetNonlinConvCoef(void *ida_mem, realtype epcon);
|
||||
SUNDIALS_EXPORT int IDASetMaxErrTestFails(void *ida_mem, int maxnef);
|
||||
SUNDIALS_EXPORT int IDASetMaxNonlinIters(void *ida_mem, int maxcor);
|
||||
SUNDIALS_EXPORT int IDASetMaxConvFails(void *ida_mem, int maxncf);
|
||||
SUNDIALS_EXPORT int IDASetSuppressAlg(void *ida_mem, booleantype suppressalg);
|
||||
SUNDIALS_EXPORT int IDASetId(void *ida_mem, N_Vector id);
|
||||
SUNDIALS_EXPORT int IDASetConstraints(void *ida_mem, N_Vector constraints);
|
||||
|
||||
SUNDIALS_EXPORT int IDASetNonlinearSolver(void *ida_mem,
|
||||
SUNNonlinearSolver NLS);
|
||||
|
||||
/* Rootfinding initialization function */
|
||||
SUNDIALS_EXPORT int IDARootInit(void *ida_mem, int nrtfn, IDARootFn g);
|
||||
|
||||
/* Rootfinding optional input functions */
|
||||
SUNDIALS_EXPORT int IDASetRootDirection(void *ida_mem, int *rootdir);
|
||||
SUNDIALS_EXPORT int IDASetNoInactiveRootWarn(void *ida_mem);
|
||||
|
||||
/* Solver function */
|
||||
SUNDIALS_EXPORT int IDASolve(void *ida_mem, realtype tout, realtype *tret,
|
||||
N_Vector yret, N_Vector ypret, int itask);
|
||||
|
||||
/* Utility functions to update/compute y and yp based on ycor */
|
||||
SUNDIALS_EXPORT int IDAComputeY(void *ida_mem, N_Vector ycor, N_Vector y);
|
||||
SUNDIALS_EXPORT int IDAComputeYp(void *ida_mem, N_Vector ycor, N_Vector yp);
|
||||
|
||||
/* Dense output function */
|
||||
SUNDIALS_EXPORT int IDAGetDky(void *ida_mem, realtype t, int k, N_Vector dky);
|
||||
|
||||
/* Optional output functions */
|
||||
SUNDIALS_EXPORT int IDAGetWorkSpace(void *ida_mem, long int *lenrw,
|
||||
long int *leniw);
|
||||
SUNDIALS_EXPORT int IDAGetNumSteps(void *ida_mem, long int *nsteps);
|
||||
SUNDIALS_EXPORT int IDAGetNumResEvals(void *ida_mem, long int *nrevals);
|
||||
SUNDIALS_EXPORT int IDAGetNumLinSolvSetups(void *ida_mem, long int *nlinsetups);
|
||||
SUNDIALS_EXPORT int IDAGetNumErrTestFails(void *ida_mem, long int *netfails);
|
||||
SUNDIALS_EXPORT int IDAGetNumBacktrackOps(void *ida_mem, long int *nbacktr);
|
||||
SUNDIALS_EXPORT int IDAGetConsistentIC(void *ida_mem, N_Vector yy0_mod,
|
||||
N_Vector yp0_mod);
|
||||
SUNDIALS_EXPORT int IDAGetLastOrder(void *ida_mem, int *klast);
|
||||
SUNDIALS_EXPORT int IDAGetCurrentOrder(void *ida_mem, int *kcur);
|
||||
SUNDIALS_EXPORT int IDAGetCurrentCj(void *ida_mem, realtype *cj);
|
||||
SUNDIALS_EXPORT int IDAGetCurrentY(void *ida_mem, N_Vector *ycur);
|
||||
SUNDIALS_EXPORT int IDAGetCurrentYp(void *ida_mem, N_Vector *ypcur);
|
||||
SUNDIALS_EXPORT int IDAGetActualInitStep(void *ida_mem, realtype *hinused);
|
||||
SUNDIALS_EXPORT int IDAGetLastStep(void *ida_mem, realtype *hlast);
|
||||
SUNDIALS_EXPORT int IDAGetCurrentStep(void *ida_mem, realtype *hcur);
|
||||
SUNDIALS_EXPORT int IDAGetCurrentTime(void *ida_mem, realtype *tcur);
|
||||
SUNDIALS_EXPORT int IDAGetTolScaleFactor(void *ida_mem, realtype *tolsfact);
|
||||
SUNDIALS_EXPORT int IDAGetErrWeights(void *ida_mem, N_Vector eweight);
|
||||
SUNDIALS_EXPORT int IDAGetEstLocalErrors(void *ida_mem, N_Vector ele);
|
||||
SUNDIALS_EXPORT int IDAGetNumGEvals(void *ida_mem, long int *ngevals);
|
||||
SUNDIALS_EXPORT int IDAGetRootInfo(void *ida_mem, int *rootsfound);
|
||||
SUNDIALS_EXPORT int IDAGetIntegratorStats(void *ida_mem, long int *nsteps,
|
||||
long int *nrevals,
|
||||
long int *nlinsetups,
|
||||
long int *netfails,
|
||||
int *qlast, int *qcur,
|
||||
realtype *hinused, realtype *hlast,
|
||||
realtype *hcur, realtype *tcur);
|
||||
SUNDIALS_EXPORT int IDAGetNumNonlinSolvIters(void *ida_mem, long int *nniters);
|
||||
SUNDIALS_EXPORT int IDAGetNumNonlinSolvConvFails(void *ida_mem,
|
||||
long int *nncfails);
|
||||
SUNDIALS_EXPORT int IDAGetNonlinSolvStats(void *ida_mem, long int *nniters,
|
||||
long int *nncfails);
|
||||
SUNDIALS_EXPORT char *IDAGetReturnFlagName(long int flag);
|
||||
|
||||
/* Free function */
|
||||
SUNDIALS_EXPORT void IDAFree(void **ida_mem);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
65
bazaar/plugin/sundials/include/ida/ida_bbdpre.h
Normal file
65
bazaar/plugin/sundials/include/ida/ida_bbdpre.h
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
/* -----------------------------------------------------------------
|
||||
* Programmer(s): Daniel R. Reynolds @ SMU,
|
||||
* Alan C. Hindmarsh, Radu Serban and Aaron Collier @ LLNL
|
||||
* -----------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
* -----------------------------------------------------------------
|
||||
* This is the header file for the IDABBDPRE module, for a
|
||||
* band-block-diagonal preconditioner, i.e. a block-diagonal
|
||||
* matrix with banded blocks.
|
||||
* -----------------------------------------------------------------*/
|
||||
|
||||
#ifndef _IDABBDPRE_H
|
||||
#define _IDABBDPRE_H
|
||||
|
||||
#include <sundials/sundials_nvector.h>
|
||||
|
||||
#ifdef __cplusplus /* wrapper to enable C++ usage */
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* User-supplied function Types */
|
||||
|
||||
typedef int (*IDABBDLocalFn)(sunindextype Nlocal, realtype tt,
|
||||
N_Vector yy, N_Vector yp, N_Vector gval,
|
||||
void *user_data);
|
||||
|
||||
typedef int (*IDABBDCommFn)(sunindextype Nlocal, realtype tt,
|
||||
N_Vector yy, N_Vector yp, void *user_data);
|
||||
|
||||
/* Exported Functions */
|
||||
|
||||
SUNDIALS_EXPORT int IDABBDPrecInit(void *ida_mem, sunindextype Nlocal,
|
||||
sunindextype mudq, sunindextype mldq,
|
||||
sunindextype mukeep, sunindextype mlkeep,
|
||||
realtype dq_rel_yy,
|
||||
IDABBDLocalFn Gres, IDABBDCommFn Gcomm);
|
||||
|
||||
SUNDIALS_EXPORT int IDABBDPrecReInit(void *ida_mem,
|
||||
sunindextype mudq, sunindextype mldq,
|
||||
realtype dq_rel_yy);
|
||||
|
||||
/* Optional output functions */
|
||||
|
||||
SUNDIALS_EXPORT int IDABBDPrecGetWorkSpace(void *ida_mem,
|
||||
long int *lenrwBBDP,
|
||||
long int *leniwBBDP);
|
||||
|
||||
SUNDIALS_EXPORT int IDABBDPrecGetNumGfnEvals(void *ida_mem,
|
||||
long int *ngevalsBBDP);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
61
bazaar/plugin/sundials/include/ida/ida_direct.h
Normal file
61
bazaar/plugin/sundials/include/ida/ida_direct.h
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
/* -----------------------------------------------------------------
|
||||
* Programmer(s): Daniel R. Reynolds @ SMU
|
||||
* Radu Serban @ LLNL
|
||||
* -----------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
* -----------------------------------------------------------------
|
||||
* Header file for the deprecated direct linear solver interface in
|
||||
* IDA; these routines now just wrap the updated IDA generic
|
||||
* linear solver interface in ida_ls.h.
|
||||
* -----------------------------------------------------------------*/
|
||||
|
||||
#ifndef _IDADLS_H
|
||||
#define _IDADLS_H
|
||||
|
||||
#include <ida/ida_ls.h>
|
||||
|
||||
#ifdef __cplusplus /* wrapper to enable C++ usage */
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*=================================================================
|
||||
Function Types (typedefs for equivalent types in ida_ls.h)
|
||||
=================================================================*/
|
||||
|
||||
typedef IDALsJacFn IDADlsJacFn;
|
||||
|
||||
/*===================================================================
|
||||
Exported Functions (wrappers for equivalent routines in ida_ls.h)
|
||||
===================================================================*/
|
||||
|
||||
SUNDIALS_EXPORT int IDADlsSetLinearSolver(void *ida_mem, SUNLinearSolver LS,
|
||||
SUNMatrix A);
|
||||
|
||||
SUNDIALS_EXPORT int IDADlsSetJacFn(void *ida_mem, IDADlsJacFn jac);
|
||||
|
||||
SUNDIALS_EXPORT int IDADlsGetWorkSpace(void *ida_mem, long int *lenrwLS,
|
||||
long int *leniwLS);
|
||||
|
||||
SUNDIALS_EXPORT int IDADlsGetNumJacEvals(void *ida_mem, long int *njevals);
|
||||
|
||||
SUNDIALS_EXPORT int IDADlsGetNumResEvals(void *ida_mem, long int *nrevalsLS);
|
||||
|
||||
SUNDIALS_EXPORT int IDADlsGetLastFlag(void *ida_mem, long int *flag);
|
||||
|
||||
SUNDIALS_EXPORT char *IDADlsGetReturnFlagName(long int flag);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
137
bazaar/plugin/sundials/include/ida/ida_ls.h
Normal file
137
bazaar/plugin/sundials/include/ida/ida_ls.h
Normal file
|
|
@ -0,0 +1,137 @@
|
|||
/* ----------------------------------------------------------------
|
||||
* Programmer(s): Daniel R. Reynolds @ SMU
|
||||
* Alan Hindmarsh, Radu Serban and
|
||||
* Aaron Collier @ LLNL
|
||||
* ----------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
* ----------------------------------------------------------------
|
||||
* This is the header file for IDA's linear solver interface.
|
||||
* ----------------------------------------------------------------*/
|
||||
|
||||
#ifndef _IDALS_H
|
||||
#define _IDALS_H
|
||||
|
||||
#include <sundials/sundials_direct.h>
|
||||
#include <sundials/sundials_iterative.h>
|
||||
#include <sundials/sundials_linearsolver.h>
|
||||
#include <sundials/sundials_matrix.h>
|
||||
#include <sundials/sundials_nvector.h>
|
||||
|
||||
#ifdef __cplusplus /* wrapper to enable C++ usage */
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*=================================================================
|
||||
IDALS Constants
|
||||
=================================================================*/
|
||||
|
||||
#define IDALS_SUCCESS 0
|
||||
#define IDALS_MEM_NULL -1
|
||||
#define IDALS_LMEM_NULL -2
|
||||
#define IDALS_ILL_INPUT -3
|
||||
#define IDALS_MEM_FAIL -4
|
||||
#define IDALS_PMEM_NULL -5
|
||||
#define IDALS_JACFUNC_UNRECVR -6
|
||||
#define IDALS_JACFUNC_RECVR -7
|
||||
#define IDALS_SUNMAT_FAIL -8
|
||||
#define IDALS_SUNLS_FAIL -9
|
||||
|
||||
|
||||
/*=================================================================
|
||||
IDALS user-supplied function prototypes
|
||||
=================================================================*/
|
||||
|
||||
typedef int (*IDALsJacFn)(realtype t, realtype c_j, N_Vector y,
|
||||
N_Vector yp, N_Vector r, SUNMatrix Jac,
|
||||
void *user_data, N_Vector tmp1,
|
||||
N_Vector tmp2, N_Vector tmp3);
|
||||
|
||||
typedef int (*IDALsPrecSetupFn)(realtype tt, N_Vector yy,
|
||||
N_Vector yp, N_Vector rr,
|
||||
realtype c_j, void *user_data);
|
||||
|
||||
typedef int (*IDALsPrecSolveFn)(realtype tt, N_Vector yy,
|
||||
N_Vector yp, N_Vector rr,
|
||||
N_Vector rvec, N_Vector zvec,
|
||||
realtype c_j, realtype delta,
|
||||
void *user_data);
|
||||
|
||||
typedef int (*IDALsJacTimesSetupFn)(realtype tt, N_Vector yy,
|
||||
N_Vector yp, N_Vector rr,
|
||||
realtype c_j, void *user_data);
|
||||
|
||||
typedef int (*IDALsJacTimesVecFn)(realtype tt, N_Vector yy,
|
||||
N_Vector yp, N_Vector rr,
|
||||
N_Vector v, N_Vector Jv,
|
||||
realtype c_j, void *user_data,
|
||||
N_Vector tmp1, N_Vector tmp2);
|
||||
|
||||
|
||||
/*=================================================================
|
||||
IDALS Exported functions
|
||||
=================================================================*/
|
||||
|
||||
SUNDIALS_EXPORT int IDASetLinearSolver(void *ida_mem,
|
||||
SUNLinearSolver LS,
|
||||
SUNMatrix A);
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------
|
||||
Optional inputs to the IDALS linear solver interface
|
||||
-----------------------------------------------------------------*/
|
||||
|
||||
SUNDIALS_EXPORT int IDASetJacFn(void *ida_mem, IDALsJacFn jac);
|
||||
SUNDIALS_EXPORT int IDASetPreconditioner(void *ida_mem,
|
||||
IDALsPrecSetupFn pset,
|
||||
IDALsPrecSolveFn psolve);
|
||||
SUNDIALS_EXPORT int IDASetJacTimes(void *ida_mem,
|
||||
IDALsJacTimesSetupFn jtsetup,
|
||||
IDALsJacTimesVecFn jtimes);
|
||||
SUNDIALS_EXPORT int IDASetEpsLin(void *ida_mem, realtype eplifac);
|
||||
SUNDIALS_EXPORT int IDASetLinearSolutionScaling(void *ida_mem,
|
||||
booleantype onoff);
|
||||
SUNDIALS_EXPORT int IDASetIncrementFactor(void *ida_mem,
|
||||
realtype dqincfac);
|
||||
|
||||
/*-----------------------------------------------------------------
|
||||
Optional outputs from the IDALS linear solver interface
|
||||
-----------------------------------------------------------------*/
|
||||
|
||||
SUNDIALS_EXPORT int IDAGetLinWorkSpace(void *ida_mem,
|
||||
long int *lenrwLS,
|
||||
long int *leniwLS);
|
||||
SUNDIALS_EXPORT int IDAGetNumJacEvals(void *ida_mem,
|
||||
long int *njevals);
|
||||
SUNDIALS_EXPORT int IDAGetNumPrecEvals(void *ida_mem,
|
||||
long int *npevals);
|
||||
SUNDIALS_EXPORT int IDAGetNumPrecSolves(void *ida_mem,
|
||||
long int *npsolves);
|
||||
SUNDIALS_EXPORT int IDAGetNumLinIters(void *ida_mem,
|
||||
long int *nliters);
|
||||
SUNDIALS_EXPORT int IDAGetNumLinConvFails(void *ida_mem,
|
||||
long int *nlcfails);
|
||||
SUNDIALS_EXPORT int IDAGetNumJTSetupEvals(void *ida_mem,
|
||||
long int *njtsetups);
|
||||
SUNDIALS_EXPORT int IDAGetNumJtimesEvals(void *ida_mem,
|
||||
long int *njvevals);
|
||||
SUNDIALS_EXPORT int IDAGetNumLinResEvals(void *ida_mem,
|
||||
long int *nrevalsLS);
|
||||
SUNDIALS_EXPORT int IDAGetLastLinFlag(void *ida_mem,
|
||||
long int *flag);
|
||||
SUNDIALS_EXPORT char *IDAGetLinReturnFlagName(long int flag);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
80
bazaar/plugin/sundials/include/ida/ida_spils.h
Normal file
80
bazaar/plugin/sundials/include/ida/ida_spils.h
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
/* -----------------------------------------------------------------
|
||||
* Programmer(s): Daniel R. Reynolds @ SMU
|
||||
* Alan Hindmarsh, Radu Serban and Aaron Collier @ LLNL
|
||||
* -----------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
* -----------------------------------------------------------------
|
||||
* Header file for the deprecated Scaled, Preconditioned Iterative
|
||||
* Linear Solver interface in IDA; these routines now just wrap
|
||||
* the updated IDA generic linear solver interface in ida_ls.h.
|
||||
* -----------------------------------------------------------------*/
|
||||
|
||||
#ifndef _IDASPILS_H
|
||||
#define _IDASPILS_H
|
||||
|
||||
#include <ida/ida_ls.h>
|
||||
|
||||
#ifdef __cplusplus /* wrapper to enable C++ usage */
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*===============================================================
|
||||
Function Types (typedefs for equivalent types in ida_ls.h)
|
||||
===============================================================*/
|
||||
|
||||
typedef IDALsPrecSetupFn IDASpilsPrecSetupFn;
|
||||
typedef IDALsPrecSolveFn IDASpilsPrecSolveFn;
|
||||
typedef IDALsJacTimesSetupFn IDASpilsJacTimesSetupFn;
|
||||
typedef IDALsJacTimesVecFn IDASpilsJacTimesVecFn;
|
||||
|
||||
/*====================================================================
|
||||
Exported Functions (wrappers for equivalent routines in ida_ls.h)
|
||||
====================================================================*/
|
||||
|
||||
SUNDIALS_EXPORT int IDASpilsSetLinearSolver(void *ida_mem, SUNLinearSolver LS);
|
||||
|
||||
SUNDIALS_EXPORT int IDASpilsSetPreconditioner(void *ida_mem, IDASpilsPrecSetupFn pset,
|
||||
IDASpilsPrecSolveFn psolve);
|
||||
|
||||
SUNDIALS_EXPORT int IDASpilsSetJacTimes(void *ida_mem, IDASpilsJacTimesSetupFn jtsetup,
|
||||
IDASpilsJacTimesVecFn jtimes);
|
||||
|
||||
SUNDIALS_EXPORT int IDASpilsSetEpsLin(void *ida_mem, realtype eplifac);
|
||||
|
||||
SUNDIALS_EXPORT int IDASpilsSetIncrementFactor(void *ida_mem, realtype dqincfac);
|
||||
|
||||
SUNDIALS_EXPORT int IDASpilsGetWorkSpace(void *ida_mem, long int *lenrwLS, long int *leniwLS);
|
||||
|
||||
SUNDIALS_EXPORT int IDASpilsGetNumPrecEvals(void *ida_mem, long int *npevals);
|
||||
|
||||
SUNDIALS_EXPORT int IDASpilsGetNumPrecSolves(void *ida_mem, long int *npsolves);
|
||||
|
||||
SUNDIALS_EXPORT int IDASpilsGetNumLinIters(void *ida_mem, long int *nliters);
|
||||
|
||||
SUNDIALS_EXPORT int IDASpilsGetNumConvFails(void *ida_mem, long int *nlcfails);
|
||||
|
||||
SUNDIALS_EXPORT int IDASpilsGetNumJTSetupEvals(void *ida_mem, long int *njtsetups);
|
||||
|
||||
SUNDIALS_EXPORT int IDASpilsGetNumJtimesEvals(void *ida_mem, long int *njvevals);
|
||||
|
||||
SUNDIALS_EXPORT int IDASpilsGetNumResEvals(void *ida_mem, long int *nrevalsLS);
|
||||
|
||||
SUNDIALS_EXPORT int IDASpilsGetLastFlag(void *ida_mem, long int *flag);
|
||||
|
||||
SUNDIALS_EXPORT char *IDASpilsGetReturnFlagName(long int flag);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
150
bazaar/plugin/sundials/include/kinsol/kinsol.h
Normal file
150
bazaar/plugin/sundials/include/kinsol/kinsol.h
Normal file
|
|
@ -0,0 +1,150 @@
|
|||
/* -----------------------------------------------------------------
|
||||
* Programmer(s): Allan Taylor, Alan Hindmarsh, Radu Serban, and
|
||||
* Aaron Collier @ LLNL
|
||||
* -----------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
* -----------------------------------------------------------------
|
||||
* This is the header file for the main KINSOL solver.
|
||||
* -----------------------------------------------------------------*/
|
||||
|
||||
#ifndef _KINSOL_H
|
||||
#define _KINSOL_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sundials/sundials_nvector.h>
|
||||
#include <kinsol/kinsol_ls.h>
|
||||
|
||||
#ifdef __cplusplus /* wrapper to enable C++ usage */
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* -----------------
|
||||
* KINSOL Constants
|
||||
* ----------------- */
|
||||
|
||||
/* return values */
|
||||
|
||||
#define KIN_SUCCESS 0
|
||||
#define KIN_INITIAL_GUESS_OK 1
|
||||
#define KIN_STEP_LT_STPTOL 2
|
||||
|
||||
#define KIN_WARNING 99
|
||||
|
||||
#define KIN_MEM_NULL -1
|
||||
#define KIN_ILL_INPUT -2
|
||||
#define KIN_NO_MALLOC -3
|
||||
#define KIN_MEM_FAIL -4
|
||||
#define KIN_LINESEARCH_NONCONV -5
|
||||
#define KIN_MAXITER_REACHED -6
|
||||
#define KIN_MXNEWT_5X_EXCEEDED -7
|
||||
#define KIN_LINESEARCH_BCFAIL -8
|
||||
#define KIN_LINSOLV_NO_RECOVERY -9
|
||||
#define KIN_LINIT_FAIL -10
|
||||
#define KIN_LSETUP_FAIL -11
|
||||
#define KIN_LSOLVE_FAIL -12
|
||||
|
||||
#define KIN_SYSFUNC_FAIL -13
|
||||
#define KIN_FIRST_SYSFUNC_ERR -14
|
||||
#define KIN_REPTD_SYSFUNC_ERR -15
|
||||
|
||||
#define KIN_VECTOROP_ERR -16
|
||||
|
||||
/* Enumeration for eta choice */
|
||||
#define KIN_ETACHOICE1 1
|
||||
#define KIN_ETACHOICE2 2
|
||||
#define KIN_ETACONSTANT 3
|
||||
|
||||
/* Enumeration for global strategy */
|
||||
#define KIN_NONE 0
|
||||
#define KIN_LINESEARCH 1
|
||||
#define KIN_PICARD 2
|
||||
#define KIN_FP 3
|
||||
|
||||
/* ------------------------------
|
||||
* User-Supplied Function Types
|
||||
* ------------------------------ */
|
||||
|
||||
typedef int (*KINSysFn)(N_Vector uu, N_Vector fval, void *user_data );
|
||||
|
||||
typedef void (*KINErrHandlerFn)(int error_code,
|
||||
const char *module, const char *function,
|
||||
char *msg, void *user_data);
|
||||
|
||||
typedef void (*KINInfoHandlerFn)(const char *module, const char *function,
|
||||
char *msg, void *user_data);
|
||||
|
||||
/* -------------------
|
||||
* Exported Functions
|
||||
* ------------------- */
|
||||
|
||||
/* Creation function */
|
||||
SUNDIALS_EXPORT void *KINCreate(void);
|
||||
|
||||
/* Initialization function */
|
||||
SUNDIALS_EXPORT int KINInit(void *kinmem, KINSysFn func, N_Vector tmpl);
|
||||
|
||||
/* Solver function */
|
||||
SUNDIALS_EXPORT int KINSol(void *kinmem, N_Vector uu, int strategy,
|
||||
N_Vector u_scale, N_Vector f_scale);
|
||||
|
||||
/* Optional input functions */
|
||||
SUNDIALS_EXPORT int KINSetErrHandlerFn(void *kinmem, KINErrHandlerFn ehfun,
|
||||
void *eh_data);
|
||||
SUNDIALS_EXPORT int KINSetErrFile(void *kinmem, FILE *errfp);
|
||||
SUNDIALS_EXPORT int KINSetInfoHandlerFn(void *kinmem, KINInfoHandlerFn ihfun,
|
||||
void *ih_data);
|
||||
SUNDIALS_EXPORT int KINSetInfoFile(void *kinmem, FILE *infofp);
|
||||
SUNDIALS_EXPORT int KINSetUserData(void *kinmem, void *user_data);
|
||||
SUNDIALS_EXPORT int KINSetPrintLevel(void *kinmemm, int printfl);
|
||||
SUNDIALS_EXPORT int KINSetMAA(void *kinmem, long int maa);
|
||||
SUNDIALS_EXPORT int KINSetDampingAA(void *kinmem, realtype beta);
|
||||
SUNDIALS_EXPORT int KINSetNumMaxIters(void *kinmem, long int mxiter);
|
||||
SUNDIALS_EXPORT int KINSetNoInitSetup(void *kinmem, booleantype noInitSetup);
|
||||
SUNDIALS_EXPORT int KINSetNoResMon(void *kinmem, booleantype noNNIResMon);
|
||||
SUNDIALS_EXPORT int KINSetMaxSetupCalls(void *kinmem, long int msbset);
|
||||
SUNDIALS_EXPORT int KINSetMaxSubSetupCalls(void *kinmem, long int msbsetsub);
|
||||
SUNDIALS_EXPORT int KINSetEtaForm(void *kinmem, int etachoice);
|
||||
SUNDIALS_EXPORT int KINSetEtaConstValue(void *kinmem, realtype eta);
|
||||
SUNDIALS_EXPORT int KINSetEtaParams(void *kinmem, realtype egamma,
|
||||
realtype ealpha);
|
||||
SUNDIALS_EXPORT int KINSetResMonParams(void *kinmem, realtype omegamin,
|
||||
realtype omegamax);
|
||||
SUNDIALS_EXPORT int KINSetResMonConstValue(void *kinmem, realtype omegaconst);
|
||||
SUNDIALS_EXPORT int KINSetNoMinEps(void *kinmem, booleantype noMinEps);
|
||||
SUNDIALS_EXPORT int KINSetMaxNewtonStep(void *kinmem, realtype mxnewtstep);
|
||||
SUNDIALS_EXPORT int KINSetMaxBetaFails(void *kinmem, long int mxnbcf);
|
||||
SUNDIALS_EXPORT int KINSetRelErrFunc(void *kinmem, realtype relfunc);
|
||||
SUNDIALS_EXPORT int KINSetFuncNormTol(void *kinmem, realtype fnormtol);
|
||||
SUNDIALS_EXPORT int KINSetScaledStepTol(void *kinmem, realtype scsteptol);
|
||||
SUNDIALS_EXPORT int KINSetConstraints(void *kinmem, N_Vector constraints);
|
||||
SUNDIALS_EXPORT int KINSetSysFunc(void *kinmem, KINSysFn func);
|
||||
|
||||
|
||||
/* Optional output functions */
|
||||
SUNDIALS_EXPORT int KINGetWorkSpace(void *kinmem, long int *lenrw,
|
||||
long int *leniw);
|
||||
SUNDIALS_EXPORT int KINGetNumNonlinSolvIters(void *kinmem, long int *nniters);
|
||||
SUNDIALS_EXPORT int KINGetNumFuncEvals(void *kinmem, long int *nfevals);
|
||||
SUNDIALS_EXPORT int KINGetNumBetaCondFails(void *kinmem, long int *nbcfails);
|
||||
SUNDIALS_EXPORT int KINGetNumBacktrackOps(void *kinmem, long int *nbacktr);
|
||||
SUNDIALS_EXPORT int KINGetFuncNorm(void *kinmem, realtype *fnorm);
|
||||
SUNDIALS_EXPORT int KINGetStepLength(void *kinmem, realtype *steplength);
|
||||
SUNDIALS_EXPORT char *KINGetReturnFlagName(long int flag);
|
||||
|
||||
/* Free function */
|
||||
SUNDIALS_EXPORT void KINFree(void **kinmem);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
66
bazaar/plugin/sundials/include/kinsol/kinsol_bbdpre.h
Normal file
66
bazaar/plugin/sundials/include/kinsol/kinsol_bbdpre.h
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
/* -----------------------------------------------------------------
|
||||
* Programmer(s): Daniel R. Reynolds @ SMU
|
||||
* Alan Hindmarsh, Radu Serban, and
|
||||
* Aaron Collier @ LLNL
|
||||
* -----------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
* -----------------------------------------------------------------
|
||||
* This is the header file for the KINBBDPRE module, for a
|
||||
* band-block-diagonal preconditioner, i.e. a block-diagonal
|
||||
* matrix with banded blocks.
|
||||
* -----------------------------------------------------------------*/
|
||||
|
||||
#ifndef _KINBBDPRE_H
|
||||
#define _KINBBDPRE_H
|
||||
|
||||
#include <sundials/sundials_nvector.h>
|
||||
|
||||
#ifdef __cplusplus /* wrapper to enable C++ usage */
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* KINBBDPRE return values */
|
||||
|
||||
#define KINBBDPRE_SUCCESS 0
|
||||
#define KINBBDPRE_PDATA_NULL -11
|
||||
#define KINBBDPRE_FUNC_UNRECVR -12
|
||||
|
||||
/* User-supplied function Types */
|
||||
|
||||
typedef int (*KINBBDCommFn)(sunindextype Nlocal, N_Vector u,
|
||||
void *user_data);
|
||||
|
||||
typedef int (*KINBBDLocalFn)(sunindextype Nlocal, N_Vector uu,
|
||||
N_Vector gval, void *user_data);
|
||||
|
||||
/* Exported Functions */
|
||||
|
||||
SUNDIALS_EXPORT int KINBBDPrecInit(void *kinmem, sunindextype Nlocal,
|
||||
sunindextype mudq, sunindextype mldq,
|
||||
sunindextype mukeep, sunindextype mlkeep,
|
||||
realtype dq_rel_uu,
|
||||
KINBBDLocalFn gloc, KINBBDCommFn gcomm);
|
||||
|
||||
/* Optional output functions */
|
||||
|
||||
SUNDIALS_EXPORT int KINBBDPrecGetWorkSpace(void *kinmem,
|
||||
long int *lenrwBBDP,
|
||||
long int *leniwBBDP);
|
||||
|
||||
SUNDIALS_EXPORT int KINBBDPrecGetNumGfnEvals(void *kinmem,
|
||||
long int *ngevalsBBDP);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
59
bazaar/plugin/sundials/include/kinsol/kinsol_direct.h
Normal file
59
bazaar/plugin/sundials/include/kinsol/kinsol_direct.h
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
/* -----------------------------------------------------------------
|
||||
* Programmer(s): Daniel R. Reynolds @ SMU
|
||||
* Radu Serban @ LLNL
|
||||
* -----------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
* -----------------------------------------------------------------
|
||||
* Header file for the deprecated direct linear solver interface in
|
||||
* KINSOL; these routines now just wrap the updated KINSOL generic
|
||||
* linear solver interface in kinsol_ls.h.
|
||||
* -----------------------------------------------------------------*/
|
||||
|
||||
#ifndef _KINDLS_H
|
||||
#define _KINDLS_H
|
||||
|
||||
#include <kinsol/kinsol_ls.h>
|
||||
|
||||
#ifdef __cplusplus /* wrapper to enable C++ usage */
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*=================================================================
|
||||
Function Types (typedefs for equivalent types in kinsol_ls.h)
|
||||
=================================================================*/
|
||||
|
||||
typedef KINLsJacFn KINDlsJacFn;
|
||||
|
||||
/*===================================================================
|
||||
Exported Functions (wrappers for equivalent routines in kinsol_ls.h)
|
||||
===================================================================*/
|
||||
|
||||
SUNDIALS_EXPORT int KINDlsSetLinearSolver(void *kinmem, SUNLinearSolver LS, SUNMatrix A);
|
||||
|
||||
SUNDIALS_EXPORT int KINDlsSetJacFn(void *kinmem, KINDlsJacFn jac);
|
||||
|
||||
SUNDIALS_EXPORT int KINDlsGetWorkSpace(void *kinmem, long int *lenrw, long int *leniw);
|
||||
|
||||
SUNDIALS_EXPORT int KINDlsGetNumJacEvals(void *kinmem, long int *njevals);
|
||||
|
||||
SUNDIALS_EXPORT int KINDlsGetNumFuncEvals(void *kinmem, long int *nfevals);
|
||||
|
||||
SUNDIALS_EXPORT int KINDlsGetLastFlag(void *kinmem, long int *flag);
|
||||
|
||||
SUNDIALS_EXPORT char *KINDlsGetReturnFlagName(long int flag);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
117
bazaar/plugin/sundials/include/kinsol/kinsol_ls.h
Normal file
117
bazaar/plugin/sundials/include/kinsol/kinsol_ls.h
Normal file
|
|
@ -0,0 +1,117 @@
|
|||
/* ----------------------------------------------------------------
|
||||
* Programmer(s): Daniel R. Reynolds @ SMU
|
||||
* Scott Cohen, Alan Hindmarsh, Radu Serban, and
|
||||
* Aaron Collier @ LLNL
|
||||
* ----------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
* ----------------------------------------------------------------
|
||||
* This is the header file for KINSOL's linear solver interface.
|
||||
* ----------------------------------------------------------------*/
|
||||
|
||||
#ifndef _KINLS_H
|
||||
#define _KINLS_H
|
||||
|
||||
#include <sundials/sundials_direct.h>
|
||||
#include <sundials/sundials_iterative.h>
|
||||
#include <sundials/sundials_linearsolver.h>
|
||||
#include <sundials/sundials_matrix.h>
|
||||
#include <sundials/sundials_nvector.h>
|
||||
|
||||
#ifdef __cplusplus /* wrapper to enable C++ usage */
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*==================================================================
|
||||
KINLS Constants
|
||||
==================================================================*/
|
||||
|
||||
#define KINLS_SUCCESS 0
|
||||
|
||||
#define KINLS_MEM_NULL -1
|
||||
#define KINLS_LMEM_NULL -2
|
||||
#define KINLS_ILL_INPUT -3
|
||||
#define KINLS_MEM_FAIL -4
|
||||
#define KINLS_PMEM_NULL -5
|
||||
#define KINLS_JACFUNC_ERR -6
|
||||
#define KINLS_SUNMAT_FAIL -7
|
||||
#define KINLS_SUNLS_FAIL -8
|
||||
|
||||
|
||||
/*===============================================================
|
||||
KINLS user-supplied function prototypes
|
||||
===============================================================*/
|
||||
|
||||
typedef int (*KINLsJacFn)(N_Vector u, N_Vector fu, SUNMatrix J,
|
||||
void *user_data, N_Vector tmp1, N_Vector tmp2);
|
||||
|
||||
typedef int (*KINLsPrecSetupFn)(N_Vector uu, N_Vector uscale,
|
||||
N_Vector fval, N_Vector fscale,
|
||||
void *user_data);
|
||||
|
||||
typedef int (*KINLsPrecSolveFn)(N_Vector uu, N_Vector uscale,
|
||||
N_Vector fval, N_Vector fscale,
|
||||
N_Vector vv, void *user_data);
|
||||
|
||||
typedef int (*KINLsJacTimesVecFn)(N_Vector v, N_Vector Jv, N_Vector uu,
|
||||
booleantype *new_uu, void *J_data);
|
||||
|
||||
|
||||
/*==================================================================
|
||||
KINLS Exported functions
|
||||
==================================================================*/
|
||||
|
||||
SUNDIALS_EXPORT int KINSetLinearSolver(void *kinmem, SUNLinearSolver LS,
|
||||
SUNMatrix A);
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------
|
||||
Optional inputs to the KINLS linear solver interface
|
||||
-----------------------------------------------------------------*/
|
||||
|
||||
SUNDIALS_EXPORT int KINSetJacFn(void *kinmem, KINLsJacFn jac);
|
||||
SUNDIALS_EXPORT int KINSetPreconditioner(void *kinmem,
|
||||
KINLsPrecSetupFn psetup,
|
||||
KINLsPrecSolveFn psolve);
|
||||
SUNDIALS_EXPORT int KINSetJacTimesVecFn(void *kinmem,
|
||||
KINLsJacTimesVecFn jtv);
|
||||
|
||||
/*-----------------------------------------------------------------
|
||||
Optional outputs from the KINLS linear solver interface
|
||||
-----------------------------------------------------------------*/
|
||||
|
||||
SUNDIALS_EXPORT int KINGetLinWorkSpace(void *kinmem,
|
||||
long int *lenrwLS,
|
||||
long int *leniwLS);
|
||||
SUNDIALS_EXPORT int KINGetNumJacEvals(void *kinmem,
|
||||
long int *njevals);
|
||||
SUNDIALS_EXPORT int KINGetNumLinFuncEvals(void *kinmem,
|
||||
long int *nfevals);
|
||||
SUNDIALS_EXPORT int KINGetNumPrecEvals(void *kinmem,
|
||||
long int *npevals);
|
||||
SUNDIALS_EXPORT int KINGetNumPrecSolves(void *kinmem,
|
||||
long int *npsolves);
|
||||
SUNDIALS_EXPORT int KINGetNumLinIters(void *kinmem,
|
||||
long int *nliters);
|
||||
SUNDIALS_EXPORT int KINGetNumLinConvFails(void *kinmem,
|
||||
long int *nlcfails);
|
||||
SUNDIALS_EXPORT int KINGetNumJtimesEvals(void *kinmem,
|
||||
long int *njvevals);
|
||||
SUNDIALS_EXPORT int KINGetLastLinFlag(void *kinmem,
|
||||
long int *flag);
|
||||
SUNDIALS_EXPORT char *KINGetLinReturnFlagName(long int flag);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
73
bazaar/plugin/sundials/include/kinsol/kinsol_spils.h
Normal file
73
bazaar/plugin/sundials/include/kinsol/kinsol_spils.h
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
/* -----------------------------------------------------------------
|
||||
* Programmer(s): Daniel R. Reynolds @ SMU
|
||||
* Scott Cohen, Alan Hindmarsh, Radu Serban,
|
||||
* and Aaron Collier @ LLNL
|
||||
* -----------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
* -----------------------------------------------------------------
|
||||
* Header file for the deprecated Scaled Preconditioned Iterative
|
||||
* Linear Solver interface in KINSOL; these routines now just wrap
|
||||
* the updated KINSOL generic linear solver interface in kinsol_ls.h.
|
||||
* -----------------------------------------------------------------*/
|
||||
|
||||
#ifndef _KINSPILS_H
|
||||
#define _KINSPILS_H
|
||||
|
||||
#include <kinsol/kinsol_ls.h>
|
||||
|
||||
#ifdef __cplusplus /* wrapper to enable C++ usage */
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*===============================================================
|
||||
Function Types (typedefs for equivalent types in kinsol_ls.h)
|
||||
===============================================================*/
|
||||
|
||||
typedef KINLsPrecSetupFn KINSpilsPrecSetupFn;
|
||||
typedef KINLsPrecSolveFn KINSpilsPrecSolveFn;
|
||||
typedef KINLsJacTimesVecFn KINSpilsJacTimesVecFn;
|
||||
|
||||
/*====================================================================
|
||||
Exported Functions (wrappers for equivalent routines in kinsol_ls.h)
|
||||
====================================================================*/
|
||||
|
||||
SUNDIALS_EXPORT int KINSpilsSetLinearSolver(void *kinmem, SUNLinearSolver LS);
|
||||
|
||||
SUNDIALS_EXPORT int KINSpilsSetPreconditioner(void *kinmem, KINSpilsPrecSetupFn psetup,
|
||||
KINSpilsPrecSolveFn psolve);
|
||||
|
||||
SUNDIALS_EXPORT int KINSpilsSetJacTimesVecFn(void *kinmem, KINSpilsJacTimesVecFn jtv);
|
||||
|
||||
SUNDIALS_EXPORT int KINSpilsGetWorkSpace(void *kinmem, long int *lenrwLS, long int *leniwLS);
|
||||
|
||||
SUNDIALS_EXPORT int KINSpilsGetNumPrecEvals(void *kinmem, long int *npevals);
|
||||
|
||||
SUNDIALS_EXPORT int KINSpilsGetNumPrecSolves(void *kinmem, long int *npsolves);
|
||||
|
||||
SUNDIALS_EXPORT int KINSpilsGetNumLinIters(void *kinmem, long int *nliters);
|
||||
|
||||
SUNDIALS_EXPORT int KINSpilsGetNumConvFails(void *kinmem, long int *nlcfails);
|
||||
|
||||
SUNDIALS_EXPORT int KINSpilsGetNumJtimesEvals(void *kinmem, long int *njvevals);
|
||||
|
||||
SUNDIALS_EXPORT int KINSpilsGetNumFuncEvals(void *kinmem, long int *nfevals);
|
||||
|
||||
SUNDIALS_EXPORT int KINSpilsGetLastFlag(void *kinmem, long int *flag);
|
||||
|
||||
SUNDIALS_EXPORT char *KINSpilsGetReturnFlagName(long int flag);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,386 @@
|
|||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Programmer(s): Slaven Peles @ LLNL
|
||||
* -----------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef _THREAD_PARTITIONING_HPP_
|
||||
#define _THREAD_PARTITIONING_HPP_
|
||||
|
||||
#include <iostream>
|
||||
#include <cuda_runtime.h>
|
||||
|
||||
#include <sundials/sundials_types.h>
|
||||
|
||||
namespace suncudavec
|
||||
{
|
||||
|
||||
using SUNAllocFn = void* (*)(size_t);
|
||||
using SUNFreeFn = void (*)(void*);
|
||||
|
||||
template<class T, class I>
|
||||
class ThreadPartitioning
|
||||
{
|
||||
|
||||
public:
|
||||
ThreadPartitioning()
|
||||
: block_(1),
|
||||
grid_(1),
|
||||
shMemSize_(0),
|
||||
stream_(0),
|
||||
bufferSize_(0),
|
||||
allocfn_(nullptr),
|
||||
freefn_(nullptr),
|
||||
d_buffer_(nullptr),
|
||||
h_buffer_(nullptr),
|
||||
ownBuffer_(true)
|
||||
{}
|
||||
|
||||
ThreadPartitioning(unsigned block,
|
||||
SUNAllocFn allocfn = nullptr,
|
||||
SUNFreeFn freefn = nullptr)
|
||||
: block_(block),
|
||||
grid_(1),
|
||||
shMemSize_(0),
|
||||
stream_(0),
|
||||
bufferSize_(0),
|
||||
allocfn_(allocfn),
|
||||
freefn_(freefn),
|
||||
d_buffer_(nullptr),
|
||||
h_buffer_(nullptr),
|
||||
ownBuffer_(true)
|
||||
{}
|
||||
|
||||
explicit ThreadPartitioning(ThreadPartitioning<T, I>& p)
|
||||
: block_(p.block_),
|
||||
grid_(p.grid_),
|
||||
shMemSize_(p.shMemSize_),
|
||||
stream_(p.stream_),
|
||||
allocfn_(p.allocfn_),
|
||||
freefn_(p.freefn_)
|
||||
{}
|
||||
|
||||
virtual ~ThreadPartitioning(){}
|
||||
|
||||
unsigned grid() const
|
||||
{
|
||||
return grid_;
|
||||
}
|
||||
|
||||
unsigned block() const
|
||||
{
|
||||
return block_;
|
||||
}
|
||||
|
||||
unsigned shmem() const
|
||||
{
|
||||
return shMemSize_;
|
||||
}
|
||||
|
||||
cudaStream_t stream() const
|
||||
{
|
||||
return stream_;
|
||||
}
|
||||
|
||||
unsigned int bufferSize()
|
||||
{
|
||||
return bufferSize_;
|
||||
}
|
||||
|
||||
T* devBuffer()
|
||||
{
|
||||
return d_buffer_;
|
||||
}
|
||||
|
||||
const T* devBuffer() const
|
||||
{
|
||||
return d_buffer_;
|
||||
}
|
||||
|
||||
T* hostBuffer()
|
||||
{
|
||||
return h_buffer_;
|
||||
}
|
||||
|
||||
const T* hostBuffer() const
|
||||
{
|
||||
return h_buffer_;
|
||||
}
|
||||
|
||||
void setStream(const cudaStream_t& stream)
|
||||
{
|
||||
stream_ = stream;
|
||||
}
|
||||
|
||||
virtual void copyFromDevBuffer(unsigned int n) const
|
||||
{
|
||||
std::cerr << "Trying to copy buffer from base class in "
|
||||
<< "suncudavec::ThreadPartitioning::copyFromDevBuffer\n";
|
||||
}
|
||||
|
||||
/* pure virtual functions to get the relevant partitioning information */
|
||||
virtual int calcPartitioning(I N, unsigned& grid, unsigned& block, unsigned& shMemSize, cudaStream_t& stream) = 0;
|
||||
virtual int calcPartitioning(I N, unsigned& grid, unsigned& block, unsigned& shMemSize) = 0;
|
||||
|
||||
protected:
|
||||
unsigned block_;
|
||||
unsigned grid_;
|
||||
unsigned shMemSize_;
|
||||
unsigned bufferSize_;
|
||||
cudaStream_t stream_;
|
||||
T* d_buffer_;
|
||||
T* h_buffer_;
|
||||
bool ownBuffer_;
|
||||
|
||||
/* custom allocators for the internal buffers */
|
||||
SUNAllocFn allocfn_;
|
||||
SUNFreeFn freefn_;
|
||||
|
||||
}; // class ThreadPartitioning
|
||||
|
||||
|
||||
|
||||
template<class T, class I>
|
||||
class StreamPartitioning : public ThreadPartitioning<T, I>
|
||||
{
|
||||
using ThreadPartitioning<T, I>::block_;
|
||||
using ThreadPartitioning<T, I>::grid_;
|
||||
using ThreadPartitioning<T, I>::stream_;
|
||||
|
||||
public:
|
||||
StreamPartitioning(I N, unsigned block, cudaStream_t stream)
|
||||
: ThreadPartitioning<T, I>(block)
|
||||
{
|
||||
grid_ = (N + block_ - 1) / block_;
|
||||
stream_ = stream;
|
||||
}
|
||||
|
||||
StreamPartitioning(I N, unsigned block)
|
||||
: ThreadPartitioning<T, I>(block)
|
||||
{
|
||||
grid_ = (N + block_ - 1) / block_;
|
||||
}
|
||||
|
||||
explicit StreamPartitioning(StreamPartitioning<T, I>& p)
|
||||
: ThreadPartitioning<T, I>(p)
|
||||
{
|
||||
}
|
||||
|
||||
virtual int calcPartitioning(I N, unsigned& grid, unsigned& block, unsigned& shMemSize,
|
||||
cudaStream_t& stream)
|
||||
{
|
||||
block = block_;
|
||||
grid = (N + block_ - 1) / block_;
|
||||
shMemSize = 0;
|
||||
stream = stream_;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual int calcPartitioning(I N, unsigned& grid, unsigned& block, unsigned& shMemSize)
|
||||
{
|
||||
block = block_;
|
||||
grid = (N + block_ - 1) / block_;
|
||||
shMemSize = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
}; // class StreamPartitioning
|
||||
|
||||
|
||||
template<class T, class I=int>
|
||||
class ReducePartitioning : public ThreadPartitioning<T, I>
|
||||
{
|
||||
using ThreadPartitioning<T, I>::block_;
|
||||
using ThreadPartitioning<T, I>::grid_;
|
||||
using ThreadPartitioning<T, I>::shMemSize_;
|
||||
using ThreadPartitioning<T, I>::stream_;
|
||||
using ThreadPartitioning<T, I>::bufferSize_;
|
||||
using ThreadPartitioning<T, I>::d_buffer_;
|
||||
using ThreadPartitioning<T, I>::h_buffer_;
|
||||
using ThreadPartitioning<T, I>::ownBuffer_;
|
||||
using ThreadPartitioning<T, I>::allocfn_;
|
||||
using ThreadPartitioning<T, I>::freefn_;
|
||||
|
||||
public:
|
||||
ReducePartitioning(I N, unsigned block,
|
||||
SUNAllocFn allocfn = nullptr, SUNFreeFn freefn = nullptr)
|
||||
: ThreadPartitioning<T, I>(block, allocfn, freefn)
|
||||
{
|
||||
grid_ = (N + (block_ * 2 - 1)) / (block_ * 2);
|
||||
shMemSize_ = block_*sizeof(T);
|
||||
allocateBuffer(false, allocfn != nullptr);
|
||||
}
|
||||
|
||||
ReducePartitioning(I N, unsigned block, cudaStream_t stream,
|
||||
SUNAllocFn allocfn = nullptr, SUNFreeFn freefn = nullptr)
|
||||
: ThreadPartitioning<T, I>(block, allocfn, freefn)
|
||||
{
|
||||
grid_ = (N + (block_ * 2 - 1)) / (block_ * 2);
|
||||
shMemSize_ = block_*sizeof(T);
|
||||
stream_ = stream;
|
||||
allocateBuffer(false, allocfn != nullptr);
|
||||
}
|
||||
|
||||
ReducePartitioning(T *h_buffer, T *d_buffer, I N, unsigned block, cudaStream_t stream = 0)
|
||||
: ThreadPartitioning<T, I>(block)
|
||||
{
|
||||
grid_ = (N + (block_ * 2 - 1)) / (block_ * 2);
|
||||
shMemSize_ = block_*sizeof(T);
|
||||
stream_ = stream;
|
||||
h_buffer_ = h_buffer;
|
||||
d_buffer_ = d_buffer;
|
||||
ownBuffer_ = false;
|
||||
}
|
||||
|
||||
explicit ReducePartitioning(ReducePartitioning<T, I>& p)
|
||||
: ThreadPartitioning<T, I>(p)
|
||||
{
|
||||
shMemSize_ = p.shMemSize_;
|
||||
/* if device buffer and host buffer are the same, then assume managed memory */
|
||||
allocateBuffer(p.d_buffer_ == p.h_buffer_, p.allocfn_ != nullptr);
|
||||
}
|
||||
|
||||
~ReducePartitioning()
|
||||
{
|
||||
cudaError_t err;
|
||||
|
||||
if (ownBuffer_ && bufferSize_ > 0) {
|
||||
|
||||
if (d_buffer_ == h_buffer_) {
|
||||
/* managed memory */
|
||||
if (freefn_) {
|
||||
freefn_(d_buffer_);
|
||||
} else {
|
||||
err = cudaFree(d_buffer_);
|
||||
if(err != cudaSuccess)
|
||||
std::cerr << "Failed to free device vector "
|
||||
<< "in suncudavec::ReducePartitioning::~ReducePartitioning "
|
||||
<< "(CUDA error code " << err << ")\n";
|
||||
}
|
||||
d_buffer_ = h_buffer_ = nullptr;
|
||||
} else {
|
||||
/* unmanaged memory */
|
||||
err = cudaFree(d_buffer_);
|
||||
if(err != cudaSuccess)
|
||||
std::cerr << "Failed to free device vector "
|
||||
<< "in suncudavec::ReducePartitioning::~ReducePartitioning "
|
||||
<< "(CUDA error code " << err << ")\n";
|
||||
free(h_buffer_);
|
||||
d_buffer_ = nullptr;
|
||||
h_buffer_ = nullptr;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
virtual int calcPartitioning(I N, unsigned& grid, unsigned& block, unsigned& shMemSize,
|
||||
cudaStream_t& stream)
|
||||
{
|
||||
block = block_;
|
||||
grid = (N + (block_ * 2 - 1)) / (block_ * 2);
|
||||
shMemSize = block_ * sizeof(T);
|
||||
stream = stream_;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual int calcPartitioning(I N, unsigned& grid, unsigned& block, unsigned& shMemSize)
|
||||
{
|
||||
block = block_;
|
||||
grid = (N + (block_ * 2 - 1)) / (block_ * 2);
|
||||
shMemSize = block_ * sizeof(T);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual void copyFromDevBuffer(unsigned int n) const
|
||||
{
|
||||
cudaError_t err;
|
||||
|
||||
/* If the host and device pointers are the same, then we don't need
|
||||
to do a copy (this happens in the managed memory case), but we
|
||||
still need to synchronize the device to adhere to the unified
|
||||
memory access rules. */
|
||||
if (h_buffer_ == d_buffer_) {
|
||||
err = cudaStreamSynchronize(stream_);
|
||||
if(err != cudaSuccess)
|
||||
std::cerr << "Failed to synchronize stream in "
|
||||
<< "suncudavec::ReducePartitioning::copyFromDevBuffer "
|
||||
<< "(CUDA error code " << err << ")\n";
|
||||
} else {
|
||||
err = cudaMemcpyAsync(h_buffer_, d_buffer_, n*sizeof(T), cudaMemcpyDeviceToHost,
|
||||
stream_);
|
||||
if(err != cudaSuccess)
|
||||
std::cerr << "Failed to copy vector from device to host in "
|
||||
<< "suncudavec::ReducePartitioning::copyFromDevBuffer "
|
||||
<< "(CUDA error code " << err << ")\n";
|
||||
}
|
||||
}
|
||||
|
||||
static unsigned calcBufferSize(I N, unsigned block)
|
||||
{
|
||||
return (N + (block * 2 - 1)) / (block * 2) * sizeof(T);
|
||||
}
|
||||
|
||||
private:
|
||||
int allocateBuffer(bool use_managed_memory = false, bool custom_allocator = false)
|
||||
{
|
||||
cudaError_t err;
|
||||
|
||||
bufferSize_ = grid_ * sizeof(T);
|
||||
if (bufferSize_ == 0) return 0;
|
||||
|
||||
if (custom_allocator) {
|
||||
|
||||
d_buffer_ = static_cast<T*>(allocfn_(bufferSize_));
|
||||
if(d_buffer_ == NULL)
|
||||
std::cerr << "Failed to allocate managed buffer with custom allocator in "
|
||||
<< "suncudavec::ReducePartitioning::allocateBuffer\n";
|
||||
h_buffer_ = d_buffer_;
|
||||
|
||||
} else if (use_managed_memory) {
|
||||
|
||||
err = cudaMallocManaged((void**) &d_buffer_, bufferSize_);
|
||||
if(err != cudaSuccess)
|
||||
std::cerr << "Failed to allocate internal managed buffer in "
|
||||
<< "suncudavec::ReducePartitioning::allocateBuffer "
|
||||
<< "(CUDA error code " << err << ")\n";
|
||||
h_buffer_ = d_buffer_;
|
||||
|
||||
} else {
|
||||
|
||||
h_buffer_ = static_cast<T*>(malloc(bufferSize_));
|
||||
if(h_buffer_ == NULL)
|
||||
std::cerr << "Failed to allocate internal host buffer in "
|
||||
<< "suncudavec::ReducePartitioning::allocateBuffer\n";
|
||||
err = cudaMalloc((void**) &d_buffer_, bufferSize_);
|
||||
if(err != cudaSuccess)
|
||||
std::cerr << "Failed to allocate internal device buffer "
|
||||
<< "in suncudavec::ReducePartitioning::allocateBuffer "
|
||||
<< "(CUDA error code " << err << ")\n";
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
}; // class ReducePartitioning
|
||||
|
||||
|
||||
} // namespace suncudavec
|
||||
|
||||
#endif // _THREAD_PARTITIONING_HPP_
|
||||
371
bazaar/plugin/sundials/include/nvector/cuda/Vector.hpp
Normal file
371
bazaar/plugin/sundials/include/nvector/cuda/Vector.hpp
Normal file
|
|
@ -0,0 +1,371 @@
|
|||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Programmer(s): Slaven Peles, and Cody J. Balos @ LLNL
|
||||
* -----------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Vector class
|
||||
*
|
||||
* Manages vector data layout for CUDA implementation of N_Vector.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _NVECTOR_CUDA_HPP_
|
||||
#define _NVECTOR_CUDA_HPP_
|
||||
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
|
||||
#include <cuda_runtime.h>
|
||||
#include "ThreadPartitioning.hpp"
|
||||
|
||||
#include <nvector/nvector_cuda.h>
|
||||
#include <sundials/sundials_config.h>
|
||||
|
||||
namespace suncudavec
|
||||
{
|
||||
|
||||
template <typename T, typename I>
|
||||
class Vector : public _N_VectorContent_Cuda
|
||||
{
|
||||
|
||||
public:
|
||||
Vector(I N,
|
||||
bool use_managed_memory = false, bool allocate_data = true,
|
||||
T* const h_vec = nullptr, T* const d_vec = nullptr)
|
||||
: size_(N),
|
||||
mem_size_(N*sizeof(T)),
|
||||
ownPartitioning_(true),
|
||||
ownData_(allocate_data),
|
||||
managed_mem_(use_managed_memory),
|
||||
allocfn_(nullptr),
|
||||
freefn_(nullptr),
|
||||
h_vec_(h_vec),
|
||||
d_vec_(d_vec)
|
||||
{
|
||||
// Set partitioning
|
||||
partStream_ = new StreamPartitioning<T, I>(N, 256);
|
||||
partReduce_ = new ReducePartitioning<T, I>(N, 256);
|
||||
|
||||
// Allocate data arrays
|
||||
if (allocate_data)
|
||||
allocate();
|
||||
}
|
||||
|
||||
Vector(I N, cudaStream_t stream,
|
||||
bool use_managed_memory = false, bool allocate_data = true,
|
||||
T* const h_vec = nullptr, T* const d_vec = nullptr)
|
||||
: size_(N),
|
||||
mem_size_(N*sizeof(T)),
|
||||
ownPartitioning_(true),
|
||||
ownData_(allocate_data),
|
||||
managed_mem_(use_managed_memory),
|
||||
allocfn_(nullptr),
|
||||
freefn_(nullptr),
|
||||
h_vec_(h_vec),
|
||||
d_vec_(d_vec)
|
||||
{
|
||||
// Set partitioning
|
||||
partStream_ = new StreamPartitioning<T, I>(N, 256, stream);
|
||||
partReduce_ = new ReducePartitioning<T, I>(N, 256, stream);
|
||||
|
||||
// Allocate data arrays
|
||||
if (allocate_data)
|
||||
allocate();
|
||||
}
|
||||
|
||||
Vector(I N,
|
||||
SUNAllocFn allocfn, SUNFreeFn freefn,
|
||||
bool allocate_data = true)
|
||||
: size_(N),
|
||||
mem_size_(N*sizeof(T)),
|
||||
ownPartitioning_(true),
|
||||
ownData_(allocate_data),
|
||||
managed_mem_(true),
|
||||
allocfn_(allocfn),
|
||||
freefn_(freefn),
|
||||
h_vec_(nullptr),
|
||||
d_vec_(nullptr)
|
||||
{
|
||||
// Set partitioning
|
||||
partStream_ = new StreamPartitioning<T, I>(N, 256);
|
||||
partReduce_ = new ReducePartitioning<T, I>(N, 256, allocfn, freefn);
|
||||
|
||||
// Allocate data arrays
|
||||
if (allocate_data)
|
||||
allocate();
|
||||
}
|
||||
|
||||
Vector(I N, cudaStream_t stream,
|
||||
SUNAllocFn allocfn, SUNFreeFn freefn,
|
||||
bool allocate_data = true)
|
||||
: size_(N),
|
||||
mem_size_(N*sizeof(T)),
|
||||
ownPartitioning_(true),
|
||||
ownData_(allocate_data),
|
||||
managed_mem_(true),
|
||||
allocfn_(allocfn),
|
||||
freefn_(freefn),
|
||||
h_vec_(nullptr),
|
||||
d_vec_(nullptr)
|
||||
{
|
||||
// Set partitioning
|
||||
partStream_ = new StreamPartitioning<T, I>(N, 256, stream);
|
||||
partReduce_ = new ReducePartitioning<T, I>(N, 256, stream, allocfn, freefn);
|
||||
|
||||
// Allocate data arrays
|
||||
if (allocate_data)
|
||||
allocate();
|
||||
}
|
||||
|
||||
// Copy constructor does not copy data array values
|
||||
explicit Vector(const Vector& v)
|
||||
: size_(v.size()),
|
||||
mem_size_(size_*sizeof(T)),
|
||||
partStream_(v.partStream_),
|
||||
partReduce_(v.partReduce_),
|
||||
ownPartitioning_(false),
|
||||
ownData_(true),
|
||||
managed_mem_(v.managed_mem_),
|
||||
allocfn_(v.allocfn_),
|
||||
freefn_(v.freefn_),
|
||||
h_vec_(nullptr),
|
||||
d_vec_(nullptr)
|
||||
{
|
||||
allocate();
|
||||
}
|
||||
|
||||
~Vector()
|
||||
{
|
||||
cudaError_t err;
|
||||
|
||||
if (ownPartitioning_) {
|
||||
delete partReduce_;
|
||||
delete partStream_;
|
||||
}
|
||||
|
||||
if (ownData_) {
|
||||
if (freefn_) {
|
||||
freefn_(d_vec_);
|
||||
d_vec_ = nullptr;
|
||||
h_vec_ = nullptr;
|
||||
} else {
|
||||
if (!managed_mem_)
|
||||
free(h_vec_);
|
||||
err = cudaFree(d_vec_);
|
||||
if(err != cudaSuccess)
|
||||
std::cerr << "Failed to free device vector "
|
||||
<< "in suncudavec::Vector::~Vector "
|
||||
<< "(error code " << err << ")\n";
|
||||
d_vec_ = nullptr;
|
||||
h_vec_ = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void allocate()
|
||||
{
|
||||
if (allocfn_) {
|
||||
allocateCustom();
|
||||
} else if (managed_mem_) {
|
||||
allocateManaged();
|
||||
} else {
|
||||
allocateUnmanaged();
|
||||
}
|
||||
}
|
||||
|
||||
void allocateManaged()
|
||||
{
|
||||
cudaError_t err;
|
||||
err = cudaMallocManaged((void**) &d_vec_, mem_size_);
|
||||
if (err != cudaSuccess)
|
||||
std::cerr << "Failed to allocate managed vector "
|
||||
<< "in suncudavec::Vector::allocateManaged "
|
||||
<< "(error code " << err << ")\n";
|
||||
h_vec_ = d_vec_;
|
||||
}
|
||||
|
||||
void allocateUnmanaged()
|
||||
{
|
||||
cudaError_t err;
|
||||
|
||||
h_vec_ = static_cast<T*>(malloc(mem_size_));
|
||||
if(h_vec_ == nullptr)
|
||||
std::cerr << "Failed to allocate host vector "
|
||||
<< "in suncudavec::Vector::allocateUnmanaged\n";
|
||||
|
||||
err = cudaMalloc((void**) &d_vec_, mem_size_);
|
||||
if(err != cudaSuccess)
|
||||
std::cerr << "Failed to allocate device vector "
|
||||
<< "in suncudavec::Vector::allocateUnmanaged "
|
||||
<< "(error code " << err << ")\n";
|
||||
}
|
||||
|
||||
void allocateCustom()
|
||||
{
|
||||
/* We assume managed memory when a custom allocator is provided */
|
||||
d_vec_ = (realtype *) allocfn_(mem_size_);
|
||||
if (d_vec_ == nullptr)
|
||||
std::cerr << "Failed to allocate vector with user-provied allocator "
|
||||
<< "in suncudavec::Vector::allocateCustom()\n";
|
||||
h_vec_ = d_vec_;
|
||||
}
|
||||
|
||||
int size() const
|
||||
{
|
||||
return size_;
|
||||
}
|
||||
|
||||
T* host()
|
||||
{
|
||||
// If the vector is using managed memory, and a user
|
||||
// is accessing a data array, then we need to synchronzie
|
||||
// to ensure all kernels have completed since a memcpy
|
||||
// won't have to happen.
|
||||
if (managed_mem_)
|
||||
cudaStreamSynchronize(partReduce_->stream());
|
||||
return h_vec_;
|
||||
}
|
||||
|
||||
const T* host() const
|
||||
{
|
||||
// If the vector is using managed memory, and a user
|
||||
// is accessing a data array, then we need to synchronzie
|
||||
// to ensure all kernels have completed since a memcpy
|
||||
// won't have to happen.
|
||||
if (managed_mem_)
|
||||
cudaStreamSynchronize(partReduce_->stream());
|
||||
return h_vec_;
|
||||
}
|
||||
|
||||
T* device()
|
||||
{
|
||||
// If the vector is using managed memory, and a user
|
||||
// is accessing a data array, then we need to synchronzie
|
||||
// to ensure all kernels have completed since a memcpy
|
||||
// won't have to happen.
|
||||
if (managed_mem_)
|
||||
cudaStreamSynchronize(partReduce_->stream());
|
||||
return d_vec_;
|
||||
}
|
||||
|
||||
const T* device() const
|
||||
{
|
||||
// If the vector is using managed memory, and a user
|
||||
// is accessing a data array, then we need to synchronzie
|
||||
// to ensure all kernels have completed since a memcpy
|
||||
// won't have to happen.
|
||||
if (managed_mem_)
|
||||
cudaStreamSynchronize(partReduce_->stream());
|
||||
return d_vec_;
|
||||
}
|
||||
|
||||
bool isManaged() const
|
||||
{
|
||||
return managed_mem_;
|
||||
}
|
||||
|
||||
void copyToDev()
|
||||
{
|
||||
cudaError_t err;
|
||||
|
||||
/* If the host and device pointers are the same, then we don't need
|
||||
to do a copy (this happens in the managed memory case), but we
|
||||
still need to synchronize the device to adhere to the unified
|
||||
memory access rules. */
|
||||
if (h_vec_ == d_vec_) {
|
||||
err = cudaStreamSynchronize(partReduce_->stream());
|
||||
if(err != cudaSuccess)
|
||||
std::cerr << "Failed to synchronize stream in "
|
||||
<< "suncudavec::Vector::copyToDev "
|
||||
<< "(error code " << err << ")\n";
|
||||
} else {
|
||||
err = cudaMemcpyAsync(d_vec_, h_vec_, mem_size_, cudaMemcpyHostToDevice,
|
||||
partReduce_->stream());
|
||||
if(err != cudaSuccess)
|
||||
std::cerr << "Failed to copy vector from host to device in "
|
||||
<< "suncudavec::Vector::copyToDev "
|
||||
<< "(error code " << err << ")\n";
|
||||
}
|
||||
}
|
||||
|
||||
void copyFromDev()
|
||||
{
|
||||
cudaError_t err;
|
||||
|
||||
/* If the host and device pointers are the same, then we don't need
|
||||
to do a copy (this happens in the managed memory case), but we
|
||||
still need to synchronize the device to adhere to the unified
|
||||
memory access rules. */
|
||||
if (h_vec_ == d_vec_) {
|
||||
err = cudaStreamSynchronize(partReduce_->stream());
|
||||
if(err != cudaSuccess)
|
||||
std::cerr << "Failed to synchronize stream in "
|
||||
<< "suncudavec::Vector::copyFromDev "
|
||||
<< "(error code " << err << ")\n";
|
||||
} else {
|
||||
err = cudaMemcpyAsync(h_vec_, d_vec_, mem_size_, cudaMemcpyDeviceToHost,
|
||||
partReduce_->stream());
|
||||
if(err != cudaSuccess)
|
||||
std::cerr << "Failed to copy vector from device to host in "
|
||||
<< "suncudavec::Vector::copyFromDev "
|
||||
<< "(error code " << err << ")\n";
|
||||
}
|
||||
}
|
||||
|
||||
void setPartitioning(ThreadPartitioning<T, I>* stream, ThreadPartitioning<T, I>* reduce)
|
||||
{
|
||||
if (ownPartitioning_) {
|
||||
delete partStream_;
|
||||
delete partReduce_;
|
||||
}
|
||||
partStream_ = stream;
|
||||
partReduce_ = reduce;
|
||||
ownPartitioning_ = false;
|
||||
}
|
||||
|
||||
ThreadPartitioning<T, I>& partStream() const
|
||||
{
|
||||
return *partStream_;
|
||||
}
|
||||
|
||||
ThreadPartitioning<T, I>& partReduce() const
|
||||
{
|
||||
return *partReduce_;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
I size_;
|
||||
I mem_size_;
|
||||
T* h_vec_;
|
||||
T* d_vec_;
|
||||
ThreadPartitioning<T, I>* partStream_;
|
||||
ThreadPartitioning<T, I>* partReduce_;
|
||||
bool ownPartitioning_;
|
||||
bool ownData_;
|
||||
bool managed_mem_;
|
||||
SUNAllocFn allocfn_;
|
||||
SUNFreeFn freefn_;
|
||||
|
||||
};
|
||||
|
||||
|
||||
} // namespace suncudavec
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // _NVECTOR_CUDA_HPP_
|
||||
189
bazaar/plugin/sundials/include/nvector/nvector_cuda.h
Normal file
189
bazaar/plugin/sundials/include/nvector/nvector_cuda.h
Normal file
|
|
@ -0,0 +1,189 @@
|
|||
/* -----------------------------------------------------------------
|
||||
* Programmer(s): Slaven Peles and Cody J. Balos @ LLNL
|
||||
* -----------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
* -----------------------------------------------------------------
|
||||
* This is the header file for the CUDA implementation of the
|
||||
* NVECTOR module.
|
||||
*
|
||||
* Notes:
|
||||
*
|
||||
* - The definition of the generic N_Vector structure can be found
|
||||
* in the header file sundials_nvector.h.
|
||||
*
|
||||
* - The definitions of the types 'realtype' and 'sunindextype' can
|
||||
* be found in the header file sundials_types.h, and it may be
|
||||
* changed (at the configuration stage) according to the user's needs.
|
||||
* The sundials_types.h file also contains the definition
|
||||
* for the type 'booleantype'.
|
||||
*
|
||||
* - N_Vector arguments to arithmetic vector operations need not
|
||||
* be distinct. For example, the following call:
|
||||
*
|
||||
* N_VLinearSum_Cuda(a,x,b,y,y);
|
||||
*
|
||||
* (which stores the result of the operation a*x+b*y in y)
|
||||
* is legal.
|
||||
* -----------------------------------------------------------------*/
|
||||
|
||||
#ifndef _NVECTOR_CUDA_H
|
||||
#define _NVECTOR_CUDA_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sundials/sundials_nvector.h>
|
||||
#include <sundials/sundials_config.h>
|
||||
|
||||
#ifdef __cplusplus /* wrapper to enable C++ usage */
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* CUDA implementation of N_Vector
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
* CUDA implementation of the N_Vector 'content' is in C++ class
|
||||
* Vector. The class inherits from structure _N_VectorContent_Cuda
|
||||
* to create C <--> C++ interface.
|
||||
*/
|
||||
|
||||
struct _N_VectorContent_Cuda {};
|
||||
|
||||
typedef struct _N_VectorContent_Cuda *N_VectorContent_Cuda;
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Functions exported by nvector_cuda
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
SUNDIALS_EXPORT N_Vector N_VNew_Cuda(sunindextype length);
|
||||
|
||||
SUNDIALS_EXPORT N_Vector N_VNewManaged_Cuda(sunindextype length);
|
||||
|
||||
SUNDIALS_EXPORT N_Vector N_VNewEmpty_Cuda();
|
||||
|
||||
SUNDIALS_EXPORT N_Vector N_VMake_Cuda(sunindextype length,
|
||||
realtype *h_vdata,
|
||||
realtype *d_vdata);
|
||||
|
||||
SUNDIALS_EXPORT N_Vector N_VMakeManaged_Cuda(sunindextype length,
|
||||
realtype *vdata);
|
||||
|
||||
SUNDIALS_EXPORT N_Vector N_VMakeWithManagedAllocator_Cuda(sunindextype length,
|
||||
void* (*allocfn)(size_t),
|
||||
void (*freefn)(void*));
|
||||
|
||||
SUNDIALS_EXPORT sunindextype N_VGetLength_Cuda(N_Vector v);
|
||||
|
||||
SUNDIALS_EXPORT realtype *N_VGetHostArrayPointer_Cuda(N_Vector v);
|
||||
|
||||
SUNDIALS_EXPORT realtype *N_VGetDeviceArrayPointer_Cuda(N_Vector v);
|
||||
|
||||
SUNDIALS_EXPORT booleantype N_VIsManagedMemory_Cuda(N_Vector x);
|
||||
|
||||
SUNDIALS_EXPORT void N_VSetCudaStream_Cuda(N_Vector x, cudaStream_t *stream);
|
||||
|
||||
SUNDIALS_EXPORT void N_VCopyToDevice_Cuda(N_Vector v);
|
||||
|
||||
SUNDIALS_EXPORT void N_VCopyFromDevice_Cuda(N_Vector v);
|
||||
|
||||
SUNDIALS_EXPORT void N_VPrint_Cuda(N_Vector v);
|
||||
|
||||
SUNDIALS_EXPORT void N_VPrintFile_Cuda(N_Vector v, FILE *outfile);
|
||||
|
||||
SUNDIALS_EXPORT N_Vector N_VCloneEmpty_Cuda(N_Vector w);
|
||||
SUNDIALS_EXPORT N_Vector N_VClone_Cuda(N_Vector w);
|
||||
SUNDIALS_EXPORT void N_VDestroy_Cuda(N_Vector v);
|
||||
SUNDIALS_EXPORT void N_VSpace_Cuda(N_Vector v, sunindextype *lrw, sunindextype *liw);
|
||||
|
||||
/* standard vector operations */
|
||||
SUNDIALS_EXPORT void N_VLinearSum_Cuda(realtype a, N_Vector x, realtype b, N_Vector y, N_Vector z);
|
||||
SUNDIALS_EXPORT void N_VConst_Cuda(realtype c, N_Vector z);
|
||||
SUNDIALS_EXPORT void N_VProd_Cuda(N_Vector x, N_Vector y, N_Vector z);
|
||||
SUNDIALS_EXPORT void N_VDiv_Cuda(N_Vector x, N_Vector y, N_Vector z);
|
||||
SUNDIALS_EXPORT void N_VScale_Cuda(realtype c, N_Vector x, N_Vector z);
|
||||
SUNDIALS_EXPORT void N_VAbs_Cuda(N_Vector x, N_Vector z);
|
||||
SUNDIALS_EXPORT void N_VInv_Cuda(N_Vector x, N_Vector z);
|
||||
SUNDIALS_EXPORT void N_VAddConst_Cuda(N_Vector x, realtype b, N_Vector z);
|
||||
SUNDIALS_EXPORT realtype N_VDotProd_Cuda(N_Vector x, N_Vector y);
|
||||
SUNDIALS_EXPORT realtype N_VMaxNorm_Cuda(N_Vector x);
|
||||
SUNDIALS_EXPORT realtype N_VWrmsNorm_Cuda(N_Vector x, N_Vector w);
|
||||
SUNDIALS_EXPORT realtype N_VWrmsNormMask_Cuda(N_Vector x, N_Vector w, N_Vector id);
|
||||
SUNDIALS_EXPORT realtype N_VMin_Cuda(N_Vector x);
|
||||
SUNDIALS_EXPORT realtype N_VWL2Norm_Cuda(N_Vector x, N_Vector w);
|
||||
SUNDIALS_EXPORT realtype N_VL1Norm_Cuda(N_Vector x);
|
||||
SUNDIALS_EXPORT void N_VCompare_Cuda(realtype c, N_Vector x, N_Vector z);
|
||||
SUNDIALS_EXPORT booleantype N_VInvTest_Cuda(N_Vector x, N_Vector z);
|
||||
SUNDIALS_EXPORT booleantype N_VConstrMask_Cuda(N_Vector c, N_Vector x, N_Vector m);
|
||||
SUNDIALS_EXPORT realtype N_VMinQuotient_Cuda(N_Vector num, N_Vector denom);
|
||||
|
||||
/* fused vector operations */
|
||||
SUNDIALS_EXPORT int N_VLinearCombination_Cuda(int nvec, realtype* c, N_Vector* X,
|
||||
N_Vector Z);
|
||||
SUNDIALS_EXPORT int N_VScaleAddMulti_Cuda(int nvec, realtype* c, N_Vector X,
|
||||
N_Vector* Y, N_Vector* Z);
|
||||
SUNDIALS_EXPORT int N_VDotProdMulti_Cuda(int nvec, N_Vector x, N_Vector* Y,
|
||||
realtype* dotprods);
|
||||
|
||||
/* vector array operations */
|
||||
SUNDIALS_EXPORT int N_VLinearSumVectorArray_Cuda(int nvec,
|
||||
realtype a, N_Vector* X,
|
||||
realtype b, N_Vector* Y,
|
||||
N_Vector* Z);
|
||||
SUNDIALS_EXPORT int N_VScaleVectorArray_Cuda(int nvec, realtype* c, N_Vector* X,
|
||||
N_Vector* Z);
|
||||
SUNDIALS_EXPORT int N_VConstVectorArray_Cuda(int nvec, realtype c, N_Vector* Z);
|
||||
SUNDIALS_EXPORT int N_VScaleAddMultiVectorArray_Cuda(int nvec, int nsum,
|
||||
realtype* a, N_Vector* X,
|
||||
N_Vector** Y, N_Vector** Z);
|
||||
SUNDIALS_EXPORT int N_VLinearCombinationVectorArray_Cuda(int nvec, int nsum,
|
||||
realtype* c,
|
||||
N_Vector** X,
|
||||
N_Vector* Z);
|
||||
SUNDIALS_EXPORT int N_VWrmsNormVectorArray_Cuda(int nvec, N_Vector* X,
|
||||
N_Vector* W, realtype* nrm);
|
||||
SUNDIALS_EXPORT int N_VWrmsNormMaskVectorArray_Cuda(int nvec, N_Vector* X,
|
||||
N_Vector* W, N_Vector id,
|
||||
realtype* nrm);
|
||||
|
||||
/* OPTIONAL local reduction kernels (no parallel communication) */
|
||||
SUNDIALS_EXPORT realtype N_VWSqrSumLocal_Cuda(N_Vector x, N_Vector w);
|
||||
SUNDIALS_EXPORT realtype N_VWSqrSumMaskLocal_Cuda(N_Vector x, N_Vector w, N_Vector id);
|
||||
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Enable / disable fused vector operations
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
SUNDIALS_EXPORT int N_VEnableFusedOps_Cuda(N_Vector v, booleantype tf);
|
||||
|
||||
SUNDIALS_EXPORT int N_VEnableLinearCombination_Cuda(N_Vector v, booleantype tf);
|
||||
SUNDIALS_EXPORT int N_VEnableScaleAddMulti_Cuda(N_Vector v, booleantype tf);
|
||||
SUNDIALS_EXPORT int N_VEnableDotProdMulti_Cuda(N_Vector v, booleantype tf);
|
||||
|
||||
SUNDIALS_EXPORT int N_VEnableLinearSumVectorArray_Cuda(N_Vector v, booleantype tf);
|
||||
SUNDIALS_EXPORT int N_VEnableScaleVectorArray_Cuda(N_Vector v, booleantype tf);
|
||||
SUNDIALS_EXPORT int N_VEnableConstVectorArray_Cuda(N_Vector v, booleantype tf);
|
||||
SUNDIALS_EXPORT int N_VEnableWrmsNormVectorArray_Cuda(N_Vector v, booleantype tf);
|
||||
SUNDIALS_EXPORT int N_VEnableWrmsNormMaskVectorArray_Cuda(N_Vector v, booleantype tf);
|
||||
SUNDIALS_EXPORT int N_VEnableScaleAddMultiVectorArray_Cuda(N_Vector v, booleantype tf);
|
||||
SUNDIALS_EXPORT int N_VEnableLinearCombinationVectorArray_Cuda(N_Vector v, booleantype tf);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
163
bazaar/plugin/sundials/include/nvector/nvector_manyvector.h
Normal file
163
bazaar/plugin/sundials/include/nvector/nvector_manyvector.h
Normal file
|
|
@ -0,0 +1,163 @@
|
|||
/* -----------------------------------------------------------------
|
||||
* Programmer(s): Daniel R. Reynolds @ SMU
|
||||
* -----------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
* -----------------------------------------------------------------
|
||||
* This is the main header file for the "ManyVector" implementation
|
||||
* of the NVECTOR module.
|
||||
*
|
||||
* Notes:
|
||||
*
|
||||
* - The definition of the generic N_Vector structure can be found
|
||||
* in the header file sundials_nvector.h.
|
||||
*
|
||||
* - The definitions of the types 'realtype' and 'sunindextype' can
|
||||
* be found in the header file sundials_types.h, and it may be
|
||||
* changed (at the configuration stage) according to the user's needs.
|
||||
* The sundials_types.h file also contains the definition
|
||||
* for the type 'booleantype'.
|
||||
*
|
||||
* - N_Vector arguments to arithmetic vector operations need not
|
||||
* be distinct. For example, the following call:
|
||||
*
|
||||
* N_VLinearSum_ManyVector(a,x,b,y,y);
|
||||
*
|
||||
* (which stores the result of the operation a*x+b*y in y)
|
||||
* is legal.
|
||||
* -----------------------------------------------------------------*/
|
||||
|
||||
#ifndef _NVECTOR_MANY_VECTOR_H
|
||||
#define _NVECTOR_MANY_VECTOR_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sundials/sundials_nvector.h>
|
||||
|
||||
#ifdef __cplusplus /* wrapper to enable C++ usage */
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* -----------------------------------------------------------------
|
||||
ManyVector implementation of N_Vector
|
||||
----------------------------------------------------------------- */
|
||||
|
||||
struct _N_VectorContent_ManyVector {
|
||||
sunindextype num_subvectors; /* number of vectors attached */
|
||||
sunindextype global_length; /* overall manyvector length */
|
||||
N_Vector* subvec_array; /* pointer to N_Vector array */
|
||||
booleantype own_data; /* flag indicating data ownership */
|
||||
};
|
||||
|
||||
typedef struct _N_VectorContent_ManyVector *N_VectorContent_ManyVector;
|
||||
|
||||
/* -----------------------------------------------------------------
|
||||
functions exported by ManyVector
|
||||
----------------------------------------------------------------- */
|
||||
|
||||
SUNDIALS_EXPORT N_Vector N_VNew_ManyVector(sunindextype num_subvectors,
|
||||
N_Vector *vec_array);
|
||||
|
||||
SUNDIALS_EXPORT N_Vector N_VGetSubvector_ManyVector(N_Vector v,
|
||||
sunindextype vec_num);
|
||||
|
||||
SUNDIALS_EXPORT realtype *N_VGetSubvectorArrayPointer_ManyVector(N_Vector v,
|
||||
sunindextype vec_num);
|
||||
|
||||
SUNDIALS_EXPORT int N_VSetSubvectorArrayPointer_ManyVector(realtype *v_data, N_Vector v,
|
||||
sunindextype vec_num);
|
||||
|
||||
SUNDIALS_EXPORT sunindextype N_VGetNumSubvectors_ManyVector(N_Vector v);
|
||||
|
||||
/* standard vector operations */
|
||||
SUNDIALS_EXPORT N_Vector_ID N_VGetVectorID_ManyVector(N_Vector v);
|
||||
SUNDIALS_EXPORT N_Vector N_VCloneEmpty_ManyVector(N_Vector w);
|
||||
SUNDIALS_EXPORT N_Vector N_VClone_ManyVector(N_Vector w);
|
||||
SUNDIALS_EXPORT void N_VDestroy_ManyVector(N_Vector v);
|
||||
SUNDIALS_EXPORT void N_VSpace_ManyVector(N_Vector v, sunindextype *lrw,
|
||||
sunindextype *liw);
|
||||
SUNDIALS_EXPORT sunindextype N_VGetLength_ManyVector(N_Vector v);
|
||||
SUNDIALS_EXPORT void N_VLinearSum_ManyVector(realtype a, N_Vector x,
|
||||
realtype b, N_Vector y,
|
||||
N_Vector z);
|
||||
SUNDIALS_EXPORT void N_VConst_ManyVector(realtype c, N_Vector z);
|
||||
SUNDIALS_EXPORT void N_VProd_ManyVector(N_Vector x, N_Vector y, N_Vector z);
|
||||
SUNDIALS_EXPORT void N_VDiv_ManyVector(N_Vector x, N_Vector y, N_Vector z);
|
||||
SUNDIALS_EXPORT void N_VScale_ManyVector(realtype c, N_Vector x, N_Vector z);
|
||||
SUNDIALS_EXPORT void N_VAbs_ManyVector(N_Vector x, N_Vector z);
|
||||
SUNDIALS_EXPORT void N_VInv_ManyVector(N_Vector x, N_Vector z);
|
||||
SUNDIALS_EXPORT void N_VAddConst_ManyVector(N_Vector x, realtype b,
|
||||
N_Vector z);
|
||||
SUNDIALS_EXPORT realtype N_VWrmsNorm_ManyVector(N_Vector x, N_Vector w);
|
||||
SUNDIALS_EXPORT realtype N_VWrmsNormMask_ManyVector(N_Vector x, N_Vector w,
|
||||
N_Vector id);
|
||||
SUNDIALS_EXPORT realtype N_VWL2Norm_ManyVector(N_Vector x, N_Vector w);
|
||||
SUNDIALS_EXPORT void N_VCompare_ManyVector(realtype c, N_Vector x, N_Vector z);
|
||||
|
||||
/* fused vector operations */
|
||||
SUNDIALS_EXPORT int N_VLinearCombination_ManyVector(int nvec, realtype* c,
|
||||
N_Vector* V, N_Vector z);
|
||||
SUNDIALS_EXPORT int N_VScaleAddMulti_ManyVector(int nvec, realtype* a,
|
||||
N_Vector x, N_Vector* Y,
|
||||
N_Vector* Z);
|
||||
SUNDIALS_EXPORT int N_VDotProdMulti_ManyVector(int nvec, N_Vector x,
|
||||
N_Vector *Y,
|
||||
realtype* dotprods);
|
||||
|
||||
/* vector array operations */
|
||||
SUNDIALS_EXPORT int N_VLinearSumVectorArray_ManyVector(int nvec,
|
||||
realtype a, N_Vector* X,
|
||||
realtype b, N_Vector* Y,
|
||||
N_Vector* Z);
|
||||
SUNDIALS_EXPORT int N_VScaleVectorArray_ManyVector(int nvec, realtype* c,
|
||||
N_Vector* X, N_Vector* Z);
|
||||
SUNDIALS_EXPORT int N_VConstVectorArray_ManyVector(int nvecs, realtype c,
|
||||
N_Vector* Z);
|
||||
SUNDIALS_EXPORT int N_VWrmsNormVectorArray_ManyVector(int nvecs, N_Vector* X,
|
||||
N_Vector* W, realtype* nrm);
|
||||
SUNDIALS_EXPORT int N_VWrmsNormMaskVectorArray_ManyVector(int nvec,
|
||||
N_Vector* X,
|
||||
N_Vector* W,
|
||||
N_Vector id,
|
||||
realtype* nrm);
|
||||
|
||||
/* OPTIONAL local reduction kernels (no parallel communication) */
|
||||
SUNDIALS_EXPORT realtype N_VDotProdLocal_ManyVector(N_Vector x, N_Vector y);
|
||||
SUNDIALS_EXPORT realtype N_VMaxNormLocal_ManyVector(N_Vector x);
|
||||
SUNDIALS_EXPORT realtype N_VMinLocal_ManyVector(N_Vector x);
|
||||
SUNDIALS_EXPORT realtype N_VL1NormLocal_ManyVector(N_Vector x);
|
||||
SUNDIALS_EXPORT realtype N_VWSqrSumLocal_ManyVector(N_Vector x, N_Vector w);
|
||||
SUNDIALS_EXPORT realtype N_VWSqrSumMaskLocal_ManyVector(N_Vector x, N_Vector w,
|
||||
N_Vector id);
|
||||
SUNDIALS_EXPORT booleantype N_VInvTestLocal_ManyVector(N_Vector x, N_Vector z);
|
||||
SUNDIALS_EXPORT booleantype N_VConstrMaskLocal_ManyVector(N_Vector c, N_Vector x,
|
||||
N_Vector m);
|
||||
SUNDIALS_EXPORT realtype N_VMinQuotientLocal_ManyVector(N_Vector num,
|
||||
N_Vector denom);
|
||||
|
||||
/* -----------------------------------------------------------------
|
||||
Enable / disable fused vector operations
|
||||
----------------------------------------------------------------- */
|
||||
|
||||
SUNDIALS_EXPORT int N_VEnableFusedOps_ManyVector(N_Vector v, booleantype tf);
|
||||
|
||||
SUNDIALS_EXPORT int N_VEnableLinearCombination_ManyVector(N_Vector v, booleantype tf);
|
||||
SUNDIALS_EXPORT int N_VEnableScaleAddMulti_ManyVector(N_Vector v, booleantype tf);
|
||||
SUNDIALS_EXPORT int N_VEnableDotProdMulti_ManyVector(N_Vector v, booleantype tf);
|
||||
|
||||
SUNDIALS_EXPORT int N_VEnableLinearSumVectorArray_ManyVector(N_Vector v, booleantype tf);
|
||||
SUNDIALS_EXPORT int N_VEnableScaleVectorArray_ManyVector(N_Vector v, booleantype tf);
|
||||
SUNDIALS_EXPORT int N_VEnableConstVectorArray_ManyVector(N_Vector v, booleantype tf);
|
||||
SUNDIALS_EXPORT int N_VEnableWrmsNormVectorArray_ManyVector(N_Vector v, booleantype tf);
|
||||
SUNDIALS_EXPORT int N_VEnableWrmsNormMaskVectorArray_ManyVector(N_Vector v, booleantype tf);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
203
bazaar/plugin/sundials/include/nvector/nvector_openmp.h
Normal file
203
bazaar/plugin/sundials/include/nvector/nvector_openmp.h
Normal file
|
|
@ -0,0 +1,203 @@
|
|||
/* -----------------------------------------------------------------
|
||||
* Programmer(s): David J. Gardner and Carol S. Woodward @ LLNL
|
||||
* -----------------------------------------------------------------
|
||||
* Acknowledgements: This NVECTOR module is based on the NVECTOR
|
||||
* Serial module by Scott D. Cohen, Alan C.
|
||||
* Hindmarsh, Radu Serban, and Aaron Collier
|
||||
* @ LLNL
|
||||
* -----------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
* -----------------------------------------------------------------
|
||||
* This is the header file for the OpenMP implementation of the
|
||||
* NVECTOR module.
|
||||
*
|
||||
* Notes:
|
||||
*
|
||||
* - The definition of the generic N_Vector structure can be found
|
||||
* in the header file sundials_nvector.h.
|
||||
*
|
||||
* - The definition of the type 'realtype' can be found in the
|
||||
* header file sundials_types.h, and it may be changed (at the
|
||||
* configuration stage) according to the user's needs.
|
||||
* The sundials_types.h file also contains the definition
|
||||
* for the type 'booleantype'.
|
||||
*
|
||||
* - N_Vector arguments to arithmetic vector operations need not
|
||||
* be distinct. For example, the following call:
|
||||
*
|
||||
* N_VLinearSum_OpenMP(a,x,b,y,y);
|
||||
*
|
||||
* (which stores the result of the operation a*x+b*y in y)
|
||||
* is legal.
|
||||
* -----------------------------------------------------------------*/
|
||||
|
||||
#ifndef _NVECTOR_OPENMP_H
|
||||
#define _NVECTOR_OPENMP_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sundials/sundials_nvector.h>
|
||||
|
||||
#ifdef __cplusplus /* wrapper to enable C++ usage */
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* OpenMP implementation of N_Vector
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
struct _N_VectorContent_OpenMP {
|
||||
sunindextype length; /* vector length */
|
||||
booleantype own_data; /* data ownership flag */
|
||||
realtype *data; /* data array */
|
||||
int num_threads; /* number of OpenMP threads */
|
||||
};
|
||||
|
||||
typedef struct _N_VectorContent_OpenMP *N_VectorContent_OpenMP;
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Macros NV_CONTENT_OMP, NV_DATA_OMP, NV_OWN_DATA_OMP,
|
||||
* NV_LENGTH_OMP, and NV_Ith_OMP
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#define NV_CONTENT_OMP(v) ( (N_VectorContent_OpenMP)(v->content) )
|
||||
|
||||
#define NV_LENGTH_OMP(v) ( NV_CONTENT_OMP(v)->length )
|
||||
|
||||
#define NV_NUM_THREADS_OMP(v) ( NV_CONTENT_OMP(v)->num_threads )
|
||||
|
||||
#define NV_OWN_DATA_OMP(v) ( NV_CONTENT_OMP(v)->own_data )
|
||||
|
||||
#define NV_DATA_OMP(v) ( NV_CONTENT_OMP(v)->data )
|
||||
|
||||
#define NV_Ith_OMP(v,i) ( NV_DATA_OMP(v)[i] )
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Functions exported by nvector_openmp
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
SUNDIALS_EXPORT N_Vector N_VNew_OpenMP(sunindextype vec_length, int num_threads);
|
||||
|
||||
SUNDIALS_EXPORT N_Vector N_VNewEmpty_OpenMP(sunindextype vec_length, int num_threads);
|
||||
|
||||
SUNDIALS_EXPORT N_Vector N_VMake_OpenMP(sunindextype vec_length, realtype *v_data,
|
||||
int num_threads);
|
||||
|
||||
SUNDIALS_EXPORT N_Vector* N_VCloneVectorArray_OpenMP(int count, N_Vector w);
|
||||
|
||||
SUNDIALS_EXPORT N_Vector* N_VCloneVectorArrayEmpty_OpenMP(int count, N_Vector w);
|
||||
|
||||
SUNDIALS_EXPORT void N_VDestroyVectorArray_OpenMP(N_Vector* vs, int count);
|
||||
|
||||
SUNDIALS_EXPORT sunindextype N_VGetLength_OpenMP(N_Vector v);
|
||||
|
||||
SUNDIALS_EXPORT void N_VPrint_OpenMP(N_Vector v);
|
||||
|
||||
SUNDIALS_EXPORT void N_VPrintFile_OpenMP(N_Vector v, FILE *outfile);
|
||||
|
||||
|
||||
SUNDIALS_EXPORT N_Vector_ID N_VGetVectorID_OpenMP(N_Vector v);
|
||||
SUNDIALS_EXPORT N_Vector N_VCloneEmpty_OpenMP(N_Vector w);
|
||||
SUNDIALS_EXPORT N_Vector N_VClone_OpenMP(N_Vector w);
|
||||
SUNDIALS_EXPORT void N_VDestroy_OpenMP(N_Vector v);
|
||||
SUNDIALS_EXPORT void N_VSpace_OpenMP(N_Vector v, sunindextype *lrw, sunindextype *liw);
|
||||
SUNDIALS_EXPORT realtype *N_VGetArrayPointer_OpenMP(N_Vector v);
|
||||
SUNDIALS_EXPORT void N_VSetArrayPointer_OpenMP(realtype *v_data, N_Vector v);
|
||||
|
||||
/* standard vector operations */
|
||||
SUNDIALS_EXPORT void N_VLinearSum_OpenMP(realtype a, N_Vector x, realtype b, N_Vector y, N_Vector z);
|
||||
SUNDIALS_EXPORT void N_VConst_OpenMP(realtype c, N_Vector z);
|
||||
SUNDIALS_EXPORT void N_VProd_OpenMP(N_Vector x, N_Vector y, N_Vector z);
|
||||
SUNDIALS_EXPORT void N_VDiv_OpenMP(N_Vector x, N_Vector y, N_Vector z);
|
||||
SUNDIALS_EXPORT void N_VScale_OpenMP(realtype c, N_Vector x, N_Vector z);
|
||||
SUNDIALS_EXPORT void N_VAbs_OpenMP(N_Vector x, N_Vector z);
|
||||
SUNDIALS_EXPORT void N_VInv_OpenMP(N_Vector x, N_Vector z);
|
||||
SUNDIALS_EXPORT void N_VAddConst_OpenMP(N_Vector x, realtype b, N_Vector z);
|
||||
SUNDIALS_EXPORT realtype N_VDotProd_OpenMP(N_Vector x, N_Vector y);
|
||||
SUNDIALS_EXPORT realtype N_VMaxNorm_OpenMP(N_Vector x);
|
||||
SUNDIALS_EXPORT realtype N_VWrmsNorm_OpenMP(N_Vector x, N_Vector w);
|
||||
SUNDIALS_EXPORT realtype N_VWrmsNormMask_OpenMP(N_Vector x, N_Vector w, N_Vector id);
|
||||
SUNDIALS_EXPORT realtype N_VMin_OpenMP(N_Vector x);
|
||||
SUNDIALS_EXPORT realtype N_VWL2Norm_OpenMP(N_Vector x, N_Vector w);
|
||||
SUNDIALS_EXPORT realtype N_VL1Norm_OpenMP(N_Vector x);
|
||||
SUNDIALS_EXPORT void N_VCompare_OpenMP(realtype c, N_Vector x, N_Vector z);
|
||||
SUNDIALS_EXPORT booleantype N_VInvTest_OpenMP(N_Vector x, N_Vector z);
|
||||
SUNDIALS_EXPORT booleantype N_VConstrMask_OpenMP(N_Vector c, N_Vector x, N_Vector m);
|
||||
SUNDIALS_EXPORT realtype N_VMinQuotient_OpenMP(N_Vector num, N_Vector denom);
|
||||
|
||||
/* fused vector operations */
|
||||
SUNDIALS_EXPORT int N_VLinearCombination_OpenMP(int nvec, realtype* c,
|
||||
N_Vector* V, N_Vector z);
|
||||
SUNDIALS_EXPORT int N_VScaleAddMulti_OpenMP(int nvec, realtype* a, N_Vector x,
|
||||
N_Vector* Y, N_Vector* Z);
|
||||
SUNDIALS_EXPORT int N_VDotProdMulti_OpenMP(int nvec, N_Vector x,
|
||||
N_Vector* Y, realtype* dotprods);
|
||||
|
||||
/* vector array operations */
|
||||
SUNDIALS_EXPORT int N_VLinearSumVectorArray_OpenMP(int nvec,
|
||||
realtype a, N_Vector* X,
|
||||
realtype b, N_Vector* Y,
|
||||
N_Vector* Z);
|
||||
SUNDIALS_EXPORT int N_VScaleVectorArray_OpenMP(int nvec, realtype* c,
|
||||
N_Vector* X, N_Vector* Z);
|
||||
SUNDIALS_EXPORT int N_VConstVectorArray_OpenMP(int nvecs, realtype c,
|
||||
N_Vector* Z);
|
||||
SUNDIALS_EXPORT int N_VWrmsNormVectorArray_OpenMP(int nvecs, N_Vector* X,
|
||||
N_Vector* W, realtype* nrm);
|
||||
SUNDIALS_EXPORT int N_VWrmsNormMaskVectorArray_OpenMP(int nvecs, N_Vector* X,
|
||||
N_Vector* W, N_Vector id,
|
||||
realtype* nrm);
|
||||
SUNDIALS_EXPORT int N_VScaleAddMultiVectorArray_OpenMP(int nvec, int nsum,
|
||||
realtype* a,
|
||||
N_Vector* X,
|
||||
N_Vector** Y,
|
||||
N_Vector** Z);
|
||||
SUNDIALS_EXPORT int N_VLinearCombinationVectorArray_OpenMP(int nvec, int nsum,
|
||||
realtype* c,
|
||||
N_Vector** X,
|
||||
N_Vector* Z);
|
||||
|
||||
/* OPTIONAL local reduction kernels (no parallel communication) */
|
||||
SUNDIALS_EXPORT realtype N_VWSqrSumLocal_OpenMP(N_Vector x, N_Vector w);
|
||||
SUNDIALS_EXPORT realtype N_VWSqrSumMaskLocal_OpenMP(N_Vector x, N_Vector w,
|
||||
N_Vector id);
|
||||
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Enable / disable fused vector operations
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
SUNDIALS_EXPORT int N_VEnableFusedOps_OpenMP(N_Vector v, booleantype tf);
|
||||
|
||||
SUNDIALS_EXPORT int N_VEnableLinearCombination_OpenMP(N_Vector v, booleantype tf);
|
||||
SUNDIALS_EXPORT int N_VEnableScaleAddMulti_OpenMP(N_Vector v, booleantype tf);
|
||||
SUNDIALS_EXPORT int N_VEnableDotProdMulti_OpenMP(N_Vector v, booleantype tf);
|
||||
|
||||
SUNDIALS_EXPORT int N_VEnableLinearSumVectorArray_OpenMP(N_Vector v, booleantype tf);
|
||||
SUNDIALS_EXPORT int N_VEnableScaleVectorArray_OpenMP(N_Vector v, booleantype tf);
|
||||
SUNDIALS_EXPORT int N_VEnableConstVectorArray_OpenMP(N_Vector v, booleantype tf);
|
||||
SUNDIALS_EXPORT int N_VEnableWrmsNormVectorArray_OpenMP(N_Vector v, booleantype tf);
|
||||
SUNDIALS_EXPORT int N_VEnableWrmsNormMaskVectorArray_OpenMP(N_Vector v, booleantype tf);
|
||||
SUNDIALS_EXPORT int N_VEnableScaleAddMultiVectorArray_OpenMP(N_Vector v, booleantype tf);
|
||||
SUNDIALS_EXPORT int N_VEnableLinearCombinationVectorArray_OpenMP(N_Vector v, booleantype tf);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
207
bazaar/plugin/sundials/include/nvector/nvector_openmpdev.h
Normal file
207
bazaar/plugin/sundials/include/nvector/nvector_openmpdev.h
Normal file
|
|
@ -0,0 +1,207 @@
|
|||
/* -------------------------------------------------------------------
|
||||
* Programmer(s): David J. Gardner and Shelby Lockhart @ LLNL
|
||||
* -------------------------------------------------------------------
|
||||
* Acknowledgements: This NVECTOR module is based on the NVECTOR
|
||||
* Serial module by Scott D. Cohen, Alan C.
|
||||
* Hindmarsh, Radu Serban, and Aaron Collier
|
||||
* @ LLNL
|
||||
* -------------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
* -----------------------------------------------------------------
|
||||
* This is the header file for the OpenMP 4.5+ implementation of the
|
||||
* NVECTOR module.
|
||||
*
|
||||
* Notes:
|
||||
*
|
||||
* - The definition of the generic N_Vector structure can be found
|
||||
* in the header file sundials_nvector.h.
|
||||
*
|
||||
* - The definition of the type 'realtype' can be found in the
|
||||
* header file sundials_types.h, and it may be changed (at the
|
||||
* configuration stage) according to the user's needs.
|
||||
* The sundials_types.h file also contains the definition
|
||||
* for the type 'booleantype'.
|
||||
*
|
||||
* - N_Vector arguments to arithmetic vector operations need not
|
||||
* be distinct. For example, the following call:
|
||||
*
|
||||
* N_VLinearSum_OpenMPDEV(a,x,b,y,y);
|
||||
*
|
||||
* (which stores the result of the operation a*x+b*y in y)
|
||||
* is legal.
|
||||
* -----------------------------------------------------------------*/
|
||||
|
||||
#ifndef _NVECTOR_OPENMPDEV_H
|
||||
#define _NVECTOR_OPENMPDEV_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sundials/sundials_nvector.h>
|
||||
|
||||
#ifdef __cplusplus /* wrapper to enable C++ usage */
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* OpenMPDEV implementation of N_Vector
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
struct _N_VectorContent_OpenMPDEV {
|
||||
sunindextype length; /* vector length */
|
||||
booleantype own_data; /* data ownership flag */
|
||||
realtype *host_data; /* host data array */
|
||||
realtype *dev_data; /* device data array */
|
||||
};
|
||||
|
||||
typedef struct _N_VectorContent_OpenMPDEV *N_VectorContent_OpenMPDEV;
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Macros NV_CONTENT_OMPDEV, NV_DATA_HOST_OMPDEV, NV_OWN_DATA_OMPDEV,
|
||||
* NV_LENGTH_OMPDEV, and NV_Ith_OMPDEV
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#define NV_CONTENT_OMPDEV(v) ( (N_VectorContent_OpenMPDEV)(v->content) )
|
||||
|
||||
#define NV_LENGTH_OMPDEV(v) ( NV_CONTENT_OMPDEV(v)->length )
|
||||
|
||||
#define NV_OWN_DATA_OMPDEV(v) ( NV_CONTENT_OMPDEV(v)->own_data )
|
||||
|
||||
#define NV_DATA_HOST_OMPDEV(v) ( NV_CONTENT_OMPDEV(v)->host_data )
|
||||
|
||||
#define NV_DATA_DEV_OMPDEV(v) ( NV_CONTENT_OMPDEV(v)->dev_data )
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Functions exported by nvector_openmpdev
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
SUNDIALS_EXPORT N_Vector N_VNew_OpenMPDEV(sunindextype vec_length);
|
||||
|
||||
SUNDIALS_EXPORT N_Vector N_VNewEmpty_OpenMPDEV(sunindextype vec_length);
|
||||
|
||||
SUNDIALS_EXPORT N_Vector N_VMake_OpenMPDEV(sunindextype vec_length,
|
||||
realtype *h_data,
|
||||
realtype *v_data);
|
||||
|
||||
SUNDIALS_EXPORT N_Vector *N_VCloneVectorArray_OpenMPDEV(int count, N_Vector w);
|
||||
|
||||
SUNDIALS_EXPORT N_Vector *N_VCloneVectorArrayEmpty_OpenMPDEV(int count, N_Vector w);
|
||||
|
||||
SUNDIALS_EXPORT void N_VDestroyVectorArray_OpenMPDEV(N_Vector *vs, int count);
|
||||
|
||||
SUNDIALS_EXPORT sunindextype N_VGetLength_OpenMPDEV(N_Vector v);
|
||||
|
||||
SUNDIALS_EXPORT realtype *N_VGetHostArrayPointer_OpenMPDEV(N_Vector v);
|
||||
|
||||
SUNDIALS_EXPORT realtype *N_VGetDeviceArrayPointer_OpenMPDEV(N_Vector v);
|
||||
|
||||
SUNDIALS_EXPORT void N_VPrint_OpenMPDEV(N_Vector v);
|
||||
|
||||
SUNDIALS_EXPORT void N_VPrintFile_OpenMPDEV(N_Vector v, FILE *outfile);
|
||||
|
||||
SUNDIALS_EXPORT void N_VCopyToDevice_OpenMPDEV(N_Vector v);
|
||||
|
||||
SUNDIALS_EXPORT void N_VCopyFromDevice_OpenMPDEV(N_Vector v);
|
||||
|
||||
SUNDIALS_EXPORT N_Vector_ID N_VGetVectorID_OpenMPDEV(N_Vector v);
|
||||
SUNDIALS_EXPORT N_Vector N_VCloneEmpty_OpenMPDEV(N_Vector w);
|
||||
SUNDIALS_EXPORT N_Vector N_VClone_OpenMPDEV(N_Vector w);
|
||||
SUNDIALS_EXPORT void N_VDestroy_OpenMPDEV(N_Vector v);
|
||||
SUNDIALS_EXPORT void N_VSpace_OpenMPDEV(N_Vector v, sunindextype *lrw, sunindextype *liw);
|
||||
|
||||
/* standard vector operations */
|
||||
SUNDIALS_EXPORT void N_VLinearSum_OpenMPDEV(realtype a, N_Vector x, realtype b, N_Vector y, N_Vector z);
|
||||
SUNDIALS_EXPORT void N_VConst_OpenMPDEV(realtype c, N_Vector z);
|
||||
SUNDIALS_EXPORT void N_VProd_OpenMPDEV(N_Vector x, N_Vector y, N_Vector z);
|
||||
SUNDIALS_EXPORT void N_VDiv_OpenMPDEV(N_Vector x, N_Vector y, N_Vector z);
|
||||
SUNDIALS_EXPORT void N_VScale_OpenMPDEV(realtype c, N_Vector x, N_Vector z);
|
||||
SUNDIALS_EXPORT void N_VAbs_OpenMPDEV(N_Vector x, N_Vector z);
|
||||
SUNDIALS_EXPORT void N_VInv_OpenMPDEV(N_Vector x, N_Vector z);
|
||||
SUNDIALS_EXPORT void N_VAddConst_OpenMPDEV(N_Vector x, realtype b, N_Vector z);
|
||||
SUNDIALS_EXPORT realtype N_VDotProd_OpenMPDEV(N_Vector x, N_Vector y);
|
||||
SUNDIALS_EXPORT realtype N_VMaxNorm_OpenMPDEV(N_Vector x);
|
||||
SUNDIALS_EXPORT realtype N_VWrmsNorm_OpenMPDEV(N_Vector x, N_Vector w);
|
||||
SUNDIALS_EXPORT realtype N_VWrmsNormMask_OpenMPDEV(N_Vector x, N_Vector w, N_Vector id);
|
||||
SUNDIALS_EXPORT realtype N_VMin_OpenMPDEV(N_Vector x);
|
||||
SUNDIALS_EXPORT realtype N_VWL2Norm_OpenMPDEV(N_Vector x, N_Vector w);
|
||||
SUNDIALS_EXPORT realtype N_VL1Norm_OpenMPDEV(N_Vector x);
|
||||
SUNDIALS_EXPORT void N_VCompare_OpenMPDEV(realtype c, N_Vector x, N_Vector z);
|
||||
SUNDIALS_EXPORT booleantype N_VInvTest_OpenMPDEV(N_Vector x, N_Vector z);
|
||||
SUNDIALS_EXPORT booleantype N_VConstrMask_OpenMPDEV(N_Vector c, N_Vector x, N_Vector m);
|
||||
SUNDIALS_EXPORT realtype N_VMinQuotient_OpenMPDEV(N_Vector num, N_Vector denom);
|
||||
|
||||
/* fused vector operations */
|
||||
SUNDIALS_EXPORT int N_VLinearCombination_OpenMPDEV(int nvec, realtype* c,
|
||||
N_Vector* V, N_Vector z);
|
||||
SUNDIALS_EXPORT int N_VScaleAddMulti_OpenMPDEV(int nvec, realtype* a, N_Vector x,
|
||||
N_Vector* Y, N_Vector* Z);
|
||||
SUNDIALS_EXPORT int N_VDotProdMulti_OpenMPDEV(int nvec, N_Vector x,
|
||||
N_Vector *Y, realtype* dotprods);
|
||||
|
||||
/* vector array operations */
|
||||
SUNDIALS_EXPORT int N_VLinearSumVectorArray_OpenMPDEV(int nvec,
|
||||
realtype a, N_Vector* X,
|
||||
realtype b, N_Vector* Y,
|
||||
N_Vector* Z);
|
||||
SUNDIALS_EXPORT int N_VScaleVectorArray_OpenMPDEV(int nvec, realtype* c,
|
||||
N_Vector* X, N_Vector* Z);
|
||||
SUNDIALS_EXPORT int N_VConstVectorArray_OpenMPDEV(int nvecs, realtype c,
|
||||
N_Vector* Z);
|
||||
SUNDIALS_EXPORT int N_VWrmsNormVectorArray_OpenMPDEV(int nvecs, N_Vector* X,
|
||||
N_Vector* W, realtype* nrm);
|
||||
SUNDIALS_EXPORT int N_VWrmsNormMaskVectorArray_OpenMPDEV(int nvecs, N_Vector* X,
|
||||
N_Vector* W, N_Vector id,
|
||||
realtype* nrm);
|
||||
SUNDIALS_EXPORT int N_VScaleAddMultiVectorArray_OpenMPDEV(int nvec, int nsum,
|
||||
realtype* a,
|
||||
N_Vector* X,
|
||||
N_Vector** Y,
|
||||
N_Vector** Z);
|
||||
SUNDIALS_EXPORT int N_VLinearCombinationVectorArray_OpenMPDEV(int nvec, int nsum,
|
||||
realtype* c,
|
||||
N_Vector** X,
|
||||
N_Vector* Z);
|
||||
|
||||
/* OPTIONAL local reduction kernels (no parallel communication) */
|
||||
SUNDIALS_EXPORT realtype N_VWSqrSumLocal_OpenMPDEV(N_Vector x, N_Vector w);
|
||||
SUNDIALS_EXPORT realtype N_VWSqrSumMaskLocal_OpenMPDEV(N_Vector x, N_Vector w,
|
||||
N_Vector id);
|
||||
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Enable / disable fused vector operations
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
SUNDIALS_EXPORT int N_VEnableFusedOps_OpenMPDEV(N_Vector v, booleantype tf);
|
||||
|
||||
SUNDIALS_EXPORT int N_VEnableLinearCombination_OpenMPDEV(N_Vector v, booleantype tf);
|
||||
SUNDIALS_EXPORT int N_VEnableScaleAddMulti_OpenMPDEV(N_Vector v, booleantype tf);
|
||||
SUNDIALS_EXPORT int N_VEnableDotProdMulti_OpenMPDEV(N_Vector v, booleantype tf);
|
||||
|
||||
SUNDIALS_EXPORT int N_VEnableLinearSumVectorArray_OpenMPDEV(N_Vector v, booleantype tf);
|
||||
SUNDIALS_EXPORT int N_VEnableScaleVectorArray_OpenMPDEV(N_Vector v, booleantype tf);
|
||||
SUNDIALS_EXPORT int N_VEnableConstVectorArray_OpenMPDEV(N_Vector v, booleantype tf);
|
||||
SUNDIALS_EXPORT int N_VEnableWrmsNormVectorArray_OpenMPDEV(N_Vector v, booleantype tf);
|
||||
SUNDIALS_EXPORT int N_VEnableWrmsNormMaskVectorArray_OpenMPDEV(N_Vector v, booleantype tf);
|
||||
SUNDIALS_EXPORT int N_VEnableScaleAddMultiVectorArray_OpenMPDEV(N_Vector v, booleantype tf);
|
||||
SUNDIALS_EXPORT int N_VEnableLinearCombinationVectorArray_OpenMPDEV(N_Vector v, booleantype tf);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
166
bazaar/plugin/sundials/include/nvector/nvector_raja.h
Normal file
166
bazaar/plugin/sundials/include/nvector/nvector_raja.h
Normal file
|
|
@ -0,0 +1,166 @@
|
|||
/* -----------------------------------------------------------------
|
||||
* Programmer(s): Slaven Peles @ LLNL
|
||||
* -----------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
* -----------------------------------------------------------------
|
||||
* This is the header file for the RAJA implementation of the
|
||||
* NVECTOR module.
|
||||
*
|
||||
* Notes:
|
||||
*
|
||||
* - The definition of the generic N_Vector structure can be found
|
||||
* in the header file sundials_nvector.h.
|
||||
*
|
||||
* - The definition of the type 'realtype' can be found in the
|
||||
* header file sundials_types.h, and it may be changed (at the
|
||||
* configuration stage) according to the user's needs.
|
||||
* The sundials_types.h file also contains the definition
|
||||
* for the type 'booleantype'.
|
||||
*
|
||||
* - N_Vector arguments to arithmetic vector operations need not
|
||||
* be distinct. For example, the following call:
|
||||
*
|
||||
* N_VLinearSum_Raja(a,x,b,y,y);
|
||||
*
|
||||
* (which stores the result of the operation a*x+b*y in y)
|
||||
* is legal.
|
||||
* -----------------------------------------------------------------*/
|
||||
|
||||
#ifndef _NVECTOR_RAJA_H
|
||||
#define _NVECTOR_RAJA_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sundials/sundials_nvector.h>
|
||||
#include <sundials/sundials_config.h>
|
||||
|
||||
#ifdef __cplusplus /* wrapper to enable C++ usage */
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* RAJA implementation of N_Vector
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* RAJA implementation of the N_Vector 'content' structure
|
||||
contains the length of the vector, a pointer to an array
|
||||
of 'realtype' components, and a flag indicating ownership of
|
||||
the data */
|
||||
|
||||
struct _N_VectorContent_Raja {};
|
||||
|
||||
typedef struct _N_VectorContent_Raja *N_VectorContent_Raja;
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Functions exported by nvector_raja
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
SUNDIALS_EXPORT N_Vector N_VNew_Raja(sunindextype length);
|
||||
|
||||
SUNDIALS_EXPORT N_Vector N_VNewEmpty_Raja();
|
||||
|
||||
SUNDIALS_EXPORT N_Vector N_VMake_Raja(N_VectorContent_Raja c);
|
||||
|
||||
SUNDIALS_EXPORT sunindextype N_VGetLength_Raja(N_Vector v);
|
||||
|
||||
SUNDIALS_EXPORT realtype *N_VGetHostArrayPointer_Raja(N_Vector v);
|
||||
|
||||
SUNDIALS_EXPORT realtype *N_VGetDeviceArrayPointer_Raja(N_Vector v);
|
||||
|
||||
SUNDIALS_EXPORT void N_VCopyToDevice_Raja(N_Vector v);
|
||||
|
||||
SUNDIALS_EXPORT void N_VCopyFromDevice_Raja(N_Vector v);
|
||||
|
||||
SUNDIALS_EXPORT void N_VPrint_Raja(N_Vector v);
|
||||
|
||||
SUNDIALS_EXPORT void N_VPrintFile_Raja(N_Vector v, FILE *outfile);
|
||||
|
||||
SUNDIALS_EXPORT N_Vector_ID N_VGetVectorID_Raja(N_Vector v);
|
||||
SUNDIALS_EXPORT N_Vector N_VCloneEmpty_Raja(N_Vector w);
|
||||
SUNDIALS_EXPORT N_Vector N_VClone_Raja(N_Vector w);
|
||||
SUNDIALS_EXPORT void N_VDestroy_Raja(N_Vector v);
|
||||
SUNDIALS_EXPORT void N_VSpace_Raja(N_Vector v, sunindextype *lrw, sunindextype *liw);
|
||||
SUNDIALS_EXPORT realtype *N_VGetArrayPointer_Raja(N_Vector v);
|
||||
SUNDIALS_EXPORT void N_VSetArrayPointer_Raja(realtype *v_data, N_Vector v);
|
||||
|
||||
/* standard vector operations */
|
||||
SUNDIALS_EXPORT void N_VLinearSum_Raja(realtype a, N_Vector x, realtype b, N_Vector y, N_Vector z);
|
||||
SUNDIALS_EXPORT void N_VConst_Raja(realtype c, N_Vector z);
|
||||
SUNDIALS_EXPORT void N_VProd_Raja(N_Vector x, N_Vector y, N_Vector z);
|
||||
SUNDIALS_EXPORT void N_VDiv_Raja(N_Vector x, N_Vector y, N_Vector z);
|
||||
SUNDIALS_EXPORT void N_VScale_Raja(realtype c, N_Vector x, N_Vector z);
|
||||
SUNDIALS_EXPORT void N_VAbs_Raja(N_Vector x, N_Vector z);
|
||||
SUNDIALS_EXPORT void N_VInv_Raja(N_Vector x, N_Vector z);
|
||||
SUNDIALS_EXPORT void N_VAddConst_Raja(N_Vector x, realtype b, N_Vector z);
|
||||
SUNDIALS_EXPORT realtype N_VDotProd_Raja(N_Vector x, N_Vector y);
|
||||
SUNDIALS_EXPORT realtype N_VMaxNorm_Raja(N_Vector x);
|
||||
SUNDIALS_EXPORT realtype N_VWrmsNorm_Raja(N_Vector x, N_Vector w);
|
||||
SUNDIALS_EXPORT realtype N_VWrmsNormMask_Raja(N_Vector x, N_Vector w, N_Vector id);
|
||||
SUNDIALS_EXPORT realtype N_VMin_Raja(N_Vector x);
|
||||
SUNDIALS_EXPORT realtype N_VWL2Norm_Raja(N_Vector x, N_Vector w);
|
||||
SUNDIALS_EXPORT realtype N_VL1Norm_Raja(N_Vector x);
|
||||
SUNDIALS_EXPORT void N_VCompare_Raja(realtype c, N_Vector x, N_Vector z);
|
||||
SUNDIALS_EXPORT booleantype N_VInvTest_Raja(N_Vector x, N_Vector z);
|
||||
SUNDIALS_EXPORT booleantype N_VConstrMask_Raja(N_Vector c, N_Vector x, N_Vector m);
|
||||
SUNDIALS_EXPORT realtype N_VMinQuotient_Raja(N_Vector num, N_Vector denom);
|
||||
|
||||
/* fused vector operations */
|
||||
SUNDIALS_EXPORT int N_VLinearCombination_Raja(int nvec, realtype* c, N_Vector* X,
|
||||
N_Vector z);
|
||||
SUNDIALS_EXPORT int N_VScaleAddMulti_Raja(int nvec, realtype* c, N_Vector x,
|
||||
N_Vector* Y, N_Vector* Z);
|
||||
|
||||
/* vector array operations */
|
||||
SUNDIALS_EXPORT int N_VLinearSumVectorArray_Raja(int nvec,
|
||||
realtype a, N_Vector* X,
|
||||
realtype b, N_Vector* Y,
|
||||
N_Vector* Z);
|
||||
SUNDIALS_EXPORT int N_VScaleVectorArray_Raja(int nvec, realtype* c, N_Vector* X,
|
||||
N_Vector* Z);
|
||||
SUNDIALS_EXPORT int N_VConstVectorArray_Raja(int nvec, realtype c, N_Vector* Z);
|
||||
SUNDIALS_EXPORT int N_VScaleAddMultiVectorArray_Raja(int nvec, int nsum,
|
||||
realtype* a,
|
||||
N_Vector* X, N_Vector** Y,
|
||||
N_Vector** Z);
|
||||
SUNDIALS_EXPORT int N_VLinearCombinationVectorArray_Raja(int nvec, int nsum,
|
||||
realtype* c,
|
||||
N_Vector** X,
|
||||
N_Vector* Z);
|
||||
|
||||
/* OPTIONAL local reduction kernels (no parallel communication) */
|
||||
SUNDIALS_EXPORT realtype N_VWSqrSumLocal_Raja(N_Vector x, N_Vector w);
|
||||
SUNDIALS_EXPORT realtype N_VWSqrSumMaskLocal_Raja(N_Vector x, N_Vector w, N_Vector id);
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Enable / disable fused vector operations
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
SUNDIALS_EXPORT int N_VEnableFusedOps_Raja(N_Vector v, booleantype tf);
|
||||
|
||||
SUNDIALS_EXPORT int N_VEnableLinearCombination_Raja(N_Vector v, booleantype tf);
|
||||
SUNDIALS_EXPORT int N_VEnableScaleAddMulti_Raja(N_Vector v, booleantype tf);
|
||||
|
||||
SUNDIALS_EXPORT int N_VEnableLinearSumVectorArray_Raja(N_Vector v, booleantype tf);
|
||||
SUNDIALS_EXPORT int N_VEnableScaleVectorArray_Raja(N_Vector v, booleantype tf);
|
||||
SUNDIALS_EXPORT int N_VEnableConstVectorArray_Raja(N_Vector v, booleantype tf);
|
||||
SUNDIALS_EXPORT int N_VEnableScaleAddMultiVectorArray_Raja(N_Vector v, booleantype tf);
|
||||
SUNDIALS_EXPORT int N_VEnableLinearCombinationVectorArray_Raja(N_Vector v, booleantype tf);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
192
bazaar/plugin/sundials/include/nvector/nvector_serial.h
Normal file
192
bazaar/plugin/sundials/include/nvector/nvector_serial.h
Normal file
|
|
@ -0,0 +1,192 @@
|
|||
/* -----------------------------------------------------------------
|
||||
* Programmer(s): Scott D. Cohen, Alan C. Hindmarsh, Radu Serban,
|
||||
* and Aaron Collier @ LLNL
|
||||
* -----------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
* -----------------------------------------------------------------
|
||||
* This is the header file for the serial implementation of the
|
||||
* NVECTOR module.
|
||||
*
|
||||
* Notes:
|
||||
*
|
||||
* - The definition of the generic N_Vector structure can be found
|
||||
* in the header file sundials_nvector.h.
|
||||
*
|
||||
* - The definition of the type 'realtype' can be found in the
|
||||
* header file sundials_types.h, and it may be changed (at the
|
||||
* configuration stage) according to the user's needs.
|
||||
* The sundials_types.h file also contains the definition
|
||||
* for the type 'booleantype'.
|
||||
*
|
||||
* - N_Vector arguments to arithmetic vector operations need not
|
||||
* be distinct. For example, the following call:
|
||||
*
|
||||
* N_VLinearSum_Serial(a,x,b,y,y);
|
||||
*
|
||||
* (which stores the result of the operation a*x+b*y in y)
|
||||
* is legal.
|
||||
* -----------------------------------------------------------------*/
|
||||
|
||||
#ifndef _NVECTOR_SERIAL_H
|
||||
#define _NVECTOR_SERIAL_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sundials/sundials_nvector.h>
|
||||
|
||||
#ifdef __cplusplus /* wrapper to enable C++ usage */
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* SERIAL implementation of N_Vector
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
struct _N_VectorContent_Serial {
|
||||
sunindextype length; /* vector length */
|
||||
booleantype own_data; /* data ownership flag */
|
||||
realtype *data; /* data array */
|
||||
};
|
||||
|
||||
typedef struct _N_VectorContent_Serial *N_VectorContent_Serial;
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Macros NV_CONTENT_S, NV_DATA_S, NV_OWN_DATA_S,
|
||||
* NV_LENGTH_S, and NV_Ith_S
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#define NV_CONTENT_S(v) ( (N_VectorContent_Serial)(v->content) )
|
||||
|
||||
#define NV_LENGTH_S(v) ( NV_CONTENT_S(v)->length )
|
||||
|
||||
#define NV_OWN_DATA_S(v) ( NV_CONTENT_S(v)->own_data )
|
||||
|
||||
#define NV_DATA_S(v) ( NV_CONTENT_S(v)->data )
|
||||
|
||||
#define NV_Ith_S(v,i) ( NV_DATA_S(v)[i] )
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Functions exported by nvector_serial
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
SUNDIALS_EXPORT N_Vector N_VNew_Serial(sunindextype vec_length);
|
||||
|
||||
SUNDIALS_EXPORT N_Vector N_VNewEmpty_Serial(sunindextype vec_length);
|
||||
|
||||
SUNDIALS_EXPORT N_Vector N_VMake_Serial(sunindextype vec_length, realtype *v_data);
|
||||
|
||||
SUNDIALS_EXPORT N_Vector* N_VCloneVectorArray_Serial(int count, N_Vector w);
|
||||
|
||||
SUNDIALS_EXPORT N_Vector* N_VCloneVectorArrayEmpty_Serial(int count, N_Vector w);
|
||||
|
||||
SUNDIALS_EXPORT void N_VDestroyVectorArray_Serial(N_Vector* vs, int count);
|
||||
|
||||
SUNDIALS_EXPORT sunindextype N_VGetLength_Serial(N_Vector v);
|
||||
|
||||
SUNDIALS_EXPORT void N_VPrint_Serial(N_Vector v);
|
||||
|
||||
SUNDIALS_EXPORT void N_VPrintFile_Serial(N_Vector v, FILE *outfile);
|
||||
|
||||
SUNDIALS_EXPORT N_Vector_ID N_VGetVectorID_Serial(N_Vector v);
|
||||
SUNDIALS_EXPORT N_Vector N_VCloneEmpty_Serial(N_Vector w);
|
||||
SUNDIALS_EXPORT N_Vector N_VClone_Serial(N_Vector w);
|
||||
SUNDIALS_EXPORT void N_VDestroy_Serial(N_Vector v);
|
||||
SUNDIALS_EXPORT void N_VSpace_Serial(N_Vector v, sunindextype *lrw, sunindextype *liw);
|
||||
SUNDIALS_EXPORT realtype *N_VGetArrayPointer_Serial(N_Vector v);
|
||||
SUNDIALS_EXPORT void N_VSetArrayPointer_Serial(realtype *v_data, N_Vector v);
|
||||
|
||||
/* standard vector operations */
|
||||
SUNDIALS_EXPORT void N_VLinearSum_Serial(realtype a, N_Vector x, realtype b, N_Vector y, N_Vector z);
|
||||
SUNDIALS_EXPORT void N_VConst_Serial(realtype c, N_Vector z);
|
||||
SUNDIALS_EXPORT void N_VProd_Serial(N_Vector x, N_Vector y, N_Vector z);
|
||||
SUNDIALS_EXPORT void N_VDiv_Serial(N_Vector x, N_Vector y, N_Vector z);
|
||||
SUNDIALS_EXPORT void N_VScale_Serial(realtype c, N_Vector x, N_Vector z);
|
||||
SUNDIALS_EXPORT void N_VAbs_Serial(N_Vector x, N_Vector z);
|
||||
SUNDIALS_EXPORT void N_VInv_Serial(N_Vector x, N_Vector z);
|
||||
SUNDIALS_EXPORT void N_VAddConst_Serial(N_Vector x, realtype b, N_Vector z);
|
||||
SUNDIALS_EXPORT realtype N_VDotProd_Serial(N_Vector x, N_Vector y);
|
||||
SUNDIALS_EXPORT realtype N_VMaxNorm_Serial(N_Vector x);
|
||||
SUNDIALS_EXPORT realtype N_VWrmsNorm_Serial(N_Vector x, N_Vector w);
|
||||
SUNDIALS_EXPORT realtype N_VWrmsNormMask_Serial(N_Vector x, N_Vector w, N_Vector id);
|
||||
SUNDIALS_EXPORT realtype N_VMin_Serial(N_Vector x);
|
||||
SUNDIALS_EXPORT realtype N_VWL2Norm_Serial(N_Vector x, N_Vector w);
|
||||
SUNDIALS_EXPORT realtype N_VL1Norm_Serial(N_Vector x);
|
||||
SUNDIALS_EXPORT void N_VCompare_Serial(realtype c, N_Vector x, N_Vector z);
|
||||
SUNDIALS_EXPORT booleantype N_VInvTest_Serial(N_Vector x, N_Vector z);
|
||||
SUNDIALS_EXPORT booleantype N_VConstrMask_Serial(N_Vector c, N_Vector x, N_Vector m);
|
||||
SUNDIALS_EXPORT realtype N_VMinQuotient_Serial(N_Vector num, N_Vector denom);
|
||||
|
||||
/* fused vector operations */
|
||||
SUNDIALS_EXPORT int N_VLinearCombination_Serial(int nvec, realtype* c, N_Vector* V,
|
||||
N_Vector z);
|
||||
SUNDIALS_EXPORT int N_VScaleAddMulti_Serial(int nvec, realtype* a, N_Vector x,
|
||||
N_Vector* Y, N_Vector* Z);
|
||||
SUNDIALS_EXPORT int N_VDotProdMulti_Serial(int nvec, N_Vector x,
|
||||
N_Vector* Y, realtype* dotprods);
|
||||
|
||||
/* vector array operations */
|
||||
SUNDIALS_EXPORT int N_VLinearSumVectorArray_Serial(int nvec,
|
||||
realtype a, N_Vector* X,
|
||||
realtype b, N_Vector* Y,
|
||||
N_Vector* Z);
|
||||
SUNDIALS_EXPORT int N_VScaleVectorArray_Serial(int nvec, realtype* c,
|
||||
N_Vector* X, N_Vector* Z);
|
||||
SUNDIALS_EXPORT int N_VConstVectorArray_Serial(int nvecs, realtype c,
|
||||
N_Vector* Z);
|
||||
SUNDIALS_EXPORT int N_VWrmsNormVectorArray_Serial(int nvecs, N_Vector* X,
|
||||
N_Vector* W, realtype* nrm);
|
||||
SUNDIALS_EXPORT int N_VWrmsNormMaskVectorArray_Serial(int nvecs, N_Vector* X,
|
||||
N_Vector* W, N_Vector id,
|
||||
realtype* nrm);
|
||||
SUNDIALS_EXPORT int N_VScaleAddMultiVectorArray_Serial(int nvec, int nsum,
|
||||
realtype* a,
|
||||
N_Vector* X,
|
||||
N_Vector** Y,
|
||||
N_Vector** Z);
|
||||
SUNDIALS_EXPORT int N_VLinearCombinationVectorArray_Serial(int nvec, int nsum,
|
||||
realtype* c,
|
||||
N_Vector** X,
|
||||
N_Vector* Z);
|
||||
|
||||
/* OPTIONAL local reduction kernels (no parallel communication) */
|
||||
SUNDIALS_EXPORT realtype N_VWSqrSumLocal_Serial(N_Vector x, N_Vector w);
|
||||
SUNDIALS_EXPORT realtype N_VWSqrSumMaskLocal_Serial(N_Vector x, N_Vector w, N_Vector id);
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Enable / disable fused vector operations
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
SUNDIALS_EXPORT int N_VEnableFusedOps_Serial(N_Vector v, booleantype tf);
|
||||
|
||||
SUNDIALS_EXPORT int N_VEnableLinearCombination_Serial(N_Vector v, booleantype tf);
|
||||
SUNDIALS_EXPORT int N_VEnableScaleAddMulti_Serial(N_Vector v, booleantype tf);
|
||||
SUNDIALS_EXPORT int N_VEnableDotProdMulti_Serial(N_Vector v, booleantype tf);
|
||||
|
||||
SUNDIALS_EXPORT int N_VEnableLinearSumVectorArray_Serial(N_Vector v, booleantype tf);
|
||||
SUNDIALS_EXPORT int N_VEnableScaleVectorArray_Serial(N_Vector v, booleantype tf);
|
||||
SUNDIALS_EXPORT int N_VEnableConstVectorArray_Serial(N_Vector v, booleantype tf);
|
||||
SUNDIALS_EXPORT int N_VEnableWrmsNormVectorArray_Serial(N_Vector v, booleantype tf);
|
||||
SUNDIALS_EXPORT int N_VEnableWrmsNormMaskVectorArray_Serial(N_Vector v, booleantype tf);
|
||||
SUNDIALS_EXPORT int N_VEnableScaleAddMultiVectorArray_Serial(N_Vector v, booleantype tf);
|
||||
SUNDIALS_EXPORT int N_VEnableLinearCombinationVectorArray_Serial(N_Vector v, booleantype tf);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
141
bazaar/plugin/sundials/include/nvector/nvector_trilinos.h
Normal file
141
bazaar/plugin/sundials/include/nvector/nvector_trilinos.h
Normal file
|
|
@ -0,0 +1,141 @@
|
|||
/* -----------------------------------------------------------------
|
||||
* Programmer(s): Slaven Peles @ LLNL
|
||||
* -----------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
* -----------------------------------------------------------------
|
||||
* This is the main header file for the Trilinos vector wrapper
|
||||
* for NVECTOR module.
|
||||
*
|
||||
* Part I contains declarations specific to the Trilinos vector wrapper
|
||||
* implementation.
|
||||
*
|
||||
* Part II contains the prototype for the constructor
|
||||
* N_VMake_Trilinos as well as Trilinos-specific prototypes
|
||||
* for various useful vector operations.
|
||||
*
|
||||
* Notes:
|
||||
*
|
||||
* - The definition of the generic N_Vector structure can be
|
||||
* found in the header file sundials_nvector.h.
|
||||
*
|
||||
* - The definition of the type realtype can be found in the
|
||||
* header file sundials_types.h, and it may be changed (at the
|
||||
* build configuration stage) according to the user's needs.
|
||||
* The sundials_types.h file also contains the definition
|
||||
* for the type booleantype.
|
||||
*
|
||||
* - N_Vector arguments to arithmetic vector operations need not
|
||||
* be distinct. For example, the following call:
|
||||
*
|
||||
* N_VLinearSum_Trilinos(a,x,b,y,y);
|
||||
*
|
||||
* (which stores the result of the operation a*x+b*y in y)
|
||||
* is legal.
|
||||
* -----------------------------------------------------------------*/
|
||||
|
||||
#ifndef _NVECTOR_TRILINOS_H
|
||||
#define _NVECTOR_TRILINOS_H
|
||||
|
||||
#include <sundials/sundials_nvector.h>
|
||||
|
||||
#ifdef __cplusplus /* wrapper to enable C++ usage */
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* PART I: N_Vector interface to Trilinos vector
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
* Dummy _N_VectorContent_Trilinos structure is used for
|
||||
* interfacing C with C++ code
|
||||
*/
|
||||
|
||||
struct _N_VectorContent_Trilinos {};
|
||||
|
||||
typedef struct _N_VectorContent_Trilinos *N_VectorContent_Trilinos;
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* PART II: functions exported by nvector_Trilinos
|
||||
*
|
||||
* CONSTRUCTORS:
|
||||
* N_VNewEmpty_Trilinos
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Function : N_VNewEmpty_Trilinos
|
||||
* -----------------------------------------------------------------
|
||||
* This function creates a new N_Vector wrapper for a Trilinos
|
||||
* vector.
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
SUNDIALS_EXPORT N_Vector N_VNewEmpty_Trilinos();
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Trilinos implementations of the vector operations
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
SUNDIALS_EXPORT N_Vector_ID N_VGetVectorID_Trilinos(N_Vector v);
|
||||
SUNDIALS_EXPORT N_Vector N_VCloneEmpty_Trilinos(N_Vector w);
|
||||
SUNDIALS_EXPORT N_Vector N_VClone_Trilinos(N_Vector w);
|
||||
SUNDIALS_EXPORT void N_VDestroy_Trilinos(N_Vector v);
|
||||
SUNDIALS_EXPORT void N_VSpace_Trilinos(N_Vector v, sunindextype *lrw, sunindextype *liw);
|
||||
SUNDIALS_EXPORT void *N_VGetCommunicator_Trilinos(N_Vector v);
|
||||
SUNDIALS_EXPORT sunindextype N_VGetLength_Trilinos(N_Vector v);
|
||||
SUNDIALS_EXPORT void N_VLinearSum_Trilinos(realtype a, N_Vector x, realtype b, N_Vector y, N_Vector z);
|
||||
SUNDIALS_EXPORT void N_VConst_Trilinos(realtype c, N_Vector z);
|
||||
SUNDIALS_EXPORT void N_VProd_Trilinos(N_Vector x, N_Vector y, N_Vector z);
|
||||
SUNDIALS_EXPORT void N_VDiv_Trilinos(N_Vector x, N_Vector y, N_Vector z);
|
||||
SUNDIALS_EXPORT void N_VScale_Trilinos(realtype c, N_Vector x, N_Vector z);
|
||||
SUNDIALS_EXPORT void N_VAbs_Trilinos(N_Vector x, N_Vector z);
|
||||
SUNDIALS_EXPORT void N_VInv_Trilinos(N_Vector x, N_Vector z);
|
||||
SUNDIALS_EXPORT void N_VAddConst_Trilinos(N_Vector x, realtype b, N_Vector z);
|
||||
SUNDIALS_EXPORT realtype N_VDotProd_Trilinos(N_Vector x, N_Vector y);
|
||||
SUNDIALS_EXPORT realtype N_VMaxNorm_Trilinos(N_Vector x);
|
||||
SUNDIALS_EXPORT realtype N_VWrmsNorm_Trilinos(N_Vector x, N_Vector w);
|
||||
SUNDIALS_EXPORT realtype N_VWrmsNormMask_Trilinos(N_Vector x, N_Vector w, N_Vector id);
|
||||
SUNDIALS_EXPORT realtype N_VMin_Trilinos(N_Vector x);
|
||||
SUNDIALS_EXPORT realtype N_VWL2Norm_Trilinos(N_Vector x, N_Vector w);
|
||||
SUNDIALS_EXPORT realtype N_VL1Norm_Trilinos(N_Vector x);
|
||||
SUNDIALS_EXPORT void N_VCompare_Trilinos(realtype c, N_Vector x, N_Vector z);
|
||||
SUNDIALS_EXPORT booleantype N_VInvTest_Trilinos(N_Vector x, N_Vector z);
|
||||
SUNDIALS_EXPORT booleantype N_VConstrMask_Trilinos(N_Vector c, N_Vector x, N_Vector m);
|
||||
SUNDIALS_EXPORT realtype N_VMinQuotient_Trilinos(N_Vector num, N_Vector denom);
|
||||
|
||||
/* OPTIONAL local reduction kernels (no parallel communication) */
|
||||
SUNDIALS_EXPORT realtype N_VDotProdLocal_Trilinos(N_Vector x, N_Vector y);
|
||||
SUNDIALS_EXPORT realtype N_VMaxNormLocal_Trilinos(N_Vector x);
|
||||
SUNDIALS_EXPORT realtype N_VMinLocal_Trilinos(N_Vector x);
|
||||
SUNDIALS_EXPORT realtype N_VL1NormLocal_Trilinos(N_Vector x);
|
||||
SUNDIALS_EXPORT realtype N_VWSqrSumLocal_Trilinos(N_Vector x, N_Vector w);
|
||||
SUNDIALS_EXPORT realtype N_VWSqrSumMaskLocal_Trilinos(N_Vector x, N_Vector w,
|
||||
N_Vector id);
|
||||
SUNDIALS_EXPORT booleantype N_VInvTestLocal_Trilinos(N_Vector x, N_Vector z);
|
||||
SUNDIALS_EXPORT booleantype N_VConstrMaskLocal_Trilinos(N_Vector c, N_Vector x,
|
||||
N_Vector m);
|
||||
SUNDIALS_EXPORT realtype N_VMinQuotientLocal_Trilinos(N_Vector num,
|
||||
N_Vector denom);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _NVECTOR_TRILINOS_H */
|
||||
128
bazaar/plugin/sundials/include/nvector/raja/Vector.hpp
Normal file
128
bazaar/plugin/sundials/include/nvector/raja/Vector.hpp
Normal file
|
|
@ -0,0 +1,128 @@
|
|||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Programmer(s): Slaven Peles @ LLNL
|
||||
* -----------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Vector class
|
||||
*
|
||||
* Manages vector data layout for RAJA implementation of N_Vector.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _NVECTOR_RAJA_HPP_
|
||||
#define _NVECTOR_RAJA_HPP_
|
||||
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
|
||||
#include <sundials/sundials_config.h>
|
||||
#include <nvector/nvector_raja.h>
|
||||
|
||||
namespace sunrajavec
|
||||
{
|
||||
|
||||
template <typename T, typename I>
|
||||
class Vector : public _N_VectorContent_Raja
|
||||
{
|
||||
public:
|
||||
Vector(I N)
|
||||
: size_(N),
|
||||
mem_size_(N*sizeof(T))
|
||||
{
|
||||
allocate();
|
||||
}
|
||||
|
||||
// Copy constructor does not copy values
|
||||
explicit Vector(const Vector& v)
|
||||
: size_(v.size()),
|
||||
mem_size_(size_*sizeof(T))
|
||||
{
|
||||
allocate();
|
||||
}
|
||||
|
||||
~Vector()
|
||||
{
|
||||
cudaError_t err;
|
||||
free(h_vec_);
|
||||
err = cudaFree(d_vec_);
|
||||
if(err != cudaSuccess)
|
||||
std::cout << "Failed to free device vector (error code " << err << ")!\n";
|
||||
}
|
||||
|
||||
|
||||
void allocate()
|
||||
{
|
||||
cudaError_t err;
|
||||
h_vec_ = static_cast<T*>(malloc(mem_size_));
|
||||
if(h_vec_ == NULL)
|
||||
std::cout << "Failed to allocate host vector!\n";
|
||||
err = cudaMalloc((void**) &d_vec_, mem_size_);
|
||||
if(err != cudaSuccess)
|
||||
std::cout << "Failed to allocate device vector (error code " << err << ")!\n";
|
||||
}
|
||||
|
||||
int size() const
|
||||
{
|
||||
return size_;
|
||||
}
|
||||
|
||||
T* host()
|
||||
{
|
||||
return h_vec_;
|
||||
}
|
||||
|
||||
const T* host() const
|
||||
{
|
||||
return h_vec_;
|
||||
}
|
||||
|
||||
T* device()
|
||||
{
|
||||
return d_vec_;
|
||||
}
|
||||
|
||||
const T* device() const
|
||||
{
|
||||
return d_vec_;
|
||||
}
|
||||
|
||||
void copyToDev()
|
||||
{
|
||||
cudaError_t err = cudaMemcpy(d_vec_, h_vec_, mem_size_, cudaMemcpyHostToDevice);
|
||||
if(err != cudaSuccess)
|
||||
std::cerr << "Failed to copy vector from host to device (error code " << err << ")!\n";
|
||||
}
|
||||
|
||||
void copyFromDev()
|
||||
{
|
||||
cudaError_t err = cudaMemcpy(h_vec_, d_vec_, mem_size_, cudaMemcpyDeviceToHost);
|
||||
if(err != cudaSuccess)
|
||||
std::cerr << "Failed to copy vector from device to host (error code " << err << ")!\n";
|
||||
}
|
||||
|
||||
private:
|
||||
I size_;
|
||||
I mem_size_;
|
||||
T* h_vec_;
|
||||
T* d_vec_;
|
||||
};
|
||||
|
||||
|
||||
} // namespace sunrajavec
|
||||
|
||||
|
||||
|
||||
#endif // _NVECTOR_RAJA_HPP_
|
||||
181
bazaar/plugin/sundials/include/sundials/sundials_band.h
Normal file
181
bazaar/plugin/sundials/include/sundials/sundials_band.h
Normal file
|
|
@ -0,0 +1,181 @@
|
|||
/* -----------------------------------------------------------------
|
||||
* Programmer(s): Alan C. Hindmarsh and Radu Serban @ LLNL
|
||||
* -----------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
* -----------------------------------------------------------------
|
||||
* This is the header file for a generic BAND linear solver
|
||||
* package, based on the DlsMat type defined in sundials_direct.h.
|
||||
*
|
||||
* There are two sets of band solver routines listed in
|
||||
* this file: one set uses type DlsMat defined below and the
|
||||
* other set uses the type realtype ** for band matrix arguments.
|
||||
* Routines that work with the type DlsMat begin with "Band".
|
||||
* Routines that work with realtype ** begin with "band".
|
||||
* -----------------------------------------------------------------*/
|
||||
|
||||
#ifndef _SUNDIALS_BAND_H
|
||||
#define _SUNDIALS_BAND_H
|
||||
|
||||
#include <sundials/sundials_direct.h>
|
||||
|
||||
#ifdef __cplusplus /* wrapper to enable C++ usage */
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Function : BandGBTRF
|
||||
* -----------------------------------------------------------------
|
||||
* Usage : ier = BandGBTRF(A, p);
|
||||
* if (ier != 0) ... A is singular
|
||||
* -----------------------------------------------------------------
|
||||
* BandGBTRF performs the LU factorization of the N by N band
|
||||
* matrix A. This is done using standard Gaussian elimination
|
||||
* with partial pivoting.
|
||||
*
|
||||
* A successful LU factorization leaves the "matrix" A and the
|
||||
* pivot array p with the following information:
|
||||
*
|
||||
* (1) p[k] contains the row number of the pivot element chosen
|
||||
* at the beginning of elimination step k, k=0, 1, ..., N-1.
|
||||
*
|
||||
* (2) If the unique LU factorization of A is given by PA = LU,
|
||||
* where P is a permutation matrix, L is a lower triangular
|
||||
* matrix with all 1's on the diagonal, and U is an upper
|
||||
* triangular matrix, then the upper triangular part of A
|
||||
* (including its diagonal) contains U and the strictly lower
|
||||
* triangular part of A contains the multipliers, I-L.
|
||||
*
|
||||
* BandGBTRF returns 0 if successful. Otherwise it encountered
|
||||
* a zero diagonal element during the factorization. In this case
|
||||
* it returns the column index (numbered from one) at which
|
||||
* it encountered the zero.
|
||||
*
|
||||
* Important Note: A must be allocated to accommodate the increase
|
||||
* in upper bandwidth that occurs during factorization. If
|
||||
* mathematically, A is a band matrix with upper bandwidth mu and
|
||||
* lower bandwidth ml, then the upper triangular factor U can
|
||||
* have upper bandwidth as big as smu = MIN(n-1,mu+ml). The lower
|
||||
* triangular factor L has lower bandwidth ml. Allocate A with
|
||||
* call A = BandAllocMat(N,mu,ml,smu), where mu, ml, and smu are
|
||||
* as defined above. The user does not have to zero the "extra"
|
||||
* storage allocated for the purpose of factorization. This will
|
||||
* handled by the BandGBTRF routine.
|
||||
*
|
||||
* BandGBTRF is only a wrapper around bandGBTRF. All work is done
|
||||
* in bandGBTRF, which works directly on the data in the DlsMat A
|
||||
* (i.e. in the field A->cols).
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
SUNDIALS_EXPORT sunindextype BandGBTRF(DlsMat A, sunindextype *p);
|
||||
SUNDIALS_EXPORT sunindextype bandGBTRF(realtype **a, sunindextype n,
|
||||
sunindextype mu, sunindextype ml,
|
||||
sunindextype smu, sunindextype *p);
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Function : BandGBTRS
|
||||
* -----------------------------------------------------------------
|
||||
* Usage : BandGBTRS(A, p, b);
|
||||
* -----------------------------------------------------------------
|
||||
* BandGBTRS solves the N-dimensional system A x = b using
|
||||
* the LU factorization in A and the pivot information in p
|
||||
* computed in BandGBTRF. The solution x is returned in b. This
|
||||
* routine cannot fail if the corresponding call to BandGBTRF
|
||||
* did not fail.
|
||||
*
|
||||
* BandGBTRS is only a wrapper around bandGBTRS which does all the
|
||||
* work directly on the data in the DlsMat A (i.e. in A->cols).
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
SUNDIALS_EXPORT void BandGBTRS(DlsMat A, sunindextype *p, realtype *b);
|
||||
SUNDIALS_EXPORT void bandGBTRS(realtype **a, sunindextype n, sunindextype smu,
|
||||
sunindextype ml, sunindextype *p, realtype *b);
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Function : BandCopy
|
||||
* -----------------------------------------------------------------
|
||||
* Usage : BandCopy(A, B, copymu, copyml);
|
||||
* -----------------------------------------------------------------
|
||||
* BandCopy copies the submatrix with upper and lower bandwidths
|
||||
* copymu, copyml of the N by N band matrix A into the N by N
|
||||
* band matrix B.
|
||||
*
|
||||
* BandCopy is a wrapper around bandCopy which accesses the data
|
||||
* in the DlsMat A and DlsMat B (i.e. the fields cols).
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
SUNDIALS_EXPORT void BandCopy(DlsMat A, DlsMat B, sunindextype copymu,
|
||||
sunindextype copyml);
|
||||
SUNDIALS_EXPORT void bandCopy(realtype **a, realtype **b, sunindextype n,
|
||||
sunindextype a_smu, sunindextype b_smu,
|
||||
sunindextype copymu, sunindextype copyml);
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Function: BandScale
|
||||
* -----------------------------------------------------------------
|
||||
* Usage : BandScale(c, A);
|
||||
* -----------------------------------------------------------------
|
||||
* A(i,j) <- c*A(i,j), j-(A->mu) <= i <= j+(A->ml).
|
||||
*
|
||||
* BandScale is a wrapper around bandScale which performs the actual
|
||||
* scaling by accessing the data in the DlsMat A (i.e. the field
|
||||
* A->cols).
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
SUNDIALS_EXPORT void BandScale(realtype c, DlsMat A);
|
||||
SUNDIALS_EXPORT void bandScale(realtype c, realtype **a, sunindextype n,
|
||||
sunindextype mu, sunindextype ml,
|
||||
sunindextype smu);
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Function: bandAddIdentity
|
||||
* -----------------------------------------------------------------
|
||||
* bandAddIdentity adds the identity matrix to the n-by-n matrix
|
||||
* stored in the realtype** arrays.
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
SUNDIALS_EXPORT void bandAddIdentity(realtype **a, sunindextype n,
|
||||
sunindextype smu);
|
||||
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Function: BandMatvec
|
||||
* -----------------------------------------------------------------
|
||||
* BandMatvec computes the matrix-vector product y = A*x, where A
|
||||
* is an M-by-N band matrix, x is a vector of length N, and y is a
|
||||
* vector of length M. No error checking is performed on the length
|
||||
* of the arrays x and y. Only y is modified in this routine.
|
||||
*
|
||||
* BandMatvec is a wrapper around bandMatvec which performs the
|
||||
* actual product by accessing the data in the DlsMat A.
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
SUNDIALS_EXPORT void BandMatvec(DlsMat A, realtype *x, realtype *y);
|
||||
SUNDIALS_EXPORT void bandMatvec(realtype **a, realtype *x, realtype *y,
|
||||
sunindextype n, sunindextype mu,
|
||||
sunindextype ml, sunindextype smu);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
135
bazaar/plugin/sundials/include/sundials/sundials_config.h
Normal file
135
bazaar/plugin/sundials/include/sundials/sundials_config.h
Normal file
|
|
@ -0,0 +1,135 @@
|
|||
/* -----------------------------------------------------------------
|
||||
* Programmer(s): Aaron Collier and Radu Serban @ LLNL
|
||||
* -----------------------------------------------------------------
|
||||
* LLNS/SMU Copyright Start
|
||||
* Copyright (c) 2002-2018, Southern Methodist University and
|
||||
* Lawrence Livermore National Security
|
||||
*
|
||||
* This work was performed under the auspices of the U.S. Department
|
||||
* of Energy by Southern Methodist University and Lawrence Livermore
|
||||
* National Laboratory under Contract DE-AC52-07NA27344.
|
||||
* Produced at Southern Methodist University and the Lawrence
|
||||
* Livermore National Laboratory.
|
||||
*
|
||||
* All rights reserved.
|
||||
* For details, see the LICENSE file.
|
||||
* LLNS/SMU Copyright End
|
||||
* -----------------------------------------------------------------
|
||||
* SUNDIALS configuration header file
|
||||
* -----------------------------------------------------------------*/
|
||||
|
||||
/* Define SUNDIALS version numbers */
|
||||
#define SUNDIALS_VERSION "5.2.0"
|
||||
#define SUNDIALS_VERSION_MAJOR 5
|
||||
#define SUNDIALS_VERSION_MINOR 2
|
||||
#define SUNDIALS_VERSION_PATCH 0
|
||||
#define SUNDIALS_VERSION_LABEL ""
|
||||
|
||||
/* FCMIX: Define Fortran name-mangling macro for C identifiers.
|
||||
* Depending on the inferred scheme, one of the following six
|
||||
* macros will be defined:
|
||||
* #define SUNDIALS_F77_FUNC(name,NAME) name
|
||||
* #define SUNDIALS_F77_FUNC(name,NAME) name ## _
|
||||
* #define SUNDIALS_F77_FUNC(name,NAME) name ## __
|
||||
* #define SUNDIALS_F77_FUNC(name,NAME) NAME
|
||||
* #define SUNDIALS_F77_FUNC(name,NAME) NAME ## _
|
||||
* #define SUNDIALS_F77_FUNC(name,NAME) NAME ## __
|
||||
*/
|
||||
|
||||
|
||||
/* FCMIX: Define Fortran name-mangling macro for C identifiers
|
||||
* which contain underscores.
|
||||
*/
|
||||
|
||||
|
||||
/* Define precision of SUNDIALS data type 'realtype'
|
||||
* Depending on the precision level, one of the following
|
||||
* three macros will be defined:
|
||||
* #define SUNDIALS_SINGLE_PRECISION 1
|
||||
* #define SUNDIALS_DOUBLE_PRECISION 1
|
||||
* #define SUNDIALS_EXTENDED_PRECISION 1
|
||||
*/
|
||||
#define SUNDIALS_DOUBLE_PRECISION 1
|
||||
|
||||
/* Define type of vector indices in SUNDIALS 'sunindextype'.
|
||||
* Depending on user choice of index type, one of the following
|
||||
* two macros will be defined:
|
||||
* #define SUNDIALS_INT64_T 1
|
||||
* #define SUNDIALS_INT32_T 1
|
||||
*/
|
||||
#define SUNDIALS_INT64_T 1
|
||||
|
||||
/* Define the type of vector indices in SUNDIALS 'sunindextype'.
|
||||
* The macro will be defined with a type of the appropriate size.
|
||||
*/
|
||||
#define SUNDIALS_INDEX_TYPE int64_t
|
||||
|
||||
/* Use generic math functions
|
||||
* If it was decided that generic math functions can be used, then
|
||||
* #define SUNDIALS_USE_GENERIC_MATH
|
||||
*/
|
||||
/* #undef SUNDIALS_USE_GENERIC_MATH */
|
||||
|
||||
/* Use POSIX timers if available.
|
||||
* #define SUNDIALS_HAVE_POSIX_TIMERS
|
||||
*/
|
||||
/* #undef SUNDIALS_HAVE_POSIX_TIMERS */
|
||||
|
||||
/* Blas/Lapack available
|
||||
* If working libraries for Blas/lapack support were found, then
|
||||
* #define SUNDIALS_BLAS_LAPACK
|
||||
*/
|
||||
/* #undef SUNDIALS_BLAS_LAPACK */
|
||||
|
||||
/* SUPERLUMT available
|
||||
* If working libraries for SUPERLUMT support were found, then
|
||||
* #define SUNDIALS_SUPERLUMT
|
||||
*/
|
||||
/* #undef SUNDIALS_SUPERLUMT */
|
||||
/* #undef SUNDIALS_SUPERLUMT_THREAD_TYPE */
|
||||
|
||||
/* SUPERLUDIST available
|
||||
* If working libraries for SUPERLUDIST support were found, then
|
||||
* #define SUNDIALS_SUPERLUDIST
|
||||
*/
|
||||
/* #undef SUNDIALS_SUPERLUDIST */
|
||||
|
||||
/* KLU available
|
||||
* If working libraries for KLU support were found, then
|
||||
* #define SUNDIALS_KLU
|
||||
*/
|
||||
/* #undef SUNDIALS_KLU */
|
||||
|
||||
/* Trilinos available
|
||||
* If working libraries for Trilinos support were found, then
|
||||
* #define SUNDIALS_TRILINOS
|
||||
*/
|
||||
/* #undef SUNDIALS_TRILINOS */
|
||||
|
||||
/* Trilinos with MPI is available, then
|
||||
* #define SUNDIALS_TRILINOS_HAVE_MPI
|
||||
*/
|
||||
/* #undef SUNDIALS_TRILINOS_HAVE_MPI */
|
||||
|
||||
/* Set if SUNDIALS is built with MPI support.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/* FNVECTOR: Allow user to specify different MPI communicator
|
||||
* If it was found that the MPI implementation supports MPI_Comm_f2c, then
|
||||
* #define SUNDIALS_MPI_COMM_F2C 1
|
||||
* otherwise
|
||||
* #define SUNDIALS_MPI_COMM_F2C 0
|
||||
*/
|
||||
#define SUNDIALS_MPI_COMM_F2C 0
|
||||
|
||||
/* Mark SUNDIALS API functions for export/import
|
||||
* When building shared SUNDIALS libraries under Windows, use
|
||||
* #define SUNDIALS_EXPORT __declspec(dllexport)
|
||||
* When linking to shared SUNDIALS libraries under Windows, use
|
||||
* #define SUNDIALS_EXPORT __declspec(dllimport)
|
||||
* In all other cases (other platforms or static libraries under
|
||||
* Windows), the SUNDIALS_EXPORT macro is empty
|
||||
*/
|
||||
#define SUNDIALS_EXPORT
|
||||
212
bazaar/plugin/sundials/include/sundials/sundials_dense.h
Normal file
212
bazaar/plugin/sundials/include/sundials/sundials_dense.h
Normal file
|
|
@ -0,0 +1,212 @@
|
|||
/* -----------------------------------------------------------------
|
||||
* Programmer: Radu Serban @ LLNL
|
||||
* -----------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
* -----------------------------------------------------------------
|
||||
* This is the header file for a generic package of DENSE matrix
|
||||
* operations, based on the DlsMat type defined in sundials_direct.h.
|
||||
*
|
||||
* There are two sets of dense solver routines listed in
|
||||
* this file: one set uses type DlsMat defined below and the
|
||||
* other set uses the type realtype ** for dense matrix arguments.
|
||||
* Routines that work with the type DlsMat begin with "Dense".
|
||||
* Routines that work with realtype** begin with "dense".
|
||||
* -----------------------------------------------------------------*/
|
||||
|
||||
#ifndef _SUNDIALS_DENSE_H
|
||||
#define _SUNDIALS_DENSE_H
|
||||
|
||||
#include <sundials/sundials_direct.h>
|
||||
|
||||
#ifdef __cplusplus /* wrapper to enable C++ usage */
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Functions: DenseGETRF and DenseGETRS
|
||||
* -----------------------------------------------------------------
|
||||
* DenseGETRF performs the LU factorization of the M by N dense
|
||||
* matrix A. This is done using standard Gaussian elimination
|
||||
* with partial (row) pivoting. Note that this applies only
|
||||
* to matrices with M >= N and full column rank.
|
||||
*
|
||||
* A successful LU factorization leaves the matrix A and the
|
||||
* pivot array p with the following information:
|
||||
*
|
||||
* (1) p[k] contains the row number of the pivot element chosen
|
||||
* at the beginning of elimination step k, k=0, 1, ..., N-1.
|
||||
*
|
||||
* (2) If the unique LU factorization of A is given by PA = LU,
|
||||
* where P is a permutation matrix, L is a lower trapezoidal
|
||||
* matrix with all 1's on the diagonal, and U is an upper
|
||||
* triangular matrix, then the upper triangular part of A
|
||||
* (including its diagonal) contains U and the strictly lower
|
||||
* trapezoidal part of A contains the multipliers, I-L.
|
||||
*
|
||||
* For square matrices (M = N), L is unit lower triangular.
|
||||
*
|
||||
* DenseGETRF returns 0 if successful. Otherwise it encountered
|
||||
* a zero diagonal element during the factorization. In this case
|
||||
* it returns the column index (numbered from one) at which
|
||||
* it encountered the zero.
|
||||
*
|
||||
* DenseGETRS solves the N-dimensional system A x = b using
|
||||
* the LU factorization in A and the pivot information in p
|
||||
* computed in DenseGETRF. The solution x is returned in b. This
|
||||
* routine cannot fail if the corresponding call to DenseGETRF
|
||||
* did not fail.
|
||||
* DenseGETRS does NOT check for a square matrix!
|
||||
*
|
||||
* -----------------------------------------------------------------
|
||||
* DenseGETRF and DenseGETRS are simply wrappers around denseGETRF
|
||||
* and denseGETRS, respectively, which perform all the work by
|
||||
* directly accessing the data in the DlsMat A (i.e. in A->cols).
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
SUNDIALS_EXPORT sunindextype DenseGETRF(DlsMat A, sunindextype *p);
|
||||
SUNDIALS_EXPORT void DenseGETRS(DlsMat A, sunindextype *p, realtype *b);
|
||||
|
||||
SUNDIALS_EXPORT sunindextype denseGETRF(realtype **a, sunindextype m,
|
||||
sunindextype n, sunindextype *p);
|
||||
SUNDIALS_EXPORT void denseGETRS(realtype **a, sunindextype n, sunindextype *p,
|
||||
realtype *b);
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Functions : DensePOTRF and DensePOTRS
|
||||
* -----------------------------------------------------------------
|
||||
* DensePOTRF computes the Cholesky factorization of a real symmetric
|
||||
* positive definite matrix A.
|
||||
* -----------------------------------------------------------------
|
||||
* DensePOTRS solves a system of linear equations A*X = B with a
|
||||
* symmetric positive definite matrix A using the Cholesky factorization
|
||||
* A = L*L**T computed by DensePOTRF.
|
||||
*
|
||||
* -----------------------------------------------------------------
|
||||
* DensePOTRF and DensePOTRS are simply wrappers around densePOTRF
|
||||
* and densePOTRS, respectively, which perform all the work by
|
||||
* directly accessing the data in the DlsMat A (i.e. the field cols)
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
SUNDIALS_EXPORT sunindextype DensePOTRF(DlsMat A);
|
||||
SUNDIALS_EXPORT void DensePOTRS(DlsMat A, realtype *b);
|
||||
|
||||
SUNDIALS_EXPORT sunindextype densePOTRF(realtype **a, sunindextype m);
|
||||
SUNDIALS_EXPORT void densePOTRS(realtype **a, sunindextype m, realtype *b);
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Functions : DenseGEQRF and DenseORMQR
|
||||
* -----------------------------------------------------------------
|
||||
* DenseGEQRF computes a QR factorization of a real M-by-N matrix A:
|
||||
* A = Q * R (with M>= N).
|
||||
*
|
||||
* DenseGEQRF requires a temporary work vector wrk of length M.
|
||||
* -----------------------------------------------------------------
|
||||
* DenseORMQR computes the product w = Q * v where Q is a real
|
||||
* orthogonal matrix defined as the product of k elementary reflectors
|
||||
*
|
||||
* Q = H(1) H(2) . . . H(k)
|
||||
*
|
||||
* as returned by DenseGEQRF. Q is an M-by-N matrix, v is a vector
|
||||
* of length N and w is a vector of length M (with M >= N).
|
||||
*
|
||||
* DenseORMQR requires a temporary work vector wrk of length M.
|
||||
*
|
||||
* -----------------------------------------------------------------
|
||||
* DenseGEQRF and DenseORMQR are simply wrappers around denseGEQRF
|
||||
* and denseORMQR, respectively, which perform all the work by
|
||||
* directly accessing the data in the DlsMat A (i.e. the field cols)
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
SUNDIALS_EXPORT int DenseGEQRF(DlsMat A, realtype *beta, realtype *wrk);
|
||||
SUNDIALS_EXPORT int DenseORMQR(DlsMat A, realtype *beta, realtype *vn,
|
||||
realtype *vm, realtype *wrk);
|
||||
|
||||
SUNDIALS_EXPORT int denseGEQRF(realtype **a, sunindextype m, sunindextype n,
|
||||
realtype *beta, realtype *wrk);
|
||||
SUNDIALS_EXPORT int denseORMQR(realtype **a, sunindextype m, sunindextype n,
|
||||
realtype *beta, realtype *v, realtype *w,
|
||||
realtype *wrk);
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Function : DenseCopy
|
||||
* -----------------------------------------------------------------
|
||||
* DenseCopy copies the contents of the M-by-N matrix A into the
|
||||
* M-by-N matrix B.
|
||||
*
|
||||
* DenseCopy is a wrapper around denseCopy which accesses the data
|
||||
* in the DlsMat A and DlsMat B (i.e. the fields cols)
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
SUNDIALS_EXPORT void DenseCopy(DlsMat A, DlsMat B);
|
||||
SUNDIALS_EXPORT void denseCopy(realtype **a, realtype **b, sunindextype m,
|
||||
sunindextype n);
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Function: DenseScale
|
||||
* -----------------------------------------------------------------
|
||||
* DenseScale scales the elements of the M-by-N matrix A by the
|
||||
* constant c and stores the result back in A.
|
||||
*
|
||||
* DenseScale is a wrapper around denseScale which performs the actual
|
||||
* scaling by accessing the data in the DlsMat A (i.e. in A->cols).
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
SUNDIALS_EXPORT void DenseScale(realtype c, DlsMat A);
|
||||
SUNDIALS_EXPORT void denseScale(realtype c, realtype **a, sunindextype m,
|
||||
sunindextype n);
|
||||
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Function: denseAddIdentity
|
||||
* -----------------------------------------------------------------
|
||||
* denseAddIdentity adds the identity matrix to the n-by-n matrix
|
||||
* stored in a realtype** array.
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
SUNDIALS_EXPORT void denseAddIdentity(realtype **a, sunindextype n);
|
||||
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Function: DenseMatvec
|
||||
* -----------------------------------------------------------------
|
||||
* DenseMatvec computes the matrix-vector product y = A*x, where A
|
||||
* is an M-by-N matrix, x is a vector of length N, and y is a vector
|
||||
* of length M. No error checking is performed on the length of the
|
||||
* arrays x and y. Only y is modified in this routine.
|
||||
*
|
||||
* DenseMatvec is a wrapper around denseMatvec which performs the
|
||||
* actual product by accessing the data in the DlsMat A.
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
SUNDIALS_EXPORT void DenseMatvec(DlsMat A, realtype *x, realtype *y);
|
||||
SUNDIALS_EXPORT void denseMatvec(realtype **a, realtype *x, realtype *y,
|
||||
sunindextype m, sunindextype n);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
339
bazaar/plugin/sundials/include/sundials/sundials_direct.h
Normal file
339
bazaar/plugin/sundials/include/sundials/sundials_direct.h
Normal file
|
|
@ -0,0 +1,339 @@
|
|||
/* -----------------------------------------------------------------
|
||||
* Programmer: Radu Serban @ LLNL
|
||||
* -----------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
* -----------------------------------------------------------------
|
||||
* This header file contains definitions and declarations for use by
|
||||
* generic direct linear solvers for Ax = b. It defines types for
|
||||
* dense and banded matrices and corresponding accessor macros.
|
||||
* -----------------------------------------------------------------*/
|
||||
|
||||
#ifndef _SUNDIALS_DIRECT_H
|
||||
#define _SUNDIALS_DIRECT_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sundials/sundials_types.h>
|
||||
|
||||
#ifdef __cplusplus /* wrapper to enable C++ usage */
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* =================================================================
|
||||
* C O N S T A N T S
|
||||
* =================================================================
|
||||
*/
|
||||
|
||||
/*
|
||||
* SUNDIALS_DENSE: dense matrix
|
||||
* SUNDIALS_BAND: banded matrix
|
||||
*/
|
||||
|
||||
#define SUNDIALS_DENSE 1
|
||||
#define SUNDIALS_BAND 2
|
||||
|
||||
/*
|
||||
* ==================================================================
|
||||
* Type definitions
|
||||
* ==================================================================
|
||||
*/
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Type : DlsMat
|
||||
* -----------------------------------------------------------------
|
||||
* The type DlsMat is defined to be a pointer to a structure
|
||||
* with various sizes, a data field, and an array of pointers to
|
||||
* the columns which defines a dense or band matrix for use in
|
||||
* direct linear solvers. The M and N fields indicates the number
|
||||
* of rows and columns, respectively. The data field is a one
|
||||
* dimensional array used for component storage. The cols field
|
||||
* stores the pointers in data for the beginning of each column.
|
||||
* -----------------------------------------------------------------
|
||||
* For DENSE matrices, the relevant fields in DlsMat are:
|
||||
* type = SUNDIALS_DENSE
|
||||
* M - number of rows
|
||||
* N - number of columns
|
||||
* ldim - leading dimension (ldim >= M)
|
||||
* data - pointer to a contiguous block of realtype variables
|
||||
* ldata - length of the data array =ldim*N
|
||||
* cols - array of pointers. cols[j] points to the first element
|
||||
* of the j-th column of the matrix in the array data.
|
||||
*
|
||||
* The elements of a dense matrix are stored columnwise (i.e. columns
|
||||
* are stored one on top of the other in memory).
|
||||
* If A is of type DlsMat, then the (i,j)th element of A (with
|
||||
* 0 <= i < M and 0 <= j < N) is given by (A->data)[j*n+i].
|
||||
*
|
||||
* The DENSE_COL and DENSE_ELEM macros below allow a user to access
|
||||
* efficiently individual matrix elements without writing out explicit
|
||||
* data structure references and without knowing too much about the
|
||||
* underlying element storage. The only storage assumption needed is
|
||||
* that elements are stored columnwise and that a pointer to the
|
||||
* jth column of elements can be obtained via the DENSE_COL macro.
|
||||
* -----------------------------------------------------------------
|
||||
* For BAND matrices, the relevant fields in DlsMat are:
|
||||
* type = SUNDIALS_BAND
|
||||
* M - number of rows
|
||||
* N - number of columns
|
||||
* mu - upper bandwidth, 0 <= mu <= min(M,N)
|
||||
* ml - lower bandwidth, 0 <= ml <= min(M,N)
|
||||
* s_mu - storage upper bandwidth, mu <= s_mu <= N-1.
|
||||
* The dgbtrf routine writes the LU factors into the storage
|
||||
* for A. The upper triangular factor U, however, may have
|
||||
* an upper bandwidth as big as MIN(N-1,mu+ml) because of
|
||||
* partial pivoting. The s_mu field holds the upper
|
||||
* bandwidth allocated for A.
|
||||
* ldim - leading dimension (ldim >= s_mu)
|
||||
* data - pointer to a contiguous block of realtype variables
|
||||
* ldata - length of the data array =ldim*(s_mu+ml+1)
|
||||
* cols - array of pointers. cols[j] points to the first element
|
||||
* of the j-th column of the matrix in the array data.
|
||||
*
|
||||
* The BAND_COL, BAND_COL_ELEM, and BAND_ELEM macros below allow a
|
||||
* user to access individual matrix elements without writing out
|
||||
* explicit data structure references and without knowing too much
|
||||
* about the underlying element storage. The only storage assumption
|
||||
* needed is that elements are stored columnwise and that a pointer
|
||||
* into the jth column of elements can be obtained via the BAND_COL
|
||||
* macro. The BAND_COL_ELEM macro selects an element from a column
|
||||
* which has already been isolated via BAND_COL. The macro
|
||||
* BAND_COL_ELEM allows the user to avoid the translation
|
||||
* from the matrix location (i,j) to the index in the array returned
|
||||
* by BAND_COL at which the (i,j)th element is stored.
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
typedef struct _DlsMat {
|
||||
int type;
|
||||
sunindextype M;
|
||||
sunindextype N;
|
||||
sunindextype ldim;
|
||||
sunindextype mu;
|
||||
sunindextype ml;
|
||||
sunindextype s_mu;
|
||||
realtype *data;
|
||||
sunindextype ldata;
|
||||
realtype **cols;
|
||||
} *DlsMat;
|
||||
|
||||
/*
|
||||
* ==================================================================
|
||||
* Data accessor macros
|
||||
* ==================================================================
|
||||
*/
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* DENSE_COL and DENSE_ELEM
|
||||
* -----------------------------------------------------------------
|
||||
*
|
||||
* DENSE_COL(A,j) references the jth column of the M-by-N dense
|
||||
* matrix A, 0 <= j < N. The type of the expression DENSE_COL(A,j)
|
||||
* is (realtype *). After the assignment col_j = DENSE_COL(A,j),
|
||||
* col_j may be treated as an array indexed from 0 to M-1.
|
||||
* The (i,j)-th element of A is thus referenced by col_j[i].
|
||||
*
|
||||
* DENSE_ELEM(A,i,j) references the (i,j)th element of the dense
|
||||
* M-by-N matrix A, 0 <= i < M ; 0 <= j < N.
|
||||
*
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#define DENSE_COL(A,j) ((A->cols)[j])
|
||||
#define DENSE_ELEM(A,i,j) ((A->cols)[j][i])
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* BAND_COL, BAND_COL_ELEM, and BAND_ELEM
|
||||
* -----------------------------------------------------------------
|
||||
*
|
||||
* BAND_COL(A,j) references the diagonal element of the jth column
|
||||
* of the N by N band matrix A, 0 <= j <= N-1. The type of the
|
||||
* expression BAND_COL(A,j) is realtype *. The pointer returned by
|
||||
* the call BAND_COL(A,j) can be treated as an array which is
|
||||
* indexed from -(A->mu) to (A->ml).
|
||||
*
|
||||
* BAND_COL_ELEM references the (i,j)th entry of the band matrix A
|
||||
* when used in conjunction with BAND_COL. The index (i,j) should
|
||||
* satisfy j-(A->mu) <= i <= j+(A->ml).
|
||||
*
|
||||
* BAND_ELEM(A,i,j) references the (i,j)th element of the M-by-N
|
||||
* band matrix A, where 0 <= i,j <= N-1. The location (i,j) should
|
||||
* further satisfy j-(A->mu) <= i <= j+(A->ml).
|
||||
*
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#define BAND_COL(A,j) (((A->cols)[j])+(A->s_mu))
|
||||
#define BAND_COL_ELEM(col_j,i,j) (col_j[(i)-(j)])
|
||||
#define BAND_ELEM(A,i,j) ((A->cols)[j][(i)-(j)+(A->s_mu)])
|
||||
|
||||
/*
|
||||
* ==================================================================
|
||||
* Exported function prototypes (functions working on dlsMat)
|
||||
* ==================================================================
|
||||
*/
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Function: NewDenseMat
|
||||
* -----------------------------------------------------------------
|
||||
* NewDenseMat allocates memory for an M-by-N dense matrix and
|
||||
* returns the storage allocated (type DlsMat). NewDenseMat
|
||||
* returns NULL if the request for matrix storage cannot be
|
||||
* satisfied. See the above documentation for the type DlsMat
|
||||
* for matrix storage details.
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
SUNDIALS_EXPORT DlsMat NewDenseMat(sunindextype M, sunindextype N);
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Function: NewBandMat
|
||||
* -----------------------------------------------------------------
|
||||
* NewBandMat allocates memory for an M-by-N band matrix
|
||||
* with upper bandwidth mu, lower bandwidth ml, and storage upper
|
||||
* bandwidth smu. Pass smu as follows depending on whether A will
|
||||
* be LU factored:
|
||||
*
|
||||
* (1) Pass smu = mu if A will not be factored.
|
||||
*
|
||||
* (2) Pass smu = MIN(N-1,mu+ml) if A will be factored.
|
||||
*
|
||||
* NewBandMat returns the storage allocated (type DlsMat) or
|
||||
* NULL if the request for matrix storage cannot be satisfied.
|
||||
* See the documentation for the type DlsMat for matrix storage
|
||||
* details.
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
SUNDIALS_EXPORT DlsMat NewBandMat(sunindextype N, sunindextype mu,
|
||||
sunindextype ml, sunindextype smu);
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Functions: DestroyMat
|
||||
* -----------------------------------------------------------------
|
||||
* DestroyMat frees the memory allocated by NewDenseMat or NewBandMat
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
SUNDIALS_EXPORT void DestroyMat(DlsMat A);
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Function: NewIntArray
|
||||
* -----------------------------------------------------------------
|
||||
* NewIntArray allocates memory an array of N int's and returns
|
||||
* the pointer to the memory it allocates. If the request for
|
||||
* memory storage cannot be satisfied, it returns NULL.
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
SUNDIALS_EXPORT int *NewIntArray(int N);
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Function: NewIndexArray
|
||||
* -----------------------------------------------------------------
|
||||
* NewIndexArray allocates memory an array of N sunindextype's and
|
||||
* returns the pointer to the memory it allocates. If the request
|
||||
* for memory storage cannot be satisfied, it returns NULL.
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
SUNDIALS_EXPORT sunindextype *NewIndexArray(sunindextype N);
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Function: NewRealArray
|
||||
* -----------------------------------------------------------------
|
||||
* NewRealArray allocates memory an array of N realtype and returns
|
||||
* the pointer to the memory it allocates. If the request for
|
||||
* memory storage cannot be satisfied, it returns NULL.
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
SUNDIALS_EXPORT realtype *NewRealArray(sunindextype N);
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Function: DestroyArray
|
||||
* -----------------------------------------------------------------
|
||||
* DestroyArray frees memory allocated by NewIntArray, NewIndexArray,
|
||||
* or NewRealArray.
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
SUNDIALS_EXPORT void DestroyArray(void *p);
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Function : AddIdentity
|
||||
* -----------------------------------------------------------------
|
||||
* AddIdentity adds 1.0 to the main diagonal (A_ii, i=0,1,...,N-1) of
|
||||
* the M-by-N matrix A (M>= N) and stores the result back in A.
|
||||
* AddIdentity is typically used with square matrices.
|
||||
* AddIdentity does not check for M >= N and therefore a segmentation
|
||||
* fault will occur if M < N!
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
SUNDIALS_EXPORT void AddIdentity(DlsMat A);
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Function : SetToZero
|
||||
* -----------------------------------------------------------------
|
||||
* SetToZero sets all the elements of the M-by-N matrix A to 0.0.
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
SUNDIALS_EXPORT void SetToZero(DlsMat A);
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Functions: PrintMat
|
||||
* -----------------------------------------------------------------
|
||||
* This function prints the M-by-N (dense or band) matrix A to
|
||||
* outfile as it would normally appear on paper.
|
||||
* It is intended as debugging tools with small values of M and N.
|
||||
* The elements are printed using the %g/%lg/%Lg option.
|
||||
* A blank line is printed before and after the matrix.
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
SUNDIALS_EXPORT void PrintMat(DlsMat A, FILE *outfile);
|
||||
|
||||
|
||||
/*
|
||||
* ==================================================================
|
||||
* Exported function prototypes (functions working on realtype**)
|
||||
* ==================================================================
|
||||
*/
|
||||
|
||||
SUNDIALS_EXPORT realtype **newDenseMat(sunindextype m, sunindextype n);
|
||||
SUNDIALS_EXPORT realtype **newBandMat(sunindextype n, sunindextype smu,
|
||||
sunindextype ml);
|
||||
SUNDIALS_EXPORT void destroyMat(realtype **a);
|
||||
SUNDIALS_EXPORT int *newIntArray(int n);
|
||||
SUNDIALS_EXPORT sunindextype *newIndexArray(sunindextype n);
|
||||
SUNDIALS_EXPORT realtype *newRealArray(sunindextype m);
|
||||
SUNDIALS_EXPORT void destroyArray(void *v);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
51
bazaar/plugin/sundials/include/sundials/sundials_fconfig.h
Normal file
51
bazaar/plugin/sundials/include/sundials/sundials_fconfig.h
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
!
|
||||
! -----------------------------------------------------------------
|
||||
! Programmer(s): Daniel R. Reynolds @ SMU
|
||||
!-----------------------------------------------------------------
|
||||
! LLNS/SMU Copyright Start
|
||||
! Copyright (c) 2002-2018, Southern Methodist University and
|
||||
! Lawrence Livermore National Security
|
||||
!
|
||||
! This work was performed under the auspices of the U.S. Department
|
||||
! of Energy by Southern Methodist University and Lawrence Livermore
|
||||
! National Laboratory under Contract DE-AC52-07NA27344.
|
||||
! Produced at Southern Methodist University and the Lawrence
|
||||
! Livermore National Laboratory.
|
||||
!
|
||||
! All rights reserved.
|
||||
! For details, see the LICENSE file.
|
||||
! LLNS/SMU Copyright End
|
||||
! ------------------------------------------------------------------
|
||||
! SUNDIALS fortran configuration input
|
||||
! ------------------------------------------------------------------
|
||||
|
||||
! Define precision of SUNDIALS data type 'realtype' as Fortran
|
||||
! parameter "REALTYPE"
|
||||
!
|
||||
! Depending on the precision level, this value will be one of
|
||||
! 4 (SUNDIALS_SINGLE_PRECISION)
|
||||
! 8 (SUNDIALS_DOUBLE_PRECISION)
|
||||
! 16 (SUNDIALS_EXTENDED_PRECISION)
|
||||
!
|
||||
integer REALTYPE
|
||||
parameter (REALTYPE=8)
|
||||
|
||||
! Define type of vector indices in SUNDIALS 'sunindextype' as
|
||||
! the Fortran parameter "SUNINDEXTYPE"
|
||||
!
|
||||
! Depending on the user choice of indextype, this will be one of
|
||||
! 4 (32BIT)
|
||||
! 8 (64BIT)
|
||||
!
|
||||
integer SUNINDEXTYPE
|
||||
parameter (SUNINDEXTYPE=8)
|
||||
|
||||
! If building with MPI enabled, define the logical flag
|
||||
! "SUNDIALS_MPI_COMM_F2C" indicating whether the user can specify
|
||||
! a different MPI communicator than MPI_COMM_WORLD to FNVInitP
|
||||
!
|
||||
! .true. (communicator can differ from MPI_COMM_WORLD)
|
||||
! .false. (communicator must be MPI_COMM_WORLD)
|
||||
!
|
||||
logical SUNDIALS_MPI_COMM_F2C
|
||||
parameter (SUNDIALS_MPI_COMM_F2C=.false.)
|
||||
42
bazaar/plugin/sundials/include/sundials/sundials_fnvector.h
Normal file
42
bazaar/plugin/sundials/include/sundials/sundials_fnvector.h
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
/* -----------------------------------------------------------------
|
||||
* Programmer(s): Radu Serban and Aaron Collier @ LLNL
|
||||
* -----------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
* -----------------------------------------------------------------
|
||||
* This file (companion of nvector.h) contains definitions
|
||||
* needed for the initialization of vector operations in Fortran.
|
||||
* -----------------------------------------------------------------*/
|
||||
|
||||
|
||||
#ifndef _FNVECTOR_H
|
||||
#define _FNVECTOR_H
|
||||
|
||||
#ifndef _SUNDIALS_CONFIG_H
|
||||
#define _SUNDIALS_CONFIG_H
|
||||
#include <sundials/sundials_config.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus /* wrapper to enable C++ usage */
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* SUNDIALS solver IDs */
|
||||
|
||||
#define FCMIX_CVODE 1
|
||||
#define FCMIX_IDA 2
|
||||
#define FCMIX_KINSOL 3
|
||||
#define FCMIX_ARKODE 4
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
38
bazaar/plugin/sundials/include/sundials/sundials_futils.h
Normal file
38
bazaar/plugin/sundials/include/sundials/sundials_futils.h
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
/* -----------------------------------------------------------------
|
||||
* Programmer(s): Cody J. Balos
|
||||
* -----------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
* -----------------------------------------------------------------
|
||||
* SUNDIALS Fortran 2003 interface utility definitions.
|
||||
* -----------------------------------------------------------------*/
|
||||
|
||||
#ifndef _SUNDIALS_FUTILS_H
|
||||
#define _SUNDIALS_FUTILS_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sundials/sundials_config.h>
|
||||
|
||||
#ifdef __cplusplus /* wrapper to enable C++ usage */
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Create a file pointer with the given file name and mode. */
|
||||
SUNDIALS_EXPORT FILE* SUNDIALSFileOpen(const char* filename, const char* modes);
|
||||
|
||||
/* Close a file pointer with the given file name. */
|
||||
SUNDIALS_EXPORT void SUNDIALSFileClose(FILE* fp);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
263
bazaar/plugin/sundials/include/sundials/sundials_iterative.h
Normal file
263
bazaar/plugin/sundials/include/sundials/sundials_iterative.h
Normal file
|
|
@ -0,0 +1,263 @@
|
|||
/* -----------------------------------------------------------------
|
||||
* Programmer(s): Scott D. Cohen and Alan C. Hindmarsh @ LLNL
|
||||
* -----------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
* -----------------------------------------------------------------
|
||||
* This header file contains declarations intended for use by
|
||||
* generic iterative solvers of Ax = b. The enumeration gives
|
||||
* symbolic names for the type of preconditioning to be used.
|
||||
* The function type declarations give the prototypes for the
|
||||
* functions to be called within an iterative linear solver, that
|
||||
* are responsible for
|
||||
* multiplying A by a given vector v (ATimesFn),
|
||||
* setting up a preconditioner P (PSetupFn), and
|
||||
* solving the preconditioner equation Pz = r (PSolveFn).
|
||||
* -----------------------------------------------------------------*/
|
||||
|
||||
#ifndef _ITERATIVE_H
|
||||
#define _ITERATIVE_H
|
||||
|
||||
#include <sundials/sundials_nvector.h>
|
||||
|
||||
#ifdef __cplusplus /* wrapper to enable C++ usage */
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* enum : types of preconditioning
|
||||
* -----------------------------------------------------------------
|
||||
* PREC_NONE : The iterative linear solver should not use
|
||||
* preconditioning.
|
||||
*
|
||||
* PREC_LEFT : The iterative linear solver uses preconditioning on
|
||||
* the left only.
|
||||
*
|
||||
* PREC_RIGHT : The iterative linear solver uses preconditioning on
|
||||
* the right only.
|
||||
*
|
||||
* PREC_BOTH : The iterative linear solver uses preconditioning on
|
||||
* both the left and the right.
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
enum { PREC_NONE, PREC_LEFT, PREC_RIGHT, PREC_BOTH };
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* enum : types of Gram-Schmidt routines
|
||||
* -----------------------------------------------------------------
|
||||
* MODIFIED_GS : The iterative solver uses the modified
|
||||
* Gram-Schmidt routine ModifiedGS listed in this
|
||||
* file.
|
||||
*
|
||||
* CLASSICAL_GS : The iterative solver uses the classical
|
||||
* Gram-Schmidt routine ClassicalGS listed in this
|
||||
* file.
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
enum { MODIFIED_GS = 1, CLASSICAL_GS = 2 };
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Type: ATimesFn
|
||||
* -----------------------------------------------------------------
|
||||
* An ATimesFn multiplies Av and stores the result in z. The
|
||||
* caller is responsible for allocating memory for the z vector.
|
||||
* The parameter A_data is a pointer to any information about A
|
||||
* which the function needs in order to do its job. The vector v
|
||||
* is unchanged. An ATimesFn returns 0 if successful and a
|
||||
* non-zero value if unsuccessful.
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
typedef int (*ATimesFn)(void *A_data, N_Vector v, N_Vector z);
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Type: PSetupFn
|
||||
* -----------------------------------------------------------------
|
||||
* A PSetupFn is an integrator-supplied routine that accesses data
|
||||
* stored in the integrator memory structure (P_data), and calls
|
||||
* the user-supplied, integrator-specific preconditioner setup
|
||||
* routine.
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
typedef int (*PSetupFn)(void *P_data);
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Type: PSolveFn
|
||||
* -----------------------------------------------------------------
|
||||
* A PSolveFn solves the preconditioner equation Pz = r for the
|
||||
* vector z. The caller is responsible for allocating memory for
|
||||
* the z vector. The parameter P_data is a pointer to any
|
||||
* information about P which the function needs in order to do
|
||||
* its job. The parameter lr is input, and indicates whether P
|
||||
* is to be taken as the left preconditioner or the right
|
||||
* preconditioner: lr = 1 for left and lr = 2 for right.
|
||||
* If preconditioning is on one side only, lr can be ignored.
|
||||
* If the preconditioner is iterative, then it should strive to
|
||||
* solve the preconditioner equation so that
|
||||
* || Pz - r ||_wrms < tol
|
||||
* where the weight vector for the WRMS norm may be accessed from
|
||||
* the main integrator memory structure.
|
||||
* The vector r should not be modified by the PSolveFn.
|
||||
* A PSolveFn returns 0 if successful and a non-zero value if
|
||||
* unsuccessful. On a failure, a negative return value indicates
|
||||
* an unrecoverable condition, while a positive value indicates
|
||||
* a recoverable one, in which the calling routine may reattempt
|
||||
* the solution after updating preconditioner data.
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
typedef int (*PSolveFn)(void *P_data, N_Vector r, N_Vector z,
|
||||
realtype tol, int lr);
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Function: ModifiedGS
|
||||
* -----------------------------------------------------------------
|
||||
* ModifiedGS performs a modified Gram-Schmidt orthogonalization
|
||||
* of the N_Vector v[k] against the p unit N_Vectors at
|
||||
* v[k-1], v[k-2], ..., v[k-p].
|
||||
*
|
||||
* v is an array of (k+1) N_Vectors v[i], i=0, 1, ..., k.
|
||||
* v[k-1], v[k-2], ..., v[k-p] are assumed to have L2-norm
|
||||
* equal to 1.
|
||||
*
|
||||
* h is the output k by k Hessenberg matrix of inner products.
|
||||
* This matrix must be allocated row-wise so that the (i,j)th
|
||||
* entry is h[i][j]. The inner products (v[i],v[k]),
|
||||
* i=i0, i0+1, ..., k-1, are stored at h[i][k-1]. Here
|
||||
* i0=SUNMAX(0,k-p).
|
||||
*
|
||||
* k is the index of the vector in the v array that needs to be
|
||||
* orthogonalized against previous vectors in the v array.
|
||||
*
|
||||
* p is the number of previous vectors in the v array against
|
||||
* which v[k] is to be orthogonalized.
|
||||
*
|
||||
* new_vk_norm is a pointer to memory allocated by the caller to
|
||||
* hold the Euclidean norm of the orthogonalized vector v[k].
|
||||
*
|
||||
* If (k-p) < 0, then ModifiedGS uses p=k. The orthogonalized
|
||||
* v[k] is NOT normalized and is stored over the old v[k]. Once
|
||||
* the orthogonalization has been performed, the Euclidean norm
|
||||
* of v[k] is stored in (*new_vk_norm).
|
||||
*
|
||||
* ModifiedGS returns 0 to indicate success. It cannot fail.
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
SUNDIALS_EXPORT int ModifiedGS(N_Vector* v, realtype **h, int k, int p,
|
||||
realtype *new_vk_norm);
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Function: ClassicalGS
|
||||
* -----------------------------------------------------------------
|
||||
* ClassicalGS performs a classical Gram-Schmidt
|
||||
* orthogonalization of the N_Vector v[k] against the p unit
|
||||
* N_Vectors at v[k-1], v[k-2], ..., v[k-p]. The parameters v, h,
|
||||
* k, p, and new_vk_norm are as described in the documentation
|
||||
* for ModifiedGS.
|
||||
*
|
||||
* stemp is a length k+1 array of realtype which can be used as
|
||||
* workspace by the ClassicalGS routine.
|
||||
*
|
||||
* vtemp is an N_Vector array of k+1 vectors which can be used as
|
||||
* workspace by the ClassicalGS routine.
|
||||
*
|
||||
* ClassicalGS returns 0 to indicate success.
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
SUNDIALS_EXPORT int ClassicalGS(N_Vector* v, realtype **h, int k, int p,
|
||||
realtype *new_vk_norm, realtype *stemp,
|
||||
N_Vector* vtemp);
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Function: QRfact
|
||||
* -----------------------------------------------------------------
|
||||
* QRfact performs a QR factorization of the Hessenberg matrix H.
|
||||
*
|
||||
* n is the problem size; the matrix H is (n+1) by n.
|
||||
*
|
||||
* h is the (n+1) by n Hessenberg matrix H to be factored. It is
|
||||
* stored row-wise.
|
||||
*
|
||||
* q is an array of length 2*n containing the Givens rotations
|
||||
* computed by this function. A Givens rotation has the form:
|
||||
* | c -s |
|
||||
* | s c |.
|
||||
* The components of the Givens rotations are stored in q as
|
||||
* (c, s, c, s, ..., c, s).
|
||||
*
|
||||
* job is a control flag. If job==0, then a new QR factorization
|
||||
* is performed. If job!=0, then it is assumed that the first
|
||||
* n-1 columns of h have already been factored and only the last
|
||||
* column needs to be updated.
|
||||
*
|
||||
* QRfact returns 0 if successful. If a zero is encountered on
|
||||
* the diagonal of the triangular factor R, then QRfact returns
|
||||
* the equation number of the zero entry, where the equations are
|
||||
* numbered from 1, not 0. If QRsol is subsequently called in
|
||||
* this situation, it will return an error because it could not
|
||||
* divide by the zero diagonal entry.
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
SUNDIALS_EXPORT int QRfact(int n, realtype **h, realtype *q, int job);
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Function: QRsol
|
||||
* -----------------------------------------------------------------
|
||||
* QRsol solves the linear least squares problem
|
||||
*
|
||||
* min (b - H*x, b - H*x), x in R^n,
|
||||
*
|
||||
* where H is a Hessenberg matrix, and b is in R^(n+1).
|
||||
* It uses the QR factors of H computed by QRfact.
|
||||
*
|
||||
* n is the problem size; the matrix H is (n+1) by n.
|
||||
*
|
||||
* h is a matrix (computed by QRfact) containing the upper
|
||||
* triangular factor R of the original Hessenberg matrix H.
|
||||
*
|
||||
* q is an array of length 2*n (computed by QRfact) containing
|
||||
* the Givens rotations used to factor H.
|
||||
*
|
||||
* b is the (n+1)-vector appearing in the least squares problem
|
||||
* above.
|
||||
*
|
||||
* On return, b contains the solution x of the least squares
|
||||
* problem, if QRsol was successful.
|
||||
*
|
||||
* QRsol returns a 0 if successful. Otherwise, a zero was
|
||||
* encountered on the diagonal of the triangular factor R.
|
||||
* In this case, QRsol returns the equation number (numbered
|
||||
* from 1, not 0) of the zero entry.
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
SUNDIALS_EXPORT int QRsol(int n, realtype **h, realtype *q, realtype *b);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
256
bazaar/plugin/sundials/include/sundials/sundials_lapack.h
Normal file
256
bazaar/plugin/sundials/include/sundials/sundials_lapack.h
Normal file
|
|
@ -0,0 +1,256 @@
|
|||
/* -----------------------------------------------------------------
|
||||
* Programmer: Radu Serban @ LLNL
|
||||
* Daniel Reynolds @ SMU
|
||||
* -----------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
* -----------------------------------------------------------------
|
||||
* This is the header file for a generic package of direct matrix
|
||||
* operations for use with BLAS/LAPACK.
|
||||
* -----------------------------------------------------------------*/
|
||||
|
||||
#ifndef _SUNDIALS_LAPACK_H
|
||||
#define _SUNDIALS_LAPACK_H
|
||||
|
||||
#include <sundials/sundials_types.h>
|
||||
|
||||
#ifdef __cplusplus /* wrapper to enable C++ usage */
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* ==================================================================
|
||||
* Blas and Lapack functions
|
||||
* ==================================================================
|
||||
*/
|
||||
|
||||
#if defined(SUNDIALS_F77_FUNC)
|
||||
|
||||
#define dcopy_f77 SUNDIALS_F77_FUNC(dcopy, DCOPY)
|
||||
#define dscal_f77 SUNDIALS_F77_FUNC(dscal, DSCAL)
|
||||
#define dgemv_f77 SUNDIALS_F77_FUNC(dgemv, DGEMV)
|
||||
#define dtrsv_f77 SUNDIALS_F77_FUNC(dtrsv, DTRSV)
|
||||
#define dsyrk_f77 SUNDIALS_F77_FUNC(dsyrk, DSKYR)
|
||||
|
||||
#define dgbtrf_f77 SUNDIALS_F77_FUNC(dgbtrf, DGBTRF)
|
||||
#define dgbtrs_f77 SUNDIALS_F77_FUNC(dgbtrs, DGBTRS)
|
||||
#define dgetrf_f77 SUNDIALS_F77_FUNC(dgetrf, DGETRF)
|
||||
#define dgetrs_f77 SUNDIALS_F77_FUNC(dgetrs, DGETRS)
|
||||
#define dgeqp3_f77 SUNDIALS_F77_FUNC(dgeqp3, DGEQP3)
|
||||
#define dgeqrf_f77 SUNDIALS_F77_FUNC(dgeqrf, DGEQRF)
|
||||
#define dormqr_f77 SUNDIALS_F77_FUNC(dormqr, DORMQR)
|
||||
#define dpotrf_f77 SUNDIALS_F77_FUNC(dpotrf, DPOTRF)
|
||||
#define dpotrs_f77 SUNDIALS_F77_FUNC(dpotrs, DPOTRS)
|
||||
|
||||
#define scopy_f77 SUNDIALS_F77_FUNC(scopy, SCOPY)
|
||||
#define sscal_f77 SUNDIALS_F77_FUNC(sscal, SSCAL)
|
||||
#define sgemv_f77 SUNDIALS_F77_FUNC(sgemv, SGEMV)
|
||||
#define strsv_f77 SUNDIALS_F77_FUNC(strsv, STRSV)
|
||||
#define ssyrk_f77 SUNDIALS_F77_FUNC(ssyrk, SSKYR)
|
||||
|
||||
#define sgbtrf_f77 SUNDIALS_F77_FUNC(sgbtrf, SGBTRF)
|
||||
#define sgbtrs_f77 SUNDIALS_F77_FUNC(sgbtrs, SGBTRS)
|
||||
#define sgetrf_f77 SUNDIALS_F77_FUNC(sgetrf, SGETRF)
|
||||
#define sgetrs_f77 SUNDIALS_F77_FUNC(sgetrs, SGETRS)
|
||||
#define sgeqp3_f77 SUNDIALS_F77_FUNC(sgeqp3, SGEQP3)
|
||||
#define sgeqrf_f77 SUNDIALS_F77_FUNC(sgeqrf, SGEQRF)
|
||||
#define sormqr_f77 SUNDIALS_F77_FUNC(sormqr, SORMQR)
|
||||
#define spotrf_f77 SUNDIALS_F77_FUNC(spotrf, SPOTRF)
|
||||
#define spotrs_f77 SUNDIALS_F77_FUNC(spotrs, SPOTRS)
|
||||
|
||||
#else
|
||||
|
||||
#define dcopy_f77 dcopy_
|
||||
#define dscal_f77 dscal_
|
||||
#define dgemv_f77 dgemv_
|
||||
#define dtrsv_f77 dtrsv_
|
||||
#define dsyrk_f77 dsyrk_
|
||||
|
||||
#define dgbtrf_f77 dgbtrf_
|
||||
#define dgbtrs_f77 dgbtrs_
|
||||
#define dgeqp3_f77 dgeqp3_
|
||||
#define dgeqrf_f77 dgeqrf_
|
||||
#define dgetrf_f77 dgetrf_
|
||||
#define dgetrs_f77 dgetrs_
|
||||
#define dormqr_f77 dormqr_
|
||||
#define dpotrf_f77 dpotrf_
|
||||
#define dpotrs_f77 dpotrs_
|
||||
|
||||
#define scopy_f77 scopy_
|
||||
#define sscal_f77 sscal_
|
||||
#define sgemv_f77 sgemv_
|
||||
#define strsv_f77 strsv_
|
||||
#define ssyrk_f77 ssyrk_
|
||||
|
||||
#define sgbtrf_f77 sgbtrf_
|
||||
#define sgbtrs_f77 sgbtrs_
|
||||
#define sgeqp3_f77 sgeqp3_
|
||||
#define sgeqrf_f77 sgeqrf_
|
||||
#define sgetrf_f77 sgetrf_
|
||||
#define sgetrs_f77 sgetrs_
|
||||
#define sormqr_f77 sormqr_
|
||||
#define spotrf_f77 spotrf_
|
||||
#define spotrs_f77 spotrs_
|
||||
|
||||
#endif
|
||||
|
||||
/* Level-1 BLAS */
|
||||
|
||||
extern void dcopy_f77(sunindextype *n, const double *x,
|
||||
const sunindextype *inc_x, double *y,
|
||||
const sunindextype *inc_y);
|
||||
|
||||
extern void dscal_f77(sunindextype *n, const double *alpha, double *x,
|
||||
const sunindextype *inc_x);
|
||||
|
||||
extern void scopy_f77(sunindextype *n, const float *x,
|
||||
const sunindextype *inc_x, float *y,
|
||||
const sunindextype *inc_y);
|
||||
|
||||
extern void sscal_f77(sunindextype *n, const float *alpha, float *x,
|
||||
const sunindextype *inc_x);
|
||||
|
||||
/* Level-2 BLAS */
|
||||
|
||||
extern void dgemv_f77(const char *trans, sunindextype *m, sunindextype *n,
|
||||
const double *alpha, const double *a, sunindextype *lda,
|
||||
const double *x, sunindextype *inc_x, const double *beta,
|
||||
double *y, sunindextype *inc_y);
|
||||
|
||||
extern void dtrsv_f77(const char *uplo, const char *trans, const char *diag,
|
||||
const sunindextype *n, const double *a,
|
||||
const sunindextype *lda, double *x,
|
||||
const sunindextype *inc_x);
|
||||
|
||||
extern void sgemv_f77(const char *trans, sunindextype *m, sunindextype *n,
|
||||
const float *alpha, const float *a, sunindextype *lda,
|
||||
const float *x, sunindextype *inc_x, const float *beta,
|
||||
float *y, sunindextype *inc_y);
|
||||
|
||||
extern void strsv_f77(const char *uplo, const char *trans, const char *diag,
|
||||
const sunindextype *n, const float *a,
|
||||
const sunindextype *lda, float *x,
|
||||
const sunindextype *inc_x);
|
||||
|
||||
/* Level-3 BLAS */
|
||||
|
||||
extern void dsyrk_f77(const char *uplo, const char *trans,
|
||||
const sunindextype *n, const sunindextype *k,
|
||||
const double *alpha, const double *a,
|
||||
const sunindextype *lda, const double *beta,
|
||||
const double *c, const sunindextype *ldc);
|
||||
|
||||
extern void ssyrk_f77(const char *uplo, const char *trans,
|
||||
const sunindextype *n, const sunindextype *k,
|
||||
const float *alpha, const float *a,
|
||||
const sunindextype *lda, const float *beta,
|
||||
const float *c, const sunindextype *ldc);
|
||||
|
||||
/* LAPACK */
|
||||
|
||||
extern void dgbtrf_f77(const sunindextype *m, const sunindextype *n,
|
||||
const sunindextype *kl, const sunindextype *ku,
|
||||
double *ab, sunindextype *ldab, sunindextype *ipiv,
|
||||
sunindextype *info);
|
||||
|
||||
extern void dgbtrs_f77(const char *trans, const sunindextype *n,
|
||||
const sunindextype *kl, const sunindextype *ku,
|
||||
const sunindextype *nrhs, double *ab,
|
||||
const sunindextype *ldab, sunindextype *ipiv,
|
||||
double *b, const sunindextype *ldb, sunindextype *info);
|
||||
|
||||
|
||||
extern void dgeqp3_f77(const sunindextype *m, const sunindextype *n, double *a,
|
||||
const sunindextype *lda, sunindextype *jpvt, double *tau,
|
||||
double *work, const sunindextype *lwork,
|
||||
sunindextype *info);
|
||||
|
||||
extern void dgeqrf_f77(const sunindextype *m, const sunindextype *n, double *a,
|
||||
const sunindextype *lda, double *tau, double *work,
|
||||
const sunindextype *lwork, sunindextype *info);
|
||||
|
||||
extern void dgetrf_f77(const sunindextype *m, const sunindextype *n, double *a,
|
||||
sunindextype *lda, sunindextype *ipiv,
|
||||
sunindextype *info);
|
||||
|
||||
extern void dgetrs_f77(const char *trans, const sunindextype *n,
|
||||
const sunindextype *nrhs, double *a,
|
||||
const sunindextype *lda, sunindextype *ipiv, double *b,
|
||||
const sunindextype *ldb, sunindextype *info);
|
||||
|
||||
|
||||
extern void dormqr_f77(const char *side, const char *trans,
|
||||
const sunindextype *m, const sunindextype *n,
|
||||
const sunindextype *k, double *a,
|
||||
const sunindextype *lda, double *tau, double *c,
|
||||
const sunindextype *ldc, double *work,
|
||||
const sunindextype *lwork, sunindextype *info);
|
||||
|
||||
extern void dpotrf_f77(const char *uplo, const sunindextype *n, double *a,
|
||||
sunindextype *lda, sunindextype *info);
|
||||
|
||||
extern void dpotrs_f77(const char *uplo, const sunindextype *n,
|
||||
const sunindextype *nrhs, double *a,
|
||||
const sunindextype *lda, double *b,
|
||||
const sunindextype *ldb, sunindextype *info);
|
||||
|
||||
|
||||
extern void sgbtrf_f77(const sunindextype *m, const sunindextype *n,
|
||||
const sunindextype *kl, const sunindextype *ku,
|
||||
float *ab, sunindextype *ldab, sunindextype *ipiv,
|
||||
sunindextype *info);
|
||||
|
||||
extern void sgbtrs_f77(const char *trans, const sunindextype *n,
|
||||
const sunindextype *kl, const sunindextype *ku,
|
||||
const sunindextype *nrhs, float *ab,
|
||||
const sunindextype *ldab, sunindextype *ipiv,
|
||||
float *b, const sunindextype *ldb, sunindextype *info);
|
||||
|
||||
|
||||
extern void sgeqp3_f77(const sunindextype *m, const sunindextype *n, float *a,
|
||||
const sunindextype *lda, sunindextype *jpvt, float *tau,
|
||||
float *work, const sunindextype *lwork,
|
||||
sunindextype *info);
|
||||
|
||||
extern void sgeqrf_f77(const sunindextype *m, const sunindextype *n, float *a,
|
||||
const sunindextype *lda, float *tau, float *work,
|
||||
const sunindextype *lwork, sunindextype *info);
|
||||
|
||||
extern void sgetrf_f77(const sunindextype *m, const sunindextype *n, float *a,
|
||||
sunindextype *lda, sunindextype *ipiv,
|
||||
sunindextype *info);
|
||||
|
||||
extern void sgetrs_f77(const char *trans, const sunindextype *n,
|
||||
const sunindextype *nrhs, float *a,
|
||||
const sunindextype *lda, sunindextype *ipiv,
|
||||
float *b, const sunindextype *ldb, sunindextype *info);
|
||||
|
||||
|
||||
extern void sormqr_f77(const char *side, const char *trans,
|
||||
const sunindextype *m, const sunindextype *n,
|
||||
const sunindextype *k, float *a, const sunindextype *lda,
|
||||
float *tau, float *c, const sunindextype *ldc,
|
||||
float *work, const sunindextype *lwork,
|
||||
sunindextype *info);
|
||||
|
||||
extern void spotrf_f77(const char *uplo, const sunindextype *n, float *a,
|
||||
sunindextype *lda, sunindextype *info);
|
||||
|
||||
extern void spotrs_f77(const char *uplo, const sunindextype *n,
|
||||
const sunindextype *nrhs, float *a,
|
||||
const sunindextype *lda, float *b,
|
||||
const sunindextype *ldb, sunindextype *info);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
204
bazaar/plugin/sundials/include/sundials/sundials_linearsolver.h
Normal file
204
bazaar/plugin/sundials/include/sundials/sundials_linearsolver.h
Normal file
|
|
@ -0,0 +1,204 @@
|
|||
/* -----------------------------------------------------------------
|
||||
* Programmer(s): Daniel Reynolds @ SMU
|
||||
* David Gardner, Carol Woodward, Slaven Peles @ LLNL
|
||||
* -----------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
* -----------------------------------------------------------------
|
||||
* This is the header file for a generic linear solver package.
|
||||
* It defines the SUNLinearSolver structure (_generic_SUNLinearSolver)
|
||||
* which contains the following fields:
|
||||
* - an implementation-dependent 'content' field which contains
|
||||
* any internal data required by the solver
|
||||
* - an 'ops' filed which contains a structure listing operations
|
||||
* acting on/by such solvers
|
||||
*
|
||||
* We consider both direct linear solvers and iterative linear solvers
|
||||
* as available implementations of this package. Furthermore, iterative
|
||||
* linear solvers can either use a matrix or be matrix-free. As a
|
||||
* result of these different solver characteristics, some of the
|
||||
* routines are applicable only to some types of linear solver.
|
||||
* -----------------------------------------------------------------
|
||||
* This header file contains:
|
||||
* - enumeration constants for all SUNDIALS-defined linear solver
|
||||
* types, as well as a generic type for user-supplied linear
|
||||
* solver types,
|
||||
* - type declarations for the _generic_SUNLinearSolver and
|
||||
* _generic_SUNLinearSolver_Ops structures, as well as references
|
||||
* to pointers to such structures (SUNLinearSolver),
|
||||
* - prototypes for the linear solver functions which operate
|
||||
* on/by SUNLinearSolver objects, and
|
||||
* - return codes for SUNLinearSolver objects.
|
||||
* -----------------------------------------------------------------
|
||||
* At a minimum, a particular implementation of a SUNLinearSolver must
|
||||
* do the following:
|
||||
* - specify the 'content' field of SUNLinearSolver,
|
||||
* - implement the operations on/by those SUNLinearSolver objects,
|
||||
* - provide a constructor routine for new SUNLinearSolver objects
|
||||
*
|
||||
* Additionally, a SUNLinearSolver implementation may provide the
|
||||
* following:
|
||||
* - "Set" routines to control solver-specific parameters/options
|
||||
* - "Get" routines to access solver-specific performance metrics
|
||||
* -----------------------------------------------------------------*/
|
||||
|
||||
#ifndef _SUNLINEARSOLVER_H
|
||||
#define _SUNLINEARSOLVER_H
|
||||
|
||||
#include <sundials/sundials_types.h>
|
||||
#include <sundials/sundials_iterative.h>
|
||||
#include <sundials/sundials_matrix.h>
|
||||
#include <sundials/sundials_nvector.h>
|
||||
|
||||
#ifdef __cplusplus /* wrapper to enable C++ usage */
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* -----------------------------------------------------------------
|
||||
* Implemented SUNLinearSolver types and IDs:
|
||||
* ----------------------------------------------------------------- */
|
||||
|
||||
typedef enum {
|
||||
SUNLINEARSOLVER_DIRECT,
|
||||
SUNLINEARSOLVER_ITERATIVE,
|
||||
SUNLINEARSOLVER_MATRIX_ITERATIVE
|
||||
} SUNLinearSolver_Type;
|
||||
|
||||
typedef enum {
|
||||
SUNLINEARSOLVER_BAND,
|
||||
SUNLINEARSOLVER_DENSE,
|
||||
SUNLINEARSOLVER_KLU,
|
||||
SUNLINEARSOLVER_LAPACKBAND,
|
||||
SUNLINEARSOLVER_LAPACKDENSE,
|
||||
SUNLINEARSOLVER_PCG,
|
||||
SUNLINEARSOLVER_SPBCGS,
|
||||
SUNLINEARSOLVER_SPFGMR,
|
||||
SUNLINEARSOLVER_SPGMR,
|
||||
SUNLINEARSOLVER_SPTFQMR,
|
||||
SUNLINEARSOLVER_SUPERLUDIST,
|
||||
SUNLINEARSOLVER_SUPERLUMT,
|
||||
SUNLINEARSOLVER_CUSOLVERSP_BATCHQR,
|
||||
SUNLINEARSOLVER_CUSTOM
|
||||
} SUNLinearSolver_ID;
|
||||
|
||||
|
||||
/* -----------------------------------------------------------------
|
||||
* Generic definition of SUNLinearSolver
|
||||
* ----------------------------------------------------------------- */
|
||||
|
||||
/* Forward reference for pointer to SUNLinearSolver_Ops object */
|
||||
typedef _SUNDIALS_STRUCT_ _generic_SUNLinearSolver_Ops *SUNLinearSolver_Ops;
|
||||
|
||||
/* Forward reference for pointer to SUNLinearSolver object */
|
||||
typedef _SUNDIALS_STRUCT_ _generic_SUNLinearSolver *SUNLinearSolver;
|
||||
|
||||
/* Structure containing function pointers to linear solver operations */
|
||||
struct _generic_SUNLinearSolver_Ops {
|
||||
SUNLinearSolver_Type (*gettype)(SUNLinearSolver);
|
||||
SUNLinearSolver_ID (*getid)(SUNLinearSolver);
|
||||
int (*setatimes)(SUNLinearSolver, void*, ATimesFn);
|
||||
int (*setpreconditioner)(SUNLinearSolver, void*,
|
||||
PSetupFn, PSolveFn);
|
||||
int (*setscalingvectors)(SUNLinearSolver,
|
||||
N_Vector, N_Vector);
|
||||
int (*initialize)(SUNLinearSolver);
|
||||
int (*setup)(SUNLinearSolver, SUNMatrix);
|
||||
int (*solve)(SUNLinearSolver, SUNMatrix, N_Vector,
|
||||
N_Vector, realtype);
|
||||
int (*numiters)(SUNLinearSolver);
|
||||
realtype (*resnorm)(SUNLinearSolver);
|
||||
sunindextype (*lastflag)(SUNLinearSolver);
|
||||
int (*space)(SUNLinearSolver, long int*, long int*);
|
||||
N_Vector (*resid)(SUNLinearSolver);
|
||||
int (*free)(SUNLinearSolver);
|
||||
};
|
||||
|
||||
/* A linear solver is a structure with an implementation-dependent
|
||||
'content' field, and a pointer to a structure of linear solver
|
||||
operations corresponding to that implementation. */
|
||||
struct _generic_SUNLinearSolver {
|
||||
void *content;
|
||||
SUNLinearSolver_Ops ops;
|
||||
};
|
||||
|
||||
|
||||
/* -----------------------------------------------------------------
|
||||
* Functions exported by SUNLinearSolver module
|
||||
* ----------------------------------------------------------------- */
|
||||
|
||||
SUNDIALS_EXPORT SUNLinearSolver SUNLinSolNewEmpty();
|
||||
|
||||
SUNDIALS_EXPORT void SUNLinSolFreeEmpty(SUNLinearSolver S);
|
||||
|
||||
SUNDIALS_EXPORT SUNLinearSolver_Type SUNLinSolGetType(SUNLinearSolver S);
|
||||
|
||||
SUNDIALS_EXPORT SUNLinearSolver_ID SUNLinSolGetID(SUNLinearSolver S);
|
||||
|
||||
SUNDIALS_EXPORT int SUNLinSolSetATimes(SUNLinearSolver S, void* A_data,
|
||||
ATimesFn ATimes);
|
||||
|
||||
SUNDIALS_EXPORT int SUNLinSolSetPreconditioner(SUNLinearSolver S, void* P_data,
|
||||
PSetupFn Pset, PSolveFn Psol);
|
||||
|
||||
SUNDIALS_EXPORT int SUNLinSolSetScalingVectors(SUNLinearSolver S, N_Vector s1,
|
||||
N_Vector s2);
|
||||
|
||||
SUNDIALS_EXPORT int SUNLinSolInitialize(SUNLinearSolver S);
|
||||
|
||||
SUNDIALS_EXPORT int SUNLinSolSetup(SUNLinearSolver S, SUNMatrix A);
|
||||
|
||||
SUNDIALS_EXPORT int SUNLinSolSolve(SUNLinearSolver S, SUNMatrix A, N_Vector x,
|
||||
N_Vector b, realtype tol);
|
||||
|
||||
SUNDIALS_EXPORT int SUNLinSolNumIters(SUNLinearSolver S);
|
||||
|
||||
SUNDIALS_EXPORT realtype SUNLinSolResNorm(SUNLinearSolver S);
|
||||
|
||||
SUNDIALS_EXPORT N_Vector SUNLinSolResid(SUNLinearSolver S);
|
||||
|
||||
SUNDIALS_EXPORT sunindextype SUNLinSolLastFlag(SUNLinearSolver S);
|
||||
|
||||
SUNDIALS_EXPORT int SUNLinSolSpace(SUNLinearSolver S, long int *lenrwLS,
|
||||
long int *leniwLS);
|
||||
|
||||
SUNDIALS_EXPORT int SUNLinSolFree(SUNLinearSolver S);
|
||||
|
||||
|
||||
/* -----------------------------------------------------------------
|
||||
* SUNLinearSolver return values
|
||||
* ----------------------------------------------------------------- */
|
||||
|
||||
#define SUNLS_SUCCESS 0 /* successful/converged */
|
||||
|
||||
#define SUNLS_MEM_NULL -801 /* mem argument is NULL */
|
||||
#define SUNLS_ILL_INPUT -802 /* illegal function input */
|
||||
#define SUNLS_MEM_FAIL -803 /* failed memory access */
|
||||
#define SUNLS_ATIMES_FAIL_UNREC -804 /* atimes unrecoverable failure */
|
||||
#define SUNLS_PSET_FAIL_UNREC -805 /* pset unrecoverable failure */
|
||||
#define SUNLS_PSOLVE_FAIL_UNREC -806 /* psolve unrecoverable failure */
|
||||
#define SUNLS_PACKAGE_FAIL_UNREC -807 /* external package unrec. fail */
|
||||
#define SUNLS_GS_FAIL -808 /* Gram-Schmidt failure */
|
||||
#define SUNLS_QRSOL_FAIL -809 /* QRsol found singular R */
|
||||
#define SUNLS_VECTOROP_ERR -810 /* vector operation error */
|
||||
|
||||
#define SUNLS_RES_REDUCED 801 /* nonconv. solve, resid reduced */
|
||||
#define SUNLS_CONV_FAIL 802 /* nonconvergent solve */
|
||||
#define SUNLS_ATIMES_FAIL_REC 803 /* atimes failed recoverably */
|
||||
#define SUNLS_PSET_FAIL_REC 804 /* pset failed recoverably */
|
||||
#define SUNLS_PSOLVE_FAIL_REC 805 /* psolve failed recoverably */
|
||||
#define SUNLS_PACKAGE_FAIL_REC 806 /* external package recov. fail */
|
||||
#define SUNLS_QRFACT_FAIL 807 /* QRfact found singular matrix */
|
||||
#define SUNLS_LUFACT_FAIL 808 /* LUfact found singular matrix */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
193
bazaar/plugin/sundials/include/sundials/sundials_math.h
Normal file
193
bazaar/plugin/sundials/include/sundials/sundials_math.h
Normal file
|
|
@ -0,0 +1,193 @@
|
|||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Programmer(s): Scott D. Cohen, Alan C. Hindmarsh and
|
||||
* Aaron Collier @ LLNL
|
||||
* -----------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
* -----------------------------------------------------------------
|
||||
* This is the header file for a simple C-language math library. The
|
||||
* routines listed here work with the type realtype as defined in
|
||||
* the header file sundials_types.h.
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef _SUNDIALSMATH_H
|
||||
#define _SUNDIALSMATH_H
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include <sundials/sundials_types.h>
|
||||
|
||||
#ifdef __cplusplus /* wrapper to enable C++ usage */
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Macros
|
||||
* -----------------------------------------------------------------
|
||||
* SUNMIN(A,B) returns the minimum of A and B
|
||||
*
|
||||
* SUNMAX(A,B) returns the maximum of A and B
|
||||
*
|
||||
* SUNSQR(A) returns A^2
|
||||
*
|
||||
* SUNRsqrt calls the appropriate version of sqrt
|
||||
*
|
||||
* SUNRabs calls the appropriate version of abs
|
||||
*
|
||||
* SUNRexp calls the appropriate version of exp
|
||||
*
|
||||
* SUNRceil calls the appropriate version of ceil
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef SUNMIN
|
||||
#define SUNMIN(A, B) ((A) < (B) ? (A) : (B))
|
||||
#endif
|
||||
|
||||
#ifndef SUNMAX
|
||||
#define SUNMAX(A, B) ((A) > (B) ? (A) : (B))
|
||||
#endif
|
||||
|
||||
#ifndef SUNSQR
|
||||
#define SUNSQR(A) ((A)*(A))
|
||||
#endif
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Function : SUNRsqrt
|
||||
* -----------------------------------------------------------------
|
||||
* Usage : realtype sqrt_x;
|
||||
* sqrt_x = SUNRsqrt(x);
|
||||
* -----------------------------------------------------------------
|
||||
* SUNRsqrt(x) returns the square root of x. If x < ZERO, then
|
||||
* SUNRsqrt returns ZERO.
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef SUNRsqrt
|
||||
#if defined(SUNDIALS_USE_GENERIC_MATH)
|
||||
#define SUNRsqrt(x) ((x) <= RCONST(0.0) ? (RCONST(0.0)) : ((realtype) sqrt((double) (x))))
|
||||
#elif defined(SUNDIALS_DOUBLE_PRECISION)
|
||||
#define SUNRsqrt(x) ((x) <= RCONST(0.0) ? (RCONST(0.0)) : (sqrt((x))))
|
||||
#elif defined(SUNDIALS_SINGLE_PRECISION)
|
||||
#define SUNRsqrt(x) ((x) <= RCONST(0.0) ? (RCONST(0.0)) : (sqrtf((x))))
|
||||
#elif defined(SUNDIALS_EXTENDED_PRECISION)
|
||||
#define SUNRsqrt(x) ((x) <= RCONST(0.0) ? (RCONST(0.0)) : (sqrtl((x))))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Function : SUNRabs
|
||||
* -----------------------------------------------------------------
|
||||
* Usage : realtype abs_x;
|
||||
* abs_x = SUNRabs(x);
|
||||
* -----------------------------------------------------------------
|
||||
* SUNRabs(x) returns the absolute value of x.
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef SUNRabs
|
||||
#if defined(SUNDIALS_USE_GENERIC_MATH)
|
||||
#define SUNRabs(x) ((realtype) fabs((double) (x)))
|
||||
#elif defined(SUNDIALS_DOUBLE_PRECISION)
|
||||
#define SUNRabs(x) (fabs((x)))
|
||||
#elif defined(SUNDIALS_SINGLE_PRECISION)
|
||||
#define SUNRabs(x) (fabsf((x)))
|
||||
#elif defined(SUNDIALS_EXTENDED_PRECISION)
|
||||
#define SUNRabs(x) (fabsl((x)))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Function : SUNRexp
|
||||
* -----------------------------------------------------------------
|
||||
* Usage : realtype exp_x;
|
||||
* exp_x = SUNRexp(x);
|
||||
* -----------------------------------------------------------------
|
||||
* SUNRexp(x) returns e^x (base-e exponential function).
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef SUNRexp
|
||||
#if defined(SUNDIALS_USE_GENERIC_MATH)
|
||||
#define SUNRexp(x) ((realtype) exp((double) (x)))
|
||||
#elif defined(SUNDIALS_DOUBLE_PRECISION)
|
||||
#define SUNRexp(x) (exp((x)))
|
||||
#elif defined(SUNDIALS_SINGLE_PRECISION)
|
||||
#define SUNRexp(x) (expf((x)))
|
||||
#elif defined(SUNDIALS_EXTENDED_PRECISION)
|
||||
#define SUNRexp(x) (expl((x)))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Function : SUNRceil
|
||||
* -----------------------------------------------------------------
|
||||
* Usage : realtype ceil_x;
|
||||
* ceil_x = SUNRceil(x);
|
||||
* -----------------------------------------------------------------
|
||||
* SUNRceil(x) returns the smallest integer value not less than x.
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef SUNRceil
|
||||
#if defined(SUNDIALS_USE_GENERIC_MATH)
|
||||
#define SUNRceil(x) ((realtype) ceil((double) (x)))
|
||||
#elif defined(SUNDIALS_DOUBLE_PRECISION)
|
||||
#define SUNRceil(x) (ceil((x)))
|
||||
#elif defined(SUNDIALS_SINGLE_PRECISION)
|
||||
#define SUNRceil(x) (ceilf((x)))
|
||||
#elif defined(SUNDIALS_EXTENDED_PRECISION)
|
||||
#define SUNRceil(x) (ceill((x)))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Function : SUNRpowerI
|
||||
* -----------------------------------------------------------------
|
||||
* Usage : int exponent;
|
||||
* realtype base, ans;
|
||||
* ans = SUNRpowerI(base,exponent);
|
||||
* -----------------------------------------------------------------
|
||||
* SUNRpowerI returns the value of base^exponent, where base is of type
|
||||
* realtype and exponent is of type int.
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
SUNDIALS_EXPORT realtype SUNRpowerI(realtype base, int exponent);
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Function : SUNRpowerR
|
||||
* -----------------------------------------------------------------
|
||||
* Usage : realtype base, exponent, ans;
|
||||
* ans = SUNRpowerR(base,exponent);
|
||||
* -----------------------------------------------------------------
|
||||
* SUNRpowerR returns the value of base^exponent, where both base and
|
||||
* exponent are of type realtype. If base < ZERO, then SUNRpowerR
|
||||
* returns ZERO.
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
SUNDIALS_EXPORT realtype SUNRpowerR(realtype base, realtype exponent);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
135
bazaar/plugin/sundials/include/sundials/sundials_matrix.h
Normal file
135
bazaar/plugin/sundials/include/sundials/sundials_matrix.h
Normal file
|
|
@ -0,0 +1,135 @@
|
|||
/* -----------------------------------------------------------------
|
||||
* Programmer(s): Daniel Reynolds @ SMU
|
||||
* David Gardner, Carol Woodward, Slaven Peles,
|
||||
* Cody Balos @ LLNL
|
||||
* -----------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
* -----------------------------------------------------------------
|
||||
* This is the header file for a generic matrix package.
|
||||
* It defines the SUNMatrix structure (_generic_SUNMatrix) which
|
||||
* contains the following fields:
|
||||
* - an implementation-dependent 'content' field which contains
|
||||
* the description and actual data of the matrix
|
||||
* - an 'ops' filed which contains a structure listing operations
|
||||
* acting on such matrices
|
||||
* -----------------------------------------------------------------
|
||||
* This header file contains:
|
||||
* - enumeration constants for all SUNDIALS-defined matrix types,
|
||||
* as well as a generic type for user-supplied matrix types,
|
||||
* - type declarations for the _generic_SUNMatrix and
|
||||
* _generic_SUNMatrix_Ops structures, as well as references to
|
||||
* pointers to such structures (SUNMatrix), and
|
||||
* - prototypes for the matrix functions which operate on
|
||||
* SUNMatrix objects.
|
||||
* -----------------------------------------------------------------
|
||||
* At a minimum, a particular implementation of a SUNMatrix must
|
||||
* do the following:
|
||||
* - specify the 'content' field of SUNMatrix,
|
||||
* - implement the operations on those SUNMatrix objects,
|
||||
* - provide a constructor routine for new SUNMatrix objects
|
||||
*
|
||||
* Additionally, a SUNMatrix implementation may provide the following:
|
||||
* - macros to access the underlying SUNMatrix data
|
||||
* - a routine to print the content of a SUNMatrix
|
||||
* -----------------------------------------------------------------*/
|
||||
|
||||
#ifndef _SUNMATRIX_H
|
||||
#define _SUNMATRIX_H
|
||||
|
||||
#include <sundials/sundials_types.h>
|
||||
#include <sundials/sundials_nvector.h>
|
||||
|
||||
#ifdef __cplusplus /* wrapper to enable C++ usage */
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* -----------------------------------------------------------------
|
||||
* Implemented SUNMatrix types
|
||||
* ----------------------------------------------------------------- */
|
||||
|
||||
typedef enum {
|
||||
SUNMATRIX_DENSE,
|
||||
SUNMATRIX_BAND,
|
||||
SUNMATRIX_SPARSE,
|
||||
SUNMATRIX_SLUNRLOC,
|
||||
SUNMATRIX_CUSPARSE,
|
||||
SUNMATRIX_CUSTOM
|
||||
} SUNMatrix_ID;
|
||||
|
||||
|
||||
/* -----------------------------------------------------------------
|
||||
* Generic definition of SUNMatrix
|
||||
* ----------------------------------------------------------------- */
|
||||
|
||||
/* Forward reference for pointer to SUNMatrix_Ops object */
|
||||
typedef _SUNDIALS_STRUCT_ _generic_SUNMatrix_Ops *SUNMatrix_Ops;
|
||||
|
||||
/* Forward reference for pointer to SUNMatrix object */
|
||||
typedef _SUNDIALS_STRUCT_ _generic_SUNMatrix *SUNMatrix;
|
||||
|
||||
/* Structure containing function pointers to matrix operations */
|
||||
struct _generic_SUNMatrix_Ops {
|
||||
SUNMatrix_ID (*getid)(SUNMatrix);
|
||||
SUNMatrix (*clone)(SUNMatrix);
|
||||
void (*destroy)(SUNMatrix);
|
||||
int (*zero)(SUNMatrix);
|
||||
int (*copy)(SUNMatrix, SUNMatrix);
|
||||
int (*scaleadd)(realtype, SUNMatrix, SUNMatrix);
|
||||
int (*scaleaddi)(realtype, SUNMatrix);
|
||||
int (*matvecsetup)(SUNMatrix);
|
||||
int (*matvec)(SUNMatrix, N_Vector, N_Vector);
|
||||
int (*space)(SUNMatrix, long int*, long int*);
|
||||
};
|
||||
|
||||
/* A matrix is a structure with an implementation-dependent
|
||||
'content' field, and a pointer to a structure of matrix
|
||||
operations corresponding to that implementation. */
|
||||
struct _generic_SUNMatrix {
|
||||
void *content;
|
||||
SUNMatrix_Ops ops;
|
||||
};
|
||||
|
||||
|
||||
/* -----------------------------------------------------------------
|
||||
* Functions exported by SUNMatrix module
|
||||
* ----------------------------------------------------------------- */
|
||||
|
||||
SUNDIALS_EXPORT SUNMatrix SUNMatNewEmpty();
|
||||
SUNDIALS_EXPORT void SUNMatFreeEmpty(SUNMatrix A);
|
||||
SUNDIALS_EXPORT int SUNMatCopyOps(SUNMatrix A, SUNMatrix B);
|
||||
SUNDIALS_EXPORT SUNMatrix_ID SUNMatGetID(SUNMatrix A);
|
||||
SUNDIALS_EXPORT SUNMatrix SUNMatClone(SUNMatrix A);
|
||||
SUNDIALS_EXPORT void SUNMatDestroy(SUNMatrix A);
|
||||
SUNDIALS_EXPORT int SUNMatZero(SUNMatrix A);
|
||||
SUNDIALS_EXPORT int SUNMatCopy(SUNMatrix A, SUNMatrix B);
|
||||
SUNDIALS_EXPORT int SUNMatScaleAdd(realtype c, SUNMatrix A, SUNMatrix B);
|
||||
SUNDIALS_EXPORT int SUNMatScaleAddI(realtype c, SUNMatrix A);
|
||||
SUNDIALS_EXPORT int SUNMatMatvecSetup(SUNMatrix A);
|
||||
SUNDIALS_EXPORT int SUNMatMatvec(SUNMatrix A, N_Vector x, N_Vector y);
|
||||
SUNDIALS_EXPORT int SUNMatSpace(SUNMatrix A, long int *lenrw, long int *leniw);
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* IV. SUNMatrix error codes
|
||||
* ---------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#define SUNMAT_SUCCESS 0 /* function successfull */
|
||||
#define SUNMAT_ILL_INPUT -701 /* illegal function input */
|
||||
#define SUNMAT_MEM_FAIL -702 /* failed memory access/alloc */
|
||||
#define SUNMAT_OPERATION_FAIL -703 /* a SUNMatrix operation returned nonzero */
|
||||
#define SUNMAT_MATVEC_SETUP_REQUIRED -704 /* the SUNMatMatvecSetup routine needs to be called */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
39
bazaar/plugin/sundials/include/sundials/sundials_mpi_types.h
Normal file
39
bazaar/plugin/sundials/include/sundials/sundials_mpi_types.h
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
/* -----------------------------------------------------------------
|
||||
* Programmer(s): Scott Cohen, Alan Hindmarsh, Radu Serban,
|
||||
* Aaron Collier, and Slaven Peles @ LLNL
|
||||
* -----------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
* -----------------------------------------------------------------
|
||||
* This header file contains definitions of MPI data types, which
|
||||
* are used by MPI parallel vector implementations.
|
||||
* -----------------------------------------------------------------*/
|
||||
|
||||
#include <sundials/sundials_types.h>
|
||||
|
||||
/* define MPI data types */
|
||||
|
||||
#if defined(SUNDIALS_SINGLE_PRECISION)
|
||||
#define MPI_SUNREALTYPE MPI_FLOAT
|
||||
#elif defined(SUNDIALS_DOUBLE_PRECISION)
|
||||
#define MPI_SUNREALTYPE MPI_DOUBLE
|
||||
#elif defined(SUNDIALS_EXTENDED_PRECISION)
|
||||
#define MPI_SUNREALTYPE MPI_LONG_DOUBLE
|
||||
#endif
|
||||
|
||||
#if defined(SUNDIALS_INT64_T)
|
||||
#define MPI_SUNINDEXTYPE MPI_INT64_T
|
||||
#elif defined(SUNDIALS_INT32_T)
|
||||
#define MPI_SUNINDEXTYPE MPI_INT32_T
|
||||
#endif
|
||||
|
||||
/* define legacy SUNDIALS MPI data types */
|
||||
#define PVEC_REAL_MPI_TYPE MPI_SUNREALTYPE
|
||||
#define PVEC_INTEGER_MPI_TYPE MPI_SUNINDEXTYPE
|
||||
|
|
@ -0,0 +1,197 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* Programmer(s): David J. Gardner @ LLNL
|
||||
* -----------------------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
* -----------------------------------------------------------------------------
|
||||
* This is the header file for a generic nonlinear solver package. It defines
|
||||
* the SUNNonlinearSolver structure (_generic_SUNNonlinearSolver) which contains
|
||||
* the following fields:
|
||||
* - an implementation-dependent 'content' field which contains any internal
|
||||
* data required by the solver
|
||||
* - an 'ops' filed which contains a structure listing operations acting on/by
|
||||
* such solvers
|
||||
*
|
||||
* We consider iterative nonlinear solvers for systems in both root finding
|
||||
* (F(y) = 0) or fixed-point (G(y) = y) form. As a result, some of the routines
|
||||
* are applicable only to one type of nonlinear solver.
|
||||
* -----------------------------------------------------------------------------
|
||||
* This header file contains:
|
||||
* - function types supplied to a SUNNonlinearSolver,
|
||||
* - enumeration constants for SUNDIALS-defined nonlinear solver types,
|
||||
* - type declarations for the _generic_SUNNonlinearSolver and
|
||||
* _generic_SUNNonlinearSolver_Ops structures, as well as references to
|
||||
* pointers to such structures (SUNNonlinearSolver),
|
||||
* - prototypes for the nonlinear solver functions which operate
|
||||
* on/by SUNNonlinearSolver objects, and
|
||||
* - return codes for SUNLinearSolver objects.
|
||||
* -----------------------------------------------------------------------------
|
||||
* At a minimum, a particular implementation of a SUNNonlinearSolver must do the
|
||||
* following:
|
||||
* - specify the 'content' field of a SUNNonlinearSolver,
|
||||
* - implement the operations on/by the SUNNonlinearSovler objects,
|
||||
* - provide a constructor routine for new SUNNonlinearSolver objects
|
||||
*
|
||||
* Additionally, a SUNNonlinearSolver implementation may provide the following:
|
||||
* - "Set" routines to control solver-specific parameters/options
|
||||
* - "Get" routines to access solver-specific performance metrics
|
||||
* ---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef _SUNNONLINEARSOLVER_H
|
||||
#define _SUNNONLINEARSOLVER_H
|
||||
|
||||
#include <sundials/sundials_types.h>
|
||||
#include <sundials/sundials_nvector.h>
|
||||
|
||||
#ifdef __cplusplus /* wrapper to enable C++ usage */
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Forward references for SUNNonlinearSolver types defined below
|
||||
* ---------------------------------------------------------------------------*/
|
||||
|
||||
/* Forward reference for pointer to SUNNonlinearSolver_Ops object */
|
||||
typedef _SUNDIALS_STRUCT_ _generic_SUNNonlinearSolver_Ops *SUNNonlinearSolver_Ops;
|
||||
|
||||
/* Forward reference for pointer to SUNNonlinearSolver object */
|
||||
typedef _SUNDIALS_STRUCT_ _generic_SUNNonlinearSolver *SUNNonlinearSolver;
|
||||
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Integrator supplied function types
|
||||
* ---------------------------------------------------------------------------*/
|
||||
|
||||
typedef int (*SUNNonlinSolSysFn)(N_Vector y, N_Vector F, void* mem);
|
||||
|
||||
typedef int (*SUNNonlinSolLSetupFn)(booleantype jbad, booleantype* jcur,
|
||||
void* mem);
|
||||
|
||||
typedef int (*SUNNonlinSolLSolveFn)(N_Vector b, void* mem);
|
||||
|
||||
typedef int (*SUNNonlinSolConvTestFn)(SUNNonlinearSolver NLS, N_Vector y,
|
||||
N_Vector del, realtype tol, N_Vector ewt,
|
||||
void* mem);
|
||||
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* SUNNonlinearSolver types
|
||||
* ---------------------------------------------------------------------------*/
|
||||
|
||||
typedef enum {
|
||||
SUNNONLINEARSOLVER_ROOTFIND,
|
||||
SUNNONLINEARSOLVER_FIXEDPOINT
|
||||
} SUNNonlinearSolver_Type;
|
||||
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Generic definition of SUNNonlinearSolver
|
||||
* ---------------------------------------------------------------------------*/
|
||||
|
||||
/* Structure containing function pointers to nonlinear solver operations */
|
||||
struct _generic_SUNNonlinearSolver_Ops {
|
||||
SUNNonlinearSolver_Type (*gettype)(SUNNonlinearSolver);
|
||||
int (*initialize)(SUNNonlinearSolver);
|
||||
int (*setup)(SUNNonlinearSolver, N_Vector, void*);
|
||||
int (*solve)(SUNNonlinearSolver, N_Vector, N_Vector, N_Vector, realtype,
|
||||
booleantype, void*);
|
||||
int (*free)(SUNNonlinearSolver);
|
||||
int (*setsysfn)(SUNNonlinearSolver, SUNNonlinSolSysFn);
|
||||
int (*setlsetupfn)(SUNNonlinearSolver, SUNNonlinSolLSetupFn);
|
||||
int (*setlsolvefn)(SUNNonlinearSolver, SUNNonlinSolLSolveFn);
|
||||
int (*setctestfn)(SUNNonlinearSolver, SUNNonlinSolConvTestFn, void*);
|
||||
int (*setmaxiters)(SUNNonlinearSolver, int);
|
||||
int (*getnumiters)(SUNNonlinearSolver, long int*);
|
||||
int (*getcuriter)(SUNNonlinearSolver, int*);
|
||||
int (*getnumconvfails)(SUNNonlinearSolver, long int*);
|
||||
};
|
||||
|
||||
/* A nonlinear solver is a structure with an implementation-dependent 'content'
|
||||
field, and a pointer to a structure of solver nonlinear solver operations
|
||||
corresponding to that implementation. */
|
||||
struct _generic_SUNNonlinearSolver {
|
||||
void *content;
|
||||
SUNNonlinearSolver_Ops ops;
|
||||
};
|
||||
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Functions exported by SUNNonlinearSolver module
|
||||
* ---------------------------------------------------------------------------*/
|
||||
|
||||
/* empty constructor/destructor */
|
||||
SUNDIALS_EXPORT SUNNonlinearSolver SUNNonlinSolNewEmpty();
|
||||
SUNDIALS_EXPORT void SUNNonlinSolFreeEmpty(SUNNonlinearSolver NLS);
|
||||
|
||||
/* core functions */
|
||||
SUNDIALS_EXPORT SUNNonlinearSolver_Type SUNNonlinSolGetType(SUNNonlinearSolver NLS);
|
||||
|
||||
SUNDIALS_EXPORT int SUNNonlinSolInitialize(SUNNonlinearSolver NLS);
|
||||
|
||||
SUNDIALS_EXPORT int SUNNonlinSolSetup(SUNNonlinearSolver NLS,
|
||||
N_Vector y, void* mem);
|
||||
|
||||
SUNDIALS_EXPORT int SUNNonlinSolSolve(SUNNonlinearSolver NLS,
|
||||
N_Vector y0, N_Vector y,
|
||||
N_Vector w, realtype tol,
|
||||
booleantype callLSetup, void *mem);
|
||||
|
||||
SUNDIALS_EXPORT int SUNNonlinSolFree(SUNNonlinearSolver NLS);
|
||||
|
||||
/* set functions */
|
||||
SUNDIALS_EXPORT int SUNNonlinSolSetSysFn(SUNNonlinearSolver NLS,
|
||||
SUNNonlinSolSysFn SysFn);
|
||||
|
||||
SUNDIALS_EXPORT int SUNNonlinSolSetLSetupFn(SUNNonlinearSolver NLS,
|
||||
SUNNonlinSolLSetupFn SetupFn);
|
||||
|
||||
SUNDIALS_EXPORT int SUNNonlinSolSetLSolveFn(SUNNonlinearSolver NLS,
|
||||
SUNNonlinSolLSolveFn SolveFn);
|
||||
|
||||
SUNDIALS_EXPORT int SUNNonlinSolSetConvTestFn(SUNNonlinearSolver NLS,
|
||||
SUNNonlinSolConvTestFn CTestFn,
|
||||
void* ctest_data);
|
||||
|
||||
SUNDIALS_EXPORT int SUNNonlinSolSetMaxIters(SUNNonlinearSolver NLS,
|
||||
int maxiters);
|
||||
/* get functions */
|
||||
SUNDIALS_EXPORT int SUNNonlinSolGetNumIters(SUNNonlinearSolver NLS,
|
||||
long int *niters);
|
||||
|
||||
SUNDIALS_EXPORT int SUNNonlinSolGetCurIter(SUNNonlinearSolver NLS,
|
||||
int *iter);
|
||||
|
||||
SUNDIALS_EXPORT int SUNNonlinSolGetNumConvFails(SUNNonlinearSolver NLS,
|
||||
long int *nconvfails);
|
||||
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* SUNNonlinearSolver return values
|
||||
* ---------------------------------------------------------------------------*/
|
||||
|
||||
#define SUN_NLS_SUCCESS 0 /* successful / converged */
|
||||
|
||||
/* Recoverable */
|
||||
#define SUN_NLS_CONTINUE +901 /* not converged, keep iterating */
|
||||
#define SUN_NLS_CONV_RECVR +902 /* convergece failure, try to recover */
|
||||
|
||||
/* Unrecoverable */
|
||||
#define SUN_NLS_MEM_NULL -901 /* memory argument is NULL */
|
||||
#define SUN_NLS_MEM_FAIL -902 /* failed memory access / allocation */
|
||||
#define SUN_NLS_ILL_INPUT -903 /* illegal function input */
|
||||
#define SUN_NLS_VECTOROP_ERR -904 /* failed NVector operation */
|
||||
#define SUN_NLS_EXT_FAIL -905 /* failed in external library call */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
264
bazaar/plugin/sundials/include/sundials/sundials_nvector.h
Normal file
264
bazaar/plugin/sundials/include/sundials/sundials_nvector.h
Normal file
|
|
@ -0,0 +1,264 @@
|
|||
/* -----------------------------------------------------------------
|
||||
* Programmer(s): Radu Serban and Aaron Collier @ LLNL
|
||||
* -----------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
* -----------------------------------------------------------------
|
||||
* This is the header file for a generic NVECTOR package.
|
||||
* It defines the N_Vector structure (_generic_N_Vector) which
|
||||
* contains the following fields:
|
||||
* - an implementation-dependent 'content' field which contains
|
||||
* the description and actual data of the vector
|
||||
* - an 'ops' filed which contains a structure listing operations
|
||||
* acting on such vectors
|
||||
* -----------------------------------------------------------------
|
||||
* This header file contains:
|
||||
* - enumeration constants for all SUNDIALS-defined vector types,
|
||||
* as well as a generic type for user-supplied vector types,
|
||||
* - type declarations for the _generic_N_Vector and
|
||||
* _generic_N_Vector_Ops structures, as well as references to
|
||||
* pointers to such structures (N_Vector), and
|
||||
* - prototypes for the vector functions which operate on
|
||||
* N_Vector objects.
|
||||
* -----------------------------------------------------------------
|
||||
* At a minimum, a particular implementation of an NVECTOR must
|
||||
* do the following:
|
||||
* - specify the 'content' field of N_Vector,
|
||||
* - implement the operations on those N_Vector objects,
|
||||
* - provide a constructor routine for new N_Vector objects
|
||||
*
|
||||
* Additionally, an NVECTOR implementation may provide the following:
|
||||
* - macros to access the underlying N_Vector data
|
||||
* - a constructor for an array of N_Vectors
|
||||
* - a constructor for an empty N_Vector (i.e., a new N_Vector with
|
||||
* a NULL data pointer).
|
||||
* - a routine to print the content of an N_Vector
|
||||
* -----------------------------------------------------------------*/
|
||||
|
||||
#ifndef _NVECTOR_H
|
||||
#define _NVECTOR_H
|
||||
|
||||
#include <sundials/sundials_types.h>
|
||||
|
||||
#ifdef __cplusplus /* wrapper to enable C++ usage */
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* -----------------------------------------------------------------
|
||||
* Implemented N_Vector types
|
||||
* ----------------------------------------------------------------- */
|
||||
|
||||
typedef enum {
|
||||
SUNDIALS_NVEC_SERIAL,
|
||||
SUNDIALS_NVEC_PARALLEL,
|
||||
SUNDIALS_NVEC_OPENMP,
|
||||
SUNDIALS_NVEC_PTHREADS,
|
||||
SUNDIALS_NVEC_PARHYP,
|
||||
SUNDIALS_NVEC_PETSC,
|
||||
SUNDIALS_NVEC_CUDA,
|
||||
SUNDIALS_NVEC_RAJA,
|
||||
SUNDIALS_NVEC_OPENMPDEV,
|
||||
SUNDIALS_NVEC_TRILINOS,
|
||||
SUNDIALS_NVEC_MANYVECTOR,
|
||||
SUNDIALS_NVEC_MPIMANYVECTOR,
|
||||
SUNDIALS_NVEC_MPIPLUSX,
|
||||
SUNDIALS_NVEC_CUSTOM
|
||||
} N_Vector_ID;
|
||||
|
||||
|
||||
/* -----------------------------------------------------------------
|
||||
* Generic definition of N_Vector
|
||||
* ----------------------------------------------------------------- */
|
||||
|
||||
/* Forward reference for pointer to N_Vector_Ops object */
|
||||
typedef _SUNDIALS_STRUCT_ _generic_N_Vector_Ops *N_Vector_Ops;
|
||||
|
||||
/* Forward reference for pointer to N_Vector object */
|
||||
typedef _SUNDIALS_STRUCT_ _generic_N_Vector *N_Vector;
|
||||
|
||||
/* Define array of N_Vectors */
|
||||
typedef N_Vector *N_Vector_S;
|
||||
|
||||
/* Structure containing function pointers to vector operations */
|
||||
struct _generic_N_Vector_Ops {
|
||||
N_Vector_ID (*nvgetvectorid)(N_Vector);
|
||||
N_Vector (*nvclone)(N_Vector);
|
||||
N_Vector (*nvcloneempty)(N_Vector);
|
||||
void (*nvdestroy)(N_Vector);
|
||||
void (*nvspace)(N_Vector, sunindextype *, sunindextype *);
|
||||
realtype* (*nvgetarraypointer)(N_Vector);
|
||||
void (*nvsetarraypointer)(realtype *, N_Vector);
|
||||
void* (*nvgetcommunicator)(N_Vector);
|
||||
sunindextype (*nvgetlength)(N_Vector);
|
||||
|
||||
/* standard vector operations */
|
||||
void (*nvlinearsum)(realtype, N_Vector, realtype, N_Vector, N_Vector);
|
||||
void (*nvconst)(realtype, N_Vector);
|
||||
void (*nvprod)(N_Vector, N_Vector, N_Vector);
|
||||
void (*nvdiv)(N_Vector, N_Vector, N_Vector);
|
||||
void (*nvscale)(realtype, N_Vector, N_Vector);
|
||||
void (*nvabs)(N_Vector, N_Vector);
|
||||
void (*nvinv)(N_Vector, N_Vector);
|
||||
void (*nvaddconst)(N_Vector, realtype, N_Vector);
|
||||
realtype (*nvdotprod)(N_Vector, N_Vector);
|
||||
realtype (*nvmaxnorm)(N_Vector);
|
||||
realtype (*nvwrmsnorm)(N_Vector, N_Vector);
|
||||
realtype (*nvwrmsnormmask)(N_Vector, N_Vector, N_Vector);
|
||||
realtype (*nvmin)(N_Vector);
|
||||
realtype (*nvwl2norm)(N_Vector, N_Vector);
|
||||
realtype (*nvl1norm)(N_Vector);
|
||||
void (*nvcompare)(realtype, N_Vector, N_Vector);
|
||||
booleantype (*nvinvtest)(N_Vector, N_Vector);
|
||||
booleantype (*nvconstrmask)(N_Vector, N_Vector, N_Vector);
|
||||
realtype (*nvminquotient)(N_Vector, N_Vector);
|
||||
|
||||
/* fused vector operations */
|
||||
int (*nvlinearcombination)(int, realtype*, N_Vector*, N_Vector);
|
||||
int (*nvscaleaddmulti)(int, realtype*, N_Vector, N_Vector*, N_Vector*);
|
||||
int (*nvdotprodmulti)(int, N_Vector, N_Vector*, realtype*);
|
||||
|
||||
/* vector array operations */
|
||||
int (*nvlinearsumvectorarray)(int, realtype, N_Vector*, realtype, N_Vector*,
|
||||
N_Vector*);
|
||||
int (*nvscalevectorarray)(int, realtype*, N_Vector*, N_Vector*);
|
||||
int (*nvconstvectorarray)(int, realtype, N_Vector*);
|
||||
int (*nvwrmsnormvectorarray)(int, N_Vector*, N_Vector*, realtype*);
|
||||
int (*nvwrmsnormmaskvectorarray)(int, N_Vector*, N_Vector*, N_Vector, realtype*);
|
||||
int (*nvscaleaddmultivectorarray)(int, int, realtype*, N_Vector*, N_Vector**, N_Vector**);
|
||||
int (*nvlinearcombinationvectorarray)(int, int, realtype*, N_Vector**, N_Vector*);
|
||||
|
||||
/* OPTIONAL local reduction kernels (no parallel communication) */
|
||||
realtype (*nvdotprodlocal)(N_Vector, N_Vector);
|
||||
realtype (*nvmaxnormlocal)(N_Vector);
|
||||
realtype (*nvminlocal)(N_Vector);
|
||||
realtype (*nvl1normlocal)(N_Vector);
|
||||
booleantype (*nvinvtestlocal)(N_Vector, N_Vector);
|
||||
booleantype (*nvconstrmasklocal)(N_Vector, N_Vector, N_Vector);
|
||||
realtype (*nvminquotientlocal)(N_Vector, N_Vector);
|
||||
realtype (*nvwsqrsumlocal)(N_Vector, N_Vector);
|
||||
realtype (*nvwsqrsummasklocal)(N_Vector, N_Vector, N_Vector);
|
||||
};
|
||||
|
||||
/* A vector is a structure with an implementation-dependent
|
||||
'content' field, and a pointer to a structure of vector
|
||||
operations corresponding to that implementation. */
|
||||
struct _generic_N_Vector {
|
||||
void *content;
|
||||
N_Vector_Ops ops;
|
||||
};
|
||||
|
||||
|
||||
/* -----------------------------------------------------------------
|
||||
* Functions exported by NVECTOR module
|
||||
* ----------------------------------------------------------------- */
|
||||
|
||||
SUNDIALS_EXPORT N_Vector N_VNewEmpty();
|
||||
SUNDIALS_EXPORT void N_VFreeEmpty(N_Vector v);
|
||||
SUNDIALS_EXPORT int N_VCopyOps(N_Vector w, N_Vector v);
|
||||
|
||||
SUNDIALS_EXPORT N_Vector_ID N_VGetVectorID(N_Vector w);
|
||||
SUNDIALS_EXPORT N_Vector N_VClone(N_Vector w);
|
||||
SUNDIALS_EXPORT N_Vector N_VCloneEmpty(N_Vector w);
|
||||
SUNDIALS_EXPORT void N_VDestroy(N_Vector v);
|
||||
SUNDIALS_EXPORT void N_VSpace(N_Vector v, sunindextype *lrw, sunindextype *liw);
|
||||
SUNDIALS_EXPORT realtype *N_VGetArrayPointer(N_Vector v);
|
||||
SUNDIALS_EXPORT void N_VSetArrayPointer(realtype *v_data, N_Vector v);
|
||||
SUNDIALS_EXPORT void *N_VGetCommunicator(N_Vector v);
|
||||
SUNDIALS_EXPORT sunindextype N_VGetLength(N_Vector v);
|
||||
|
||||
/* standard vector operations */
|
||||
SUNDIALS_EXPORT void N_VLinearSum(realtype a, N_Vector x, realtype b,
|
||||
N_Vector y, N_Vector z);
|
||||
SUNDIALS_EXPORT void N_VConst(realtype c, N_Vector z);
|
||||
SUNDIALS_EXPORT void N_VProd(N_Vector x, N_Vector y, N_Vector z);
|
||||
SUNDIALS_EXPORT void N_VDiv(N_Vector x, N_Vector y, N_Vector z);
|
||||
SUNDIALS_EXPORT void N_VScale(realtype c, N_Vector x, N_Vector z);
|
||||
SUNDIALS_EXPORT void N_VAbs(N_Vector x, N_Vector z);
|
||||
SUNDIALS_EXPORT void N_VInv(N_Vector x, N_Vector z);
|
||||
SUNDIALS_EXPORT void N_VAddConst(N_Vector x, realtype b, N_Vector z);
|
||||
SUNDIALS_EXPORT realtype N_VDotProd(N_Vector x, N_Vector y);
|
||||
SUNDIALS_EXPORT realtype N_VMaxNorm(N_Vector x);
|
||||
SUNDIALS_EXPORT realtype N_VWrmsNorm(N_Vector x, N_Vector w);
|
||||
SUNDIALS_EXPORT realtype N_VWrmsNormMask(N_Vector x, N_Vector w, N_Vector id);
|
||||
SUNDIALS_EXPORT realtype N_VMin(N_Vector x);
|
||||
SUNDIALS_EXPORT realtype N_VWL2Norm(N_Vector x, N_Vector w);
|
||||
SUNDIALS_EXPORT realtype N_VL1Norm(N_Vector x);
|
||||
SUNDIALS_EXPORT void N_VCompare(realtype c, N_Vector x, N_Vector z);
|
||||
SUNDIALS_EXPORT booleantype N_VInvTest(N_Vector x, N_Vector z);
|
||||
SUNDIALS_EXPORT booleantype N_VConstrMask(N_Vector c, N_Vector x, N_Vector m);
|
||||
SUNDIALS_EXPORT realtype N_VMinQuotient(N_Vector num, N_Vector denom);
|
||||
|
||||
/* OPTIONAL fused vector operations */
|
||||
SUNDIALS_EXPORT int N_VLinearCombination(int nvec, realtype* c, N_Vector* X,
|
||||
N_Vector z);
|
||||
|
||||
SUNDIALS_EXPORT int N_VScaleAddMulti(int nvec, realtype* a, N_Vector x,
|
||||
N_Vector* Y, N_Vector* Z);
|
||||
|
||||
SUNDIALS_EXPORT int N_VDotProdMulti(int nvec, N_Vector x, N_Vector* Y,
|
||||
realtype* dotprods);
|
||||
|
||||
/* OPTIONAL vector array operations */
|
||||
SUNDIALS_EXPORT int N_VLinearSumVectorArray(int nvec,
|
||||
realtype a, N_Vector* X,
|
||||
realtype b, N_Vector* Y,
|
||||
N_Vector* Z);
|
||||
|
||||
SUNDIALS_EXPORT int N_VScaleVectorArray(int nvec, realtype* c, N_Vector* X,
|
||||
N_Vector* Z);
|
||||
|
||||
SUNDIALS_EXPORT int N_VConstVectorArray(int nvec, realtype c, N_Vector* Z);
|
||||
|
||||
SUNDIALS_EXPORT int N_VWrmsNormVectorArray(int nvec, N_Vector* X, N_Vector* W,
|
||||
realtype* nrm);
|
||||
|
||||
SUNDIALS_EXPORT int N_VWrmsNormMaskVectorArray(int nvec, N_Vector* X,
|
||||
N_Vector* W, N_Vector id,
|
||||
realtype* nrm);
|
||||
|
||||
SUNDIALS_EXPORT int N_VScaleAddMultiVectorArray(int nvec, int nsum,
|
||||
realtype* a, N_Vector* X,
|
||||
N_Vector** Y, N_Vector** Z);
|
||||
|
||||
SUNDIALS_EXPORT int N_VLinearCombinationVectorArray(int nvec, int nsum,
|
||||
realtype* c, N_Vector** X,
|
||||
N_Vector* Z);
|
||||
|
||||
/* OPTIONAL local reduction kernels (no parallel communication) */
|
||||
SUNDIALS_EXPORT realtype N_VDotProdLocal(N_Vector x, N_Vector y);
|
||||
SUNDIALS_EXPORT realtype N_VMaxNormLocal(N_Vector x);
|
||||
SUNDIALS_EXPORT realtype N_VMinLocal(N_Vector x);
|
||||
SUNDIALS_EXPORT realtype N_VL1NormLocal(N_Vector x);
|
||||
SUNDIALS_EXPORT realtype N_VWSqrSumLocal(N_Vector x, N_Vector w);
|
||||
SUNDIALS_EXPORT realtype N_VWSqrSumMaskLocal(N_Vector x, N_Vector w, N_Vector id);
|
||||
SUNDIALS_EXPORT booleantype N_VInvTestLocal(N_Vector x, N_Vector z);
|
||||
SUNDIALS_EXPORT booleantype N_VConstrMaskLocal(N_Vector c, N_Vector x, N_Vector m);
|
||||
SUNDIALS_EXPORT realtype N_VMinQuotientLocal(N_Vector num, N_Vector denom);
|
||||
|
||||
|
||||
/* -----------------------------------------------------------------
|
||||
* Additional functions exported by NVECTOR module
|
||||
* ----------------------------------------------------------------- */
|
||||
|
||||
SUNDIALS_EXPORT N_Vector* N_VNewVectorArray(int count);
|
||||
SUNDIALS_EXPORT N_Vector* N_VCloneEmptyVectorArray(int count, N_Vector w);
|
||||
SUNDIALS_EXPORT N_Vector* N_VCloneVectorArray(int count, N_Vector w);
|
||||
SUNDIALS_EXPORT void N_VDestroyVectorArray(N_Vector* vs, int count);
|
||||
|
||||
/* These function are really only for users of the Fortran interface */
|
||||
SUNDIALS_EXPORT N_Vector N_VGetVecAtIndexVectorArray(N_Vector* vs, int index);
|
||||
SUNDIALS_EXPORT void N_VSetVecAtIndexVectorArray(N_Vector* vs, int index, N_Vector w);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,104 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* Programmer(s): David J. Gardner @ LLNL
|
||||
* -----------------------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
* -----------------------------------------------------------------------------
|
||||
* This is the header file for the implementation of the NVECTOR SensWrapper.
|
||||
*
|
||||
* Part I contains declarations specific to the implementation of the
|
||||
* vector wrapper.
|
||||
*
|
||||
* Part II defines accessor macros that allow the user to efficiently access
|
||||
* the content of the vector wrapper data structure.
|
||||
*
|
||||
* Part III contains the prototype for the constructors N_VNewEmpty_SensWrapper
|
||||
* and N_VNew_SensWrapper, as well as wrappers to NVECTOR vector operations.
|
||||
* ---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef _NVECTOR_SENSWRAPPER_H
|
||||
#define _NVECTOR_SENSWRAPPER_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sundials/sundials_nvector.h>
|
||||
|
||||
#ifdef __cplusplus /* wrapper to enable C++ usage */
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*==============================================================================
|
||||
PART I: NVector wrapper content structure
|
||||
============================================================================*/
|
||||
|
||||
struct _N_VectorContent_SensWrapper {
|
||||
N_Vector* vecs; /* array of wrapped vectors */
|
||||
int nvecs; /* number of wrapped vectors */
|
||||
booleantype own_vecs; /* flag indicating if wrapper owns vectors */
|
||||
};
|
||||
|
||||
typedef struct _N_VectorContent_SensWrapper *N_VectorContent_SensWrapper;
|
||||
|
||||
/*==============================================================================
|
||||
PART II: Macros to access wrapper content
|
||||
============================================================================*/
|
||||
|
||||
#define NV_CONTENT_SW(v) ( (N_VectorContent_SensWrapper)(v->content) )
|
||||
#define NV_VECS_SW(v) ( NV_CONTENT_SW(v)->vecs )
|
||||
#define NV_NVECS_SW(v) ( NV_CONTENT_SW(v)->nvecs )
|
||||
#define NV_OWN_VECS_SW(v) ( NV_CONTENT_SW(v)->own_vecs )
|
||||
#define NV_VEC_SW(v,i) ( NV_VECS_SW(v)[i] )
|
||||
|
||||
/*==============================================================================
|
||||
PART III: Exported functions
|
||||
============================================================================*/
|
||||
|
||||
/* constructor creates an empty vector wrapper */
|
||||
SUNDIALS_EXPORT N_Vector N_VNewEmpty_SensWrapper(int nvecs);
|
||||
SUNDIALS_EXPORT N_Vector N_VNew_SensWrapper(int count, N_Vector w);
|
||||
|
||||
/* clone operations */
|
||||
SUNDIALS_EXPORT N_Vector N_VCloneEmpty_SensWrapper(N_Vector w);
|
||||
SUNDIALS_EXPORT N_Vector N_VClone_SensWrapper(N_Vector w);
|
||||
|
||||
/* destructor */
|
||||
SUNDIALS_EXPORT void N_VDestroy_SensWrapper(N_Vector v);
|
||||
|
||||
/* standard vector operations */
|
||||
SUNDIALS_EXPORT void N_VLinearSum_SensWrapper(realtype a, N_Vector x,
|
||||
realtype b, N_Vector y,
|
||||
N_Vector z);
|
||||
SUNDIALS_EXPORT void N_VConst_SensWrapper(realtype c, N_Vector z);
|
||||
SUNDIALS_EXPORT void N_VProd_SensWrapper(N_Vector x, N_Vector y, N_Vector z);
|
||||
SUNDIALS_EXPORT void N_VDiv_SensWrapper(N_Vector x, N_Vector y, N_Vector z);
|
||||
SUNDIALS_EXPORT void N_VScale_SensWrapper(realtype c, N_Vector x, N_Vector z);
|
||||
SUNDIALS_EXPORT void N_VAbs_SensWrapper(N_Vector x, N_Vector z);
|
||||
SUNDIALS_EXPORT void N_VInv_SensWrapper(N_Vector x, N_Vector z);
|
||||
SUNDIALS_EXPORT void N_VAddConst_SensWrapper(N_Vector x, realtype b,
|
||||
N_Vector z);
|
||||
SUNDIALS_EXPORT realtype N_VDotProd_SensWrapper(N_Vector x, N_Vector y);
|
||||
SUNDIALS_EXPORT realtype N_VMaxNorm_SensWrapper(N_Vector x);
|
||||
SUNDIALS_EXPORT realtype N_VWrmsNorm_SensWrapper(N_Vector x, N_Vector w);
|
||||
SUNDIALS_EXPORT realtype N_VWrmsNormMask_SensWrapper(N_Vector x, N_Vector w,
|
||||
N_Vector id);
|
||||
SUNDIALS_EXPORT realtype N_VMin_SensWrapper(N_Vector x);
|
||||
SUNDIALS_EXPORT realtype N_VWL2Norm_SensWrapper(N_Vector x, N_Vector w);
|
||||
SUNDIALS_EXPORT realtype N_VL1Norm_SensWrapper(N_Vector x);
|
||||
SUNDIALS_EXPORT void N_VCompare_SensWrapper(realtype c, N_Vector x, N_Vector z);
|
||||
SUNDIALS_EXPORT booleantype N_VInvTest_SensWrapper(N_Vector x, N_Vector z);
|
||||
SUNDIALS_EXPORT booleantype N_VConstrMask_SensWrapper(N_Vector c, N_Vector x,
|
||||
N_Vector m);
|
||||
SUNDIALS_EXPORT realtype N_VMinQuotient_SensWrapper(N_Vector num,
|
||||
N_Vector denom);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
160
bazaar/plugin/sundials/include/sundials/sundials_types.h
Normal file
160
bazaar/plugin/sundials/include/sundials/sundials_types.h
Normal file
|
|
@ -0,0 +1,160 @@
|
|||
/* -----------------------------------------------------------------
|
||||
* Programmer(s): Scott Cohen, Alan Hindmarsh, Radu Serban,
|
||||
* Aaron Collier, and Slaven Peles @ LLNL
|
||||
* -----------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
* -----------------------------------------------------------------
|
||||
* This header file exports three types: realtype, sunindextype and
|
||||
* booleantype, as well as the constants SUNTRUE and SUNFALSE.
|
||||
*
|
||||
* Users should include the header file sundials_types.h in every
|
||||
* program file and use the exported name realtype instead of
|
||||
* float, double or long double.
|
||||
*
|
||||
* The constants SUNDIALS_SINGLE_PRECISION, SUNDIALS_DOUBLE_PRECISION
|
||||
* and SUNDIALS_LONG_DOUBLE_PRECISION indicate the underlying data
|
||||
* type of realtype.
|
||||
*
|
||||
* The legal types for realtype are float, double and long double.
|
||||
*
|
||||
* The constants SUNDIALS_INT64_T and SUNDIALS_INT32_T indicate
|
||||
* the underlying data type of sunindextype -- the integer data type
|
||||
* used for vector and matrix indices.
|
||||
*
|
||||
* Data types are set at the configuration stage.
|
||||
*
|
||||
* The macro RCONST gives the user a convenient way to define
|
||||
* real-valued literal constants. To use the constant 1.0, for example,
|
||||
* the user should write the following:
|
||||
*
|
||||
* #define ONE RCONST(1.0)
|
||||
*
|
||||
* If realtype is defined as a double, then RCONST(1.0) expands
|
||||
* to 1.0. If realtype is defined as a float, then RCONST(1.0)
|
||||
* expands to 1.0F. If realtype is defined as a long double,
|
||||
* then RCONST(1.0) expands to 1.0L. There is never a need to
|
||||
* explicitly cast 1.0 to (realtype). The macro can be used for
|
||||
* literal constants only. It cannot be used for expressions.
|
||||
* -----------------------------------------------------------------*/
|
||||
|
||||
#ifndef _SUNDIALSTYPES_H
|
||||
#define _SUNDIALSTYPES_H
|
||||
|
||||
#ifndef _SUNDIALS_CONFIG_H
|
||||
#define _SUNDIALS_CONFIG_H
|
||||
#include <sundials/sundials_config.h>
|
||||
#endif
|
||||
|
||||
#include <float.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus /* wrapper to enable C++ usage */
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
*------------------------------------------------------------------
|
||||
* Macro _SUNDIALS_STRUCT_
|
||||
* The _SUNDIALS_STRUCT_ macro is defined as a `struct` unless
|
||||
* generating the SWIG interfaces - in that case it is defined as
|
||||
* nothing. This is needed to work around a bug in SWIG which prevents
|
||||
* it from properly parsing our generic module structures.
|
||||
*------------------------------------------------------------------
|
||||
*/
|
||||
#ifdef SWIG
|
||||
#define _SUNDIALS_STRUCT_
|
||||
#else
|
||||
#define _SUNDIALS_STRUCT_ struct
|
||||
#endif
|
||||
|
||||
/*
|
||||
*------------------------------------------------------------------
|
||||
* Type realtype
|
||||
* Macro RCONST
|
||||
* Constants BIG_REAL, SMALL_REAL, and UNIT_ROUNDOFF
|
||||
*------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#if defined(SUNDIALS_SINGLE_PRECISION)
|
||||
|
||||
typedef float realtype;
|
||||
# define RCONST(x) x##F
|
||||
# define BIG_REAL FLT_MAX
|
||||
# define SMALL_REAL FLT_MIN
|
||||
# define UNIT_ROUNDOFF FLT_EPSILON
|
||||
|
||||
#elif defined(SUNDIALS_DOUBLE_PRECISION)
|
||||
|
||||
typedef double realtype;
|
||||
# define RCONST(x) x
|
||||
# define BIG_REAL DBL_MAX
|
||||
# define SMALL_REAL DBL_MIN
|
||||
# define UNIT_ROUNDOFF DBL_EPSILON
|
||||
|
||||
#elif defined(SUNDIALS_EXTENDED_PRECISION)
|
||||
|
||||
typedef long double realtype;
|
||||
# define RCONST(x) x##L
|
||||
# define BIG_REAL LDBL_MAX
|
||||
# define SMALL_REAL LDBL_MIN
|
||||
# define UNIT_ROUNDOFF LDBL_EPSILON
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*------------------------------------------------------------------
|
||||
* Type : sunindextype
|
||||
*------------------------------------------------------------------
|
||||
* Defines integer type to be used for vector and matrix indices.
|
||||
* User can build sundials to use 32- or 64-bit signed integers.
|
||||
* If compiler does not support portable data types, the SUNDIALS
|
||||
* CMake build system tries to find a type of the desired size.
|
||||
*------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
typedef SUNDIALS_INDEX_TYPE sunindextype;
|
||||
|
||||
/*
|
||||
*------------------------------------------------------------------
|
||||
* Type : booleantype
|
||||
*------------------------------------------------------------------
|
||||
* Constants : SUNFALSE and SUNTRUE
|
||||
*------------------------------------------------------------------
|
||||
* ANSI C does not have a built-in boolean data type. Below is the
|
||||
* definition for a new type called booleantype. The advantage of
|
||||
* using the name booleantype (instead of int) is an increase in
|
||||
* code readability. It also allows the programmer to make a
|
||||
* distinction between int and boolean data. Variables of type
|
||||
* booleantype are intended to have only the two values SUNFALSE and
|
||||
* SUNTRUE which are defined below to be equal to 0 and 1,
|
||||
* respectively.
|
||||
*------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef booleantype
|
||||
#define booleantype int
|
||||
#endif
|
||||
|
||||
#ifndef SUNFALSE
|
||||
#define SUNFALSE 0
|
||||
#endif
|
||||
|
||||
#ifndef SUNTRUE
|
||||
#define SUNTRUE 1
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _SUNDIALSTYPES_H */
|
||||
38
bazaar/plugin/sundials/include/sundials/sundials_version.h
Normal file
38
bazaar/plugin/sundials/include/sundials/sundials_version.h
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
/* -----------------------------------------------------------------
|
||||
* Programmer(s): David J. Gardner @ LLNL
|
||||
* -----------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
* -----------------------------------------------------------------
|
||||
* This header file is for routines to get SUNDIALS version info
|
||||
* -----------------------------------------------------------------*/
|
||||
|
||||
#ifndef _SUNDIALS_VERSION_H
|
||||
#define _SUNDIALS_VERSION_H
|
||||
|
||||
#include <sundials/sundials_config.h>
|
||||
|
||||
#ifdef __cplusplus /* wrapper to enable C++ usage */
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Fill a string with SUNDIALS version information */
|
||||
SUNDIALS_EXPORT int SUNDIALSGetVersion(char *version, int len);
|
||||
|
||||
/* Fills integers with the major, minor, and patch release version numbers and a
|
||||
string with the release label.*/
|
||||
SUNDIALS_EXPORT int SUNDIALSGetVersionNumber(int *major, int *minor, int *patch,
|
||||
char *label, int len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
76
bazaar/plugin/sundials/include/sunlinsol/sunlinsol_band.h
Normal file
76
bazaar/plugin/sundials/include/sunlinsol/sunlinsol_band.h
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Programmer(s): Daniel Reynolds, Ashley Crawford @ SMU
|
||||
* -----------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
* -----------------------------------------------------------------
|
||||
* This is the header file for the band implementation of the
|
||||
* SUNLINSOL module, SUNLINSOL_BAND.
|
||||
*
|
||||
* Note:
|
||||
* - The definition of the generic SUNLinearSolver structure can
|
||||
* be found in the header file sundials_linearsolver.h.
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef _SUNLINSOL_BAND_H
|
||||
#define _SUNLINSOL_BAND_H
|
||||
|
||||
#include <sundials/sundials_linearsolver.h>
|
||||
#include <sundials/sundials_matrix.h>
|
||||
#include <sundials/sundials_nvector.h>
|
||||
#include <sundials/sundials_band.h>
|
||||
#include <sunmatrix/sunmatrix_band.h>
|
||||
|
||||
#ifdef __cplusplus /* wrapper to enable C++ usage */
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* ---------------------------------------
|
||||
* Band Implementation of SUNLinearSolver
|
||||
* --------------------------------------- */
|
||||
|
||||
struct _SUNLinearSolverContent_Band {
|
||||
sunindextype N;
|
||||
sunindextype *pivots;
|
||||
sunindextype last_flag;
|
||||
};
|
||||
|
||||
typedef struct _SUNLinearSolverContent_Band *SUNLinearSolverContent_Band;
|
||||
|
||||
|
||||
/* --------------------------------------
|
||||
* Exported Functions for SUNLINSOL_BAND
|
||||
* -------------------------------------- */
|
||||
|
||||
SUNDIALS_EXPORT SUNLinearSolver SUNLinSol_Band(N_Vector y, SUNMatrix A);
|
||||
|
||||
/* deprecated */
|
||||
SUNDIALS_EXPORT SUNLinearSolver SUNBandLinearSolver(N_Vector y,
|
||||
SUNMatrix A);
|
||||
|
||||
SUNDIALS_EXPORT SUNLinearSolver_Type SUNLinSolGetType_Band(SUNLinearSolver S);
|
||||
SUNDIALS_EXPORT SUNLinearSolver_ID SUNLinSolGetID_Band(SUNLinearSolver S);
|
||||
SUNDIALS_EXPORT int SUNLinSolInitialize_Band(SUNLinearSolver S);
|
||||
SUNDIALS_EXPORT int SUNLinSolSetup_Band(SUNLinearSolver S, SUNMatrix A);
|
||||
SUNDIALS_EXPORT int SUNLinSolSolve_Band(SUNLinearSolver S, SUNMatrix A,
|
||||
N_Vector x, N_Vector b, realtype tol);
|
||||
SUNDIALS_EXPORT sunindextype SUNLinSolLastFlag_Band(SUNLinearSolver S);
|
||||
SUNDIALS_EXPORT int SUNLinSolSpace_Band(SUNLinearSolver S,
|
||||
long int *lenrwLS,
|
||||
long int *leniwLS);
|
||||
SUNDIALS_EXPORT int SUNLinSolFree_Band(SUNLinearSolver S);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,111 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
* Programmer(s): Cody J. Balos @ LLNL
|
||||
* ----------------------------------------------------------------------------
|
||||
* Based on work by Donald Wilcox @ LBNL
|
||||
* ----------------------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
* ----------------------------------------------------------------------------
|
||||
* Header file for cuSolverSp batched QR SUNLinearSolver interface.
|
||||
* ----------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef _SUNLINSOL_CUSOLVERSP_H
|
||||
#define _SUNLINSOL_CUSOLVERSP_H
|
||||
|
||||
#include <cuda_runtime.h>
|
||||
#include <cusolverSp.h>
|
||||
|
||||
#include <sundials/sundials_linearsolver.h>
|
||||
#include <sundials/sundials_matrix.h>
|
||||
#include <sundials/sundials_nvector.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* ----------------------------------------------------------------------------
|
||||
* PART I: cuSolverSp implementation of SUNLinearSolver
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
struct _SUNLinearSolverContent_cuSolverSp_batchQR {
|
||||
int last_flag; /* last return flag */
|
||||
booleantype first_factorize; /* is this the first factorization? */
|
||||
size_t internal_size; /* size of cusolver internal buffer for Q and R */
|
||||
size_t workspace_size; /* size of cusolver memory block for num. factorization */
|
||||
cusolverSpHandle_t cusolver_handle; /* cuSolverSp context */
|
||||
csrqrInfo_t info; /* opaque cusolver data structure */
|
||||
void* workspace; /* memory block used by cusolver */
|
||||
const char* desc; /* description of this linear solver */
|
||||
};
|
||||
|
||||
typedef struct _SUNLinearSolverContent_cuSolverSp_batchQR *SUNLinearSolverContent_cuSolverSp_batchQR;
|
||||
|
||||
|
||||
/*
|
||||
* ----------------------------------------------------------------------------
|
||||
* PART II: Functions exported by sunlinsol_sludist
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
SUNDIALS_EXPORT SUNLinearSolver SUNLinSol_cuSolverSp_batchQR(N_Vector y, SUNMatrix A,
|
||||
cusolverSpHandle_t cusol_handle);
|
||||
|
||||
|
||||
/*
|
||||
* ----------------------------------------------------------------------------
|
||||
* cuSolverSp implementations of SUNLinearSolver operations
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
SUNDIALS_EXPORT SUNLinearSolver_Type SUNLinSolGetType_cuSolverSp_batchQR(SUNLinearSolver S);
|
||||
|
||||
SUNDIALS_EXPORT SUNLinearSolver_ID SUNLinSolGetID_cuSolverSp_batchQR(SUNLinearSolver S);
|
||||
|
||||
SUNDIALS_EXPORT int SUNLinSolInitialize_cuSolverSp_batchQR(SUNLinearSolver S);
|
||||
|
||||
SUNDIALS_EXPORT int SUNLinSolSetup_cuSolverSp_batchQR(SUNLinearSolver S,
|
||||
SUNMatrix A);
|
||||
|
||||
SUNDIALS_EXPORT int SUNLinSolSolve_cuSolverSp_batchQR(SUNLinearSolver S,
|
||||
SUNMatrix A,
|
||||
N_Vector x,
|
||||
N_Vector b,
|
||||
realtype tol);
|
||||
|
||||
SUNDIALS_EXPORT sunindextype SUNLinSolLastFlag_cuSolverSp_batchQR(SUNLinearSolver S);
|
||||
|
||||
SUNDIALS_EXPORT int SUNLinSolFree_cuSolverSp_batchQR(SUNLinearSolver S);
|
||||
|
||||
|
||||
/*
|
||||
* ----------------------------------------------------------------------------
|
||||
* Additional get and set functions.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
SUNDIALS_EXPORT void SUNLinSol_cuSolverSp_batchQR_GetDescription(SUNLinearSolver S,
|
||||
char** desc);
|
||||
|
||||
SUNDIALS_EXPORT void SUNLinSol_cuSolverSp_batchQR_SetDescription(SUNLinearSolver S,
|
||||
const char* desc);
|
||||
|
||||
SUNDIALS_EXPORT void SUNLinSol_cuSolverSp_batchQR_GetDeviceSpace(SUNLinearSolver S,
|
||||
size_t* cuSolverInternal,
|
||||
size_t* cuSolverWorkspace);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
80
bazaar/plugin/sundials/include/sunlinsol/sunlinsol_dense.h
Normal file
80
bazaar/plugin/sundials/include/sunlinsol/sunlinsol_dense.h
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Programmer(s): Daniel Reynolds, Ashley Crawford @ SMU
|
||||
* -----------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
* -----------------------------------------------------------------
|
||||
* This is the header file for the dense implementation of the
|
||||
* SUNLINSOL module, SUNLINSOL_DENSE.
|
||||
*
|
||||
* Notes:
|
||||
* - The definition of the generic SUNLinearSolver structure can
|
||||
* be found in the header file sundials_linearsolver.h.
|
||||
* - The definition of the type 'realtype' can be found in the
|
||||
* header file sundials_types.h, and it may be changed (at the
|
||||
* configuration stage) according to the user's needs.
|
||||
* The sundials_types.h file also contains the definition
|
||||
* for the type 'booleantype' and 'indextype'.
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef _SUNLINSOL_DENSE_H
|
||||
#define _SUNLINSOL_DENSE_H
|
||||
|
||||
#include <sundials/sundials_linearsolver.h>
|
||||
#include <sundials/sundials_matrix.h>
|
||||
#include <sundials/sundials_nvector.h>
|
||||
#include <sundials/sundials_dense.h>
|
||||
#include <sunmatrix/sunmatrix_dense.h>
|
||||
|
||||
#ifdef __cplusplus /* wrapper to enable C++ usage */
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* ----------------------------------------
|
||||
* Dense Implementation of SUNLinearSolver
|
||||
* ---------------------------------------- */
|
||||
|
||||
struct _SUNLinearSolverContent_Dense {
|
||||
sunindextype N;
|
||||
sunindextype *pivots;
|
||||
sunindextype last_flag;
|
||||
};
|
||||
|
||||
typedef struct _SUNLinearSolverContent_Dense *SUNLinearSolverContent_Dense;
|
||||
|
||||
/* ----------------------------------------
|
||||
* Exported Functions for SUNLINSOL_DENSE
|
||||
* ---------------------------------------- */
|
||||
|
||||
SUNDIALS_EXPORT SUNLinearSolver SUNLinSol_Dense(N_Vector y, SUNMatrix A);
|
||||
|
||||
/* deprecated */
|
||||
SUNDIALS_EXPORT SUNLinearSolver SUNDenseLinearSolver(N_Vector y,
|
||||
SUNMatrix A);
|
||||
|
||||
SUNDIALS_EXPORT SUNLinearSolver_Type SUNLinSolGetType_Dense(SUNLinearSolver S);
|
||||
SUNDIALS_EXPORT SUNLinearSolver_ID SUNLinSolGetID_Dense(SUNLinearSolver S);
|
||||
SUNDIALS_EXPORT int SUNLinSolInitialize_Dense(SUNLinearSolver S);
|
||||
SUNDIALS_EXPORT int SUNLinSolSetup_Dense(SUNLinearSolver S, SUNMatrix A);
|
||||
SUNDIALS_EXPORT int SUNLinSolSolve_Dense(SUNLinearSolver S, SUNMatrix A,
|
||||
N_Vector x, N_Vector b, realtype tol);
|
||||
SUNDIALS_EXPORT sunindextype SUNLinSolLastFlag_Dense(SUNLinearSolver S);
|
||||
SUNDIALS_EXPORT int SUNLinSolSpace_Dense(SUNLinearSolver S,
|
||||
long int *lenrwLS,
|
||||
long int *leniwLS);
|
||||
SUNDIALS_EXPORT int SUNLinSolFree_Dense(SUNLinearSolver S);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,87 @@
|
|||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Programmer(s): Daniel Reynolds @ SMU
|
||||
* -----------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
* -----------------------------------------------------------------
|
||||
* This is the header file for the LAPACK band implementation of the
|
||||
* SUNLINSOL module, SUNLINSOL_LAPACKBAND.
|
||||
*
|
||||
* Note:
|
||||
* - The definition of the generic SUNLinearSolver structure can
|
||||
* be found in the header file sundials_linearsolver.h.
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef _SUNLINSOL_LAPBAND_H
|
||||
#define _SUNLINSOL_LAPBAND_H
|
||||
|
||||
#include <sundials/sundials_linearsolver.h>
|
||||
#include <sundials/sundials_lapack.h>
|
||||
#include <sundials/sundials_matrix.h>
|
||||
#include <sundials/sundials_nvector.h>
|
||||
#include <sunmatrix/sunmatrix_band.h>
|
||||
|
||||
#ifdef __cplusplus /* wrapper to enable C++ usage */
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Interfaces to match 'realtype' with the correct LAPACK functions */
|
||||
#if defined(SUNDIALS_DOUBLE_PRECISION)
|
||||
#define xgbtrf_f77 dgbtrf_f77
|
||||
#define xgbtrs_f77 dgbtrs_f77
|
||||
#elif defined(SUNDIALS_SINGLE_PRECISION)
|
||||
#define xgbtrf_f77 sgbtrf_f77
|
||||
#define xgbtrs_f77 sgbtrs_f77
|
||||
#else
|
||||
#error Incompatible realtype for LAPACK; disable LAPACK and rebuild
|
||||
#endif
|
||||
|
||||
/* ----------------------------------------------
|
||||
* LAPACK band implementation of SUNLinearSolver
|
||||
* ---------------------------------------------- */
|
||||
|
||||
struct _SUNLinearSolverContent_LapackBand {
|
||||
sunindextype N;
|
||||
sunindextype *pivots;
|
||||
sunindextype last_flag;
|
||||
};
|
||||
|
||||
typedef struct _SUNLinearSolverContent_LapackBand *SUNLinearSolverContent_LapackBand;
|
||||
|
||||
|
||||
/* --------------------------------------------
|
||||
* Exported Functions for SUNLINSOL_LAPACKBAND
|
||||
* -------------------------------------------- */
|
||||
|
||||
SUNDIALS_EXPORT SUNLinearSolver SUNLinSol_LapackBand(N_Vector y,
|
||||
SUNMatrix A);
|
||||
|
||||
/* deprecated */
|
||||
SUNDIALS_EXPORT SUNLinearSolver SUNLapackBand(N_Vector y, SUNMatrix A);
|
||||
|
||||
SUNDIALS_EXPORT SUNLinearSolver_Type SUNLinSolGetType_LapackBand(SUNLinearSolver S);
|
||||
SUNDIALS_EXPORT SUNLinearSolver_ID SUNLinSolGetID_LapackBand(SUNLinearSolver S);
|
||||
SUNDIALS_EXPORT int SUNLinSolInitialize_LapackBand(SUNLinearSolver S);
|
||||
SUNDIALS_EXPORT int SUNLinSolSetup_LapackBand(SUNLinearSolver S, SUNMatrix A);
|
||||
SUNDIALS_EXPORT int SUNLinSolSolve_LapackBand(SUNLinearSolver S, SUNMatrix A,
|
||||
N_Vector x, N_Vector b, realtype tol);
|
||||
SUNDIALS_EXPORT sunindextype SUNLinSolLastFlag_LapackBand(SUNLinearSolver S);
|
||||
SUNDIALS_EXPORT int SUNLinSolSpace_LapackBand(SUNLinearSolver S,
|
||||
long int *lenrwLS,
|
||||
long int *leniwLS);
|
||||
SUNDIALS_EXPORT int SUNLinSolFree_LapackBand(SUNLinearSolver S);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,87 @@
|
|||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Programmer(s): Daniel Reynolds @ SMU
|
||||
* -----------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
* -----------------------------------------------------------------
|
||||
* This is the header file for the LAPACK dense implementation of the
|
||||
* SUNLINSOL module, SUNLINSOL_LINPACKDENSE.
|
||||
*
|
||||
* Note:
|
||||
* - The definition of the generic SUNLinearSolver structure can
|
||||
* be found in the header file sundials_linearsolver.h.
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef _SUNLINSOL_LAPDENSE_H
|
||||
#define _SUNLINSOL_LAPDENSE_H
|
||||
|
||||
#include <sundials/sundials_linearsolver.h>
|
||||
#include <sundials/sundials_lapack.h>
|
||||
#include <sundials/sundials_matrix.h>
|
||||
#include <sundials/sundials_nvector.h>
|
||||
#include <sunmatrix/sunmatrix_dense.h>
|
||||
|
||||
#ifdef __cplusplus /* wrapper to enable C++ usage */
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Interfaces to match 'realtype' with the correct LAPACK functions */
|
||||
#if defined(SUNDIALS_DOUBLE_PRECISION)
|
||||
#define xgetrf_f77 dgetrf_f77
|
||||
#define xgetrs_f77 dgetrs_f77
|
||||
#elif defined(SUNDIALS_SINGLE_PRECISION)
|
||||
#define xgetrf_f77 sgetrf_f77
|
||||
#define xgetrs_f77 sgetrs_f77
|
||||
#else
|
||||
#error Incompatible realtype for LAPACK; disable LAPACK and rebuild
|
||||
#endif
|
||||
|
||||
/* -----------------------------------------------
|
||||
* LAPACK dense implementation of SUNLinearSolver
|
||||
* ----------------------------------------------- */
|
||||
|
||||
struct _SUNLinearSolverContent_LapackDense {
|
||||
sunindextype N;
|
||||
sunindextype *pivots;
|
||||
sunindextype last_flag;
|
||||
};
|
||||
|
||||
typedef struct _SUNLinearSolverContent_LapackDense *SUNLinearSolverContent_LapackDense;
|
||||
|
||||
|
||||
/* ---------------------------------------------
|
||||
* Exported Functions for SUNLINSOL_LAPACKDENSE
|
||||
* --------------------------------------------- */
|
||||
|
||||
SUNDIALS_EXPORT SUNLinearSolver SUNLinSol_LapackDense(N_Vector y,
|
||||
SUNMatrix A);
|
||||
|
||||
/* deprecated */
|
||||
SUNDIALS_EXPORT SUNLinearSolver SUNLapackDense(N_Vector y, SUNMatrix A);
|
||||
|
||||
SUNDIALS_EXPORT SUNLinearSolver_Type SUNLinSolGetType_LapackDense(SUNLinearSolver S);
|
||||
SUNDIALS_EXPORT SUNLinearSolver_ID SUNLinSolGetID_LapackDense(SUNLinearSolver S);
|
||||
SUNDIALS_EXPORT int SUNLinSolInitialize_LapackDense(SUNLinearSolver S);
|
||||
SUNDIALS_EXPORT int SUNLinSolSetup_LapackDense(SUNLinearSolver S, SUNMatrix A);
|
||||
SUNDIALS_EXPORT int SUNLinSolSolve_LapackDense(SUNLinearSolver S, SUNMatrix A,
|
||||
N_Vector x, N_Vector b, realtype tol);
|
||||
SUNDIALS_EXPORT sunindextype SUNLinSolLastFlag_LapackDense(SUNLinearSolver S);
|
||||
SUNDIALS_EXPORT int SUNLinSolSpace_LapackDense(SUNLinearSolver S,
|
||||
long int *lenrwLS,
|
||||
long int *leniwLS);
|
||||
SUNDIALS_EXPORT int SUNLinSolFree_LapackDense(SUNLinearSolver S);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
113
bazaar/plugin/sundials/include/sunlinsol/sunlinsol_pcg.h
Normal file
113
bazaar/plugin/sundials/include/sunlinsol/sunlinsol_pcg.h
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Programmer(s): Daniel Reynolds, Ashley Crawford @ SMU
|
||||
* -----------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
* -----------------------------------------------------------------
|
||||
* This is the header file for the PCG implementation of the
|
||||
* SUNLINSOL module, SUNLINSOL_PCG. The PCG algorithm is based
|
||||
* on the Preconditioned Conjugate Gradient.
|
||||
*
|
||||
* Note:
|
||||
* - The definition of the generic SUNLinearSolver structure can
|
||||
* be found in the header file sundials_linearsolver.h.
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef _SUNLINSOL_PCG_H
|
||||
#define _SUNLINSOL_PCG_H
|
||||
|
||||
#include <sundials/sundials_linearsolver.h>
|
||||
#include <sundials/sundials_matrix.h>
|
||||
#include <sundials/sundials_nvector.h>
|
||||
|
||||
#ifdef __cplusplus /* wrapper to enable C++ usage */
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Default PCG solver parameters */
|
||||
#define SUNPCG_MAXL_DEFAULT 5
|
||||
|
||||
/* --------------------------------------
|
||||
* PCG Implementation of SUNLinearSolver
|
||||
* -------------------------------------- */
|
||||
|
||||
struct _SUNLinearSolverContent_PCG {
|
||||
int maxl;
|
||||
int pretype;
|
||||
int numiters;
|
||||
realtype resnorm;
|
||||
int last_flag;
|
||||
|
||||
ATimesFn ATimes;
|
||||
void* ATData;
|
||||
PSetupFn Psetup;
|
||||
PSolveFn Psolve;
|
||||
void* PData;
|
||||
|
||||
N_Vector s;
|
||||
N_Vector r;
|
||||
N_Vector p;
|
||||
N_Vector z;
|
||||
N_Vector Ap;
|
||||
};
|
||||
|
||||
typedef struct _SUNLinearSolverContent_PCG *SUNLinearSolverContent_PCG;
|
||||
|
||||
|
||||
/* -------------------------------------
|
||||
* Exported Functions for SUNLINSOL_PCG
|
||||
* ------------------------------------- */
|
||||
|
||||
SUNDIALS_EXPORT SUNLinearSolver SUNLinSol_PCG(N_Vector y,
|
||||
int pretype,
|
||||
int maxl);
|
||||
SUNDIALS_EXPORT int SUNLinSol_PCGSetPrecType(SUNLinearSolver S,
|
||||
int pretype);
|
||||
SUNDIALS_EXPORT int SUNLinSol_PCGSetMaxl(SUNLinearSolver S,
|
||||
int maxl);
|
||||
|
||||
/* deprecated */
|
||||
SUNDIALS_EXPORT SUNLinearSolver SUNPCG(N_Vector y, int pretype, int maxl);
|
||||
/* deprecated */
|
||||
SUNDIALS_EXPORT int SUNPCGSetPrecType(SUNLinearSolver S, int pretype);
|
||||
/* deprecated */
|
||||
SUNDIALS_EXPORT int SUNPCGSetMaxl(SUNLinearSolver S, int maxl);
|
||||
|
||||
SUNDIALS_EXPORT SUNLinearSolver_Type SUNLinSolGetType_PCG(SUNLinearSolver S);
|
||||
SUNDIALS_EXPORT SUNLinearSolver_ID SUNLinSolGetID_PCG(SUNLinearSolver S);
|
||||
SUNDIALS_EXPORT int SUNLinSolInitialize_PCG(SUNLinearSolver S);
|
||||
SUNDIALS_EXPORT int SUNLinSolSetATimes_PCG(SUNLinearSolver S, void* A_data,
|
||||
ATimesFn ATimes);
|
||||
SUNDIALS_EXPORT int SUNLinSolSetPreconditioner_PCG(SUNLinearSolver S,
|
||||
void* P_data,
|
||||
PSetupFn Pset,
|
||||
PSolveFn Psol);
|
||||
SUNDIALS_EXPORT int SUNLinSolSetScalingVectors_PCG(SUNLinearSolver S,
|
||||
N_Vector s,
|
||||
N_Vector nul);
|
||||
SUNDIALS_EXPORT int SUNLinSolSetup_PCG(SUNLinearSolver S, SUNMatrix nul);
|
||||
SUNDIALS_EXPORT int SUNLinSolSolve_PCG(SUNLinearSolver S, SUNMatrix nul,
|
||||
N_Vector x, N_Vector b, realtype tol);
|
||||
SUNDIALS_EXPORT int SUNLinSolNumIters_PCG(SUNLinearSolver S);
|
||||
SUNDIALS_EXPORT realtype SUNLinSolResNorm_PCG(SUNLinearSolver S);
|
||||
SUNDIALS_EXPORT N_Vector SUNLinSolResid_PCG(SUNLinearSolver S);
|
||||
SUNDIALS_EXPORT sunindextype SUNLinSolLastFlag_PCG(SUNLinearSolver S);
|
||||
SUNDIALS_EXPORT int SUNLinSolSpace_PCG(SUNLinearSolver S,
|
||||
long int *lenrwLS,
|
||||
long int *leniwLS);
|
||||
SUNDIALS_EXPORT int SUNLinSolFree_PCG(SUNLinearSolver S);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
120
bazaar/plugin/sundials/include/sunlinsol/sunlinsol_spbcgs.h
Normal file
120
bazaar/plugin/sundials/include/sunlinsol/sunlinsol_spbcgs.h
Normal file
|
|
@ -0,0 +1,120 @@
|
|||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Programmer(s): Daniel Reynolds @ SMU
|
||||
* Based on code sundials_spbcgs.h by: Peter Brown and
|
||||
* Aaron Collier @ LLNL
|
||||
* -----------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
* -----------------------------------------------------------------
|
||||
* This is the header file for the SPBCGS implementation of the
|
||||
* SUNLINSOL module, SUNLINSOL_SPBCGS. The SPBCGS algorithm is based
|
||||
* on the Scaled Preconditioned Bi-CG-Stabilized method.
|
||||
*
|
||||
* Note:
|
||||
* - The definition of the generic SUNLinearSolver structure can
|
||||
* be found in the header file sundials_linearsolver.h.
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef _SUNLINSOL_SPBCGS_H
|
||||
#define _SUNLINSOL_SPBCGS_H
|
||||
|
||||
#include <sundials/sundials_linearsolver.h>
|
||||
#include <sundials/sundials_matrix.h>
|
||||
#include <sundials/sundials_nvector.h>
|
||||
|
||||
#ifdef __cplusplus /* wrapper to enable C++ usage */
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Default SPBCGS solver parameters */
|
||||
#define SUNSPBCGS_MAXL_DEFAULT 5
|
||||
|
||||
/* -----------------------------------------
|
||||
* SPBCGS Implementation of SUNLinearSolver
|
||||
* ---------------------------------------- */
|
||||
|
||||
struct _SUNLinearSolverContent_SPBCGS {
|
||||
int maxl;
|
||||
int pretype;
|
||||
int numiters;
|
||||
realtype resnorm;
|
||||
int last_flag;
|
||||
|
||||
ATimesFn ATimes;
|
||||
void* ATData;
|
||||
PSetupFn Psetup;
|
||||
PSolveFn Psolve;
|
||||
void* PData;
|
||||
|
||||
N_Vector s1;
|
||||
N_Vector s2;
|
||||
N_Vector r;
|
||||
N_Vector r_star;
|
||||
N_Vector p;
|
||||
N_Vector q;
|
||||
N_Vector u;
|
||||
N_Vector Ap;
|
||||
N_Vector vtemp;
|
||||
};
|
||||
|
||||
typedef struct _SUNLinearSolverContent_SPBCGS *SUNLinearSolverContent_SPBCGS;
|
||||
|
||||
|
||||
/* ---------------------------------------
|
||||
*Exported Functions for SUNLINSOL_SPBCGS
|
||||
* --------------------------------------- */
|
||||
|
||||
SUNDIALS_EXPORT SUNLinearSolver SUNLinSol_SPBCGS(N_Vector y,
|
||||
int pretype,
|
||||
int maxl);
|
||||
SUNDIALS_EXPORT int SUNLinSol_SPBCGSSetPrecType(SUNLinearSolver S,
|
||||
int pretype);
|
||||
SUNDIALS_EXPORT int SUNLinSol_SPBCGSSetMaxl(SUNLinearSolver S,
|
||||
int maxl);
|
||||
|
||||
/* deprecated */
|
||||
SUNDIALS_EXPORT SUNLinearSolver SUNSPBCGS(N_Vector y, int pretype, int maxl);
|
||||
/* deprecated */
|
||||
SUNDIALS_EXPORT int SUNSPBCGSSetPrecType(SUNLinearSolver S, int pretype);
|
||||
/* deprecated */
|
||||
SUNDIALS_EXPORT int SUNSPBCGSSetMaxl(SUNLinearSolver S, int maxl);
|
||||
|
||||
SUNDIALS_EXPORT SUNLinearSolver_Type SUNLinSolGetType_SPBCGS(SUNLinearSolver S);
|
||||
SUNDIALS_EXPORT SUNLinearSolver_ID SUNLinSolGetID_SPBCGS(SUNLinearSolver S);
|
||||
SUNDIALS_EXPORT int SUNLinSolInitialize_SPBCGS(SUNLinearSolver S);
|
||||
SUNDIALS_EXPORT int SUNLinSolSetATimes_SPBCGS(SUNLinearSolver S, void* A_data,
|
||||
ATimesFn ATimes);
|
||||
SUNDIALS_EXPORT int SUNLinSolSetPreconditioner_SPBCGS(SUNLinearSolver S,
|
||||
void* P_data,
|
||||
PSetupFn Pset,
|
||||
PSolveFn Psol);
|
||||
SUNDIALS_EXPORT int SUNLinSolSetScalingVectors_SPBCGS(SUNLinearSolver S,
|
||||
N_Vector s1,
|
||||
N_Vector s2);
|
||||
SUNDIALS_EXPORT int SUNLinSolSetup_SPBCGS(SUNLinearSolver S, SUNMatrix A);
|
||||
SUNDIALS_EXPORT int SUNLinSolSolve_SPBCGS(SUNLinearSolver S, SUNMatrix A,
|
||||
N_Vector x, N_Vector b, realtype tol);
|
||||
SUNDIALS_EXPORT int SUNLinSolNumIters_SPBCGS(SUNLinearSolver S);
|
||||
SUNDIALS_EXPORT realtype SUNLinSolResNorm_SPBCGS(SUNLinearSolver S);
|
||||
SUNDIALS_EXPORT N_Vector SUNLinSolResid_SPBCGS(SUNLinearSolver S);
|
||||
SUNDIALS_EXPORT sunindextype SUNLinSolLastFlag_SPBCGS(SUNLinearSolver S);
|
||||
SUNDIALS_EXPORT int SUNLinSolSpace_SPBCGS(SUNLinearSolver S,
|
||||
long int *lenrwLS,
|
||||
long int *leniwLS);
|
||||
SUNDIALS_EXPORT int SUNLinSolFree_SPBCGS(SUNLinearSolver S);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
132
bazaar/plugin/sundials/include/sunlinsol/sunlinsol_spfgmr.h
Normal file
132
bazaar/plugin/sundials/include/sunlinsol/sunlinsol_spfgmr.h
Normal file
|
|
@ -0,0 +1,132 @@
|
|||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Programmer(s): Daniel Reynolds @ SMU
|
||||
* Based on code sundials_spfgmr.h by: Daniel R. Reynolds and
|
||||
* Hilari C. Tiedeman @ SMU
|
||||
* -----------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
* -----------------------------------------------------------------
|
||||
* This is the header file for the SPFGMR implementation of the
|
||||
* SUNLINSOL module, SUNLINSOL_SPFGMR. The SPFGMR algorithm is based
|
||||
* on the Scaled Preconditioned FGMRES (Flexible Generalized Minimal
|
||||
* Residual) method [Y. Saad, SIAM J. Sci. Comput., 1993].
|
||||
*
|
||||
* Note:
|
||||
* - The definition of the generic SUNLinearSolver structure can
|
||||
* be found in the header file sundials_linearsolver.h.
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef _SUNLINSOL_SPFGMR_H
|
||||
#define _SUNLINSOL_SPFGMR_H
|
||||
|
||||
#include <sundials/sundials_linearsolver.h>
|
||||
#include <sundials/sundials_matrix.h>
|
||||
#include <sundials/sundials_nvector.h>
|
||||
|
||||
#ifdef __cplusplus /* wrapper to enable C++ usage */
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Default SPFGMR solver parameters */
|
||||
#define SUNSPFGMR_MAXL_DEFAULT 5
|
||||
#define SUNSPFGMR_MAXRS_DEFAULT 0
|
||||
#define SUNSPFGMR_GSTYPE_DEFAULT MODIFIED_GS
|
||||
|
||||
/* -----------------------------------------
|
||||
* SPFGMR Implementation of SUNLinearSolver
|
||||
* ----------------------------------------- */
|
||||
|
||||
struct _SUNLinearSolverContent_SPFGMR {
|
||||
int maxl;
|
||||
int pretype;
|
||||
int gstype;
|
||||
int max_restarts;
|
||||
int numiters;
|
||||
realtype resnorm;
|
||||
int last_flag;
|
||||
|
||||
ATimesFn ATimes;
|
||||
void* ATData;
|
||||
PSetupFn Psetup;
|
||||
PSolveFn Psolve;
|
||||
void* PData;
|
||||
|
||||
N_Vector s1;
|
||||
N_Vector s2;
|
||||
N_Vector *V;
|
||||
N_Vector *Z;
|
||||
realtype **Hes;
|
||||
realtype *givens;
|
||||
N_Vector xcor;
|
||||
realtype *yg;
|
||||
N_Vector vtemp;
|
||||
|
||||
realtype *cv;
|
||||
N_Vector *Xv;
|
||||
};
|
||||
|
||||
typedef struct _SUNLinearSolverContent_SPFGMR *SUNLinearSolverContent_SPFGMR;
|
||||
|
||||
/* ----------------------------------------
|
||||
* Exported Functions for SUNLINSOL_SPFGMR
|
||||
* ---------------------------------------- */
|
||||
|
||||
SUNDIALS_EXPORT SUNLinearSolver SUNLinSol_SPFGMR(N_Vector y,
|
||||
int pretype,
|
||||
int maxl);
|
||||
SUNDIALS_EXPORT int SUNLinSol_SPFGMRSetPrecType(SUNLinearSolver S,
|
||||
int pretype);
|
||||
SUNDIALS_EXPORT int SUNLinSol_SPFGMRSetGSType(SUNLinearSolver S,
|
||||
int gstype);
|
||||
SUNDIALS_EXPORT int SUNLinSol_SPFGMRSetMaxRestarts(SUNLinearSolver S,
|
||||
int maxrs);
|
||||
|
||||
/* deprecated */
|
||||
SUNDIALS_EXPORT SUNLinearSolver SUNSPFGMR(N_Vector y, int pretype, int maxl);
|
||||
/* deprecated */
|
||||
SUNDIALS_EXPORT int SUNSPFGMRSetPrecType(SUNLinearSolver S, int pretype);
|
||||
/* deprecated */
|
||||
SUNDIALS_EXPORT int SUNSPFGMRSetGSType(SUNLinearSolver S, int gstype);
|
||||
/* deprecated */
|
||||
SUNDIALS_EXPORT int SUNSPFGMRSetMaxRestarts(SUNLinearSolver S, int maxrs);
|
||||
|
||||
|
||||
SUNDIALS_EXPORT SUNLinearSolver_Type SUNLinSolGetType_SPFGMR(SUNLinearSolver S);
|
||||
SUNDIALS_EXPORT SUNLinearSolver_ID SUNLinSolGetID_SPFGMR(SUNLinearSolver S);
|
||||
SUNDIALS_EXPORT int SUNLinSolInitialize_SPFGMR(SUNLinearSolver S);
|
||||
SUNDIALS_EXPORT int SUNLinSolSetATimes_SPFGMR(SUNLinearSolver S, void* A_data,
|
||||
ATimesFn ATimes);
|
||||
SUNDIALS_EXPORT int SUNLinSolSetPreconditioner_SPFGMR(SUNLinearSolver S,
|
||||
void* P_data,
|
||||
PSetupFn Pset,
|
||||
PSolveFn Psol);
|
||||
SUNDIALS_EXPORT int SUNLinSolSetScalingVectors_SPFGMR(SUNLinearSolver S,
|
||||
N_Vector s1,
|
||||
N_Vector s2);
|
||||
SUNDIALS_EXPORT int SUNLinSolSetup_SPFGMR(SUNLinearSolver S, SUNMatrix A);
|
||||
SUNDIALS_EXPORT int SUNLinSolSolve_SPFGMR(SUNLinearSolver S, SUNMatrix A,
|
||||
N_Vector x, N_Vector b, realtype tol);
|
||||
SUNDIALS_EXPORT int SUNLinSolNumIters_SPFGMR(SUNLinearSolver S);
|
||||
SUNDIALS_EXPORT realtype SUNLinSolResNorm_SPFGMR(SUNLinearSolver S);
|
||||
SUNDIALS_EXPORT N_Vector SUNLinSolResid_SPFGMR(SUNLinearSolver S);
|
||||
SUNDIALS_EXPORT sunindextype SUNLinSolLastFlag_SPFGMR(SUNLinearSolver S);
|
||||
SUNDIALS_EXPORT int SUNLinSolSpace_SPFGMR(SUNLinearSolver S,
|
||||
long int *lenrwLS,
|
||||
long int *leniwLS);
|
||||
SUNDIALS_EXPORT int SUNLinSolFree_SPFGMR(SUNLinearSolver S);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
131
bazaar/plugin/sundials/include/sunlinsol/sunlinsol_spgmr.h
Normal file
131
bazaar/plugin/sundials/include/sunlinsol/sunlinsol_spgmr.h
Normal file
|
|
@ -0,0 +1,131 @@
|
|||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Programmer(s): Daniel Reynolds @ SMU
|
||||
* Based on code sundials_spgmr.h by: Scott D. Cohen,
|
||||
* Alan C. Hindmarsh and Radu Serban @ LLNL
|
||||
* -----------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
* -----------------------------------------------------------------
|
||||
* This is the header file for the SPGMR implementation of the
|
||||
* SUNLINSOL module, SUNLINSOL_SPGMR. The SPGMR algorithm is based
|
||||
* on the Scaled Preconditioned GMRES (Generalized Minimal Residual)
|
||||
* method.
|
||||
*
|
||||
* Note:
|
||||
* - The definition of the generic SUNLinearSolver structure can
|
||||
* be found in the header file sundials_linearsolver.h.
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef _SUNLINSOL_SPGMR_H
|
||||
#define _SUNLINSOL_SPGMR_H
|
||||
|
||||
#include <sundials/sundials_linearsolver.h>
|
||||
#include <sundials/sundials_matrix.h>
|
||||
#include <sundials/sundials_nvector.h>
|
||||
|
||||
#ifdef __cplusplus /* wrapper to enable C++ usage */
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Default SPGMR solver parameters */
|
||||
#define SUNSPGMR_MAXL_DEFAULT 5
|
||||
#define SUNSPGMR_MAXRS_DEFAULT 0
|
||||
#define SUNSPGMR_GSTYPE_DEFAULT MODIFIED_GS
|
||||
|
||||
/* ----------------------------------------
|
||||
* SPGMR Implementation of SUNLinearSolver
|
||||
* ---------------------------------------- */
|
||||
|
||||
struct _SUNLinearSolverContent_SPGMR {
|
||||
int maxl;
|
||||
int pretype;
|
||||
int gstype;
|
||||
int max_restarts;
|
||||
int numiters;
|
||||
realtype resnorm;
|
||||
int last_flag;
|
||||
|
||||
ATimesFn ATimes;
|
||||
void* ATData;
|
||||
PSetupFn Psetup;
|
||||
PSolveFn Psolve;
|
||||
void* PData;
|
||||
|
||||
N_Vector s1;
|
||||
N_Vector s2;
|
||||
N_Vector *V;
|
||||
realtype **Hes;
|
||||
realtype *givens;
|
||||
N_Vector xcor;
|
||||
realtype *yg;
|
||||
N_Vector vtemp;
|
||||
|
||||
realtype *cv;
|
||||
N_Vector *Xv;
|
||||
};
|
||||
|
||||
typedef struct _SUNLinearSolverContent_SPGMR *SUNLinearSolverContent_SPGMR;
|
||||
|
||||
|
||||
/* ---------------------------------------
|
||||
* Exported Functions for SUNLINSOL_SPGMR
|
||||
* --------------------------------------- */
|
||||
|
||||
SUNDIALS_EXPORT SUNLinearSolver SUNLinSol_SPGMR(N_Vector y,
|
||||
int pretype,
|
||||
int maxl);
|
||||
SUNDIALS_EXPORT int SUNLinSol_SPGMRSetPrecType(SUNLinearSolver S,
|
||||
int pretype);
|
||||
SUNDIALS_EXPORT int SUNLinSol_SPGMRSetGSType(SUNLinearSolver S,
|
||||
int gstype);
|
||||
SUNDIALS_EXPORT int SUNLinSol_SPGMRSetMaxRestarts(SUNLinearSolver S,
|
||||
int maxrs);
|
||||
|
||||
/* deprecated */
|
||||
SUNDIALS_EXPORT SUNLinearSolver SUNSPGMR(N_Vector y, int pretype, int maxl);
|
||||
/* deprecated */
|
||||
SUNDIALS_EXPORT int SUNSPGMRSetPrecType(SUNLinearSolver S, int pretype);
|
||||
/* deprecated */
|
||||
SUNDIALS_EXPORT int SUNSPGMRSetGSType(SUNLinearSolver S, int gstype);
|
||||
/* deprecated */
|
||||
SUNDIALS_EXPORT int SUNSPGMRSetMaxRestarts(SUNLinearSolver S, int maxrs);
|
||||
|
||||
SUNDIALS_EXPORT SUNLinearSolver_Type SUNLinSolGetType_SPGMR(SUNLinearSolver S);
|
||||
SUNDIALS_EXPORT SUNLinearSolver_ID SUNLinSolGetID_SPGMR(SUNLinearSolver S);
|
||||
SUNDIALS_EXPORT int SUNLinSolInitialize_SPGMR(SUNLinearSolver S);
|
||||
SUNDIALS_EXPORT int SUNLinSolSetATimes_SPGMR(SUNLinearSolver S, void* A_data,
|
||||
ATimesFn ATimes);
|
||||
SUNDIALS_EXPORT int SUNLinSolSetPreconditioner_SPGMR(SUNLinearSolver S,
|
||||
void* P_data,
|
||||
PSetupFn Pset,
|
||||
PSolveFn Psol);
|
||||
SUNDIALS_EXPORT int SUNLinSolSetScalingVectors_SPGMR(SUNLinearSolver S,
|
||||
N_Vector s1,
|
||||
N_Vector s2);
|
||||
SUNDIALS_EXPORT int SUNLinSolSetup_SPGMR(SUNLinearSolver S, SUNMatrix A);
|
||||
SUNDIALS_EXPORT int SUNLinSolSolve_SPGMR(SUNLinearSolver S, SUNMatrix A,
|
||||
N_Vector x, N_Vector b, realtype tol);
|
||||
SUNDIALS_EXPORT int SUNLinSolNumIters_SPGMR(SUNLinearSolver S);
|
||||
SUNDIALS_EXPORT realtype SUNLinSolResNorm_SPGMR(SUNLinearSolver S);
|
||||
SUNDIALS_EXPORT N_Vector SUNLinSolResid_SPGMR(SUNLinearSolver S);
|
||||
SUNDIALS_EXPORT sunindextype SUNLinSolLastFlag_SPGMR(SUNLinearSolver S);
|
||||
SUNDIALS_EXPORT int SUNLinSolSpace_SPGMR(SUNLinearSolver S,
|
||||
long int *lenrwLS,
|
||||
long int *leniwLS);
|
||||
SUNDIALS_EXPORT int SUNLinSolFree_SPGMR(SUNLinearSolver S);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
122
bazaar/plugin/sundials/include/sunlinsol/sunlinsol_sptfqmr.h
Normal file
122
bazaar/plugin/sundials/include/sunlinsol/sunlinsol_sptfqmr.h
Normal file
|
|
@ -0,0 +1,122 @@
|
|||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Programmer(s): Daniel Reynolds @ SMU
|
||||
* Based on code sundials_sptfqmr.h by: Aaron Collier @ LLNL
|
||||
* -----------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
* -----------------------------------------------------------------
|
||||
* This is the header file for the SPTFQMR implementation of the
|
||||
* SUNLINSOL module, SUNLINSOL_SPTFQMR. The SPTFQMR algorithm is
|
||||
* based on the Scaled Preconditioned Transpose-free Quasi-Minimum
|
||||
* Residual method.
|
||||
*
|
||||
* Note:
|
||||
* - The definition of the generic SUNLinearSolver structure can
|
||||
* be found in the header file sundials_linearsolver.h.
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef _SUNLINSOL_SPTFQMR_H
|
||||
#define _SUNLINSOL_SPTFQMR_H
|
||||
|
||||
#include <sundials/sundials_linearsolver.h>
|
||||
#include <sundials/sundials_matrix.h>
|
||||
#include <sundials/sundials_nvector.h>
|
||||
|
||||
#ifdef __cplusplus /* wrapper to enable C++ usage */
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Default SPTFQMR solver parameters */
|
||||
#define SUNSPTFQMR_MAXL_DEFAULT 5
|
||||
|
||||
/* ------------------------------------------
|
||||
* SPTFQMR Implementation of SUNLinearSolver
|
||||
* ------------------------------------------ */
|
||||
|
||||
struct _SUNLinearSolverContent_SPTFQMR {
|
||||
int maxl;
|
||||
int pretype;
|
||||
int numiters;
|
||||
realtype resnorm;
|
||||
int last_flag;
|
||||
|
||||
ATimesFn ATimes;
|
||||
void* ATData;
|
||||
PSetupFn Psetup;
|
||||
PSolveFn Psolve;
|
||||
void* PData;
|
||||
|
||||
N_Vector s1;
|
||||
N_Vector s2;
|
||||
N_Vector r_star;
|
||||
N_Vector q;
|
||||
N_Vector d;
|
||||
N_Vector v;
|
||||
N_Vector p;
|
||||
N_Vector *r;
|
||||
N_Vector u;
|
||||
N_Vector vtemp1;
|
||||
N_Vector vtemp2;
|
||||
N_Vector vtemp3;
|
||||
};
|
||||
|
||||
typedef struct _SUNLinearSolverContent_SPTFQMR *SUNLinearSolverContent_SPTFQMR;
|
||||
|
||||
/* -------------------------------------
|
||||
* Exported Functions SUNLINSOL_SPTFQMR
|
||||
* -------------------------------------- */
|
||||
|
||||
SUNDIALS_EXPORT SUNLinearSolver SUNLinSol_SPTFQMR(N_Vector y,
|
||||
int pretype,
|
||||
int maxl);
|
||||
SUNDIALS_EXPORT int SUNLinSol_SPTFQMRSetPrecType(SUNLinearSolver S,
|
||||
int pretype);
|
||||
SUNDIALS_EXPORT int SUNLinSol_SPTFQMRSetMaxl(SUNLinearSolver S,
|
||||
int maxl);
|
||||
|
||||
/* deprecated */
|
||||
SUNDIALS_EXPORT SUNLinearSolver SUNSPTFQMR(N_Vector y, int pretype, int maxl);
|
||||
/* deprecated */
|
||||
SUNDIALS_EXPORT int SUNSPTFQMRSetPrecType(SUNLinearSolver S, int pretype);
|
||||
/* deprecated */
|
||||
SUNDIALS_EXPORT int SUNSPTFQMRSetMaxl(SUNLinearSolver S, int maxl);
|
||||
|
||||
SUNDIALS_EXPORT SUNLinearSolver_Type SUNLinSolGetType_SPTFQMR(SUNLinearSolver S);
|
||||
SUNDIALS_EXPORT SUNLinearSolver_ID SUNLinSolGetID_SPTFQMR(SUNLinearSolver S);
|
||||
SUNDIALS_EXPORT int SUNLinSolInitialize_SPTFQMR(SUNLinearSolver S);
|
||||
SUNDIALS_EXPORT int SUNLinSolSetATimes_SPTFQMR(SUNLinearSolver S, void* A_data,
|
||||
ATimesFn ATimes);
|
||||
SUNDIALS_EXPORT int SUNLinSolSetPreconditioner_SPTFQMR(SUNLinearSolver S,
|
||||
void* P_data,
|
||||
PSetupFn Pset,
|
||||
PSolveFn Psol);
|
||||
SUNDIALS_EXPORT int SUNLinSolSetScalingVectors_SPTFQMR(SUNLinearSolver S,
|
||||
N_Vector s1,
|
||||
N_Vector s2);
|
||||
SUNDIALS_EXPORT int SUNLinSolSetup_SPTFQMR(SUNLinearSolver S, SUNMatrix A);
|
||||
SUNDIALS_EXPORT int SUNLinSolSolve_SPTFQMR(SUNLinearSolver S, SUNMatrix A,
|
||||
N_Vector x, N_Vector b, realtype tol);
|
||||
SUNDIALS_EXPORT int SUNLinSolNumIters_SPTFQMR(SUNLinearSolver S);
|
||||
SUNDIALS_EXPORT realtype SUNLinSolResNorm_SPTFQMR(SUNLinearSolver S);
|
||||
SUNDIALS_EXPORT N_Vector SUNLinSolResid_SPTFQMR(SUNLinearSolver S);
|
||||
SUNDIALS_EXPORT sunindextype SUNLinSolLastFlag_SPTFQMR(SUNLinearSolver S);
|
||||
SUNDIALS_EXPORT int SUNLinSolSpace_SPTFQMR(SUNLinearSolver S,
|
||||
long int *lenrwLS,
|
||||
long int *leniwLS);
|
||||
SUNDIALS_EXPORT int SUNLinSolFree_SPTFQMR(SUNLinearSolver S);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
119
bazaar/plugin/sundials/include/sunlinsol/sunlinsol_superludist.h
Normal file
119
bazaar/plugin/sundials/include/sunlinsol/sunlinsol_superludist.h
Normal file
|
|
@ -0,0 +1,119 @@
|
|||
/*
|
||||
* ----------------------------------------------------------------------------
|
||||
* Programmer(s): Cody J. Balos @ LLNL
|
||||
* ----------------------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
* ----------------------------------------------------------------------------
|
||||
* This is the header file for the SuperLU-DIST implementation of the SUNLINSOL
|
||||
* module.
|
||||
*
|
||||
* Part I contains declarations specific to the SuperLU-Dist implementation of
|
||||
* the supplied SUNLINSOL module.
|
||||
*
|
||||
* Part II contains the prototype for the constructor SUNSuperLUDIST as well as
|
||||
* implementation-specific prototypes for various useful solver operations.
|
||||
*
|
||||
* Notes:
|
||||
*
|
||||
* - The definition of the generic SUNLinearSolver structure can be found in
|
||||
* the header file sundials_linearsolver.h.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef _SUNLINSOL_SLUDIST_H
|
||||
#define _SUNLINSOL_SLUDIST_H
|
||||
|
||||
#include <mpi.h>
|
||||
#include <superlu_ddefs.h>
|
||||
#include <sundials/sundials_linearsolver.h>
|
||||
#include <sundials/sundials_matrix.h>
|
||||
#include <sundials/sundials_nvector.h>
|
||||
#include <sunmatrix/sunmatrix_sparse.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* ----------------------------------------------------------------------------
|
||||
* PART I: SuperLU-DIST implementation of SUNLinearSolver
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
struct _SUNLinearSolverContent_SuperLUDIST {
|
||||
booleantype first_factorize;
|
||||
int last_flag;
|
||||
realtype berr;
|
||||
gridinfo_t *grid;
|
||||
LUstruct_t *lu;
|
||||
superlu_dist_options_t *options;
|
||||
ScalePermstruct_t *scaleperm;
|
||||
SOLVEstruct_t *solve;
|
||||
SuperLUStat_t *stat;
|
||||
sunindextype N;
|
||||
};
|
||||
|
||||
typedef struct _SUNLinearSolverContent_SuperLUDIST *SUNLinearSolverContent_SuperLUDIST;
|
||||
|
||||
|
||||
/*
|
||||
* ----------------------------------------------------------------------------
|
||||
* PART II: Functions exported by sunlinsol_sludist
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
SUNDIALS_EXPORT SUNLinearSolver SUNLinSol_SuperLUDIST(N_Vector y, SUNMatrix A,
|
||||
gridinfo_t *grid,
|
||||
LUstruct_t *lu,
|
||||
ScalePermstruct_t *scaleperm,
|
||||
SOLVEstruct_t *solve,
|
||||
SuperLUStat_t *stat,
|
||||
superlu_dist_options_t *options);
|
||||
|
||||
/*
|
||||
* ----------------------------------------------------------------------------
|
||||
* Accessor functions.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
SUNDIALS_EXPORT realtype SUNLinSol_SuperLUDIST_GetBerr(SUNLinearSolver LS);
|
||||
SUNDIALS_EXPORT gridinfo_t* SUNLinSol_SuperLUDIST_GetGridinfo(SUNLinearSolver LS);
|
||||
SUNDIALS_EXPORT LUstruct_t* SUNLinSol_SuperLUDIST_GetLUstruct(SUNLinearSolver LS);
|
||||
SUNDIALS_EXPORT superlu_dist_options_t* SUNLinSol_SuperLUDIST_GetSuperLUOptions(SUNLinearSolver LS);
|
||||
SUNDIALS_EXPORT ScalePermstruct_t* SUNLinSol_SuperLUDIST_GetScalePermstruct(SUNLinearSolver LS);
|
||||
SUNDIALS_EXPORT SOLVEstruct_t* SUNLinSol_SuperLUDIST_GetSOLVEstruct(SUNLinearSolver LS);
|
||||
SUNDIALS_EXPORT SuperLUStat_t* SUNLinSol_SuperLUDIST_GetSuperLUStat(SUNLinearSolver LS);
|
||||
|
||||
/*
|
||||
* ----------------------------------------------------------------------------
|
||||
* SuperLU-DIST implementations of SUNLinearSolver operations
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
SUNDIALS_EXPORT SUNLinearSolver_Type SUNLinSolGetType_SuperLUDIST(SUNLinearSolver S);
|
||||
SUNDIALS_EXPORT SUNLinearSolver_ID SUNLinSolGetID_SuperLUDIST(SUNLinearSolver S);
|
||||
SUNDIALS_EXPORT int SUNLinSolInitialize_SuperLUDIST(SUNLinearSolver S);
|
||||
SUNDIALS_EXPORT int SUNLinSolSetup_SuperLUDIST(SUNLinearSolver S, SUNMatrix A);
|
||||
SUNDIALS_EXPORT int SUNLinSolSolve_SuperLUDIST(SUNLinearSolver S, SUNMatrix A,
|
||||
N_Vector x, N_Vector b, realtype tol);
|
||||
SUNDIALS_EXPORT sunindextype SUNLinSolLastFlag_SuperLUDIST(SUNLinearSolver S);
|
||||
SUNDIALS_EXPORT int SUNLinSolSpace_SuperLUDIST(SUNLinearSolver S,
|
||||
long int *lenrwLS,
|
||||
long int *leniwLS);
|
||||
SUNDIALS_EXPORT int SUNLinSolFree_SuperLUDIST(SUNLinearSolver S);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
129
bazaar/plugin/sundials/include/sunmatrix/sunmatrix_band.h
Normal file
129
bazaar/plugin/sundials/include/sunmatrix/sunmatrix_band.h
Normal file
|
|
@ -0,0 +1,129 @@
|
|||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Programmer(s): Daniel Reynolds @ SMU
|
||||
* David Gardner @ LLNL
|
||||
* Based on code sundials_direct.h by: Radu Serban @ LLNL
|
||||
* -----------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
* -----------------------------------------------------------------
|
||||
* This is the header file for the band implementation of the
|
||||
* SUNMATRIX module, SUNMATRIX_BAND.
|
||||
*
|
||||
* Notes:
|
||||
* - The definition of the generic SUNMatrix structure can be found
|
||||
* in the header file sundials_matrix.h.
|
||||
* - The definition of the type 'realtype' can be found in the
|
||||
* header file sundials_types.h, and it may be changed (at the
|
||||
* configuration stage) according to the user's needs.
|
||||
* The sundials_types.h file also contains the definition
|
||||
* for the type 'booleantype' and 'indextype'.
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef _SUNMATRIX_BAND_H
|
||||
#define _SUNMATRIX_BAND_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sundials/sundials_matrix.h>
|
||||
|
||||
#ifdef __cplusplus /* wrapper to enable C++ usage */
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* ---------------------------------
|
||||
* Band implementation of SUNMatrix
|
||||
* --------------------------------- */
|
||||
|
||||
struct _SUNMatrixContent_Band {
|
||||
sunindextype M;
|
||||
sunindextype N;
|
||||
sunindextype ldim;
|
||||
sunindextype mu;
|
||||
sunindextype ml;
|
||||
sunindextype s_mu;
|
||||
realtype *data;
|
||||
sunindextype ldata;
|
||||
realtype **cols;
|
||||
};
|
||||
|
||||
typedef struct _SUNMatrixContent_Band *SUNMatrixContent_Band;
|
||||
|
||||
|
||||
/* ------------------------------------
|
||||
* Macros for access to SUNMATRIX_BAND
|
||||
* ------------------------------------ */
|
||||
|
||||
#define SM_CONTENT_B(A) ( (SUNMatrixContent_Band)(A->content) )
|
||||
|
||||
#define SM_ROWS_B(A) ( SM_CONTENT_B(A)->M )
|
||||
|
||||
#define SM_COLUMNS_B(A) ( SM_CONTENT_B(A)->N )
|
||||
|
||||
#define SM_LDATA_B(A) ( SM_CONTENT_B(A)->ldata )
|
||||
|
||||
#define SM_UBAND_B(A) ( SM_CONTENT_B(A)->mu )
|
||||
|
||||
#define SM_LBAND_B(A) ( SM_CONTENT_B(A)->ml )
|
||||
|
||||
#define SM_SUBAND_B(A) ( SM_CONTENT_B(A)->s_mu )
|
||||
|
||||
#define SM_LDIM_B(A) ( SM_CONTENT_B(A)->ldim )
|
||||
|
||||
#define SM_DATA_B(A) ( SM_CONTENT_B(A)->data )
|
||||
|
||||
#define SM_COLS_B(A) ( SM_CONTENT_B(A)->cols )
|
||||
|
||||
#define SM_COLUMN_B(A,j) ( ((SM_CONTENT_B(A)->cols)[j])+SM_SUBAND_B(A) )
|
||||
|
||||
#define SM_COLUMN_ELEMENT_B(col_j,i,j) (col_j[(i)-(j)])
|
||||
|
||||
#define SM_ELEMENT_B(A,i,j) ( (SM_CONTENT_B(A)->cols)[j][(i)-(j)+SM_SUBAND_B(A)] )
|
||||
|
||||
|
||||
/* ----------------------------------------
|
||||
* Exported Functions for SUNMATRIX_BAND
|
||||
* ---------------------------------------- */
|
||||
|
||||
SUNDIALS_EXPORT SUNMatrix SUNBandMatrix(sunindextype N, sunindextype mu,
|
||||
sunindextype ml);
|
||||
|
||||
SUNDIALS_EXPORT SUNMatrix SUNBandMatrixStorage(sunindextype N,
|
||||
sunindextype mu,
|
||||
sunindextype ml,
|
||||
sunindextype smu);
|
||||
|
||||
SUNDIALS_EXPORT void SUNBandMatrix_Print(SUNMatrix A, FILE* outfile);
|
||||
|
||||
SUNDIALS_EXPORT sunindextype SUNBandMatrix_Rows(SUNMatrix A);
|
||||
SUNDIALS_EXPORT sunindextype SUNBandMatrix_Columns(SUNMatrix A);
|
||||
SUNDIALS_EXPORT sunindextype SUNBandMatrix_LowerBandwidth(SUNMatrix A);
|
||||
SUNDIALS_EXPORT sunindextype SUNBandMatrix_UpperBandwidth(SUNMatrix A);
|
||||
SUNDIALS_EXPORT sunindextype SUNBandMatrix_StoredUpperBandwidth(SUNMatrix A);
|
||||
SUNDIALS_EXPORT sunindextype SUNBandMatrix_LDim(SUNMatrix A);
|
||||
SUNDIALS_EXPORT realtype* SUNBandMatrix_Data(SUNMatrix A);
|
||||
SUNDIALS_EXPORT realtype** SUNBandMatrix_Cols(SUNMatrix A);
|
||||
SUNDIALS_EXPORT realtype* SUNBandMatrix_Column(SUNMatrix A, sunindextype j);
|
||||
|
||||
SUNDIALS_EXPORT SUNMatrix_ID SUNMatGetID_Band(SUNMatrix A);
|
||||
SUNDIALS_EXPORT SUNMatrix SUNMatClone_Band(SUNMatrix A);
|
||||
SUNDIALS_EXPORT void SUNMatDestroy_Band(SUNMatrix A);
|
||||
SUNDIALS_EXPORT int SUNMatZero_Band(SUNMatrix A);
|
||||
SUNDIALS_EXPORT int SUNMatCopy_Band(SUNMatrix A, SUNMatrix B);
|
||||
SUNDIALS_EXPORT int SUNMatScaleAdd_Band(realtype c, SUNMatrix A, SUNMatrix B);
|
||||
SUNDIALS_EXPORT int SUNMatScaleAddI_Band(realtype c, SUNMatrix A);
|
||||
SUNDIALS_EXPORT int SUNMatMatvec_Band(SUNMatrix A, N_Vector x, N_Vector y);
|
||||
SUNDIALS_EXPORT int SUNMatSpace_Band(SUNMatrix A, long int *lenrw, long int *leniw);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
121
bazaar/plugin/sundials/include/sunmatrix/sunmatrix_cusparse.h
Normal file
121
bazaar/plugin/sundials/include/sunmatrix/sunmatrix_cusparse.h
Normal file
|
|
@ -0,0 +1,121 @@
|
|||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Programmer(s): Cody J. Balos @ LLNL
|
||||
* -----------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
* -----------------------------------------------------------------
|
||||
* This is the header file is for the cuSPARSE implementation of the
|
||||
* SUNMATRIX module.
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef _SUNMATRIX_CUSPARSE_H
|
||||
#define _SUNMATRIX_CUSPARSE_H
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <cuda_runtime.h>
|
||||
#include <cusparse.h>
|
||||
|
||||
#include <sundials/sundials_matrix.h>
|
||||
|
||||
#ifdef __cplusplus /* wrapper to enable C++ usage */
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* ------------------------------------------
|
||||
* Implementation of SUNMATRIX_CUSPARSE
|
||||
* ------------------------------------------ */
|
||||
|
||||
/* storage formats */
|
||||
#define SUNMAT_CUSPARSE_CSR 0
|
||||
#define SUNMAT_CUSPARSE_BCSR 1
|
||||
|
||||
struct _SUNMatrix_Content_cuSparse {
|
||||
int M;
|
||||
int N;
|
||||
int NNZ;
|
||||
int nblocks;
|
||||
int blockrows;
|
||||
int blockcols;
|
||||
int blocknnz;
|
||||
int sparse_type;
|
||||
booleantype own_data;
|
||||
booleantype fixed_pattern;
|
||||
int* colind;
|
||||
int* rowptrs;
|
||||
realtype* data;
|
||||
cusparseMatDescr_t mat_descr;
|
||||
cusparseHandle_t cusp_handle;
|
||||
};
|
||||
|
||||
typedef struct _SUNMatrix_Content_cuSparse *SUNMatrix_Content_cuSparse;
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------
|
||||
* Constructors.
|
||||
* ------------------------------------------------------------------ */
|
||||
|
||||
SUNDIALS_EXPORT SUNMatrix SUNMatrix_cuSparse_NewCSR(int M, int N, int NNZ, cusparseHandle_t cusp);
|
||||
SUNDIALS_EXPORT SUNMatrix SUNMatrix_cuSparse_MakeCSR(cusparseMatDescr_t mat_descr, int M, int N, int NNZ,
|
||||
int *rowptrs , int *colind , realtype *data,
|
||||
cusparseHandle_t cusp);
|
||||
|
||||
/* Creates a CSR block-diagonal matrix where each block shares the same sparsity structure.
|
||||
Reduces memory usage by only storing the row pointers and column indices for one block. */
|
||||
SUNDIALS_EXPORT SUNMatrix SUNMatrix_cuSparse_NewBlockCSR(int nblocks, int blockrows, int blockcols,
|
||||
int blocknnz, cusparseHandle_t cusp);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------
|
||||
* Implementation specific routines.
|
||||
* ------------------------------------------------------------------ */
|
||||
|
||||
SUNDIALS_EXPORT int SUNMatrix_cuSparse_SparseType(SUNMatrix A);
|
||||
SUNDIALS_EXPORT int SUNMatrix_cuSparse_Rows(SUNMatrix A);
|
||||
SUNDIALS_EXPORT int SUNMatrix_cuSparse_Columns(SUNMatrix A);
|
||||
SUNDIALS_EXPORT int SUNMatrix_cuSparse_NNZ(SUNMatrix A);
|
||||
SUNDIALS_EXPORT int* SUNMatrix_cuSparse_IndexPointers(SUNMatrix A);
|
||||
SUNDIALS_EXPORT int* SUNMatrix_cuSparse_IndexValues(SUNMatrix A);
|
||||
SUNDIALS_EXPORT realtype* SUNMatrix_cuSparse_Data(SUNMatrix A);
|
||||
|
||||
SUNDIALS_EXPORT int SUNMatrix_cuSparse_SetFixedPattern(SUNMatrix A, booleantype yesno);
|
||||
SUNDIALS_EXPORT int SUNMatrix_cuSparse_NumBlocks(SUNMatrix A);
|
||||
SUNDIALS_EXPORT int SUNMatrix_cuSparse_BlockRows(SUNMatrix A);
|
||||
SUNDIALS_EXPORT int SUNMatrix_cuSparse_BlockColumns(SUNMatrix A);
|
||||
SUNDIALS_EXPORT int SUNMatrix_cuSparse_BlockNNZ(SUNMatrix A);
|
||||
SUNDIALS_EXPORT realtype* SUNMatrix_cuSparse_BlockData(SUNMatrix A, int blockidx);
|
||||
SUNDIALS_EXPORT cusparseMatDescr_t SUNMatrix_cuSparse_MatDescr(SUNMatrix A);
|
||||
SUNDIALS_EXPORT int SUNMatrix_cuSparse_CopyToDevice(SUNMatrix device, realtype* h_data,
|
||||
int* h_idxptrs, int* h_idxvals);
|
||||
SUNDIALS_EXPORT int SUNMatrix_cuSparse_CopyFromDevice(SUNMatrix device, realtype* h_data,
|
||||
int* h_idxptrs, int* h_idxvals);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------
|
||||
* SUNMatrix API routines.
|
||||
* ------------------------------------------------------------------ */
|
||||
|
||||
SUNDIALS_EXPORT SUNMatrix_ID SUNMatGetID_cuSparse(SUNMatrix A);
|
||||
SUNDIALS_EXPORT SUNMatrix SUNMatClone_cuSparse(SUNMatrix A);
|
||||
SUNDIALS_EXPORT void SUNMatDestroy_cuSparse(SUNMatrix A);
|
||||
SUNDIALS_EXPORT int SUNMatZero_cuSparse(SUNMatrix A);
|
||||
SUNDIALS_EXPORT int SUNMatCopy_cuSparse(SUNMatrix A, SUNMatrix B);
|
||||
SUNDIALS_EXPORT int SUNMatScaleAdd_cuSparse(realtype c, SUNMatrix A, SUNMatrix B);
|
||||
SUNDIALS_EXPORT int SUNMatScaleAddI_cuSparse(realtype c, SUNMatrix A);
|
||||
SUNDIALS_EXPORT int SUNMatMatvec_cuSparse(SUNMatrix A, N_Vector x, N_Vector y);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
105
bazaar/plugin/sundials/include/sunmatrix/sunmatrix_dense.h
Normal file
105
bazaar/plugin/sundials/include/sunmatrix/sunmatrix_dense.h
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Programmer(s): Daniel Reynolds @ SMU
|
||||
* David Gardner @ LLNL
|
||||
* Based on code sundials_direct.h by: Radu Serban @ LLNL
|
||||
* -----------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
* -----------------------------------------------------------------
|
||||
* This is the header file for the dense implementation of the
|
||||
* SUNMATRIX module, SUNMATRIX_DENSE.
|
||||
*
|
||||
* Notes:
|
||||
* - The definition of the generic SUNMatrix structure can be found
|
||||
* in the header file sundials_matrix.h.
|
||||
* - The definition of the type 'realtype' can be found in the
|
||||
* header file sundials_types.h, and it may be changed (at the
|
||||
* configuration stage) according to the user's needs.
|
||||
* The sundials_types.h file also contains the definition
|
||||
* for the type 'booleantype' and 'indextype'.
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef _SUNMATRIX_DENSE_H
|
||||
#define _SUNMATRIX_DENSE_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sundials/sundials_matrix.h>
|
||||
|
||||
#ifdef __cplusplus /* wrapper to enable C++ usage */
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* ----------------------------------
|
||||
* Dense implementation of SUNMatrix
|
||||
* ---------------------------------- */
|
||||
|
||||
struct _SUNMatrixContent_Dense {
|
||||
sunindextype M;
|
||||
sunindextype N;
|
||||
realtype *data;
|
||||
sunindextype ldata;
|
||||
realtype **cols;
|
||||
};
|
||||
|
||||
typedef struct _SUNMatrixContent_Dense *SUNMatrixContent_Dense;
|
||||
|
||||
/* ------------------------------------
|
||||
* Macros for access to SUNMATRIX_DENSE
|
||||
* ------------------------------------ */
|
||||
|
||||
#define SM_CONTENT_D(A) ( (SUNMatrixContent_Dense)(A->content) )
|
||||
|
||||
#define SM_ROWS_D(A) ( SM_CONTENT_D(A)->M )
|
||||
|
||||
#define SM_COLUMNS_D(A) ( SM_CONTENT_D(A)->N )
|
||||
|
||||
#define SM_LDATA_D(A) ( SM_CONTENT_D(A)->ldata )
|
||||
|
||||
#define SM_DATA_D(A) ( SM_CONTENT_D(A)->data )
|
||||
|
||||
#define SM_COLS_D(A) ( SM_CONTENT_D(A)->cols )
|
||||
|
||||
#define SM_COLUMN_D(A,j) ( (SM_CONTENT_D(A)->cols)[j] )
|
||||
|
||||
#define SM_ELEMENT_D(A,i,j) ( (SM_CONTENT_D(A)->cols)[j][i] )
|
||||
|
||||
/* ---------------------------------------
|
||||
* Exported Functions for SUNMATRIX_DENSE
|
||||
* --------------------------------------- */
|
||||
|
||||
SUNDIALS_EXPORT SUNMatrix SUNDenseMatrix(sunindextype M, sunindextype N);
|
||||
|
||||
SUNDIALS_EXPORT void SUNDenseMatrix_Print(SUNMatrix A, FILE* outfile);
|
||||
|
||||
SUNDIALS_EXPORT sunindextype SUNDenseMatrix_Rows(SUNMatrix A);
|
||||
SUNDIALS_EXPORT sunindextype SUNDenseMatrix_Columns(SUNMatrix A);
|
||||
SUNDIALS_EXPORT sunindextype SUNDenseMatrix_LData(SUNMatrix A);
|
||||
SUNDIALS_EXPORT realtype* SUNDenseMatrix_Data(SUNMatrix A);
|
||||
SUNDIALS_EXPORT realtype** SUNDenseMatrix_Cols(SUNMatrix A);
|
||||
SUNDIALS_EXPORT realtype* SUNDenseMatrix_Column(SUNMatrix A, sunindextype j);
|
||||
|
||||
SUNDIALS_EXPORT SUNMatrix_ID SUNMatGetID_Dense(SUNMatrix A);
|
||||
SUNDIALS_EXPORT SUNMatrix SUNMatClone_Dense(SUNMatrix A);
|
||||
SUNDIALS_EXPORT void SUNMatDestroy_Dense(SUNMatrix A);
|
||||
SUNDIALS_EXPORT int SUNMatZero_Dense(SUNMatrix A);
|
||||
SUNDIALS_EXPORT int SUNMatCopy_Dense(SUNMatrix A, SUNMatrix B);
|
||||
SUNDIALS_EXPORT int SUNMatScaleAdd_Dense(realtype c, SUNMatrix A, SUNMatrix B);
|
||||
SUNDIALS_EXPORT int SUNMatScaleAddI_Dense(realtype c, SUNMatrix A);
|
||||
SUNDIALS_EXPORT int SUNMatMatvec_Dense(SUNMatrix A, N_Vector x, N_Vector y);
|
||||
SUNDIALS_EXPORT int SUNMatSpace_Dense(SUNMatrix A, long int *lenrw, long int *leniw);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
146
bazaar/plugin/sundials/include/sunmatrix/sunmatrix_sparse.h
Normal file
146
bazaar/plugin/sundials/include/sunmatrix/sunmatrix_sparse.h
Normal file
|
|
@ -0,0 +1,146 @@
|
|||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Programmer(s): Daniel Reynolds @ SMU
|
||||
* David Gardner @ LLNL
|
||||
* Based on code sundials_sparse.h by: Carol Woodward and
|
||||
* Slaven Peles @ LLNL, and Daniel R. Reynolds @ SMU
|
||||
* -----------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
* -----------------------------------------------------------------
|
||||
* This is the header file for the sparse implementation of the
|
||||
* SUNMATRIX module, SUNMATRIX_SPARSE.
|
||||
*
|
||||
* Notes:
|
||||
* - The definition of the generic SUNMatrix structure can be found
|
||||
* in the header file sundials_matrix.h.
|
||||
* - The definition of the type 'realtype' can be found in the
|
||||
* header file sundials_types.h, and it may be changed (at the
|
||||
* configuration stage) according to the user's needs.
|
||||
* The sundials_types.h file also contains the definition
|
||||
* for the type 'booleantype' and 'indextype'.
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef _SUNMATRIX_SPARSE_H
|
||||
#define _SUNMATRIX_SPARSE_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sundials/sundials_matrix.h>
|
||||
#include <sunmatrix/sunmatrix_dense.h>
|
||||
#include <sunmatrix/sunmatrix_band.h>
|
||||
|
||||
#ifdef __cplusplus /* wrapper to enable C++ usage */
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* ------------------------
|
||||
* Matrix Type Definitions
|
||||
* ------------------------ */
|
||||
|
||||
#define CSC_MAT 0
|
||||
#define CSR_MAT 1
|
||||
|
||||
|
||||
/* ------------------------------------------
|
||||
* Sparse Implementation of SUNMATRIX_SPARSE
|
||||
* ------------------------------------------ */
|
||||
|
||||
struct _SUNMatrixContent_Sparse {
|
||||
sunindextype M;
|
||||
sunindextype N;
|
||||
sunindextype NNZ;
|
||||
sunindextype NP;
|
||||
realtype *data;
|
||||
int sparsetype;
|
||||
sunindextype *indexvals;
|
||||
sunindextype *indexptrs;
|
||||
/* CSC indices */
|
||||
sunindextype **rowvals;
|
||||
sunindextype **colptrs;
|
||||
/* CSR indices */
|
||||
sunindextype **colvals;
|
||||
sunindextype **rowptrs;
|
||||
};
|
||||
|
||||
typedef struct _SUNMatrixContent_Sparse *SUNMatrixContent_Sparse;
|
||||
|
||||
|
||||
/* ---------------------------------------
|
||||
* Macros for access to SUNMATRIX_SPARSE
|
||||
* --------------------------------------- */
|
||||
|
||||
#define SM_CONTENT_S(A) ( (SUNMatrixContent_Sparse)(A->content) )
|
||||
|
||||
#define SM_ROWS_S(A) ( SM_CONTENT_S(A)->M )
|
||||
|
||||
#define SM_COLUMNS_S(A) ( SM_CONTENT_S(A)->N )
|
||||
|
||||
#define SM_NNZ_S(A) ( SM_CONTENT_S(A)->NNZ )
|
||||
|
||||
#define SM_NP_S(A) ( SM_CONTENT_S(A)->NP )
|
||||
|
||||
#define SM_SPARSETYPE_S(A) ( SM_CONTENT_S(A)->sparsetype )
|
||||
|
||||
#define SM_DATA_S(A) ( SM_CONTENT_S(A)->data )
|
||||
|
||||
#define SM_INDEXVALS_S(A) ( SM_CONTENT_S(A)->indexvals )
|
||||
|
||||
#define SM_INDEXPTRS_S(A) ( SM_CONTENT_S(A)->indexptrs )
|
||||
|
||||
/* ----------------------------------------
|
||||
* Exported Functions for SUNMATRIX_SPARSE
|
||||
* ---------------------------------------- */
|
||||
|
||||
SUNDIALS_EXPORT SUNMatrix SUNSparseMatrix(sunindextype M, sunindextype N,
|
||||
sunindextype NNZ, int sparsetype);
|
||||
|
||||
SUNDIALS_EXPORT SUNMatrix SUNSparseFromDenseMatrix(SUNMatrix A,
|
||||
realtype droptol,
|
||||
int sparsetype);
|
||||
|
||||
SUNDIALS_EXPORT SUNMatrix SUNSparseFromBandMatrix(SUNMatrix A,
|
||||
realtype droptol,
|
||||
int sparsetype);
|
||||
|
||||
SUNDIALS_EXPORT int SUNSparseMatrix_ToCSR(const SUNMatrix A, SUNMatrix* Bout);
|
||||
SUNDIALS_EXPORT int SUNSparseMatrix_ToCSC(const SUNMatrix A, SUNMatrix* Bout);
|
||||
|
||||
SUNDIALS_EXPORT int SUNSparseMatrix_Realloc(SUNMatrix A);
|
||||
|
||||
SUNDIALS_EXPORT int SUNSparseMatrix_Reallocate(SUNMatrix A, sunindextype NNZ);
|
||||
|
||||
SUNDIALS_EXPORT void SUNSparseMatrix_Print(SUNMatrix A, FILE* outfile);
|
||||
|
||||
SUNDIALS_EXPORT sunindextype SUNSparseMatrix_Rows(SUNMatrix A);
|
||||
SUNDIALS_EXPORT sunindextype SUNSparseMatrix_Columns(SUNMatrix A);
|
||||
SUNDIALS_EXPORT sunindextype SUNSparseMatrix_NNZ(SUNMatrix A);
|
||||
SUNDIALS_EXPORT sunindextype SUNSparseMatrix_NP(SUNMatrix A);
|
||||
SUNDIALS_EXPORT int SUNSparseMatrix_SparseType(SUNMatrix A);
|
||||
SUNDIALS_EXPORT realtype* SUNSparseMatrix_Data(SUNMatrix A);
|
||||
SUNDIALS_EXPORT sunindextype* SUNSparseMatrix_IndexValues(SUNMatrix A);
|
||||
SUNDIALS_EXPORT sunindextype* SUNSparseMatrix_IndexPointers(SUNMatrix A);
|
||||
|
||||
SUNDIALS_EXPORT SUNMatrix_ID SUNMatGetID_Sparse(SUNMatrix A);
|
||||
SUNDIALS_EXPORT SUNMatrix SUNMatClone_Sparse(SUNMatrix A);
|
||||
SUNDIALS_EXPORT void SUNMatDestroy_Sparse(SUNMatrix A);
|
||||
SUNDIALS_EXPORT int SUNMatZero_Sparse(SUNMatrix A);
|
||||
SUNDIALS_EXPORT int SUNMatCopy_Sparse(SUNMatrix A, SUNMatrix B);
|
||||
SUNDIALS_EXPORT int SUNMatScaleAdd_Sparse(realtype c, SUNMatrix A, SUNMatrix B);
|
||||
SUNDIALS_EXPORT int SUNMatScaleAddI_Sparse(realtype c, SUNMatrix A);
|
||||
SUNDIALS_EXPORT int SUNMatMatvec_Sparse(SUNMatrix A, N_Vector x, N_Vector y);
|
||||
SUNDIALS_EXPORT int SUNMatSpace_Sparse(SUNMatrix A, long int *lenrw, long int *leniw);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,120 @@
|
|||
/*-----------------------------------------------------------------------------
|
||||
* Programmer(s): Daniel R. Reynolds @ SMU
|
||||
*-----------------------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
*-----------------------------------------------------------------------------
|
||||
* This is the header file for the SUNNonlinearSolver module implementation of
|
||||
* the Anderson-accelerated fixed-point method.
|
||||
*
|
||||
* Part I defines the solver-specific content structure.
|
||||
*
|
||||
* Part II contains prototypes for the solver constructor and operations.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef _SUNNONLINSOL_FIXEDPOINT_H
|
||||
#define _SUNNONLINSOL_FIXEDPOINT_H
|
||||
|
||||
#include "sundials/sundials_types.h"
|
||||
#include "sundials/sundials_nvector.h"
|
||||
#include "sundials/sundials_nonlinearsolver.h"
|
||||
|
||||
#ifdef __cplusplus /* wrapper to enable C++ usage */
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
I. Content structure
|
||||
---------------------------------------------------------------------------*/
|
||||
|
||||
struct _SUNNonlinearSolverContent_FixedPoint {
|
||||
|
||||
/* functions provided by the integrator */
|
||||
SUNNonlinSolSysFn Sys; /* fixed-point iteration function */
|
||||
SUNNonlinSolConvTestFn CTest; /* convergence test function */
|
||||
|
||||
/* nonlinear solver variables */
|
||||
int m; /* number of acceleration vectors to use */
|
||||
int *imap; /* array of length m */
|
||||
booleantype damping; /* flag to apply dampling in acceleration */
|
||||
realtype beta; /* damping paramter */
|
||||
realtype *R; /* array of length m*m */
|
||||
realtype *gamma; /* array of length m */
|
||||
realtype *cvals; /* array of length m+1 for fused vector op */
|
||||
N_Vector *df; /* vector array of length m */
|
||||
N_Vector *dg; /* vector array of length m */
|
||||
N_Vector *q; /* vector array of length m */
|
||||
N_Vector *Xvecs; /* array of length m+1 for fused vector op */
|
||||
N_Vector yprev; /* temporary vectors for performing solve */
|
||||
N_Vector gy;
|
||||
N_Vector fold;
|
||||
N_Vector gold;
|
||||
N_Vector delta; /* correction vector (change between 2 iterates) */
|
||||
int curiter; /* current iteration number in a solve attempt */
|
||||
int maxiters; /* maximum number of iterations per solve attempt */
|
||||
long int niters; /* total number of iterations across all solves */
|
||||
long int nconvfails; /* total number of convergence failures */
|
||||
void *ctest_data; /* data to pass to convergence test function */
|
||||
};
|
||||
|
||||
typedef struct _SUNNonlinearSolverContent_FixedPoint *SUNNonlinearSolverContent_FixedPoint;
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
II: Exported functions
|
||||
---------------------------------------------------------------------------*/
|
||||
|
||||
/* Constructor to create solver and allocates memory */
|
||||
SUNDIALS_EXPORT SUNNonlinearSolver SUNNonlinSol_FixedPoint(N_Vector y, int m);
|
||||
SUNDIALS_EXPORT SUNNonlinearSolver SUNNonlinSol_FixedPointSens(int count, N_Vector y, int m);
|
||||
|
||||
/* core functions */
|
||||
SUNDIALS_EXPORT SUNNonlinearSolver_Type SUNNonlinSolGetType_FixedPoint(SUNNonlinearSolver NLS);
|
||||
|
||||
SUNDIALS_EXPORT int SUNNonlinSolInitialize_FixedPoint(SUNNonlinearSolver NLS);
|
||||
|
||||
SUNDIALS_EXPORT int SUNNonlinSolSolve_FixedPoint(SUNNonlinearSolver NLS,
|
||||
N_Vector y0, N_Vector y,
|
||||
N_Vector w, realtype tol,
|
||||
booleantype callSetup, void *mem);
|
||||
|
||||
SUNDIALS_EXPORT int SUNNonlinSolFree_FixedPoint(SUNNonlinearSolver NLS);
|
||||
|
||||
/* set functions */
|
||||
SUNDIALS_EXPORT int SUNNonlinSolSetSysFn_FixedPoint(SUNNonlinearSolver NLS,
|
||||
SUNNonlinSolSysFn SysFn);
|
||||
|
||||
SUNDIALS_EXPORT int SUNNonlinSolSetConvTestFn_FixedPoint(SUNNonlinearSolver NLS,
|
||||
SUNNonlinSolConvTestFn CTestFn,
|
||||
void* ctest_data);
|
||||
|
||||
SUNDIALS_EXPORT int SUNNonlinSolSetMaxIters_FixedPoint(SUNNonlinearSolver NLS,
|
||||
int maxiters);
|
||||
|
||||
SUNDIALS_EXPORT int SUNNonlinSolSetDamping_FixedPoint(SUNNonlinearSolver NLS,
|
||||
realtype beta);
|
||||
|
||||
/* get functions */
|
||||
SUNDIALS_EXPORT int SUNNonlinSolGetNumIters_FixedPoint(SUNNonlinearSolver NLS,
|
||||
long int *niters);
|
||||
|
||||
SUNDIALS_EXPORT int SUNNonlinSolGetCurIter_FixedPoint(SUNNonlinearSolver NLS,
|
||||
int *iter);
|
||||
|
||||
SUNDIALS_EXPORT int SUNNonlinSolGetNumConvFails_FixedPoint(SUNNonlinearSolver NLS,
|
||||
long int *nconvfails);
|
||||
|
||||
SUNDIALS_EXPORT int SUNNonlinSolGetSysFn_FixedPoint(SUNNonlinearSolver NLS,
|
||||
SUNNonlinSolSysFn *SysFn);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,111 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* Programmer(s): David J. Gardner @ LLNL
|
||||
* -----------------------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
* -----------------------------------------------------------------------------
|
||||
* This is the header file for the SUNNonlinearSolver module implementation of
|
||||
* Newton's method.
|
||||
*
|
||||
* Part I defines the solver-specific content structure.
|
||||
*
|
||||
* Part II contains prototypes for the solver constructor and operations.
|
||||
* ---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef _SUNNONLINSOL_NEWTON_H
|
||||
#define _SUNNONLINSOL_NEWTON_H
|
||||
|
||||
#include "sundials/sundials_types.h"
|
||||
#include "sundials/sundials_nvector.h"
|
||||
#include "sundials/sundials_nonlinearsolver.h"
|
||||
|
||||
#ifdef __cplusplus /* wrapper to enable C++ usage */
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* I. Content structure
|
||||
* ---------------------------------------------------------------------------*/
|
||||
|
||||
struct _SUNNonlinearSolverContent_Newton {
|
||||
|
||||
/* functions provided by the integrator */
|
||||
SUNNonlinSolSysFn Sys; /* nonlinear system residual function */
|
||||
SUNNonlinSolLSetupFn LSetup; /* linear solver setup function */
|
||||
SUNNonlinSolLSolveFn LSolve; /* linear solver solve function */
|
||||
SUNNonlinSolConvTestFn CTest; /* nonlinear solver convergence test function */
|
||||
|
||||
/* nonlinear solver variables */
|
||||
N_Vector delta; /* Newton update vector */
|
||||
booleantype jcur; /* Jacobian status, current = SUNTRUE / stale = SUNFALSE */
|
||||
int curiter; /* current number of iterations in a solve attempt */
|
||||
int maxiters; /* maximum number of iterations in a solve attempt */
|
||||
long int niters; /* total number of nonlinear iterations across all solves */
|
||||
long int nconvfails; /* total number of convergence failures across all solves */
|
||||
void* ctest_data; /* data to pass to convergence test function */
|
||||
};
|
||||
|
||||
typedef struct _SUNNonlinearSolverContent_Newton *SUNNonlinearSolverContent_Newton;
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* II: Exported functions
|
||||
* ---------------------------------------------------------------------------*/
|
||||
|
||||
/* Constructor to create solver and allocates memory */
|
||||
SUNDIALS_EXPORT SUNNonlinearSolver SUNNonlinSol_Newton(N_Vector y);
|
||||
SUNDIALS_EXPORT SUNNonlinearSolver SUNNonlinSol_NewtonSens(int count, N_Vector y);
|
||||
|
||||
/* core functions */
|
||||
SUNDIALS_EXPORT SUNNonlinearSolver_Type SUNNonlinSolGetType_Newton(SUNNonlinearSolver NLS);
|
||||
|
||||
SUNDIALS_EXPORT int SUNNonlinSolInitialize_Newton(SUNNonlinearSolver NLS);
|
||||
|
||||
SUNDIALS_EXPORT int SUNNonlinSolSolve_Newton(SUNNonlinearSolver NLS,
|
||||
N_Vector y0, N_Vector y,
|
||||
N_Vector w, realtype tol,
|
||||
booleantype callLSetup, void *mem);
|
||||
|
||||
SUNDIALS_EXPORT int SUNNonlinSolFree_Newton(SUNNonlinearSolver NLS);
|
||||
|
||||
/* set functions */
|
||||
SUNDIALS_EXPORT int SUNNonlinSolSetSysFn_Newton(SUNNonlinearSolver NLS,
|
||||
SUNNonlinSolSysFn SysFn);
|
||||
|
||||
SUNDIALS_EXPORT int SUNNonlinSolSetLSetupFn_Newton(SUNNonlinearSolver NLS,
|
||||
SUNNonlinSolLSetupFn LSetupFn);
|
||||
|
||||
SUNDIALS_EXPORT int SUNNonlinSolSetLSolveFn_Newton(SUNNonlinearSolver NLS,
|
||||
SUNNonlinSolLSolveFn LSolveFn);
|
||||
|
||||
SUNDIALS_EXPORT int SUNNonlinSolSetConvTestFn_Newton(SUNNonlinearSolver NLS,
|
||||
SUNNonlinSolConvTestFn CTestFn,
|
||||
void* ctest_data);
|
||||
|
||||
SUNDIALS_EXPORT int SUNNonlinSolSetMaxIters_Newton(SUNNonlinearSolver NLS,
|
||||
int maxiters);
|
||||
|
||||
/* get functions */
|
||||
SUNDIALS_EXPORT int SUNNonlinSolGetNumIters_Newton(SUNNonlinearSolver NLS,
|
||||
long int *niters);
|
||||
|
||||
SUNDIALS_EXPORT int SUNNonlinSolGetCurIter_Newton(SUNNonlinearSolver NLS,
|
||||
int *iter);
|
||||
|
||||
SUNDIALS_EXPORT int SUNNonlinSolGetNumConvFails_Newton(SUNNonlinearSolver NLS,
|
||||
long int *nconvfails);
|
||||
|
||||
SUNDIALS_EXPORT int SUNNonlinSolGetSysFn_Newton(SUNNonlinearSolver NLS,
|
||||
SUNNonlinSolSysFn *SysFn);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,97 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* Programmer(s): Cody J. Balos @ LLNL
|
||||
* -----------------------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
* -----------------------------------------------------------------------------
|
||||
* This is the header file for the SUNNonlinearSolver module implementation of
|
||||
* a wrapper to the PETSc SNES nonlinear solvers.
|
||||
*
|
||||
* Part I defines the solver-specific content structure.
|
||||
*
|
||||
* Part II contains prototypes for the solver constructor and operations.
|
||||
* ---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef _SUNNONLINSOL_PETSCSNES_H
|
||||
#define _SUNNONLINSOL_PETSCSNES_H
|
||||
|
||||
#include "sundials/sundials_types.h"
|
||||
#include "sundials/sundials_nvector.h"
|
||||
#include "sundials/sundials_nonlinearsolver.h"
|
||||
#include <petscsnes.h>
|
||||
|
||||
#ifdef __cplusplus /* wrapper to enable C++ usage */
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* I. Content structure
|
||||
* ---------------------------------------------------------------------------*/
|
||||
|
||||
struct _SUNNonlinearSolverContent_PetscSNES {
|
||||
int sysfn_last_err; /* last error returned by the system function Sys */
|
||||
PetscErrorCode petsc_last_err; /* last error return by PETSc */
|
||||
long int nconvfails; /* number of nonlinear converge failures (recoverable or not) */
|
||||
long int nni; /* number of nonlinear iterations */
|
||||
void *imem; /* SUNDIALS integrator memory */
|
||||
SNES snes; /* PETSc SNES context */
|
||||
Vec r; /* nonlinear residual */
|
||||
N_Vector y, f; /* wrappers for PETSc vectors in system function */
|
||||
/* functions provided by the integrator */
|
||||
SUNNonlinSolSysFn Sys; /* nonlinear system function */
|
||||
};
|
||||
|
||||
typedef struct _SUNNonlinearSolverContent_PetscSNES *SUNNonlinearSolverContent_PetscSNES;
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* II: Exported functions
|
||||
* ---------------------------------------------------------------------------*/
|
||||
|
||||
/* Constructor to create solver and allocates memory */
|
||||
|
||||
SUNDIALS_EXPORT SUNNonlinearSolver SUNNonlinSol_PetscSNES(N_Vector y, SNES snes);
|
||||
|
||||
/* SUNNonlinearSolver API functions */
|
||||
|
||||
SUNDIALS_EXPORT SUNNonlinearSolver_Type SUNNonlinSolGetType_PetscSNES(SUNNonlinearSolver NLS);
|
||||
|
||||
SUNDIALS_EXPORT int SUNNonlinSolInitialize_PetscSNES(SUNNonlinearSolver NLS);
|
||||
|
||||
SUNDIALS_EXPORT int SUNNonlinSolSolve_PetscSNES(SUNNonlinearSolver NLS,
|
||||
N_Vector y0, N_Vector y,
|
||||
N_Vector w, realtype tol,
|
||||
booleantype callLSetup, void* mem);
|
||||
|
||||
SUNDIALS_EXPORT int SUNNonlinSolSetSysFn_PetscSNES(SUNNonlinearSolver NLS,
|
||||
SUNNonlinSolSysFn SysFn);
|
||||
|
||||
SUNDIALS_EXPORT int SUNNonlinSolGetNumIters_PetscSNES(SUNNonlinearSolver NLS, long int* nni);
|
||||
|
||||
SUNDIALS_EXPORT int SUNNonlinSolGetNumConvFails_PetscSNES(SUNNonlinearSolver NLS,
|
||||
long int* nconvfails);
|
||||
|
||||
SUNDIALS_EXPORT int SUNNonlinSolFree_PetscSNES(SUNNonlinearSolver NLS);
|
||||
|
||||
/* Implementation specific functions */
|
||||
|
||||
SUNDIALS_EXPORT int SUNNonlinSolGetSNES_PetscSNES(SUNNonlinearSolver NLS, SNES* snes);
|
||||
|
||||
SUNDIALS_EXPORT int SUNNonlinSolGetPetscError_PetscSNES(SUNNonlinearSolver NLS,
|
||||
PetscErrorCode* err);
|
||||
|
||||
SUNDIALS_EXPORT int SUNNonlinSolGetSysFn_PetscSNES(SUNNonlinearSolver NLS,
|
||||
SUNNonlinSolSysFn* SysFn);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
3488
bazaar/plugin/sundials/src/ida/ida.c
Normal file
3488
bazaar/plugin/sundials/src/ida/ida.c
Normal file
File diff suppressed because it is too large
Load diff
665
bazaar/plugin/sundials/src/ida/ida_bbdpre.c
Normal file
665
bazaar/plugin/sundials/src/ida/ida_bbdpre.c
Normal file
|
|
@ -0,0 +1,665 @@
|
|||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Programmer(s): Daniel R. Reynolds @ SMU
|
||||
* Alan C. Hindmarsh and Radu Serban @ LLNL
|
||||
* -----------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
* -----------------------------------------------------------------
|
||||
* This file contains implementations of routines for a
|
||||
* band-block-diagonal preconditioner, i.e. a block-diagonal
|
||||
* matrix with banded blocks, for use with IDA, the IDASPILS
|
||||
* linear solver interface.
|
||||
*
|
||||
* NOTE: With only one processor in use, a banded matrix results
|
||||
* rather than a block-diagonal matrix with banded blocks.
|
||||
* Diagonal blocking occurs at the processor level.
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "ida_impl.h"
|
||||
#include "ida_ls_impl.h"
|
||||
#include "ida_bbdpre_impl.h"
|
||||
#include <sundials/sundials_math.h>
|
||||
#include <nvector/nvector_serial.h>
|
||||
|
||||
|
||||
#define ZERO RCONST(0.0)
|
||||
#define ONE RCONST(1.0)
|
||||
#define TWO RCONST(2.0)
|
||||
|
||||
/* Prototypes of functions IDABBDPrecSetup and IDABBDPrecSolve */
|
||||
static int IDABBDPrecSetup(realtype tt, N_Vector yy, N_Vector yp,
|
||||
N_Vector rr, realtype c_j, void *prec_data);
|
||||
static int IDABBDPrecSolve(realtype tt, N_Vector yy, N_Vector yp,
|
||||
N_Vector rr, N_Vector rvec, N_Vector zvec,
|
||||
realtype c_j, realtype delta, void *prec_data);
|
||||
|
||||
/* Prototype for IDABBDPrecFree */
|
||||
static int IDABBDPrecFree(IDAMem ida_mem);
|
||||
|
||||
/* Prototype for difference quotient Jacobian calculation routine */
|
||||
static int IBBDDQJac(IBBDPrecData pdata, realtype tt, realtype cj,
|
||||
N_Vector yy, N_Vector yp, N_Vector gref,
|
||||
N_Vector ytemp, N_Vector yptemp, N_Vector gtemp);
|
||||
|
||||
/*---------------------------------------------------------------
|
||||
User-Callable Functions: initialization, reinit and free
|
||||
---------------------------------------------------------------*/
|
||||
int IDABBDPrecInit(void *ida_mem, sunindextype Nlocal,
|
||||
sunindextype mudq, sunindextype mldq,
|
||||
sunindextype mukeep, sunindextype mlkeep,
|
||||
realtype dq_rel_yy,
|
||||
IDABBDLocalFn Gres, IDABBDCommFn Gcomm)
|
||||
{
|
||||
IDAMem IDA_mem;
|
||||
IDALsMem idals_mem;
|
||||
IBBDPrecData pdata;
|
||||
sunindextype muk, mlk, storage_mu, lrw1, liw1;
|
||||
long int lrw, liw;
|
||||
int flag;
|
||||
|
||||
if (ida_mem == NULL) {
|
||||
IDAProcessError(NULL, IDALS_MEM_NULL, "IDABBDPRE",
|
||||
"IDABBDPrecInit", MSGBBD_MEM_NULL);
|
||||
return(IDALS_MEM_NULL);
|
||||
}
|
||||
IDA_mem = (IDAMem) ida_mem;
|
||||
|
||||
/* Test if the LS linear solver interface has been created */
|
||||
if (IDA_mem->ida_lmem == NULL) {
|
||||
IDAProcessError(IDA_mem, IDALS_LMEM_NULL, "IDABBDPRE",
|
||||
"IDABBDPrecInit", MSGBBD_LMEM_NULL);
|
||||
return(IDALS_LMEM_NULL);
|
||||
}
|
||||
idals_mem = (IDALsMem) IDA_mem->ida_lmem;
|
||||
|
||||
/* Test compatibility of NVECTOR package with the BBD preconditioner */
|
||||
if(IDA_mem->ida_tempv1->ops->nvgetarraypointer == NULL) {
|
||||
IDAProcessError(IDA_mem, IDALS_ILL_INPUT, "IDABBDPRE",
|
||||
"IDABBDPrecInit", MSGBBD_BAD_NVECTOR);
|
||||
return(IDALS_ILL_INPUT);
|
||||
}
|
||||
|
||||
/* Allocate data memory. */
|
||||
pdata = NULL;
|
||||
pdata = (IBBDPrecData) malloc(sizeof *pdata);
|
||||
if (pdata == NULL) {
|
||||
IDAProcessError(IDA_mem, IDALS_MEM_FAIL, "IDABBDPRE",
|
||||
"IDABBDPrecInit", MSGBBD_MEM_FAIL);
|
||||
return(IDALS_MEM_FAIL);
|
||||
}
|
||||
|
||||
/* Set pointers to glocal and gcomm; load half-bandwidths. */
|
||||
pdata->ida_mem = IDA_mem;
|
||||
pdata->glocal = Gres;
|
||||
pdata->gcomm = Gcomm;
|
||||
pdata->mudq = SUNMIN(Nlocal-1, SUNMAX(0, mudq));
|
||||
pdata->mldq = SUNMIN(Nlocal-1, SUNMAX(0, mldq));
|
||||
muk = SUNMIN(Nlocal-1, SUNMAX(0, mukeep));
|
||||
mlk = SUNMIN(Nlocal-1, SUNMAX(0, mlkeep));
|
||||
pdata->mukeep = muk;
|
||||
pdata->mlkeep = mlk;
|
||||
|
||||
/* Set extended upper half-bandwidth for PP (required for pivoting). */
|
||||
storage_mu = SUNMIN(Nlocal-1, muk+mlk);
|
||||
|
||||
/* Allocate memory for preconditioner matrix. */
|
||||
pdata->PP = NULL;
|
||||
pdata->PP = SUNBandMatrixStorage(Nlocal, muk, mlk, storage_mu);
|
||||
if (pdata->PP == NULL) {
|
||||
free(pdata); pdata = NULL;
|
||||
IDAProcessError(IDA_mem, IDALS_MEM_FAIL, "IDABBDPRE",
|
||||
"IDABBDPrecInit", MSGBBD_MEM_FAIL);
|
||||
return(IDALS_MEM_FAIL);
|
||||
}
|
||||
|
||||
/* Allocate memory for temporary N_Vectors */
|
||||
pdata->zlocal = NULL;
|
||||
pdata->zlocal = N_VNewEmpty_Serial(Nlocal);
|
||||
if (pdata->zlocal == NULL) {
|
||||
SUNMatDestroy(pdata->PP);
|
||||
free(pdata); pdata = NULL;
|
||||
IDAProcessError(IDA_mem, IDALS_MEM_FAIL, "IDABBDPRE",
|
||||
"IDABBDPrecInit", MSGBBD_MEM_FAIL);
|
||||
return(IDALS_MEM_FAIL);
|
||||
}
|
||||
pdata->rlocal = NULL;
|
||||
pdata->rlocal = N_VNewEmpty_Serial(Nlocal);
|
||||
if (pdata->rlocal == NULL) {
|
||||
N_VDestroy(pdata->zlocal);
|
||||
SUNMatDestroy(pdata->PP);
|
||||
free(pdata); pdata = NULL;
|
||||
IDAProcessError(IDA_mem, IDALS_MEM_FAIL, "IDABBDPRE",
|
||||
"IDABBDPrecInit", MSGBBD_MEM_FAIL);
|
||||
return(IDALS_MEM_FAIL);
|
||||
}
|
||||
pdata->tempv1 = NULL;
|
||||
pdata->tempv1 = N_VClone(IDA_mem->ida_tempv1);
|
||||
if (pdata->tempv1 == NULL){
|
||||
N_VDestroy(pdata->rlocal);
|
||||
N_VDestroy(pdata->zlocal);
|
||||
SUNMatDestroy(pdata->PP);
|
||||
free(pdata); pdata = NULL;
|
||||
IDAProcessError(IDA_mem, IDALS_MEM_FAIL, "IDABBDPRE",
|
||||
"IDABBDPrecInit", MSGBBD_MEM_FAIL);
|
||||
return(IDALS_MEM_FAIL);
|
||||
}
|
||||
pdata->tempv2 = NULL;
|
||||
pdata->tempv2 = N_VClone(IDA_mem->ida_tempv1);
|
||||
if (pdata->tempv2 == NULL){
|
||||
N_VDestroy(pdata->rlocal);
|
||||
N_VDestroy(pdata->zlocal);
|
||||
N_VDestroy(pdata->tempv1);
|
||||
SUNMatDestroy(pdata->PP);
|
||||
free(pdata); pdata = NULL;
|
||||
IDAProcessError(IDA_mem, IDALS_MEM_FAIL, "IDABBDPRE",
|
||||
"IDABBDPrecInit", MSGBBD_MEM_FAIL);
|
||||
return(IDALS_MEM_FAIL);
|
||||
}
|
||||
pdata->tempv3 = NULL;
|
||||
pdata->tempv3 = N_VClone(IDA_mem->ida_tempv1);
|
||||
if (pdata->tempv3 == NULL){
|
||||
N_VDestroy(pdata->rlocal);
|
||||
N_VDestroy(pdata->zlocal);
|
||||
N_VDestroy(pdata->tempv1);
|
||||
N_VDestroy(pdata->tempv2);
|
||||
SUNMatDestroy(pdata->PP);
|
||||
free(pdata); pdata = NULL;
|
||||
IDAProcessError(IDA_mem, IDALS_MEM_FAIL, "IDABBDPRE",
|
||||
"IDABBDPrecInit", MSGBBD_MEM_FAIL);
|
||||
return(IDALS_MEM_FAIL);
|
||||
}
|
||||
pdata->tempv4 = NULL;
|
||||
pdata->tempv4 = N_VClone(IDA_mem->ida_tempv1);
|
||||
if (pdata->tempv4 == NULL){
|
||||
N_VDestroy(pdata->rlocal);
|
||||
N_VDestroy(pdata->zlocal);
|
||||
N_VDestroy(pdata->tempv1);
|
||||
N_VDestroy(pdata->tempv2);
|
||||
N_VDestroy(pdata->tempv3);
|
||||
SUNMatDestroy(pdata->PP);
|
||||
free(pdata); pdata = NULL;
|
||||
IDAProcessError(IDA_mem, IDALS_MEM_FAIL, "IDABBDPRE",
|
||||
"IDABBDPrecInit", MSGBBD_MEM_FAIL);
|
||||
return(IDALS_MEM_FAIL);
|
||||
}
|
||||
|
||||
/* Allocate memory for banded linear solver */
|
||||
pdata->LS = NULL;
|
||||
pdata->LS = SUNLinSol_Band(pdata->rlocal, pdata->PP);
|
||||
if (pdata->LS == NULL) {
|
||||
N_VDestroy(pdata->zlocal);
|
||||
N_VDestroy(pdata->rlocal);
|
||||
N_VDestroy(pdata->tempv1);
|
||||
N_VDestroy(pdata->tempv2);
|
||||
N_VDestroy(pdata->tempv3);
|
||||
N_VDestroy(pdata->tempv4);
|
||||
SUNMatDestroy(pdata->PP);
|
||||
free(pdata); pdata = NULL;
|
||||
IDAProcessError(IDA_mem, IDALS_MEM_FAIL, "IDABBDPRE",
|
||||
"IDABBDPrecInit", MSGBBD_MEM_FAIL);
|
||||
return(IDALS_MEM_FAIL);
|
||||
}
|
||||
|
||||
/* initialize band linear solver object */
|
||||
flag = SUNLinSolInitialize(pdata->LS);
|
||||
if (flag != SUNLS_SUCCESS) {
|
||||
N_VDestroy(pdata->zlocal);
|
||||
N_VDestroy(pdata->rlocal);
|
||||
N_VDestroy(pdata->tempv1);
|
||||
N_VDestroy(pdata->tempv2);
|
||||
N_VDestroy(pdata->tempv3);
|
||||
N_VDestroy(pdata->tempv4);
|
||||
SUNMatDestroy(pdata->PP);
|
||||
SUNLinSolFree(pdata->LS);
|
||||
free(pdata); pdata = NULL;
|
||||
IDAProcessError(IDA_mem, IDALS_SUNLS_FAIL, "IDABBDPRE",
|
||||
"IDABBDPrecInit", MSGBBD_SUNLS_FAIL);
|
||||
return(IDALS_SUNLS_FAIL);
|
||||
}
|
||||
|
||||
/* Set rel_yy based on input value dq_rel_yy (0 implies default). */
|
||||
pdata->rel_yy = (dq_rel_yy > ZERO) ?
|
||||
dq_rel_yy : SUNRsqrt(IDA_mem->ida_uround);
|
||||
|
||||
/* Store Nlocal to be used in IDABBDPrecSetup */
|
||||
pdata->n_local = Nlocal;
|
||||
|
||||
/* Set work space sizes and initialize nge. */
|
||||
pdata->rpwsize = 0;
|
||||
pdata->ipwsize = 0;
|
||||
if (IDA_mem->ida_tempv1->ops->nvspace) {
|
||||
N_VSpace(IDA_mem->ida_tempv1, &lrw1, &liw1);
|
||||
pdata->rpwsize += 4*lrw1;
|
||||
pdata->ipwsize += 4*liw1;
|
||||
}
|
||||
if (pdata->rlocal->ops->nvspace) {
|
||||
N_VSpace(pdata->rlocal, &lrw1, &liw1);
|
||||
pdata->rpwsize += 2*lrw1;
|
||||
pdata->ipwsize += 2*liw1;
|
||||
}
|
||||
if (pdata->PP->ops->space) {
|
||||
flag = SUNMatSpace(pdata->PP, &lrw, &liw);
|
||||
pdata->rpwsize += lrw;
|
||||
pdata->ipwsize += liw;
|
||||
}
|
||||
if (pdata->LS->ops->space) {
|
||||
flag = SUNLinSolSpace(pdata->LS, &lrw, &liw);
|
||||
pdata->rpwsize += lrw;
|
||||
pdata->ipwsize += liw;
|
||||
}
|
||||
pdata->nge = 0;
|
||||
|
||||
/* make sure pdata is free from any previous allocations */
|
||||
if (idals_mem->pfree)
|
||||
idals_mem->pfree(IDA_mem);
|
||||
|
||||
/* Point to the new pdata field in the LS memory */
|
||||
idals_mem->pdata = pdata;
|
||||
|
||||
/* Attach the pfree function */
|
||||
idals_mem->pfree = IDABBDPrecFree;
|
||||
|
||||
/* Attach preconditioner solve and setup functions */
|
||||
flag = IDASetPreconditioner(ida_mem,
|
||||
IDABBDPrecSetup,
|
||||
IDABBDPrecSolve);
|
||||
|
||||
return(flag);
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------*/
|
||||
int IDABBDPrecReInit(void *ida_mem, sunindextype mudq,
|
||||
sunindextype mldq, realtype dq_rel_yy)
|
||||
{
|
||||
IDAMem IDA_mem;
|
||||
IDALsMem idals_mem;
|
||||
IBBDPrecData pdata;
|
||||
sunindextype Nlocal;
|
||||
|
||||
if (ida_mem == NULL) {
|
||||
IDAProcessError(NULL, IDALS_MEM_NULL, "IDABBDPRE",
|
||||
"IDABBDPrecReInit", MSGBBD_MEM_NULL);
|
||||
return(IDALS_MEM_NULL);
|
||||
}
|
||||
IDA_mem = (IDAMem) ida_mem;
|
||||
|
||||
/* Test if the LS linear solver interface has been created */
|
||||
if (IDA_mem->ida_lmem == NULL) {
|
||||
IDAProcessError(IDA_mem, IDALS_LMEM_NULL, "IDABBDPRE",
|
||||
"IDABBDPrecReInit", MSGBBD_LMEM_NULL);
|
||||
return(IDALS_LMEM_NULL);
|
||||
}
|
||||
idals_mem = (IDALsMem) IDA_mem->ida_lmem;
|
||||
|
||||
/* Test if the preconditioner data is non-NULL */
|
||||
if (idals_mem->pdata == NULL) {
|
||||
IDAProcessError(IDA_mem, IDALS_PMEM_NULL, "IDABBDPRE",
|
||||
"IDABBDPrecReInit", MSGBBD_PMEM_NULL);
|
||||
return(IDALS_PMEM_NULL);
|
||||
}
|
||||
pdata = (IBBDPrecData) idals_mem->pdata;
|
||||
|
||||
/* Load half-bandwidths. */
|
||||
Nlocal = pdata->n_local;
|
||||
pdata->mudq = SUNMIN(Nlocal-1, SUNMAX(0, mudq));
|
||||
pdata->mldq = SUNMIN(Nlocal-1, SUNMAX(0, mldq));
|
||||
|
||||
/* Set rel_yy based on input value dq_rel_yy (0 implies default). */
|
||||
pdata->rel_yy = (dq_rel_yy > ZERO) ?
|
||||
dq_rel_yy : SUNRsqrt(IDA_mem->ida_uround);
|
||||
|
||||
/* Re-initialize nge */
|
||||
pdata->nge = 0;
|
||||
|
||||
return(IDALS_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------*/
|
||||
int IDABBDPrecGetWorkSpace(void *ida_mem,
|
||||
long int *lenrwBBDP,
|
||||
long int *leniwBBDP)
|
||||
{
|
||||
IDAMem IDA_mem;
|
||||
IDALsMem idals_mem;
|
||||
IBBDPrecData pdata;
|
||||
|
||||
if (ida_mem == NULL) {
|
||||
IDAProcessError(NULL, IDALS_MEM_NULL, "IDABBDPRE",
|
||||
"IDABBDPrecGetWorkSpace", MSGBBD_MEM_NULL);
|
||||
return(IDALS_MEM_NULL);
|
||||
}
|
||||
IDA_mem = (IDAMem) ida_mem;
|
||||
|
||||
if (IDA_mem->ida_lmem == NULL) {
|
||||
IDAProcessError(IDA_mem, IDALS_LMEM_NULL, "IDABBDPRE",
|
||||
"IDABBDPrecGetWorkSpace", MSGBBD_LMEM_NULL);
|
||||
return(IDALS_LMEM_NULL);
|
||||
}
|
||||
idals_mem = (IDALsMem) IDA_mem->ida_lmem;
|
||||
|
||||
if (idals_mem->pdata == NULL) {
|
||||
IDAProcessError(IDA_mem, IDALS_PMEM_NULL, "IDABBDPRE",
|
||||
"IDABBDPrecGetWorkSpace", MSGBBD_PMEM_NULL);
|
||||
return(IDALS_PMEM_NULL);
|
||||
}
|
||||
pdata = (IBBDPrecData) idals_mem->pdata;
|
||||
|
||||
*lenrwBBDP = pdata->rpwsize;
|
||||
*leniwBBDP = pdata->ipwsize;
|
||||
|
||||
return(IDALS_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------*/
|
||||
int IDABBDPrecGetNumGfnEvals(void *ida_mem,
|
||||
long int *ngevalsBBDP)
|
||||
{
|
||||
IDAMem IDA_mem;
|
||||
IDALsMem idals_mem;
|
||||
IBBDPrecData pdata;
|
||||
|
||||
if (ida_mem == NULL) {
|
||||
IDAProcessError(NULL, IDALS_MEM_NULL, "IDABBDPRE",
|
||||
"IDABBDPrecGetNumGfnEvals", MSGBBD_MEM_NULL);
|
||||
return(IDALS_MEM_NULL);
|
||||
}
|
||||
IDA_mem = (IDAMem) ida_mem;
|
||||
|
||||
if (IDA_mem->ida_lmem == NULL) {
|
||||
IDAProcessError(IDA_mem, IDALS_LMEM_NULL, "IDABBDPRE",
|
||||
"IDABBDPrecGetNumGfnEvals", MSGBBD_LMEM_NULL);
|
||||
return(IDALS_LMEM_NULL);
|
||||
}
|
||||
idals_mem = (IDALsMem) IDA_mem->ida_lmem;
|
||||
|
||||
if (idals_mem->pdata == NULL) {
|
||||
IDAProcessError(IDA_mem, IDALS_PMEM_NULL, "IDABBDPRE",
|
||||
"IDABBDPrecGetNumGfnEvals", MSGBBD_PMEM_NULL);
|
||||
return(IDALS_PMEM_NULL);
|
||||
}
|
||||
pdata = (IBBDPrecData) idals_mem->pdata;
|
||||
|
||||
*ngevalsBBDP = pdata->nge;
|
||||
|
||||
return(IDALS_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------
|
||||
IDABBDPrecSetup:
|
||||
|
||||
IDABBDPrecSetup generates a band-block-diagonal preconditioner
|
||||
matrix, where the local block (on this processor) is a band
|
||||
matrix. Each local block is computed by a difference quotient
|
||||
scheme via calls to the user-supplied routines glocal, gcomm.
|
||||
After generating the block in the band matrix PP, this routine
|
||||
does an LU factorization in place in PP.
|
||||
|
||||
The IDABBDPrecSetup parameters used here are as follows:
|
||||
|
||||
tt is the current value of the independent variable t.
|
||||
|
||||
yy is the current value of the dependent variable vector,
|
||||
namely the predicted value of y(t).
|
||||
|
||||
yp is the current value of the derivative vector y',
|
||||
namely the predicted value of y'(t).
|
||||
|
||||
c_j is the scalar in the system Jacobian, proportional to 1/hh.
|
||||
|
||||
bbd_data is the pointer to BBD memory set by IDABBDInit
|
||||
|
||||
The argument rr is not used.
|
||||
|
||||
Return value:
|
||||
The value returned by this IDABBDPrecSetup function is a int
|
||||
flag indicating whether it was successful. This value is
|
||||
0 if successful,
|
||||
> 0 for a recoverable error (step will be retried), or
|
||||
< 0 for a nonrecoverable error (step fails).
|
||||
----------------------------------------------------------------*/
|
||||
static int IDABBDPrecSetup(realtype tt, N_Vector yy, N_Vector yp,
|
||||
N_Vector rr, realtype c_j, void *bbd_data)
|
||||
{
|
||||
IBBDPrecData pdata;
|
||||
IDAMem IDA_mem;
|
||||
int retval;
|
||||
|
||||
pdata =(IBBDPrecData) bbd_data;
|
||||
|
||||
IDA_mem = (IDAMem) pdata->ida_mem;
|
||||
|
||||
/* Call IBBDDQJac for a new Jacobian calculation and store in PP. */
|
||||
retval = SUNMatZero(pdata->PP);
|
||||
retval = IBBDDQJac(pdata, tt, c_j, yy, yp, pdata->tempv1,
|
||||
pdata->tempv2, pdata->tempv3, pdata->tempv4);
|
||||
if (retval < 0) {
|
||||
IDAProcessError(IDA_mem, -1, "IDABBDPRE", "IDABBDPrecSetup",
|
||||
MSGBBD_FUNC_FAILED);
|
||||
return(-1);
|
||||
}
|
||||
if (retval > 0) {
|
||||
return(1);
|
||||
}
|
||||
|
||||
/* Do LU factorization of matrix and return error flag */
|
||||
retval = SUNLinSolSetup_Band(pdata->LS, pdata->PP);
|
||||
return(retval);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------
|
||||
IDABBDPrecSolve
|
||||
|
||||
The function IDABBDPrecSolve computes a solution to the linear
|
||||
system P z = r, where P is the left preconditioner defined by
|
||||
the routine IDABBDPrecSetup.
|
||||
|
||||
The IDABBDPrecSolve parameters used here are as follows:
|
||||
|
||||
rvec is the input right-hand side vector r.
|
||||
|
||||
zvec is the computed solution vector z.
|
||||
|
||||
bbd_data is the pointer to BBD data set by IDABBDInit.
|
||||
|
||||
The arguments tt, yy, yp, rr, c_j and delta are NOT used.
|
||||
|
||||
IDABBDPrecSolve returns the value returned from the linear
|
||||
solver object.
|
||||
---------------------------------------------------------------*/
|
||||
static int IDABBDPrecSolve(realtype tt, N_Vector yy, N_Vector yp,
|
||||
N_Vector rr, N_Vector rvec, N_Vector zvec,
|
||||
realtype c_j, realtype delta, void *bbd_data)
|
||||
{
|
||||
IBBDPrecData pdata;
|
||||
int retval;
|
||||
|
||||
pdata = (IBBDPrecData) bbd_data;
|
||||
|
||||
/* Attach local data arrays for rvec and zvec to rlocal and zlocal */
|
||||
N_VSetArrayPointer(N_VGetArrayPointer(rvec), pdata->rlocal);
|
||||
N_VSetArrayPointer(N_VGetArrayPointer(zvec), pdata->zlocal);
|
||||
|
||||
/* Call banded solver object to do the work */
|
||||
retval = SUNLinSolSolve(pdata->LS, pdata->PP, pdata->zlocal,
|
||||
pdata->rlocal, ZERO);
|
||||
|
||||
/* Detach local data arrays from rlocal and zlocal */
|
||||
N_VSetArrayPointer(NULL, pdata->rlocal);
|
||||
N_VSetArrayPointer(NULL, pdata->zlocal);
|
||||
|
||||
return(retval);
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------*/
|
||||
static int IDABBDPrecFree(IDAMem IDA_mem)
|
||||
{
|
||||
IDALsMem idals_mem;
|
||||
IBBDPrecData pdata;
|
||||
|
||||
if (IDA_mem->ida_lmem == NULL) return(0);
|
||||
idals_mem = (IDALsMem) IDA_mem->ida_lmem;
|
||||
|
||||
if (idals_mem->pdata == NULL) return(0);
|
||||
pdata = (IBBDPrecData) idals_mem->pdata;
|
||||
|
||||
SUNLinSolFree(pdata->LS);
|
||||
N_VDestroy(pdata->rlocal);
|
||||
N_VDestroy(pdata->zlocal);
|
||||
N_VDestroy(pdata->tempv1);
|
||||
N_VDestroy(pdata->tempv2);
|
||||
N_VDestroy(pdata->tempv3);
|
||||
N_VDestroy(pdata->tempv4);
|
||||
SUNMatDestroy(pdata->PP);
|
||||
|
||||
free(pdata);
|
||||
pdata = NULL;
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------
|
||||
IBBDDQJac
|
||||
|
||||
This routine generates a banded difference quotient approximation
|
||||
to the local block of the Jacobian of G(t,y,y'). It assumes that
|
||||
a band matrix of type SUNMatrix is stored column-wise, and that
|
||||
elements within each column are contiguous.
|
||||
|
||||
All matrix elements are generated as difference quotients, by way
|
||||
of calls to the user routine glocal. By virtue of the band
|
||||
structure, the number of these calls is bandwidth + 1, where
|
||||
bandwidth = mldq + mudq + 1. But the band matrix kept has
|
||||
bandwidth = mlkeep + mukeep + 1. This routine also assumes that
|
||||
the local elements of a vector are stored contiguously.
|
||||
|
||||
Return values are: 0 (success), > 0 (recoverable error),
|
||||
or < 0 (nonrecoverable error).
|
||||
----------------------------------------------------------------*/
|
||||
static int IBBDDQJac(IBBDPrecData pdata, realtype tt, realtype cj,
|
||||
N_Vector yy, N_Vector yp, N_Vector gref,
|
||||
N_Vector ytemp, N_Vector yptemp, N_Vector gtemp)
|
||||
{
|
||||
IDAMem IDA_mem;
|
||||
realtype inc, inc_inv;
|
||||
int retval;
|
||||
sunindextype group, i, j, width, ngroups, i1, i2;
|
||||
realtype *ydata, *ypdata, *ytempdata, *yptempdata, *grefdata, *gtempdata;
|
||||
realtype *cnsdata = NULL, *ewtdata;
|
||||
realtype *col_j, conj, yj, ypj, ewtj;
|
||||
|
||||
IDA_mem = (IDAMem) pdata->ida_mem;
|
||||
|
||||
/* Initialize ytemp and yptemp. */
|
||||
N_VScale(ONE, yy, ytemp);
|
||||
N_VScale(ONE, yp, yptemp);
|
||||
|
||||
/* Obtain pointers as required to the data array of vectors. */
|
||||
ydata = N_VGetArrayPointer(yy);
|
||||
ypdata = N_VGetArrayPointer(yp);
|
||||
gtempdata = N_VGetArrayPointer(gtemp);
|
||||
ewtdata = N_VGetArrayPointer(IDA_mem->ida_ewt);
|
||||
if (IDA_mem->ida_constraintsSet)
|
||||
cnsdata = N_VGetArrayPointer(IDA_mem->ida_constraints);
|
||||
ytempdata = N_VGetArrayPointer(ytemp);
|
||||
yptempdata= N_VGetArrayPointer(yptemp);
|
||||
grefdata = N_VGetArrayPointer(gref);
|
||||
|
||||
/* Call gcomm and glocal to get base value of G(t,y,y'). */
|
||||
if (pdata->gcomm != NULL) {
|
||||
retval = pdata->gcomm(pdata->n_local, tt, yy, yp, IDA_mem->ida_user_data);
|
||||
if (retval != 0) return(retval);
|
||||
}
|
||||
|
||||
retval = pdata->glocal(pdata->n_local, tt, yy, yp, gref, IDA_mem->ida_user_data);
|
||||
pdata->nge++;
|
||||
if (retval != 0) return(retval);
|
||||
|
||||
/* Set bandwidth and number of column groups for band differencing. */
|
||||
width = pdata->mldq + pdata->mudq + 1;
|
||||
ngroups = SUNMIN(width, pdata->n_local);
|
||||
|
||||
/* Loop over groups. */
|
||||
for(group = 1; group <= ngroups; group++) {
|
||||
|
||||
/* Loop over the components in this group. */
|
||||
for(j = group-1; j < pdata->n_local; j += width) {
|
||||
yj = ydata[j];
|
||||
ypj = ypdata[j];
|
||||
ewtj = ewtdata[j];
|
||||
|
||||
/* Set increment inc to yj based on rel_yy*abs(yj), with
|
||||
adjustments using ypj and ewtj if this is small, and a further
|
||||
adjustment to give it the same sign as hh*ypj. */
|
||||
inc = pdata->rel_yy *
|
||||
SUNMAX(SUNRabs(yj), SUNMAX( SUNRabs(IDA_mem->ida_hh*ypj), ONE/ewtj));
|
||||
if (IDA_mem->ida_hh*ypj < ZERO) inc = -inc;
|
||||
inc = (yj + inc) - yj;
|
||||
|
||||
/* Adjust sign(inc) again if yj has an inequality constraint. */
|
||||
if (IDA_mem->ida_constraintsSet) {
|
||||
conj = cnsdata[j];
|
||||
if (SUNRabs(conj) == ONE) {if ((yj+inc)*conj < ZERO) inc = -inc;}
|
||||
else if (SUNRabs(conj) == TWO) {if ((yj+inc)*conj <= ZERO) inc = -inc;}
|
||||
}
|
||||
|
||||
/* Increment yj and ypj. */
|
||||
ytempdata[j] += inc;
|
||||
yptempdata[j] += cj*inc;
|
||||
|
||||
}
|
||||
|
||||
/* Evaluate G with incremented y and yp arguments. */
|
||||
retval = pdata->glocal(pdata->n_local, tt, ytemp, yptemp,
|
||||
gtemp, IDA_mem->ida_user_data);
|
||||
pdata->nge++;
|
||||
if (retval != 0) return(retval);
|
||||
|
||||
/* Loop over components of the group again; restore ytemp and yptemp. */
|
||||
for(j = group-1; j < pdata->n_local; j += width) {
|
||||
yj = ytempdata[j] = ydata[j];
|
||||
ypj = yptempdata[j] = ypdata[j];
|
||||
ewtj = ewtdata[j];
|
||||
|
||||
/* Set increment inc as before .*/
|
||||
inc = pdata->rel_yy *
|
||||
SUNMAX(SUNRabs(yj), SUNMAX( SUNRabs(IDA_mem->ida_hh*ypj), ONE/ewtj));
|
||||
if (IDA_mem->ida_hh*ypj < ZERO) inc = -inc;
|
||||
inc = (yj + inc) - yj;
|
||||
if (IDA_mem->ida_constraintsSet) {
|
||||
conj = cnsdata[j];
|
||||
if (SUNRabs(conj) == ONE) {if ((yj+inc)*conj < ZERO) inc = -inc;}
|
||||
else if (SUNRabs(conj) == TWO) {if ((yj+inc)*conj <= ZERO) inc = -inc;}
|
||||
}
|
||||
|
||||
/* Form difference quotients and load into PP. */
|
||||
inc_inv = ONE/inc;
|
||||
col_j = SUNBandMatrix_Column(pdata->PP,j);
|
||||
i1 = SUNMAX(0, j - pdata->mukeep);
|
||||
i2 = SUNMIN(j + pdata->mlkeep, pdata->n_local-1);
|
||||
for(i=i1; i <= i2; i++)
|
||||
SM_COLUMN_ELEMENT_B(col_j,i,j) =
|
||||
inc_inv * (gtempdata[i] - grefdata[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
88
bazaar/plugin/sundials/src/ida/ida_bbdpre_impl.h
Normal file
88
bazaar/plugin/sundials/src/ida/ida_bbdpre_impl.h
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
/*-----------------------------------------------------------------
|
||||
* Programmer(s): Daniel R. Reynolds @ SMU
|
||||
* Alan C. Hindmarsh and Radu Serban @ LLNL
|
||||
*-----------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
*-----------------------------------------------------------------
|
||||
* This is the header file (private version) for the IDABBDPRE
|
||||
* module, for a band-block-diagonal preconditioner, i.e. a
|
||||
* block-diagonal matrix with banded blocks, for use with IDA
|
||||
* and an IDASPILS linear solver.
|
||||
*-----------------------------------------------------------------*/
|
||||
|
||||
#ifndef _IDABBDPRE_IMPL_H
|
||||
#define _IDABBDPRE_IMPL_H
|
||||
|
||||
#include <ida/ida_bbdpre.h>
|
||||
#include <sunmatrix/sunmatrix_band.h>
|
||||
#include <sunlinsol/sunlinsol_band.h>
|
||||
|
||||
#ifdef __cplusplus /* wrapper to enable C++ usage */
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Definition of IBBDPrecData
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
typedef struct IBBDPrecDataRec {
|
||||
|
||||
/* passed by user to IDABBDPrecAlloc and used by
|
||||
IDABBDPrecSetup/IDABBDPrecSolve functions */
|
||||
sunindextype mudq, mldq, mukeep, mlkeep;
|
||||
realtype rel_yy;
|
||||
IDABBDLocalFn glocal;
|
||||
IDABBDCommFn gcomm;
|
||||
|
||||
/* set by IDABBDPrecSetup and used by IDABBDPrecSetup and
|
||||
IDABBDPrecSolve functions */
|
||||
sunindextype n_local;
|
||||
SUNMatrix PP;
|
||||
SUNLinearSolver LS;
|
||||
N_Vector zlocal;
|
||||
N_Vector rlocal;
|
||||
N_Vector tempv1;
|
||||
N_Vector tempv2;
|
||||
N_Vector tempv3;
|
||||
N_Vector tempv4;
|
||||
|
||||
/* available for optional output */
|
||||
long int rpwsize;
|
||||
long int ipwsize;
|
||||
long int nge;
|
||||
|
||||
/* pointer to ida_mem */
|
||||
void *ida_mem;
|
||||
|
||||
} *IBBDPrecData;
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* IDABBDPRE error messages
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#define MSGBBD_MEM_NULL "Integrator memory is NULL."
|
||||
#define MSGBBD_LMEM_NULL "Linear solver memory is NULL. One of the SPILS linear solvers must be attached."
|
||||
#define MSGBBD_MEM_FAIL "A memory request failed."
|
||||
#define MSGBBD_BAD_NVECTOR "A required vector operation is not implemented."
|
||||
#define MSGBBD_SUNMAT_FAIL "An error arose from a SUNBandMatrix routine."
|
||||
#define MSGBBD_SUNLS_FAIL "An error arose from a SUNBandLinearSolver routine."
|
||||
#define MSGBBD_PMEM_NULL "BBD peconditioner memory is NULL. IDABBDPrecInit must be called."
|
||||
#define MSGBBD_FUNC_FAILED "The Glocal or Gcomm routine failed in an unrecoverable manner."
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
56
bazaar/plugin/sundials/src/ida/ida_direct.c
Normal file
56
bazaar/plugin/sundials/src/ida/ida_direct.c
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
/*-----------------------------------------------------------------
|
||||
* Programmer(s): Daniel R. Reynolds @ SMU
|
||||
* Radu Serban @ LLNL
|
||||
*-----------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
*-----------------------------------------------------------------
|
||||
* Implementation file for the deprecated direct linear solver interface in
|
||||
* IDA; these routines now just wrap the updated IDA generic
|
||||
* linear solver interface in ida_ls.h.
|
||||
*-----------------------------------------------------------------*/
|
||||
|
||||
#include <ida/ida_ls.h>
|
||||
#include <ida/ida_direct.h>
|
||||
|
||||
#ifdef __cplusplus /* wrapper to enable C++ usage */
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*=================================================================
|
||||
Exported Functions (wrappers for equivalent routines in ida_ls.h)
|
||||
=================================================================*/
|
||||
|
||||
int IDADlsSetLinearSolver(void *ida_mem, SUNLinearSolver LS, SUNMatrix A)
|
||||
{ return(IDASetLinearSolver(ida_mem, LS, A)); }
|
||||
|
||||
int IDADlsSetJacFn(void *ida_mem, IDADlsJacFn jac)
|
||||
{ return(IDASetJacFn(ida_mem, jac)); }
|
||||
|
||||
int IDADlsGetWorkSpace(void *ida_mem, long int *lenrwLS, long int *leniwLS)
|
||||
{ return(IDAGetLinWorkSpace(ida_mem, lenrwLS, leniwLS)); }
|
||||
|
||||
int IDADlsGetNumJacEvals(void *ida_mem, long int *njevals)
|
||||
{ return(IDAGetNumJacEvals(ida_mem, njevals)); }
|
||||
|
||||
int IDADlsGetNumResEvals(void *ida_mem, long int *nfevalsLS)
|
||||
{ return(IDAGetNumLinResEvals(ida_mem, nfevalsLS)); }
|
||||
|
||||
int IDADlsGetLastFlag(void *ida_mem, long int *flag)
|
||||
{ return(IDAGetLastLinFlag(ida_mem, flag)); }
|
||||
|
||||
char *IDADlsGetReturnFlagName(long int flag)
|
||||
{ return(IDAGetLinReturnFlagName(flag)); }
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
704
bazaar/plugin/sundials/src/ida/ida_ic.c
Normal file
704
bazaar/plugin/sundials/src/ida/ida_ic.c
Normal file
|
|
@ -0,0 +1,704 @@
|
|||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* $Revision$
|
||||
* $Date$
|
||||
* -----------------------------------------------------------------
|
||||
* Programmers: Alan C. Hindmarsh, and Radu Serban @ LLNL
|
||||
* -----------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
* -----------------------------------------------------------------
|
||||
* This is the implementation file for the IC calculation for IDA.
|
||||
* It is independent of the linear solver in use.
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "ida_impl.h"
|
||||
#include <sundials/sundials_math.h>
|
||||
|
||||
/*
|
||||
* =================================================================
|
||||
* IDA Constants
|
||||
* =================================================================
|
||||
*/
|
||||
|
||||
/* Private Constants */
|
||||
|
||||
#define ZERO RCONST(0.0) /* real 0.0 */
|
||||
#define HALF RCONST(0.5) /* real 0.5 */
|
||||
#define ONE RCONST(1.0) /* real 1.0 */
|
||||
#define TWO RCONST(2.0) /* real 2.0 */
|
||||
#define PT99 RCONST(0.99) /* real 0.99 */
|
||||
#define PT1 RCONST(0.1) /* real 0.1 */
|
||||
#define PT001 RCONST(0.001) /* real 0.001 */
|
||||
|
||||
/* IDACalcIC control constants */
|
||||
|
||||
#define ICRATEMAX RCONST(0.9) /* max. Newton conv. rate */
|
||||
#define ALPHALS RCONST(0.0001) /* alpha in linesearch conv. test */
|
||||
|
||||
/* Return values for lower level routines used by IDACalcIC */
|
||||
|
||||
#define IC_FAIL_RECOV 1
|
||||
#define IC_CONSTR_FAILED 2
|
||||
#define IC_LINESRCH_FAILED 3
|
||||
#define IC_CONV_FAIL 4
|
||||
#define IC_SLOW_CONVRG 5
|
||||
|
||||
/*
|
||||
* =================================================================
|
||||
* Private Helper Functions Prototypes
|
||||
* =================================================================
|
||||
*/
|
||||
|
||||
extern int IDAInitialSetup(IDAMem IDA_mem);
|
||||
extern realtype IDAWrmsNorm(IDAMem IDA_mem, N_Vector x, N_Vector w,
|
||||
booleantype mask);
|
||||
|
||||
static int IDAnlsIC(IDAMem IDA_mem);
|
||||
static int IDANewtonIC(IDAMem IDA_mem);
|
||||
static int IDALineSrch(IDAMem IDA_mem, realtype *delnorm, realtype *fnorm);
|
||||
static int IDAfnorm(IDAMem IDA_mem, realtype *fnorm);
|
||||
static int IDANewyyp(IDAMem IDA_mem, realtype lambda);
|
||||
static int IDANewy(IDAMem IDA_mem);
|
||||
static int IDAICFailFlag(IDAMem IDA_mem, int retval);
|
||||
|
||||
/*
|
||||
* =================================================================
|
||||
* EXPORTED FUNCTIONS IMPLEMENTATION
|
||||
* =================================================================
|
||||
*/
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* IDACalcIC
|
||||
* -----------------------------------------------------------------
|
||||
* IDACalcIC computes consistent initial conditions, given the
|
||||
* user's initial guess for unknown components of yy0 and/or yp0.
|
||||
*
|
||||
* The return value is IDA_SUCCESS = 0 if no error occurred.
|
||||
*
|
||||
* The error return values (fully described in ida.h) are:
|
||||
* IDA_MEM_NULL ida_mem is NULL
|
||||
* IDA_NO_MALLOC ida_mem was not allocated
|
||||
* IDA_ILL_INPUT bad value for icopt, tout1, or id
|
||||
* IDA_LINIT_FAIL the linear solver linit routine failed
|
||||
* IDA_BAD_EWT zero value of some component of ewt
|
||||
* IDA_RES_FAIL res had a non-recoverable error
|
||||
* IDA_FIRST_RES_FAIL res failed recoverably on the first call
|
||||
* IDA_LSETUP_FAIL lsetup had a non-recoverable error
|
||||
* IDA_LSOLVE_FAIL lsolve had a non-recoverable error
|
||||
* IDA_NO_RECOVERY res, lsetup, or lsolve had a recoverable
|
||||
* error, but IDACalcIC could not recover
|
||||
* IDA_CONSTR_FAIL the inequality constraints could not be met
|
||||
* IDA_LINESEARCH_FAIL the linesearch failed (either on steptol test
|
||||
* or on the maxbacks test)
|
||||
* IDA_CONV_FAIL the Newton iterations failed to converge
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
int IDACalcIC(void *ida_mem, int icopt, realtype tout1)
|
||||
{
|
||||
int ewtsetOK;
|
||||
int ier, nwt, nh, mxnh, icret, retval=0;
|
||||
realtype tdist, troundoff, minid, hic, ypnorm;
|
||||
IDAMem IDA_mem;
|
||||
|
||||
/* Check if IDA memory exists */
|
||||
|
||||
if(ida_mem == NULL) {
|
||||
IDAProcessError(NULL, IDA_MEM_NULL, "IDA", "IDACalcIC", MSG_NO_MEM);
|
||||
return(IDA_MEM_NULL);
|
||||
}
|
||||
IDA_mem = (IDAMem) ida_mem;
|
||||
|
||||
/* Check if problem was malloc'ed */
|
||||
|
||||
if(IDA_mem->ida_MallocDone == SUNFALSE) {
|
||||
IDAProcessError(IDA_mem, IDA_NO_MALLOC, "IDA", "IDACalcIC", MSG_NO_MALLOC);
|
||||
return(IDA_NO_MALLOC);
|
||||
}
|
||||
|
||||
/* Check inputs to IDA for correctness and consistency */
|
||||
|
||||
ier = IDAInitialSetup(IDA_mem);
|
||||
if(ier != IDA_SUCCESS) return(IDA_ILL_INPUT);
|
||||
IDA_mem->ida_SetupDone = SUNTRUE;
|
||||
|
||||
/* Check legality of input arguments, and set IDA memory copies. */
|
||||
|
||||
if(icopt != IDA_YA_YDP_INIT && icopt != IDA_Y_INIT) {
|
||||
IDAProcessError(IDA_mem, IDA_ILL_INPUT, "IDA", "IDACalcIC", MSG_IC_BAD_ICOPT);
|
||||
return(IDA_ILL_INPUT);
|
||||
}
|
||||
IDA_mem->ida_icopt = icopt;
|
||||
|
||||
if(icopt == IDA_YA_YDP_INIT && (IDA_mem->ida_id == NULL)) {
|
||||
IDAProcessError(IDA_mem, IDA_ILL_INPUT, "IDA", "IDACalcIC", MSG_IC_MISSING_ID);
|
||||
return(IDA_ILL_INPUT);
|
||||
}
|
||||
|
||||
tdist = SUNRabs(tout1 - IDA_mem->ida_tn);
|
||||
troundoff = TWO * IDA_mem->ida_uround * (SUNRabs(IDA_mem->ida_tn) + SUNRabs(tout1));
|
||||
if(tdist < troundoff) {
|
||||
IDAProcessError(IDA_mem, IDA_ILL_INPUT, "IDA", "IDACalcIC", MSG_IC_TOO_CLOSE);
|
||||
return(IDA_ILL_INPUT);
|
||||
}
|
||||
|
||||
/* Allocate space and initialize temporary vectors */
|
||||
|
||||
IDA_mem->ida_yy0 = N_VClone(IDA_mem->ida_ee);
|
||||
IDA_mem->ida_yp0 = N_VClone(IDA_mem->ida_ee);
|
||||
IDA_mem->ida_t0 = IDA_mem->ida_tn;
|
||||
N_VScale(ONE, IDA_mem->ida_phi[0], IDA_mem->ida_yy0);
|
||||
N_VScale(ONE, IDA_mem->ida_phi[1], IDA_mem->ida_yp0);
|
||||
|
||||
/* For use in the IDA_YA_YP_INIT case, set sysindex and tscale. */
|
||||
|
||||
IDA_mem->ida_sysindex = 1;
|
||||
IDA_mem->ida_tscale = tdist;
|
||||
if(icopt == IDA_YA_YDP_INIT) {
|
||||
minid = N_VMin(IDA_mem->ida_id);
|
||||
if(minid < ZERO) {
|
||||
IDAProcessError(IDA_mem, IDA_ILL_INPUT, "IDA", "IDACalcIC", MSG_IC_BAD_ID);
|
||||
return(IDA_ILL_INPUT);
|
||||
}
|
||||
if(minid > HALF) IDA_mem->ida_sysindex = 0;
|
||||
}
|
||||
|
||||
/* Set the test constant in the Newton convergence test */
|
||||
|
||||
IDA_mem->ida_epsNewt = IDA_mem->ida_epiccon;
|
||||
|
||||
/* Initializations:
|
||||
cjratio = 1 (for use in direct linear solvers);
|
||||
set nbacktr = 0; */
|
||||
|
||||
IDA_mem->ida_cjratio = ONE;
|
||||
IDA_mem->ida_nbacktr = 0;
|
||||
|
||||
/* Set hic, hh, cj, and mxnh. */
|
||||
|
||||
hic = PT001*tdist;
|
||||
ypnorm = IDAWrmsNorm(IDA_mem, IDA_mem->ida_yp0,
|
||||
IDA_mem->ida_ewt, IDA_mem->ida_suppressalg);
|
||||
if(ypnorm > HALF/hic) hic = HALF/ypnorm;
|
||||
if(tout1 < IDA_mem->ida_tn) hic = -hic;
|
||||
IDA_mem->ida_hh = hic;
|
||||
if(icopt == IDA_YA_YDP_INIT) {
|
||||
IDA_mem->ida_cj = ONE/hic;
|
||||
mxnh = IDA_mem->ida_maxnh;
|
||||
}
|
||||
else {
|
||||
IDA_mem->ida_cj = ZERO;
|
||||
mxnh = 1;
|
||||
}
|
||||
|
||||
/* Loop over nwt = number of evaluations of ewt vector. */
|
||||
|
||||
for(nwt = 1; nwt <= 2; nwt++) {
|
||||
|
||||
/* Loop over nh = number of h values. */
|
||||
for(nh = 1; nh <= mxnh; nh++) {
|
||||
|
||||
/* Call the IC nonlinear solver function. */
|
||||
retval = IDAnlsIC(IDA_mem);
|
||||
|
||||
/* Cut h and loop on recoverable IDA_YA_YDP_INIT failure; else break. */
|
||||
if(retval == IDA_SUCCESS) break;
|
||||
IDA_mem->ida_ncfn++;
|
||||
if(retval < 0) break;
|
||||
if(nh == mxnh) break;
|
||||
/* If looping to try again, reset yy0 and yp0 if not converging. */
|
||||
if(retval != IC_SLOW_CONVRG) {
|
||||
N_VScale(ONE, IDA_mem->ida_phi[0], IDA_mem->ida_yy0);
|
||||
N_VScale(ONE, IDA_mem->ida_phi[1], IDA_mem->ida_yp0);
|
||||
}
|
||||
hic *= PT1;
|
||||
IDA_mem->ida_cj = ONE/hic;
|
||||
IDA_mem->ida_hh = hic;
|
||||
} /* End of nh loop */
|
||||
|
||||
/* Break on failure; else reset ewt, save yy0, yp0 in phi, and loop. */
|
||||
if(retval != IDA_SUCCESS) break;
|
||||
ewtsetOK = IDA_mem->ida_efun(IDA_mem->ida_yy0, IDA_mem->ida_ewt,
|
||||
IDA_mem->ida_edata);
|
||||
if(ewtsetOK != 0) {
|
||||
retval = IDA_BAD_EWT;
|
||||
break;
|
||||
}
|
||||
N_VScale(ONE, IDA_mem->ida_yy0, IDA_mem->ida_phi[0]);
|
||||
N_VScale(ONE, IDA_mem->ida_yp0, IDA_mem->ida_phi[1]);
|
||||
|
||||
} /* End of nwt loop */
|
||||
|
||||
/* Free temporary space */
|
||||
|
||||
N_VDestroy(IDA_mem->ida_yy0);
|
||||
N_VDestroy(IDA_mem->ida_yp0);
|
||||
|
||||
/* Load the optional outputs. */
|
||||
|
||||
if(icopt == IDA_YA_YDP_INIT) IDA_mem->ida_hused = hic;
|
||||
|
||||
/* On any failure, print message and return proper flag. */
|
||||
|
||||
if(retval != IDA_SUCCESS) {
|
||||
icret = IDAICFailFlag(IDA_mem, retval);
|
||||
return(icret);
|
||||
}
|
||||
|
||||
/* Otherwise return success flag. */
|
||||
|
||||
return(IDA_SUCCESS);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* =================================================================
|
||||
* PRIVATE FUNCTIONS IMPLEMENTATION
|
||||
* =================================================================
|
||||
*/
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* IDAnlsIC
|
||||
* -----------------------------------------------------------------
|
||||
* IDAnlsIC solves a nonlinear system for consistent initial
|
||||
* conditions. It calls IDANewtonIC to do most of the work.
|
||||
*
|
||||
* The return value is IDA_SUCCESS = 0 if no error occurred.
|
||||
* The error return values (positive) considered recoverable are:
|
||||
* IC_FAIL_RECOV if res, lsetup, or lsolve failed recoverably
|
||||
* IC_CONSTR_FAILED if the constraints could not be met
|
||||
* IC_LINESRCH_FAILED if the linesearch failed (either on steptol test
|
||||
* or on maxbacks test)
|
||||
* IC_CONV_FAIL if the Newton iterations failed to converge
|
||||
* IC_SLOW_CONVRG if the iterations are converging slowly
|
||||
* (failed the convergence test, but showed
|
||||
* norm reduction or convergence rate < 1)
|
||||
* The error return values (negative) considered non-recoverable are:
|
||||
* IDA_RES_FAIL if res had a non-recoverable error
|
||||
* IDA_FIRST_RES_FAIL if res failed recoverably on the first call
|
||||
* IDA_LSETUP_FAIL if lsetup had a non-recoverable error
|
||||
* IDA_LSOLVE_FAIL if lsolve had a non-recoverable error
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static int IDAnlsIC (IDAMem IDA_mem)
|
||||
{
|
||||
int retval, nj;
|
||||
N_Vector tv1, tv2, tv3;
|
||||
|
||||
tv1 = IDA_mem->ida_ee;
|
||||
tv2 = IDA_mem->ida_tempv2;
|
||||
tv3 = IDA_mem->ida_phi[2];
|
||||
|
||||
retval = IDA_mem->ida_res(IDA_mem->ida_t0, IDA_mem->ida_yy0,
|
||||
IDA_mem->ida_yp0, IDA_mem->ida_delta,
|
||||
IDA_mem->ida_user_data);
|
||||
IDA_mem->ida_nre++;
|
||||
if(retval < 0) return(IDA_RES_FAIL);
|
||||
if(retval > 0) return(IDA_FIRST_RES_FAIL);
|
||||
|
||||
N_VScale(ONE, IDA_mem->ida_delta, IDA_mem->ida_savres);
|
||||
|
||||
/* Loop over nj = number of linear solve Jacobian setups. */
|
||||
|
||||
for(nj = 1; nj <= IDA_mem->ida_maxnj; nj++) {
|
||||
|
||||
/* If there is a setup routine, call it. */
|
||||
if(IDA_mem->ida_lsetup) {
|
||||
IDA_mem->ida_nsetups++;
|
||||
retval = IDA_mem->ida_lsetup(IDA_mem, IDA_mem->ida_yy0,
|
||||
IDA_mem->ida_yp0, IDA_mem->ida_delta,
|
||||
tv1, tv2, tv3);
|
||||
if(retval < 0) return(IDA_LSETUP_FAIL);
|
||||
if(retval > 0) return(IC_FAIL_RECOV);
|
||||
}
|
||||
|
||||
/* Call the Newton iteration routine, and return if successful. */
|
||||
retval = IDANewtonIC(IDA_mem);
|
||||
if(retval == IDA_SUCCESS) return(IDA_SUCCESS);
|
||||
|
||||
/* If converging slowly and lsetup is nontrivial, retry. */
|
||||
if(retval == IC_SLOW_CONVRG && IDA_mem->ida_lsetup) {
|
||||
N_VScale(ONE, IDA_mem->ida_savres, IDA_mem->ida_delta);
|
||||
continue;
|
||||
} else {
|
||||
return(retval);
|
||||
}
|
||||
|
||||
} /* End of nj loop */
|
||||
|
||||
/* No convergence after maxnj tries; return with retval=IC_SLOW_CONVRG */
|
||||
return(retval);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* IDANewtonIC
|
||||
* -----------------------------------------------------------------
|
||||
* IDANewtonIC performs the Newton iteration to solve for consistent
|
||||
* initial conditions. It calls IDALineSrch within each iteration.
|
||||
* On return, savres contains the current residual vector.
|
||||
*
|
||||
* The return value is IDA_SUCCESS = 0 if no error occurred.
|
||||
* The error return values (positive) considered recoverable are:
|
||||
* IC_FAIL_RECOV if res or lsolve failed recoverably
|
||||
* IC_CONSTR_FAILED if the constraints could not be met
|
||||
* IC_LINESRCH_FAILED if the linesearch failed (either on steptol test
|
||||
* or on maxbacks test)
|
||||
* IC_CONV_FAIL if the Newton iterations failed to converge
|
||||
* IC_SLOW_CONVRG if the iterations appear to be converging slowly.
|
||||
* They failed the convergence test, but showed
|
||||
* an overall norm reduction (by a factor of < 0.1)
|
||||
* or a convergence rate <= ICRATEMAX).
|
||||
* The error return values (negative) considered non-recoverable are:
|
||||
* IDA_RES_FAIL if res had a non-recoverable error
|
||||
* IDA_LSOLVE_FAIL if lsolve had a non-recoverable error
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static int IDANewtonIC(IDAMem IDA_mem)
|
||||
{
|
||||
int retval, mnewt;
|
||||
realtype delnorm, fnorm, fnorm0, oldfnrm, rate;
|
||||
|
||||
/* Set pointer for vector delnew */
|
||||
IDA_mem->ida_delnew = IDA_mem->ida_phi[2];
|
||||
|
||||
/* Call the linear solve function to get the Newton step, delta. */
|
||||
retval = IDA_mem->ida_lsolve(IDA_mem, IDA_mem->ida_delta,
|
||||
IDA_mem->ida_ewt, IDA_mem->ida_yy0,
|
||||
IDA_mem->ida_yp0, IDA_mem->ida_savres);
|
||||
if(retval < 0) return(IDA_LSOLVE_FAIL);
|
||||
if(retval > 0) return(IC_FAIL_RECOV);
|
||||
|
||||
/* Compute the norm of the step; return now if this is small. */
|
||||
fnorm = IDAWrmsNorm(IDA_mem, IDA_mem->ida_delta, IDA_mem->ida_ewt, SUNFALSE);
|
||||
if(IDA_mem->ida_sysindex == 0)
|
||||
fnorm *= IDA_mem->ida_tscale * SUNRabs(IDA_mem->ida_cj);
|
||||
if(fnorm <= IDA_mem->ida_epsNewt)
|
||||
return(IDA_SUCCESS);
|
||||
fnorm0 = fnorm;
|
||||
|
||||
/* Initialize rate to avoid compiler warning message */
|
||||
rate = ZERO;
|
||||
|
||||
/* Newton iteration loop */
|
||||
|
||||
for(mnewt = 0; mnewt < IDA_mem->ida_maxnit; mnewt++) {
|
||||
|
||||
IDA_mem->ida_nni++;
|
||||
delnorm = fnorm;
|
||||
oldfnrm = fnorm;
|
||||
|
||||
/* Call the Linesearch function and return if it failed. */
|
||||
retval = IDALineSrch(IDA_mem, &delnorm, &fnorm);
|
||||
if(retval != IDA_SUCCESS) return(retval);
|
||||
|
||||
/* Set the observed convergence rate and test for convergence. */
|
||||
rate = fnorm/oldfnrm;
|
||||
if(fnorm <= IDA_mem->ida_epsNewt) return(IDA_SUCCESS);
|
||||
|
||||
/* If not converged, copy new step vector, and loop. */
|
||||
N_VScale(ONE, IDA_mem->ida_delnew, IDA_mem->ida_delta);
|
||||
|
||||
} /* End of Newton iteration loop */
|
||||
|
||||
/* Return either IC_SLOW_CONVRG or recoverable fail flag. */
|
||||
if(rate <= ICRATEMAX || fnorm < PT1*fnorm0) return(IC_SLOW_CONVRG);
|
||||
return(IC_CONV_FAIL);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* IDALineSrch
|
||||
* -----------------------------------------------------------------
|
||||
* IDALineSrch performs the Linesearch algorithm with the
|
||||
* calculation of consistent initial conditions.
|
||||
*
|
||||
* On entry, yy0 and yp0 are the current values of y and y', the
|
||||
* Newton step is delta, the current residual vector F is savres,
|
||||
* delnorm is WRMS-norm(delta), and fnorm is the norm of the vector
|
||||
* J-inverse F.
|
||||
*
|
||||
* On a successful return, yy0, yp0, and savres have been updated,
|
||||
* delnew contains the current value of J-inverse F, and fnorm is
|
||||
* WRMS-norm(delnew).
|
||||
*
|
||||
* The return value is IDA_SUCCESS = 0 if no error occurred.
|
||||
* The error return values (positive) considered recoverable are:
|
||||
* IC_FAIL_RECOV if res or lsolve failed recoverably
|
||||
* IC_CONSTR_FAILED if the constraints could not be met
|
||||
* IC_LINESRCH_FAILED if the linesearch failed (either on steptol test
|
||||
* or on maxbacks test)
|
||||
* The error return values (negative) considered non-recoverable are:
|
||||
* IDA_RES_FAIL if res had a non-recoverable error
|
||||
* IDA_LSOLVE_FAIL if lsolve had a non-recoverable error
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static int IDALineSrch(IDAMem IDA_mem, realtype *delnorm, realtype *fnorm)
|
||||
{
|
||||
booleantype conOK;
|
||||
int retval, nbacks;
|
||||
realtype f1norm, fnormp, f1normp, ratio, lambda, minlam, slpi;
|
||||
N_Vector mc;
|
||||
|
||||
/* Initialize work space pointers, f1norm, ratio.
|
||||
(Use of mc in constraint check does not conflict with ypnew.) */
|
||||
mc = IDA_mem->ida_ee;
|
||||
IDA_mem->ida_dtemp = IDA_mem->ida_phi[3];
|
||||
IDA_mem->ida_ynew = IDA_mem->ida_tempv2;
|
||||
IDA_mem->ida_ypnew = IDA_mem->ida_ee;
|
||||
f1norm = (*fnorm)*(*fnorm)*HALF;
|
||||
ratio = ONE;
|
||||
|
||||
/* If there are constraints, check and reduce step if necessary. */
|
||||
if(IDA_mem->ida_constraintsSet) {
|
||||
|
||||
/* Update y and check constraints. */
|
||||
IDANewy(IDA_mem);
|
||||
conOK = N_VConstrMask(IDA_mem->ida_constraints, IDA_mem->ida_ynew, mc);
|
||||
|
||||
if(!conOK) {
|
||||
/* Not satisfied. Compute scaled step to satisfy constraints. */
|
||||
N_VProd(mc, IDA_mem->ida_delta, IDA_mem->ida_dtemp);
|
||||
ratio = PT99*N_VMinQuotient(IDA_mem->ida_yy0, IDA_mem->ida_dtemp);
|
||||
(*delnorm) *= ratio;
|
||||
if((*delnorm) <= IDA_mem->ida_steptol) return(IC_CONSTR_FAILED);
|
||||
N_VScale(ratio, IDA_mem->ida_delta, IDA_mem->ida_delta);
|
||||
}
|
||||
|
||||
} /* End of constraints check */
|
||||
|
||||
slpi = -TWO*f1norm*ratio;
|
||||
minlam = IDA_mem->ida_steptol / (*delnorm);
|
||||
lambda = ONE;
|
||||
nbacks = 0;
|
||||
|
||||
/* In IDA_Y_INIT case, set ypnew = yp0 (fixed) for linesearch. */
|
||||
if(IDA_mem->ida_icopt == IDA_Y_INIT)
|
||||
N_VScale(ONE, IDA_mem->ida_yp0, IDA_mem->ida_ypnew);
|
||||
|
||||
/* Loop on linesearch variable lambda. */
|
||||
|
||||
for(;;) {
|
||||
|
||||
if (nbacks == IDA_mem->ida_maxbacks) return(IC_LINESRCH_FAILED);
|
||||
/* Get new (y,y') = (ynew,ypnew) and norm of new function value. */
|
||||
IDANewyyp(IDA_mem, lambda);
|
||||
retval = IDAfnorm(IDA_mem, &fnormp);
|
||||
if(retval != IDA_SUCCESS) return(retval);
|
||||
|
||||
/* If lsoff option is on, break out. */
|
||||
if(IDA_mem->ida_lsoff) break;
|
||||
|
||||
/* Do alpha-condition test. */
|
||||
f1normp = fnormp*fnormp*HALF;
|
||||
if(f1normp <= f1norm + ALPHALS*slpi*lambda) break;
|
||||
if(lambda < minlam) return(IC_LINESRCH_FAILED);
|
||||
lambda /= TWO;
|
||||
IDA_mem->ida_nbacktr++; nbacks++;
|
||||
|
||||
} /* End of breakout linesearch loop */
|
||||
|
||||
/* Update yy0, yp0, and fnorm, then return. */
|
||||
N_VScale(ONE, IDA_mem->ida_ynew, IDA_mem->ida_yy0);
|
||||
if(IDA_mem->ida_icopt == IDA_YA_YDP_INIT)
|
||||
N_VScale(ONE, IDA_mem->ida_ypnew, IDA_mem->ida_yp0);
|
||||
*fnorm = fnormp;
|
||||
return(IDA_SUCCESS);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* IDAfnorm
|
||||
* -----------------------------------------------------------------
|
||||
* IDAfnorm computes the norm of the current function value, by
|
||||
* evaluating the DAE residual function, calling the linear
|
||||
* system solver, and computing a WRMS-norm.
|
||||
*
|
||||
* On return, savres contains the current residual vector F, and
|
||||
* delnew contains J-inverse F.
|
||||
*
|
||||
* The return value is IDA_SUCCESS = 0 if no error occurred, or
|
||||
* IC_FAIL_RECOV if res or lsolve failed recoverably, or
|
||||
* IDA_RES_FAIL if res had a non-recoverable error, or
|
||||
* IDA_LSOLVE_FAIL if lsolve had a non-recoverable error.
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static int IDAfnorm(IDAMem IDA_mem, realtype *fnorm)
|
||||
{
|
||||
|
||||
int retval;
|
||||
|
||||
/* Get residual vector F, return if failed, and save F in savres. */
|
||||
retval = IDA_mem->ida_res(IDA_mem->ida_t0, IDA_mem->ida_ynew,
|
||||
IDA_mem->ida_ypnew, IDA_mem->ida_delnew,
|
||||
IDA_mem->ida_user_data);
|
||||
IDA_mem->ida_nre++;
|
||||
if(retval < 0) return(IDA_RES_FAIL);
|
||||
if(retval > 0) return(IC_FAIL_RECOV);
|
||||
|
||||
N_VScale(ONE, IDA_mem->ida_delnew, IDA_mem->ida_savres);
|
||||
|
||||
/* Call the linear solve function to get J-inverse F; return if failed. */
|
||||
retval = IDA_mem->ida_lsolve(IDA_mem, IDA_mem->ida_delnew,
|
||||
IDA_mem->ida_ewt, IDA_mem->ida_ynew,
|
||||
IDA_mem->ida_ypnew, IDA_mem->ida_savres);
|
||||
if(retval < 0) return(IDA_LSOLVE_FAIL);
|
||||
if(retval > 0) return(IC_FAIL_RECOV);
|
||||
|
||||
/* Compute the WRMS-norm; rescale if index = 0. */
|
||||
*fnorm = IDAWrmsNorm(IDA_mem, IDA_mem->ida_delnew, IDA_mem->ida_ewt, SUNFALSE);
|
||||
if(IDA_mem->ida_sysindex == 0)
|
||||
(*fnorm) *= IDA_mem->ida_tscale * SUNRabs(IDA_mem->ida_cj);
|
||||
|
||||
return(IDA_SUCCESS);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* IDANewyyp
|
||||
* -----------------------------------------------------------------
|
||||
* IDANewyyp updates the vectors ynew and ypnew from yy0 and yp0,
|
||||
* using the current step vector lambda*delta, in a manner
|
||||
* depending on icopt and the input id vector.
|
||||
*
|
||||
* The return value is always IDA_SUCCESS = 0.
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static int IDANewyyp(IDAMem IDA_mem, realtype lambda)
|
||||
{
|
||||
|
||||
/* IDA_YA_YDP_INIT case: ynew = yy0 - lambda*delta where id_i = 0
|
||||
ypnew = yp0 - cj*lambda*delta where id_i = 1. */
|
||||
if(IDA_mem->ida_icopt == IDA_YA_YDP_INIT) {
|
||||
N_VProd(IDA_mem->ida_id, IDA_mem->ida_delta, IDA_mem->ida_dtemp);
|
||||
N_VLinearSum(ONE, IDA_mem->ida_yp0, -IDA_mem->ida_cj*lambda,
|
||||
IDA_mem->ida_dtemp, IDA_mem->ida_ypnew);
|
||||
N_VLinearSum(ONE, IDA_mem->ida_delta, -ONE,
|
||||
IDA_mem->ida_dtemp, IDA_mem->ida_dtemp);
|
||||
N_VLinearSum(ONE, IDA_mem->ida_yy0, -lambda,
|
||||
IDA_mem->ida_dtemp, IDA_mem->ida_ynew);
|
||||
return(IDA_SUCCESS);
|
||||
}
|
||||
|
||||
/* IDA_Y_INIT case: ynew = yy0 - lambda*delta. (ypnew = yp0 preset.) */
|
||||
N_VLinearSum(ONE, IDA_mem->ida_yy0, -lambda,
|
||||
IDA_mem->ida_delta, IDA_mem->ida_ynew);
|
||||
return(IDA_SUCCESS);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* IDANewy
|
||||
* -----------------------------------------------------------------
|
||||
* IDANewy updates the vector ynew from yy0,
|
||||
* using the current step vector delta, in a manner
|
||||
* depending on icopt and the input id vector.
|
||||
*
|
||||
* The return value is always IDA_SUCCESS = 0.
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static int IDANewy(IDAMem IDA_mem)
|
||||
{
|
||||
|
||||
/* IDA_YA_YDP_INIT case: ynew = yy0 - delta where id_i = 0. */
|
||||
if(IDA_mem->ida_icopt == IDA_YA_YDP_INIT) {
|
||||
N_VProd(IDA_mem->ida_id, IDA_mem->ida_delta, IDA_mem->ida_dtemp);
|
||||
N_VLinearSum(ONE, IDA_mem->ida_delta, -ONE,
|
||||
IDA_mem->ida_dtemp, IDA_mem->ida_dtemp);
|
||||
N_VLinearSum(ONE, IDA_mem->ida_yy0, -ONE,
|
||||
IDA_mem->ida_dtemp, IDA_mem->ida_ynew);
|
||||
return(IDA_SUCCESS);
|
||||
}
|
||||
|
||||
/* IDA_Y_INIT case: ynew = yy0 - delta. */
|
||||
N_VLinearSum(ONE, IDA_mem->ida_yy0, -ONE,
|
||||
IDA_mem->ida_delta, IDA_mem->ida_ynew);
|
||||
return(IDA_SUCCESS);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* IDAICFailFlag
|
||||
* -----------------------------------------------------------------
|
||||
* IDAICFailFlag prints a message and sets the IDACalcIC return
|
||||
* value appropriate to the flag retval returned by IDAnlsIC.
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static int IDAICFailFlag(IDAMem IDA_mem, int retval)
|
||||
{
|
||||
|
||||
/* Depending on retval, print error message and return error flag. */
|
||||
switch(retval) {
|
||||
|
||||
case IDA_RES_FAIL:
|
||||
IDAProcessError(IDA_mem, IDA_RES_FAIL, "IDA", "IDACalcIC", MSG_IC_RES_NONREC);
|
||||
return(IDA_RES_FAIL);
|
||||
|
||||
case IDA_FIRST_RES_FAIL:
|
||||
IDAProcessError(IDA_mem, IDA_FIRST_RES_FAIL, "IDA", "IDACalcIC", MSG_IC_RES_FAIL);
|
||||
return(IDA_FIRST_RES_FAIL);
|
||||
|
||||
case IDA_LSETUP_FAIL:
|
||||
IDAProcessError(IDA_mem, IDA_LSETUP_FAIL, "IDA", "IDACalcIC", MSG_IC_SETUP_FAIL);
|
||||
return(IDA_LSETUP_FAIL);
|
||||
|
||||
case IDA_LSOLVE_FAIL:
|
||||
IDAProcessError(IDA_mem, IDA_LSOLVE_FAIL, "IDA", "IDACalcIC", MSG_IC_SOLVE_FAIL);
|
||||
return(IDA_LSOLVE_FAIL);
|
||||
|
||||
case IC_FAIL_RECOV:
|
||||
IDAProcessError(IDA_mem, IDA_NO_RECOVERY, "IDA", "IDACalcIC", MSG_IC_NO_RECOVERY);
|
||||
return(IDA_NO_RECOVERY);
|
||||
|
||||
case IC_CONSTR_FAILED:
|
||||
IDAProcessError(IDA_mem, IDA_CONSTR_FAIL, "IDA", "IDACalcIC", MSG_IC_FAIL_CONSTR);
|
||||
return(IDA_CONSTR_FAIL);
|
||||
|
||||
case IC_LINESRCH_FAILED:
|
||||
IDAProcessError(IDA_mem, IDA_LINESEARCH_FAIL, "IDA", "IDACalcIC", MSG_IC_FAILED_LINS);
|
||||
return(IDA_LINESEARCH_FAIL);
|
||||
|
||||
case IC_CONV_FAIL:
|
||||
IDAProcessError(IDA_mem, IDA_CONV_FAIL, "IDA", "IDACalcIC", MSG_IC_CONV_FAILED);
|
||||
return(IDA_CONV_FAIL);
|
||||
|
||||
case IC_SLOW_CONVRG:
|
||||
IDAProcessError(IDA_mem, IDA_CONV_FAIL, "IDA", "IDACalcIC", MSG_IC_CONV_FAILED);
|
||||
return(IDA_CONV_FAIL);
|
||||
|
||||
case IDA_BAD_EWT:
|
||||
IDAProcessError(IDA_mem, IDA_BAD_EWT, "IDA", "IDACalcIC", MSG_IC_BAD_EWT);
|
||||
return(IDA_BAD_EWT);
|
||||
|
||||
}
|
||||
return -99;
|
||||
}
|
||||
|
||||
527
bazaar/plugin/sundials/src/ida/ida_impl.h
Normal file
527
bazaar/plugin/sundials/src/ida/ida_impl.h
Normal file
|
|
@ -0,0 +1,527 @@
|
|||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* $Revision$
|
||||
* $Date$
|
||||
* -----------------------------------------------------------------
|
||||
* Programmer(s): Allan G. Taylor, Alan C. Hindmarsh, Radu Serban,
|
||||
* and Aaron Collier @ LLNL
|
||||
* -----------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
* -----------------------------------------------------------------
|
||||
* This is the header file (private version) for the main IDA solver.
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef _IDA_IMPL_H
|
||||
#define _IDA_IMPL_H
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#include <ida/ida.h>
|
||||
|
||||
#ifdef __cplusplus /* wrapper to enable C++ usage */
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* =================================================================
|
||||
* M A I N I N T E G R A T O R M E M O R Y B L O C K
|
||||
* =================================================================
|
||||
*/
|
||||
|
||||
|
||||
/* Basic IDA constants */
|
||||
|
||||
#define HMAX_INV_DEFAULT RCONST(0.0) /* hmax_inv default value */
|
||||
#define MAXORD_DEFAULT 5 /* maxord default value */
|
||||
#define MXORDP1 6 /* max. number of N_Vectors in phi */
|
||||
#define MXSTEP_DEFAULT 500 /* mxstep default value */
|
||||
|
||||
/* Return values for lower level routines used by IDASolve and functions
|
||||
provided to the nonlinear solver */
|
||||
|
||||
#define IDA_RES_RECVR +1
|
||||
#define IDA_LSETUP_RECVR +2
|
||||
#define IDA_LSOLVE_RECVR +3
|
||||
#define IDA_CONSTR_RECVR +5
|
||||
#define IDA_NLS_SETUP_RECVR +6
|
||||
|
||||
/*
|
||||
* ----------------------------------------------------------------
|
||||
* Types : struct IDAMemRec, IDAMem
|
||||
* ----------------------------------------------------------------
|
||||
* The type IDAMem is type pointer to struct IDAMemRec. This
|
||||
* structure contains fields to keep track of problem state.
|
||||
* ----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
typedef struct IDAMemRec {
|
||||
|
||||
realtype ida_uround; /* machine unit roundoff */
|
||||
|
||||
/* Problem Specification Data */
|
||||
|
||||
IDAResFn ida_res; /* F(t,y(t),y'(t))=0; the function F */
|
||||
void *ida_user_data; /* user pointer passed to res */
|
||||
|
||||
int ida_itol; /* itol = IDA_SS, IDA_SV, IDA_WF, IDA_NN */
|
||||
realtype ida_rtol; /* relative tolerance */
|
||||
realtype ida_Satol; /* scalar absolute tolerance */
|
||||
N_Vector ida_Vatol; /* vector absolute tolerance */
|
||||
booleantype ida_atolmin0; /* flag indicating that min(atol) = 0 */
|
||||
booleantype ida_user_efun; /* SUNTRUE if user provides efun */
|
||||
IDAEwtFn ida_efun; /* function to set ewt */
|
||||
void *ida_edata; /* user pointer passed to efun */
|
||||
|
||||
|
||||
booleantype ida_constraintsSet; /* constraints vector present:
|
||||
do constraints calc */
|
||||
booleantype ida_suppressalg; /* SUNTRUE means suppress algebraic vars
|
||||
in local error tests */
|
||||
|
||||
/* Divided differences array and associated minor arrays */
|
||||
|
||||
N_Vector ida_phi[MXORDP1]; /* phi = (maxord+1) arrays of divided differences */
|
||||
|
||||
realtype ida_psi[MXORDP1]; /* differences in t (sums of recent step sizes) */
|
||||
realtype ida_alpha[MXORDP1]; /* ratios of current stepsize to psi values */
|
||||
realtype ida_beta[MXORDP1]; /* ratios of current to previous product of psi's */
|
||||
realtype ida_sigma[MXORDP1]; /* product successive alpha values and factorial */
|
||||
realtype ida_gamma[MXORDP1]; /* sum of reciprocals of psi values */
|
||||
|
||||
/* N_Vectors */
|
||||
|
||||
N_Vector ida_ewt; /* error weight vector */
|
||||
N_Vector ida_yy; /* work space for y vector (= user's yret) */
|
||||
N_Vector ida_yp; /* work space for y' vector (= user's ypret) */
|
||||
N_Vector ida_yypredict; /* predicted y vector */
|
||||
N_Vector ida_yppredict; /* predicted y' vector */
|
||||
N_Vector ida_delta; /* residual vector */
|
||||
N_Vector ida_id; /* bit vector for diff./algebraic components */
|
||||
N_Vector ida_constraints; /* vector of inequality constraint options */
|
||||
N_Vector ida_savres; /* saved residual vector */
|
||||
N_Vector ida_ee; /* accumulated corrections to y vector, but
|
||||
set equal to estimated local errors upon
|
||||
successful return */
|
||||
N_Vector ida_tempv1; /* work space vector */
|
||||
N_Vector ida_tempv2; /* work space vector */
|
||||
N_Vector ida_tempv3; /* work space vector */
|
||||
N_Vector ida_ynew; /* work vector for y in IDACalcIC (= tempv2) */
|
||||
N_Vector ida_ypnew; /* work vector for yp in IDACalcIC (= ee) */
|
||||
N_Vector ida_delnew; /* work vector for delta in IDACalcIC (= phi[2]) */
|
||||
N_Vector ida_dtemp; /* work vector in IDACalcIC (= phi[3]) */
|
||||
|
||||
/* Variables for use by IDACalcIC*/
|
||||
|
||||
realtype ida_t0; /* initial t */
|
||||
N_Vector ida_yy0; /* initial y vector (user-supplied). */
|
||||
N_Vector ida_yp0; /* initial y' vector (user-supplied). */
|
||||
|
||||
int ida_icopt; /* IC calculation user option */
|
||||
booleantype ida_lsoff; /* IC calculation linesearch turnoff option */
|
||||
int ida_maxnh; /* max. number of h tries in IC calculation */
|
||||
int ida_maxnj; /* max. number of J tries in IC calculation */
|
||||
int ida_maxnit; /* max. number of Netwon iterations in IC calc. */
|
||||
int ida_nbacktr; /* number of IC linesearch backtrack operations */
|
||||
int ida_sysindex; /* computed system index (0 or 1) */
|
||||
int ida_maxbacks; /* max backtracks per Newton step */
|
||||
realtype ida_epiccon; /* IC nonlinear convergence test constant */
|
||||
realtype ida_steptol; /* minimum Newton step size in IC calculation */
|
||||
realtype ida_tscale; /* time scale factor = abs(tout1 - t0) */
|
||||
|
||||
/* Tstop information */
|
||||
|
||||
booleantype ida_tstopset;
|
||||
realtype ida_tstop;
|
||||
|
||||
/* Step Data */
|
||||
|
||||
int ida_kk; /* current BDF method order */
|
||||
int ida_kused; /* method order used on last successful step */
|
||||
int ida_knew; /* order for next step from order decrease decision */
|
||||
int ida_phase; /* flag to trigger step doubling in first few steps */
|
||||
int ida_ns; /* counts steps at fixed stepsize and order */
|
||||
|
||||
realtype ida_hin; /* initial step */
|
||||
realtype ida_h0u; /* actual initial stepsize */
|
||||
realtype ida_hh; /* current step size h */
|
||||
realtype ida_hused; /* step size used on last successful step */
|
||||
realtype ida_rr; /* rr = hnext / hused */
|
||||
realtype ida_tn; /* current internal value of t */
|
||||
realtype ida_tretlast; /* value of tret previously returned by IDASolve */
|
||||
realtype ida_cj; /* current value of scalar (-alphas/hh) in Jacobian */
|
||||
realtype ida_cjlast; /* cj value saved from last successful step */
|
||||
realtype ida_cjold; /* cj value saved from last call to lsetup */
|
||||
realtype ida_cjratio; /* ratio of cj values: cj/cjold */
|
||||
realtype ida_ss; /* scalar used in Newton iteration convergence test */
|
||||
realtype ida_oldnrm; /* norm of previous nonlinear solver update */
|
||||
realtype ida_epsNewt; /* test constant in Newton convergence test */
|
||||
realtype ida_epcon; /* coeficient of the Newton covergence test */
|
||||
realtype ida_toldel; /* tolerance in direct test on Newton corrections */
|
||||
|
||||
/* Limits */
|
||||
|
||||
int ida_maxncf; /* max numer of convergence failures */
|
||||
int ida_maxnef; /* max number of error test failures */
|
||||
|
||||
int ida_maxord; /* max value of method order k: */
|
||||
int ida_maxord_alloc; /* value of maxord used when allocating memory */
|
||||
long int ida_mxstep; /* max number of internal steps for one user call */
|
||||
realtype ida_hmax_inv; /* inverse of max. step size hmax (default = 0.0) */
|
||||
|
||||
/* Counters */
|
||||
|
||||
long int ida_nst; /* number of internal steps taken */
|
||||
long int ida_nre; /* number of function (res) calls */
|
||||
long int ida_ncfn; /* number of corrector convergence failures */
|
||||
long int ida_netf; /* number of error test failures */
|
||||
long int ida_nni; /* number of Newton iterations performed */
|
||||
long int ida_nsetups; /* number of lsetup calls */
|
||||
|
||||
/* Space requirements for IDA */
|
||||
|
||||
sunindextype ida_lrw1; /* no. of realtype words in 1 N_Vector */
|
||||
sunindextype ida_liw1; /* no. of integer words in 1 N_Vector */
|
||||
long int ida_lrw; /* number of realtype words in IDA work vectors */
|
||||
long int ida_liw; /* no. of integer words in IDA work vectors */
|
||||
|
||||
realtype ida_tolsf; /* tolerance scale factor (saved value) */
|
||||
|
||||
/* Error handler function and error ouput file */
|
||||
|
||||
IDAErrHandlerFn ida_ehfun; /* Error messages are handled by ehfun */
|
||||
void *ida_eh_data; /* dats pointer passed to ehfun */
|
||||
FILE *ida_errfp; /* IDA error messages are sent to errfp */
|
||||
|
||||
/* Flags to verify correct calling sequence */
|
||||
|
||||
booleantype ida_SetupDone; /* set to SUNFALSE by IDAMalloc and IDAReInit
|
||||
set to SUNTRUE by IDACalcIC or IDASolve */
|
||||
|
||||
booleantype ida_VatolMallocDone;
|
||||
booleantype ida_constraintsMallocDone;
|
||||
booleantype ida_idMallocDone;
|
||||
|
||||
booleantype ida_MallocDone; /* set to SUNFALSE by IDACreate
|
||||
set to SUNTRUE by IDAMAlloc
|
||||
tested by IDAReInit and IDASolve */
|
||||
|
||||
/* Nonlinear Solver */
|
||||
|
||||
SUNNonlinearSolver NLS; /* Sundials generic nonlinear solver object */
|
||||
booleantype ownNLS; /* flag indicating if IDA created the nonlinear
|
||||
solver object */
|
||||
|
||||
/* Linear Solver Data */
|
||||
|
||||
/* Linear Solver functions to be called */
|
||||
|
||||
int (*ida_linit)(struct IDAMemRec *idamem);
|
||||
|
||||
int (*ida_lsetup)(struct IDAMemRec *idamem, N_Vector yyp,
|
||||
N_Vector ypp, N_Vector resp,
|
||||
N_Vector tempv1, N_Vector tempv2, N_Vector tempv3);
|
||||
|
||||
int (*ida_lsolve)(struct IDAMemRec *idamem, N_Vector b, N_Vector weight,
|
||||
N_Vector ycur, N_Vector ypcur, N_Vector rescur);
|
||||
|
||||
int (*ida_lperf)(struct IDAMemRec *idamem, int perftask);
|
||||
|
||||
int (*ida_lfree)(struct IDAMemRec *idamem);
|
||||
|
||||
/* Linear Solver specific memory */
|
||||
|
||||
void *ida_lmem;
|
||||
|
||||
/* Flag to indicate successful ida_linit call */
|
||||
|
||||
booleantype ida_linitOK;
|
||||
|
||||
/* Rootfinding Data */
|
||||
|
||||
IDARootFn ida_gfun; /* Function g for roots sought */
|
||||
int ida_nrtfn; /* number of components of g */
|
||||
int *ida_iroots; /* array for root information */
|
||||
int *ida_rootdir; /* array specifying direction of zero-crossing */
|
||||
realtype ida_tlo; /* nearest endpoint of interval in root search */
|
||||
realtype ida_thi; /* farthest endpoint of interval in root search */
|
||||
realtype ida_trout; /* t return value from rootfinder routine */
|
||||
realtype *ida_glo; /* saved array of g values at t = tlo */
|
||||
realtype *ida_ghi; /* saved array of g values at t = thi */
|
||||
realtype *ida_grout; /* array of g values at t = trout */
|
||||
realtype ida_toutc; /* copy of tout (if NORMAL mode) */
|
||||
realtype ida_ttol; /* tolerance on root location */
|
||||
int ida_taskc; /* copy of parameter itask */
|
||||
int ida_irfnd; /* flag showing whether last step had a root */
|
||||
long int ida_nge; /* counter for g evaluations */
|
||||
booleantype *ida_gactive; /* array with active/inactive event functions */
|
||||
int ida_mxgnull; /* number of warning messages about possible g==0 */
|
||||
|
||||
/* Arrays for Fused Vector Operations */
|
||||
|
||||
realtype ida_cvals[MXORDP1];
|
||||
realtype ida_dvals[MAXORD_DEFAULT];
|
||||
|
||||
N_Vector ida_Xvecs[MXORDP1];
|
||||
N_Vector ida_Zvecs[MXORDP1];
|
||||
|
||||
} *IDAMem;
|
||||
|
||||
/*
|
||||
* =================================================================
|
||||
* I N T E R F A C E T O L I N E A R S O L V E R S
|
||||
* =================================================================
|
||||
*/
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* int (*ida_linit)(IDAMem IDA_mem);
|
||||
* -----------------------------------------------------------------
|
||||
* The purpose of ida_linit is to allocate memory for the
|
||||
* solver-specific fields in the structure *(idamem->ida_lmem) and
|
||||
* perform any needed initializations of solver-specific memory,
|
||||
* such as counters/statistics. An (*ida_linit) should return
|
||||
* 0 if it has successfully initialized the IDA linear solver and
|
||||
* a non-zero value otherwise. If an error does occur, an appropriate
|
||||
* message should be sent to the error handler function.
|
||||
* ----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* int (*ida_lsetup)(IDAMem IDA_mem, N_Vector yyp, N_Vector ypp,
|
||||
* N_Vector resp, N_Vector tempv1,
|
||||
* N_Vector tempv2, N_Vector tempv3);
|
||||
* -----------------------------------------------------------------
|
||||
* The job of ida_lsetup is to prepare the linear solver for
|
||||
* subsequent calls to ida_lsolve. Its parameters are as follows:
|
||||
*
|
||||
* idamem - problem memory pointer of type IDAMem. See the big
|
||||
* typedef earlier in this file.
|
||||
*
|
||||
* yyp - the predicted y vector for the current IDA internal
|
||||
* step.
|
||||
*
|
||||
* ypp - the predicted y' vector for the current IDA internal
|
||||
* step.
|
||||
*
|
||||
* resp - F(tn, yyp, ypp).
|
||||
*
|
||||
* tempv1, tempv2, tempv3 - temporary N_Vectors provided for use
|
||||
* by ida_lsetup.
|
||||
*
|
||||
* The ida_lsetup routine should return 0 if successful,
|
||||
* a positive value for a recoverable error, and a negative value
|
||||
* for an unrecoverable error.
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* int (*ida_lsolve)(IDAMem IDA_mem, N_Vector b, N_Vector weight,
|
||||
* N_Vector ycur, N_Vector ypcur, N_Vector rescur);
|
||||
* -----------------------------------------------------------------
|
||||
* ida_lsolve must solve the linear equation P x = b, where
|
||||
* P is some approximation to the system Jacobian
|
||||
* J = (dF/dy) + cj (dF/dy')
|
||||
* evaluated at (tn,ycur,ypcur) and the RHS vector b is input.
|
||||
* The N-vector ycur contains the solver's current approximation
|
||||
* to y(tn), ypcur contains that for y'(tn), and the vector rescur
|
||||
* contains the N-vector residual F(tn,ycur,ypcur).
|
||||
* The solution is to be returned in the vector b.
|
||||
*
|
||||
* The ida_lsolve routine should return 0 if successful,
|
||||
* a positive value for a recoverable error, and a negative value
|
||||
* for an unrecoverable error.
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* int (*ida_lperf)(IDAMem IDA_mem, int perftask);
|
||||
* -----------------------------------------------------------------
|
||||
* ida_lperf is called two places in IDA where linear solver
|
||||
* performance data is required by IDA. For perftask = 0, an
|
||||
* initialization of performance variables is performed, while for
|
||||
* perftask = 1, the performance is evaluated.
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* int (*ida_lfree)(IDAMem IDA_mem);
|
||||
* -----------------------------------------------------------------
|
||||
* ida_lfree should free up any memory allocated by the linear
|
||||
* solver. This routine is called once a problem has been
|
||||
* completed and the linear solver is no longer needed. It should
|
||||
* return 0 upon success, nonzero on failure.
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
* =================================================================
|
||||
* I D A I N T E R N A L F U N C T I O N S
|
||||
* =================================================================
|
||||
*/
|
||||
|
||||
/* Prototype of internal ewtSet function */
|
||||
|
||||
int IDAEwtSet(N_Vector ycur, N_Vector weight, void *data);
|
||||
|
||||
/* High level error handler */
|
||||
|
||||
void IDAProcessError(IDAMem IDA_mem,
|
||||
int error_code, const char *module, const char *fname,
|
||||
const char *msgfmt, ...);
|
||||
|
||||
/* Prototype of internal errHandler function */
|
||||
|
||||
void IDAErrHandler(int error_code, const char *module, const char *function,
|
||||
char *msg, void *data);
|
||||
|
||||
/* Norm functions */
|
||||
|
||||
realtype IDAWrmsNorm(IDAMem IDA_mem, N_Vector x, N_Vector w, booleantype mask);
|
||||
|
||||
/* Nonlinear solver initialization function */
|
||||
|
||||
int idaNlsInit(IDAMem IDA_mem);
|
||||
|
||||
/*
|
||||
* =================================================================
|
||||
* I D A E R R O R M E S S A G E S
|
||||
* =================================================================
|
||||
*/
|
||||
|
||||
#if defined(SUNDIALS_EXTENDED_PRECISION)
|
||||
|
||||
#define MSG_TIME "t = %Lg, "
|
||||
#define MSG_TIME_H "t = %Lg and h = %Lg, "
|
||||
#define MSG_TIME_INT "t = %Lg is not between tcur - hu = %Lg and tcur = %Lg."
|
||||
#define MSG_TIME_TOUT "tout = %Lg"
|
||||
#define MSG_TIME_TSTOP "tstop = %Lg"
|
||||
|
||||
#elif defined(SUNDIALS_DOUBLE_PRECISION)
|
||||
|
||||
#define MSG_TIME "t = %lg, "
|
||||
#define MSG_TIME_H "t = %lg and h = %lg, "
|
||||
#define MSG_TIME_INT "t = %lg is not between tcur - hu = %lg and tcur = %lg."
|
||||
#define MSG_TIME_TOUT "tout = %lg"
|
||||
#define MSG_TIME_TSTOP "tstop = %lg"
|
||||
|
||||
#else
|
||||
|
||||
#define MSG_TIME "t = %g, "
|
||||
#define MSG_TIME_H "t = %g and h = %g, "
|
||||
#define MSG_TIME_INT "t = %g is not between tcur - hu = %g and tcur = %g."
|
||||
#define MSG_TIME_TOUT "tout = %g"
|
||||
#define MSG_TIME_TSTOP "tstop = %g"
|
||||
|
||||
#endif
|
||||
|
||||
/* General errors */
|
||||
|
||||
#define MSG_MEM_FAIL "A memory request failed."
|
||||
#define MSG_NO_MEM "ida_mem = NULL illegal."
|
||||
#define MSG_NO_MALLOC "Attempt to call before IDAMalloc."
|
||||
#define MSG_BAD_NVECTOR "A required vector operation is not implemented."
|
||||
|
||||
/* Initialization errors */
|
||||
|
||||
#define MSG_Y0_NULL "y0 = NULL illegal."
|
||||
#define MSG_YP0_NULL "yp0 = NULL illegal."
|
||||
#define MSG_BAD_ITOL "Illegal value for itol. The legal values are IDA_SS, IDA_SV, and IDA_WF."
|
||||
#define MSG_RES_NULL "res = NULL illegal."
|
||||
#define MSG_BAD_RTOL "reltol < 0 illegal."
|
||||
#define MSG_ATOL_NULL "abstol = NULL illegal."
|
||||
#define MSG_BAD_ATOL "Some abstol component < 0.0 illegal."
|
||||
#define MSG_ROOT_FUNC_NULL "g = NULL illegal."
|
||||
|
||||
#define MSG_MISSING_ID "id = NULL but suppressalg option on."
|
||||
#define MSG_NO_TOLS "No integration tolerances have been specified."
|
||||
#define MSG_FAIL_EWT "The user-provide EwtSet function failed."
|
||||
#define MSG_BAD_EWT "Some initial ewt component = 0.0 illegal."
|
||||
#define MSG_Y0_FAIL_CONSTR "y0 fails to satisfy constraints."
|
||||
#define MSG_LSOLVE_NULL "The linear solver's solve routine is NULL."
|
||||
#define MSG_LINIT_FAIL "The linear solver's init routine failed."
|
||||
#define MSG_NLS_INIT_FAIL "The nonlinear solver's init routine failed."
|
||||
|
||||
/* IDACalcIC error messages */
|
||||
|
||||
#define MSG_IC_BAD_ICOPT "icopt has an illegal value."
|
||||
#define MSG_IC_BAD_MAXBACKS "maxbacks <= 0 illegal."
|
||||
#define MSG_IC_MISSING_ID "id = NULL conflicts with icopt."
|
||||
#define MSG_IC_TOO_CLOSE "tout1 too close to t0 to attempt initial condition calculation."
|
||||
#define MSG_IC_BAD_ID "id has illegal values."
|
||||
#define MSG_IC_BAD_EWT "Some initial ewt component = 0.0 illegal."
|
||||
#define MSG_IC_RES_NONREC "The residual function failed unrecoverably. "
|
||||
#define MSG_IC_RES_FAIL "The residual function failed at the first call. "
|
||||
#define MSG_IC_SETUP_FAIL "The linear solver setup failed unrecoverably."
|
||||
#define MSG_IC_SOLVE_FAIL "The linear solver solve failed unrecoverably."
|
||||
#define MSG_IC_NO_RECOVERY "The residual routine or the linear setup or solve routine had a recoverable error, but IDACalcIC was unable to recover."
|
||||
#define MSG_IC_FAIL_CONSTR "Unable to satisfy the inequality constraints."
|
||||
#define MSG_IC_FAILED_LINS "The linesearch algorithm failed: step too small or too many backtracks."
|
||||
#define MSG_IC_CONV_FAILED "Newton/Linesearch algorithm failed to converge."
|
||||
|
||||
/* IDASolve error messages */
|
||||
|
||||
#define MSG_YRET_NULL "yret = NULL illegal."
|
||||
#define MSG_YPRET_NULL "ypret = NULL illegal."
|
||||
#define MSG_TRET_NULL "tret = NULL illegal."
|
||||
#define MSG_BAD_ITASK "itask has an illegal value."
|
||||
#define MSG_TOO_CLOSE "tout too close to t0 to start integration."
|
||||
#define MSG_BAD_HINIT "Initial step is not towards tout."
|
||||
#define MSG_BAD_TSTOP "The value " MSG_TIME_TSTOP " is behind current " MSG_TIME "in the direction of integration."
|
||||
#define MSG_CLOSE_ROOTS "Root found at and very near " MSG_TIME "."
|
||||
#define MSG_MAX_STEPS "At " MSG_TIME ", mxstep steps taken before reaching tout."
|
||||
#define MSG_EWT_NOW_FAIL "At " MSG_TIME "the user-provide EwtSet function failed."
|
||||
#define MSG_EWT_NOW_BAD "At " MSG_TIME "some ewt component has become <= 0.0."
|
||||
#define MSG_TOO_MUCH_ACC "At " MSG_TIME "too much accuracy requested."
|
||||
|
||||
#define MSG_BAD_K "Illegal value for k."
|
||||
#define MSG_NULL_DKY "dky = NULL illegal."
|
||||
#define MSG_BAD_T "Illegal value for t." MSG_TIME_INT
|
||||
#define MSG_BAD_TOUT "Trouble interpolating at " MSG_TIME_TOUT ". tout too far back in direction of integration."
|
||||
|
||||
#define MSG_ERR_FAILS "At " MSG_TIME_H "the error test failed repeatedly or with |h| = hmin."
|
||||
#define MSG_CONV_FAILS "At " MSG_TIME_H "the corrector convergence failed repeatedly or with |h| = hmin."
|
||||
#define MSG_SETUP_FAILED "At " MSG_TIME "the linear solver setup failed unrecoverably."
|
||||
#define MSG_SOLVE_FAILED "At " MSG_TIME "the linear solver solve failed unrecoverably."
|
||||
#define MSG_REP_RES_ERR "At " MSG_TIME "repeated recoverable residual errors."
|
||||
#define MSG_RES_NONRECOV "At " MSG_TIME "the residual function failed unrecoverably."
|
||||
#define MSG_FAILED_CONSTR "At " MSG_TIME "unable to satisfy inequality constraints."
|
||||
#define MSG_RTFUNC_FAILED "At " MSG_TIME ", the rootfinding routine failed in an unrecoverable manner."
|
||||
#define MSG_NO_ROOT "Rootfinding was not initialized."
|
||||
#define MSG_INACTIVE_ROOTS "At the end of the first step, there are still some root functions identically 0. This warning will not be issued again."
|
||||
#define MSG_NLS_INPUT_NULL "At " MSG_TIME ", the nonlinear solver was passed a NULL input."
|
||||
#define MSG_NLS_SETUP_FAILED "At " MSG_TIME ", the nonlinear solver setup failed unrecoverably."
|
||||
#define MSG_NLS_FAIL "At " MSG_TIME ", the nonlinear solver failed in an unrecoverable manner."
|
||||
|
||||
/* IDASet* / IDAGet* error messages */
|
||||
|
||||
#define MSG_NEG_MAXORD "maxord <= 0 illegal."
|
||||
#define MSG_BAD_MAXORD "Illegal attempt to increase maximum order."
|
||||
#define MSG_NEG_HMAX "hmax < 0 illegal."
|
||||
#define MSG_NEG_EPCON "epcon <= 0.0 illegal."
|
||||
#define MSG_BAD_CONSTR "Illegal values in constraints vector."
|
||||
#define MSG_BAD_EPICCON "epiccon <= 0.0 illegal."
|
||||
#define MSG_BAD_MAXNH "maxnh <= 0 illegal."
|
||||
#define MSG_BAD_MAXNJ "maxnj <= 0 illegal."
|
||||
#define MSG_BAD_MAXNIT "maxnit <= 0 illegal."
|
||||
#define MSG_BAD_STEPTOL "steptol <= 0.0 illegal."
|
||||
|
||||
#define MSG_TOO_LATE "IDAGetConsistentIC can only be called before IDASolve."
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
1241
bazaar/plugin/sundials/src/ida/ida_io.c
Normal file
1241
bazaar/plugin/sundials/src/ida/ida_io.c
Normal file
File diff suppressed because it is too large
Load diff
1587
bazaar/plugin/sundials/src/ida/ida_ls.c
Normal file
1587
bazaar/plugin/sundials/src/ida/ida_ls.c
Normal file
File diff suppressed because it is too large
Load diff
195
bazaar/plugin/sundials/src/ida/ida_ls_impl.h
Normal file
195
bazaar/plugin/sundials/src/ida/ida_ls_impl.h
Normal file
|
|
@ -0,0 +1,195 @@
|
|||
/*-----------------------------------------------------------------
|
||||
* Programmer(s): Daniel R. Reynolds @ SMU
|
||||
* Alan C. Hindmarsh and Radu Serban @ LLNL
|
||||
*-----------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
*-----------------------------------------------------------------
|
||||
* Implementation header file for IDA's linear solver interface.
|
||||
*-----------------------------------------------------------------*/
|
||||
|
||||
#ifndef _IDALS_IMPL_H
|
||||
#define _IDALS_IMPL_H
|
||||
|
||||
#include <ida/ida_ls.h>
|
||||
#include "ida_impl.h"
|
||||
|
||||
#ifdef __cplusplus /* wrapper to enable C++ usage */
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*-----------------------------------------------------------------
|
||||
Types : struct IDALsMemRec, struct *IDALsMem
|
||||
|
||||
The type IDALsMem is a pointer to a IDALsMemRec, which is a
|
||||
structure containing fields that must be accessible by LS module
|
||||
routines.
|
||||
-----------------------------------------------------------------*/
|
||||
typedef struct IDALsMemRec {
|
||||
|
||||
/* Linear solver type information */
|
||||
booleantype iterative; /* is the solver iterative? */
|
||||
booleantype matrixbased; /* is a matrix structure used? */
|
||||
|
||||
/* Jacobian construction & storage */
|
||||
booleantype jacDQ; /* SUNTRUE if using internal DQ Jacobian approx. */
|
||||
IDALsJacFn jac; /* Jacobian routine to be called */
|
||||
void *J_data; /* J_data is passed to jac */
|
||||
|
||||
/* Linear solver, matrix and vector objects/pointers */
|
||||
SUNLinearSolver LS; /* generic linear solver object */
|
||||
SUNMatrix J; /* J = dF/dy + cj*dF/dy' */
|
||||
N_Vector ytemp; /* temp vector used by IDAAtimesDQ */
|
||||
N_Vector yptemp; /* temp vector used by IDAAtimesDQ */
|
||||
N_Vector x; /* temp vector used by the solve function */
|
||||
N_Vector ycur; /* current y vector in Newton iteration */
|
||||
N_Vector ypcur; /* current yp vector in Newton iteration */
|
||||
N_Vector rcur; /* rcur = F(tn, ycur, ypcur) */
|
||||
|
||||
/* Matrix-based solver, scale solution to account for change in cj */
|
||||
booleantype scalesol;
|
||||
|
||||
/* Iterative solver tolerance */
|
||||
realtype sqrtN; /* sqrt(N) */
|
||||
realtype eplifac; /* eplifac = linear convergence factor */
|
||||
|
||||
/* Statistics and associated parameters */
|
||||
realtype dqincfac; /* dqincfac = optional increment factor in Jv */
|
||||
long int nje; /* nje = no. of calls to jac */
|
||||
long int npe; /* npe = total number of precond calls */
|
||||
long int nli; /* nli = total number of linear iterations */
|
||||
long int nps; /* nps = total number of psolve calls */
|
||||
long int ncfl; /* ncfl = total number of convergence failures */
|
||||
long int nreDQ; /* nreDQ = total number of calls to res */
|
||||
long int njtsetup; /* njtsetup = total number of calls to jtsetup */
|
||||
long int njtimes; /* njtimes = total number of calls to jtimes */
|
||||
long int nst0; /* nst0 = saved nst (for performance monitor) */
|
||||
long int nni0; /* nni0 = saved nni (for performance monitor) */
|
||||
long int ncfn0; /* ncfn0 = saved ncfn (for performance monitor) */
|
||||
long int ncfl0; /* ncfl0 = saved ncfl (for performance monitor) */
|
||||
long int nwarn; /* nwarn = no. of warnings (for perf. monitor) */
|
||||
|
||||
int last_flag; /* last error return flag */
|
||||
|
||||
/* Preconditioner computation
|
||||
(a) user-provided:
|
||||
- pdata == user_data
|
||||
- pfree == NULL (the user dealocates memory)
|
||||
(b) internal preconditioner module
|
||||
- pdata == ida_mem
|
||||
- pfree == set by the prec. module and called in idaLsFree */
|
||||
IDALsPrecSetupFn pset;
|
||||
IDALsPrecSolveFn psolve;
|
||||
int (*pfree)(IDAMem IDA_mem);
|
||||
void *pdata;
|
||||
|
||||
/* Jacobian times vector compuation
|
||||
(a) jtimes function provided by the user:
|
||||
- jt_data == user_data
|
||||
- jtimesDQ == SUNFALSE
|
||||
(b) internal jtimes
|
||||
- jt_data == ida_mem
|
||||
- jtimesDQ == SUNTRUE */
|
||||
booleantype jtimesDQ;
|
||||
IDALsJacTimesSetupFn jtsetup;
|
||||
IDALsJacTimesVecFn jtimes;
|
||||
void *jt_data;
|
||||
|
||||
} *IDALsMem;
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------
|
||||
Prototypes of internal functions
|
||||
-----------------------------------------------------------------*/
|
||||
|
||||
/* Interface routines called by system SUNLinearSolver */
|
||||
int idaLsATimes(void *ida_mem, N_Vector v, N_Vector z);
|
||||
int idaLsPSetup(void *ida_mem);
|
||||
int idaLsPSolve(void *ida_mem, N_Vector r, N_Vector z,
|
||||
realtype tol, int lr);
|
||||
|
||||
/* Difference quotient approximation for Jac times vector */
|
||||
int idaLsDQJtimes(realtype tt, N_Vector yy, N_Vector yp,
|
||||
N_Vector rr, N_Vector v, N_Vector Jv,
|
||||
realtype c_j, void *data,
|
||||
N_Vector work1, N_Vector work2);
|
||||
|
||||
/* Difference-quotient Jacobian approximation routines */
|
||||
int idaLsDQJac(realtype tt, realtype c_j, N_Vector yy, N_Vector yp,
|
||||
N_Vector rr, SUNMatrix Jac, void *data,
|
||||
N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
|
||||
int idaLsDenseDQJac(realtype tt, realtype c_j, N_Vector yy,
|
||||
N_Vector yp, N_Vector rr, SUNMatrix Jac,
|
||||
IDAMem IDA_mem, N_Vector tmp1);
|
||||
int idaLsBandDQJac(realtype tt, realtype c_j, N_Vector yy,
|
||||
N_Vector yp, N_Vector rr, SUNMatrix Jac,
|
||||
IDAMem IDA_mem, N_Vector tmp1,
|
||||
N_Vector tmp2, N_Vector tmp3);
|
||||
|
||||
/* Generic linit/lsetup/lsolve/lperf/lfree interface routines for IDA to call */
|
||||
int idaLsInitialize(IDAMem IDA_mem);
|
||||
int idaLsSetup(IDAMem IDA_mem, N_Vector y, N_Vector yp, N_Vector r,
|
||||
N_Vector vt1, N_Vector vt2, N_Vector vt3);
|
||||
int idaLsSolve(IDAMem IDA_mem, N_Vector b, N_Vector weight,
|
||||
N_Vector ycur, N_Vector ypcur, N_Vector rescur);
|
||||
int idaLsPerf(IDAMem IDA_mem, int perftask);
|
||||
int idaLsFree(IDAMem IDA_mem);
|
||||
|
||||
|
||||
/* Auxilliary functions */
|
||||
int idaLsInitializeCounters(IDALsMem idals_mem);
|
||||
int idaLs_AccessLMem(void* ida_mem, const char* fname,
|
||||
IDAMem* IDA_mem, IDALsMem* idals_mem);
|
||||
|
||||
|
||||
/*---------------------------------------------------------------
|
||||
Error and Warning Messages
|
||||
---------------------------------------------------------------*/
|
||||
|
||||
#if defined(SUNDIALS_EXTENDED_PRECISION)
|
||||
#define MSG_LS_TIME "at t = %Lg, "
|
||||
#define MSG_LS_FRMT "%Le."
|
||||
#elif defined(SUNDIALS_DOUBLE_PRECISION)
|
||||
#define MSG_LS_TIME "at t = %lg, "
|
||||
#define MSG_LS_FRMT "%le."
|
||||
#else
|
||||
#define MSG_LS_TIME "at t = %g, "
|
||||
#define MSG_LS_FRMT "%e."
|
||||
#endif
|
||||
|
||||
/* Error Messages */
|
||||
#define MSG_LS_IDAMEM_NULL "Integrator memory is NULL."
|
||||
#define MSG_LS_MEM_FAIL "A memory request failed."
|
||||
#define MSG_LS_BAD_NVECTOR "A required vector operation is not implemented."
|
||||
#define MSG_LS_BAD_SIZES "Illegal bandwidth parameter(s). Must have 0 <= ml, mu <= N-1."
|
||||
#define MSG_LS_BAD_LSTYPE "Incompatible linear solver type."
|
||||
#define MSG_LS_LMEM_NULL "Linear solver memory is NULL."
|
||||
#define MSG_LS_BAD_GSTYPE "gstype has an illegal value."
|
||||
#define MSG_LS_NEG_MAXRS "maxrs < 0 illegal."
|
||||
#define MSG_LS_NEG_EPLIFAC "eplifac < 0.0 illegal."
|
||||
#define MSG_LS_NEG_DQINCFAC "dqincfac < 0.0 illegal."
|
||||
#define MSG_LS_PSET_FAILED "The preconditioner setup routine failed in an unrecoverable manner."
|
||||
#define MSG_LS_PSOLVE_FAILED "The preconditioner solve routine failed in an unrecoverable manner."
|
||||
#define MSG_LS_JTSETUP_FAILED "The Jacobian x vector setup routine failed in an unrecoverable manner."
|
||||
#define MSG_LS_JTIMES_FAILED "The Jacobian x vector routine failed in an unrecoverable manner."
|
||||
#define MSG_LS_JACFUNC_FAILED "The Jacobian routine failed in an unrecoverable manner."
|
||||
#define MSG_LS_MATZERO_FAILED "The SUNMatZero routine failed in an unrecoverable manner."
|
||||
|
||||
/* Warning Messages */
|
||||
#define MSG_LS_WARN "Warning: " MSG_LS_TIME "poor iterative algorithm performance. "
|
||||
#define MSG_LS_CFN_WARN MSG_LS_WARN "Nonlinear convergence failure rate is " MSG_LS_FRMT
|
||||
#define MSG_LS_CFL_WARN MSG_LS_WARN "Linear convergence failure rate is " MSG_LS_FRMT
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
286
bazaar/plugin/sundials/src/ida/ida_nls.c
Normal file
286
bazaar/plugin/sundials/src/ida/ida_nls.c
Normal file
|
|
@ -0,0 +1,286 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* Programmer(s): David J. Gardner @ LLNL
|
||||
* -----------------------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
* -----------------------------------------------------------------------------
|
||||
* This the implementation file for the IDA nonlinear solver interface.
|
||||
* ---------------------------------------------------------------------------*/
|
||||
|
||||
#include "ida_impl.h"
|
||||
#include "sundials/sundials_math.h"
|
||||
|
||||
/* constant macros */
|
||||
#define PT0001 RCONST(0.0001) /* real 0.0001 */
|
||||
#define ONE RCONST(1.0) /* real 1.0 */
|
||||
#define TWENTY RCONST(20.0) /* real 20.0 */
|
||||
|
||||
/* nonlinear solver parameters */
|
||||
#define MAXIT 4 /* default max number of nonlinear iterations */
|
||||
#define RATEMAX RCONST(0.9) /* max convergence rate used in divergence check */
|
||||
|
||||
/* private functions passed to nonlinear solver */
|
||||
static int idaNlsResidual(N_Vector ycor, N_Vector res, void* ida_mem);
|
||||
static int idaNlsLSetup(booleantype jbad, booleantype* jcur, void* ida_mem);
|
||||
static int idaNlsLSolve(N_Vector delta, void* ida_mem);
|
||||
static int idaNlsConvTest(SUNNonlinearSolver NLS, N_Vector ycor, N_Vector del,
|
||||
realtype tol, N_Vector ewt, void* ida_mem);
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
* ---------------------------------------------------------------------------*/
|
||||
|
||||
int IDASetNonlinearSolver(void *ida_mem, SUNNonlinearSolver NLS)
|
||||
{
|
||||
IDAMem IDA_mem;
|
||||
int retval;
|
||||
|
||||
/* return immediately if IDA memory is NULL */
|
||||
if (ida_mem == NULL) {
|
||||
IDAProcessError(NULL, IDA_MEM_NULL, "IDA",
|
||||
"IDASetNonlinearSolver", MSG_NO_MEM);
|
||||
return(IDA_MEM_NULL);
|
||||
}
|
||||
IDA_mem = (IDAMem) ida_mem;
|
||||
|
||||
/* return immediately if NLS memory is NULL */
|
||||
if (NLS == NULL) {
|
||||
IDAProcessError(NULL, IDA_ILL_INPUT, "IDA",
|
||||
"IDASetNonlinearSolver",
|
||||
"NLS must be non-NULL");
|
||||
return(IDA_ILL_INPUT);
|
||||
}
|
||||
|
||||
/* check for required nonlinear solver functions */
|
||||
if ( NLS->ops->gettype == NULL ||
|
||||
NLS->ops->solve == NULL ||
|
||||
NLS->ops->setsysfn == NULL ) {
|
||||
IDAProcessError(IDA_mem, IDA_ILL_INPUT, "IDA",
|
||||
"IDASetNonlinearSolver",
|
||||
"NLS does not support required operations");
|
||||
return(IDA_ILL_INPUT);
|
||||
}
|
||||
|
||||
/* check for allowed nonlinear solver types */
|
||||
if (SUNNonlinSolGetType(NLS) != SUNNONLINEARSOLVER_ROOTFIND) {
|
||||
IDAProcessError(IDA_mem, IDA_ILL_INPUT, "IDA",
|
||||
"IDASetNonlinearSolver",
|
||||
"NLS type must be SUNNONLINEARSOLVER_ROOTFIND");
|
||||
return(IDA_ILL_INPUT);
|
||||
}
|
||||
|
||||
/* free any existing nonlinear solver */
|
||||
if ((IDA_mem->NLS != NULL) && (IDA_mem->ownNLS))
|
||||
retval = SUNNonlinSolFree(IDA_mem->NLS);
|
||||
|
||||
/* set SUNNonlinearSolver pointer */
|
||||
IDA_mem->NLS = NLS;
|
||||
|
||||
/* Set NLS ownership flag. If this function was called to attach the default
|
||||
NLS, IDA will set the flag to SUNTRUE after this function returns. */
|
||||
IDA_mem->ownNLS = SUNFALSE;
|
||||
|
||||
/* set the nonlinear residual function */
|
||||
retval = SUNNonlinSolSetSysFn(IDA_mem->NLS, idaNlsResidual);
|
||||
if (retval != IDA_SUCCESS) {
|
||||
IDAProcessError(IDA_mem, IDA_ILL_INPUT, "IDA",
|
||||
"IDASetNonlinearSolver",
|
||||
"Setting nonlinear system function failed");
|
||||
return(IDA_ILL_INPUT);
|
||||
}
|
||||
|
||||
/* set convergence test function */
|
||||
retval = SUNNonlinSolSetConvTestFn(IDA_mem->NLS, idaNlsConvTest, ida_mem);
|
||||
if (retval != IDA_SUCCESS) {
|
||||
IDAProcessError(IDA_mem, IDA_ILL_INPUT, "IDA",
|
||||
"IDASetNonlinearSolver",
|
||||
"Setting convergence test function failed");
|
||||
return(IDA_ILL_INPUT);
|
||||
}
|
||||
|
||||
/* set max allowed nonlinear iterations */
|
||||
retval = SUNNonlinSolSetMaxIters(IDA_mem->NLS, MAXIT);
|
||||
if (retval != IDA_SUCCESS) {
|
||||
IDAProcessError(IDA_mem, IDA_ILL_INPUT, "IDA",
|
||||
"IDASetNonlinearSolver",
|
||||
"Setting maximum number of nonlinear iterations failed");
|
||||
return(IDA_ILL_INPUT);
|
||||
}
|
||||
|
||||
return(IDA_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Private functions
|
||||
* ---------------------------------------------------------------------------*/
|
||||
|
||||
int idaNlsInit(IDAMem IDA_mem)
|
||||
{
|
||||
int retval;
|
||||
|
||||
/* set the linear solver setup wrapper function */
|
||||
if (IDA_mem->ida_lsetup)
|
||||
retval = SUNNonlinSolSetLSetupFn(IDA_mem->NLS, idaNlsLSetup);
|
||||
else
|
||||
retval = SUNNonlinSolSetLSetupFn(IDA_mem->NLS, NULL);
|
||||
|
||||
if (retval != IDA_SUCCESS) {
|
||||
IDAProcessError(IDA_mem, IDA_ILL_INPUT, "IDA", "idaNlsInit",
|
||||
"Setting the linear solver setup function failed");
|
||||
return(IDA_NLS_INIT_FAIL);
|
||||
}
|
||||
|
||||
/* set the linear solver solve wrapper function */
|
||||
if (IDA_mem->ida_lsolve)
|
||||
retval = SUNNonlinSolSetLSolveFn(IDA_mem->NLS, idaNlsLSolve);
|
||||
else
|
||||
retval = SUNNonlinSolSetLSolveFn(IDA_mem->NLS, NULL);
|
||||
|
||||
if (retval != IDA_SUCCESS) {
|
||||
IDAProcessError(IDA_mem, IDA_ILL_INPUT, "IDA", "idaNlsInit",
|
||||
"Setting linear solver solve function failed");
|
||||
return(IDA_NLS_INIT_FAIL);
|
||||
}
|
||||
|
||||
/* initialize nonlinear solver */
|
||||
retval = SUNNonlinSolInitialize(IDA_mem->NLS);
|
||||
|
||||
if (retval != IDA_SUCCESS) {
|
||||
IDAProcessError(IDA_mem, IDA_ILL_INPUT, "IDA", "idaNlsInit",
|
||||
MSG_NLS_INIT_FAIL);
|
||||
return(IDA_NLS_INIT_FAIL);
|
||||
}
|
||||
|
||||
return(IDA_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
static int idaNlsLSetup(booleantype jbad, booleantype* jcur, void* ida_mem)
|
||||
{
|
||||
IDAMem IDA_mem;
|
||||
int retval;
|
||||
|
||||
if (ida_mem == NULL) {
|
||||
IDAProcessError(NULL, IDA_MEM_NULL, "IDA", "idaNlsLSetup", MSG_NO_MEM);
|
||||
return(IDA_MEM_NULL);
|
||||
}
|
||||
IDA_mem = (IDAMem) ida_mem;
|
||||
|
||||
IDA_mem->ida_nsetups++;
|
||||
retval = IDA_mem->ida_lsetup(IDA_mem, IDA_mem->ida_yy, IDA_mem->ida_yp,
|
||||
IDA_mem->ida_savres, IDA_mem->ida_tempv1,
|
||||
IDA_mem->ida_tempv2, IDA_mem->ida_tempv3);
|
||||
|
||||
/* update Jacobian status */
|
||||
*jcur = SUNTRUE;
|
||||
|
||||
/* update convergence test constants */
|
||||
IDA_mem->ida_cjold = IDA_mem->ida_cj;
|
||||
IDA_mem->ida_cjratio = ONE;
|
||||
IDA_mem->ida_ss = TWENTY;
|
||||
|
||||
if (retval < 0) return(IDA_LSETUP_FAIL);
|
||||
if (retval > 0) return(IDA_LSETUP_RECVR);
|
||||
|
||||
return(IDA_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
static int idaNlsLSolve(N_Vector delta, void* ida_mem)
|
||||
{
|
||||
IDAMem IDA_mem;
|
||||
int retval;
|
||||
|
||||
if (ida_mem == NULL) {
|
||||
IDAProcessError(NULL, IDA_MEM_NULL, "IDA", "idaNlsLSolve", MSG_NO_MEM);
|
||||
return(IDA_MEM_NULL);
|
||||
}
|
||||
IDA_mem = (IDAMem) ida_mem;
|
||||
|
||||
retval = IDA_mem->ida_lsolve(IDA_mem, delta, IDA_mem->ida_ewt,
|
||||
IDA_mem->ida_yy, IDA_mem->ida_yp,
|
||||
IDA_mem->ida_savres);
|
||||
|
||||
if (retval < 0) return(IDA_LSOLVE_FAIL);
|
||||
if (retval > 0) return(IDA_LSOLVE_RECVR);
|
||||
|
||||
return(IDA_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
static int idaNlsResidual(N_Vector ycor, N_Vector res, void* ida_mem)
|
||||
{
|
||||
IDAMem IDA_mem;
|
||||
int retval;
|
||||
|
||||
if (ida_mem == NULL) {
|
||||
IDAProcessError(NULL, IDA_MEM_NULL, "IDA", "idaNlsResidual", MSG_NO_MEM);
|
||||
return(IDA_MEM_NULL);
|
||||
}
|
||||
IDA_mem = (IDAMem) ida_mem;
|
||||
|
||||
/* update yy and yp based on the current correction */
|
||||
N_VLinearSum(ONE, IDA_mem->ida_yypredict, ONE, ycor, IDA_mem->ida_yy);
|
||||
N_VLinearSum(ONE, IDA_mem->ida_yppredict, IDA_mem->ida_cj, ycor, IDA_mem->ida_yp);
|
||||
|
||||
/* evaluate residual */
|
||||
retval = IDA_mem->ida_res(IDA_mem->ida_tn, IDA_mem->ida_yy, IDA_mem->ida_yp,
|
||||
res, IDA_mem->ida_user_data);
|
||||
|
||||
/* increment the number of residual evaluations */
|
||||
IDA_mem->ida_nre++;
|
||||
|
||||
/* save a copy of the residual vector in savres */
|
||||
N_VScale(ONE, res, IDA_mem->ida_savres);
|
||||
|
||||
if (retval < 0) return(IDA_RES_FAIL);
|
||||
if (retval > 0) return(IDA_RES_RECVR);
|
||||
|
||||
return(IDA_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
static int idaNlsConvTest(SUNNonlinearSolver NLS, N_Vector ycor, N_Vector del,
|
||||
realtype tol, N_Vector ewt, void* ida_mem)
|
||||
{
|
||||
IDAMem IDA_mem;
|
||||
int m, retval;
|
||||
realtype delnrm;
|
||||
realtype rate;
|
||||
|
||||
if (ida_mem == NULL) {
|
||||
IDAProcessError(NULL, IDA_MEM_NULL, "IDA", "idaNlsConvTest", MSG_NO_MEM);
|
||||
return(IDA_MEM_NULL);
|
||||
}
|
||||
IDA_mem = (IDAMem) ida_mem;
|
||||
|
||||
/* compute the norm of the correction */
|
||||
delnrm = N_VWrmsNorm(del, ewt);
|
||||
|
||||
/* get the current nonlinear solver iteration count */
|
||||
retval = SUNNonlinSolGetCurIter(NLS, &m);
|
||||
if (retval != IDA_SUCCESS) return(IDA_MEM_NULL);
|
||||
|
||||
/* test for convergence, first directly, then with rate estimate. */
|
||||
if (m == 0){
|
||||
IDA_mem->ida_oldnrm = delnrm;
|
||||
if (delnrm <= PT0001 * IDA_mem->ida_toldel) return(SUN_NLS_SUCCESS);
|
||||
} else {
|
||||
rate = SUNRpowerR( delnrm/IDA_mem->ida_oldnrm, ONE/m );
|
||||
if (rate > RATEMAX) return(SUN_NLS_CONV_RECVR);
|
||||
IDA_mem->ida_ss = rate/(ONE - rate);
|
||||
}
|
||||
|
||||
if (IDA_mem->ida_ss*delnrm <= tol) return(SUN_NLS_SUCCESS);
|
||||
|
||||
/* not yet converged */
|
||||
return(SUN_NLS_CONTINUE);
|
||||
}
|
||||
81
bazaar/plugin/sundials/src/ida/ida_spils.c
Normal file
81
bazaar/plugin/sundials/src/ida/ida_spils.c
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
/*-----------------------------------------------------------------
|
||||
* Programmer(s): Daniel R. Reynolds @ SMU
|
||||
* Alan Hindmarsh, Radu Serban and Aaron Collier @ LLNL
|
||||
*-----------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
*-----------------------------------------------------------------
|
||||
* Implementation file for the deprecated Scaled and Preconditioned
|
||||
* Iterative Linear Solver interface in IDA; these routines now just
|
||||
* wrap the updated IDA generic linear solver interface in ida_ls.h.
|
||||
*-----------------------------------------------------------------*/
|
||||
|
||||
#include <ida/ida_ls.h>
|
||||
#include <ida/ida_spils.h>
|
||||
|
||||
#ifdef __cplusplus /* wrapper to enable C++ usage */
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*=================================================================
|
||||
Exported Functions (wrappers for equivalent routines in ida_ls.h)
|
||||
=================================================================*/
|
||||
|
||||
int IDASpilsSetLinearSolver(void *ida_mem, SUNLinearSolver LS)
|
||||
{ return(IDASetLinearSolver(ida_mem, LS, NULL)); }
|
||||
|
||||
int IDASpilsSetPreconditioner(void *ida_mem, IDASpilsPrecSetupFn pset,
|
||||
IDASpilsPrecSolveFn psolve)
|
||||
{ return(IDASetPreconditioner(ida_mem, pset, psolve)); }
|
||||
|
||||
int IDASpilsSetJacTimes(void *ida_mem, IDASpilsJacTimesSetupFn jtsetup,
|
||||
IDASpilsJacTimesVecFn jtimes)
|
||||
{ return(IDASetJacTimes(ida_mem, jtsetup, jtimes)); }
|
||||
|
||||
int IDASpilsSetEpsLin(void *ida_mem, realtype eplifac)
|
||||
{ return(IDASetEpsLin(ida_mem, eplifac)); }
|
||||
|
||||
int IDASpilsSetIncrementFactor(void *ida_mem, realtype dqincfac)
|
||||
{ return(IDASetIncrementFactor(ida_mem, dqincfac)); }
|
||||
|
||||
int IDASpilsGetWorkSpace(void *ida_mem, long int *lenrwLS, long int *leniwLS)
|
||||
{ return(IDAGetLinWorkSpace(ida_mem, lenrwLS, leniwLS)); }
|
||||
|
||||
int IDASpilsGetNumPrecEvals(void *ida_mem, long int *npevals)
|
||||
{ return(IDAGetNumPrecEvals(ida_mem, npevals)); }
|
||||
|
||||
int IDASpilsGetNumPrecSolves(void *ida_mem, long int *npsolves)
|
||||
{ return(IDAGetNumPrecSolves(ida_mem, npsolves)); }
|
||||
|
||||
int IDASpilsGetNumLinIters(void *ida_mem, long int *nliters)
|
||||
{ return(IDAGetNumLinIters(ida_mem, nliters)); }
|
||||
|
||||
int IDASpilsGetNumConvFails(void *ida_mem, long int *nlcfails)
|
||||
{ return(IDAGetNumLinConvFails(ida_mem, nlcfails)); }
|
||||
|
||||
int IDASpilsGetNumJTSetupEvals(void *ida_mem, long int *njtsetups)
|
||||
{ return(IDAGetNumJTSetupEvals(ida_mem, njtsetups)); }
|
||||
|
||||
int IDASpilsGetNumJtimesEvals(void *ida_mem, long int *njvevals)
|
||||
{ return(IDAGetNumJtimesEvals(ida_mem, njvevals)); }
|
||||
|
||||
int IDASpilsGetNumResEvals(void *ida_mem, long int *nrevalsLS)
|
||||
{ return(IDAGetNumLinResEvals(ida_mem, nrevalsLS)); }
|
||||
|
||||
int IDASpilsGetLastFlag(void *ida_mem, long int *flag)
|
||||
{ return(IDAGetLastLinFlag(ida_mem, flag)); }
|
||||
|
||||
char *IDASpilsGetReturnFlagName(long int flag)
|
||||
{ return(IDAGetLinReturnFlagName(flag)); }
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
317
bazaar/plugin/sundials/src/kinsol/fcmix/fkinbbd.h
Normal file
317
bazaar/plugin/sundials/src/kinsol/fcmix/fkinbbd.h
Normal file
|
|
@ -0,0 +1,317 @@
|
|||
/* -----------------------------------------------------------------
|
||||
* Programmer(s): Allan Taylor, Alan Hindmarsh, Radu Serban, and
|
||||
* Aaron Collier @ LLNL
|
||||
* -----------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
* -----------------------------------------------------------------
|
||||
* This is the Fortran interface include file for the BBD
|
||||
* preconditioner module KINBBDPRE.
|
||||
* -----------------------------------------------------------------*/
|
||||
|
||||
/*******************************************************************************
|
||||
|
||||
FKINBBD Interface Package
|
||||
|
||||
The FKINBBD Interface Package is a package of C functions which support the
|
||||
use of the KINSOL solver and MPI-parallel N_Vector module, along with the
|
||||
KINBBDPRE preconditioner module, for the solution of nonlinear systems in a
|
||||
mixed Fortran/C setting. The combination of KINSOL and KINBBDPRE solves systems
|
||||
linear system arising from the solution of f(u) = 0 using a Krylov iterative
|
||||
linear solver via the KINSPILS interface, and with a preconditioner that is
|
||||
block-diagonal with banded blocks. While KINSOL and KINBBDPRE are written in C,
|
||||
it is assumed here that the user's calling program and user-supplied
|
||||
problem-defining routines are written in Fortran.
|
||||
|
||||
The user-callable functions in this package, with the corresponding KINSOL and
|
||||
KINBBDPRE functions, are as follows:
|
||||
|
||||
FKINBBDINIT : interfaces to KINBBDPrecInit
|
||||
FKINBBDOPT : accesses optional outputs
|
||||
FKINBBDFREE : interfaces to KINBBDPrecFree
|
||||
|
||||
In addition to the Fortran system function FKFUN, and optional Jacobian vector
|
||||
product routine FKJTIMES, the following are the user-supplied functions
|
||||
required by this package, each with the corresponding interface function which
|
||||
calls it (and its type within KINBBDPRE):
|
||||
|
||||
FKLOCFN : called by the interface function FKINgloc of type KINBBDLocalFn
|
||||
FKCOMMFN : called by the interface function FKINgcomm of type KINBBDCommFn
|
||||
|
||||
Note: The names of all user-supplied routines here are fixed, in order to
|
||||
maximize portability for the resulting mixed-language program.
|
||||
|
||||
Note: The names used within this interface package make use of the preprocessor
|
||||
to expand them appropriately for different machines/platforms. Later in this
|
||||
file, each name is expanded appropriately. For example, FKIN_BBDINIT is
|
||||
replaced with either fkinbbdinit, fkinbbdinit_, or fkinbbdinit__ depending
|
||||
upon the platform.
|
||||
|
||||
==============================================================================
|
||||
|
||||
Usage of the FKINSOL/FKINBBD Interface Packages
|
||||
|
||||
The usage of combined interface packages FKINSOL and FKINBBD requires calls
|
||||
to several interface functions, and a few user-supplied routines which define
|
||||
the problem to be solved and indirectly define the preconditioner. These
|
||||
function calls and user routines are summarized separately below.
|
||||
|
||||
Some details have been omitted, and the user is referred to the KINSOL User
|
||||
Guide for more complete information.
|
||||
|
||||
(1) User-supplied system function routine: FKFUN
|
||||
|
||||
The user must in all cases supply the following Fortran routine:
|
||||
|
||||
SUBROUTINE FKFUN (UU, FVAL, IER)
|
||||
DIMENSION UU(*), FVAL(*)
|
||||
|
||||
It must set the FVAL array to f(u), the system function, as a function
|
||||
of the array UU = u. Here UU and FVAL are vectors (distributed in the
|
||||
parallel case). IER is a return flag (currently not used).
|
||||
|
||||
(2) Optional user-supplied Jacobian-vector product routine: FKJTIMES
|
||||
|
||||
As an option, the user may supply a routine that computes the product
|
||||
of the system Jacobian and a given vector. The user-supplied function
|
||||
must have the following form:
|
||||
|
||||
SUBROUTINE FKJTIMES (V, Z, NEWU, UU, IER)
|
||||
DIMENSION V(*), Z(*), UU(*)
|
||||
|
||||
This must set the array Z to the product J*V, where J is the Jacobian
|
||||
matrix J = dF/du, and V is a given array. Here UU is an array containing
|
||||
the current value of the unknown vector u, and NEWU is an input integer
|
||||
indicating whether UU has changed since FKJTIMES was last called
|
||||
(1 = yes, 0 = no). If FKJTIMES computes and saves Jacobian data, then
|
||||
no such computation is necessary when NEWU = 0. Here V, Z, and UU are
|
||||
arrays of length NLOC - the local length of all distributed vectors.
|
||||
FKJTIMES should return IER = 0 if successful, or a nonzero IER otherwise.
|
||||
|
||||
(3) User-supplied routines to define preconditoner: FKLOCFN and FKCOMMFN
|
||||
|
||||
The routines in the KINBBDPRE (kinbbdpre.c) module provide a preconditioner
|
||||
matrix for KINSOL that is block-diagonal with banded blocks. The blocking
|
||||
corresponds to the distribution of the dependent variable vector u
|
||||
amongst the processes. Each preconditioner block is generated from the
|
||||
Jacobian of the local part (associated with the current process) of a given
|
||||
function g(u) approximating f(u). The blocks are generated by a difference
|
||||
quotient scheme (independently by each process), utilizing the assumed
|
||||
banded structure with given half-bandwidths.
|
||||
|
||||
(3.1) Local approximate function: FKLOCFN
|
||||
|
||||
The user must supply a subroutine of the following form:
|
||||
|
||||
SUBROUTINE FKLOCFN (NLOC, ULOC, GLOC, IER)
|
||||
DIMENSION ULOC(*), GLOC(*)
|
||||
|
||||
The routine is used to compute the function g(u) which approximates the
|
||||
system function f(u). This function is to be computed locally, i.e.
|
||||
without inter-process communication. Note: The case where g is
|
||||
mathematically identical to f is allowed. It takes as input the local
|
||||
vector length (NLOC) and the local real solution array ULOC. It is to
|
||||
compute the local part of g(u) and store the result in the realtype
|
||||
array GLOC. IER is a return flag (currently not used).
|
||||
|
||||
(3.2) Communication function: FKCOMMFN
|
||||
|
||||
The user must also supply a subroutine of the following form:
|
||||
|
||||
SUBROUTINE FKCOMMFN (NLOC, ULOC, IER)
|
||||
DIMENSION ULOC(*)
|
||||
|
||||
The routine is used to perform all inter-process communication necessary
|
||||
to evaluate the approximate system function g described above. This
|
||||
function takes as input the local vector length (NLOC), and the local real
|
||||
dependent variable array ULOC. It is expected to save communicated data in
|
||||
work space defined by the user, and made available to FKLOCFN. Each call
|
||||
to the FKCOMMFN function is preceded by a call to FKFUN with the same
|
||||
arguments. Thus FKCOMMFN can omit any communications done by FKFUN if
|
||||
relevant to the evaluation of g. IER is a return flag (currently not
|
||||
used).
|
||||
|
||||
(4) Initialization: FNVINITP, FKINMALLOC, FKINBBDINIT, and FKINBBDSP*
|
||||
|
||||
(4.1) To initialize the parallel machine environment, the user must make the
|
||||
following call:
|
||||
|
||||
CALL FNVINITP (5, NLOCAL, NGLOBAL, IER)
|
||||
|
||||
The arguments are:
|
||||
NLOCAL = local size of vectors associated with process
|
||||
NGLOBAL = the system size, and the global size of vectors (the sum
|
||||
of all values of NLOCAL)
|
||||
IER = return completion flag. Values are 0 = success, and
|
||||
-1 = failure.
|
||||
|
||||
(4.2) To allocate internal memory for KINSOL, make the following call:
|
||||
|
||||
CALL FKINMALLOC (MSBPRE, FNORMTOL, SCSTEPTOL, CONSTRAINTS,
|
||||
OPTIN, IOPT, ROPT, IER)
|
||||
|
||||
The arguments are:
|
||||
MSBPRE = maximum number of preconditioning solve calls without
|
||||
calling the preconditioning setup routine
|
||||
Note: 0 indicates default (10).
|
||||
FNORMTOL = tolerance on the norm of f(u) to accept convergence
|
||||
SCSTEPTOL = tolerance on minimum scaled step size
|
||||
CONSTRAINTS = array of constraint values on components of the
|
||||
solution vector UU
|
||||
INOPT = integer used as a flag to indicate whether possible
|
||||
input values in IOPT[] array are to be used for
|
||||
input: 0 = no and 1 = yes.
|
||||
IOPT = array for integer optional inputs and outputs (declare
|
||||
as INTEGER*8
|
||||
ROPT = array of real optional inputs and outputs
|
||||
IER = return completion flag. Values are 0 = success, and
|
||||
-1 = failure.
|
||||
|
||||
Note: See printed message for details in case of failure.
|
||||
|
||||
(4.3) Initialize and attach one of the SPILS linear solvers. Make one of the
|
||||
following calls to initialize a solver (see fkinsol.h for more details):
|
||||
|
||||
CALL FSUNPCGINIT(3, PRETYPE, MAXL, IER)
|
||||
CALL FSUNSPBCGSINIT(3, PRETYPE, MAXL, IER)
|
||||
CALL FSUNSPFGMRINIT(3, PRETYPE, MAXL, IER)
|
||||
CALL FSUNSPGMRINIT(3, PRETYPE, MAXL, IER)
|
||||
CALL FSUNSPTFQMRINIT(3, PRETYPE, MAXL, IER)
|
||||
|
||||
Then to attach the iterative linear solver structure the user must call:
|
||||
|
||||
CALL FKINSPILSINIT(IER)
|
||||
|
||||
(4.4) To allocate memory and initialize data associated with the BBD
|
||||
preconditioner, make the following call:
|
||||
|
||||
CALL FKINBBDINIT(NLOCAL, MUDQ, MLDQ, MU, ML, IER)
|
||||
|
||||
The arguments are:
|
||||
NLOCAL = local vector size on this process [long int, input]
|
||||
MUDQ = upper half-bandwidth to be used in the computation
|
||||
of the local Jacobian blocks by difference
|
||||
quotients. These may be smaller than the true
|
||||
half-bandwidths of the Jacobian of the local block
|
||||
of g, when smaller values may provide greater
|
||||
efficiency [long int, input]
|
||||
MLDQ = lower half-bandwidth to be used in the computation
|
||||
of the local Jacobian blocks by difference
|
||||
quotients [long int, input]
|
||||
MU = upper half-bandwidth of the band matrix that is
|
||||
retained as an approximation of the local Jacobian
|
||||
block (may be smaller than MUDQ) [long int, input]
|
||||
ML = lower half-bandwidth of the band matrix that is
|
||||
retained as an approximation of the local Jacobian
|
||||
block (may be smaller than MLDQ) [long int, input]
|
||||
IER = return completion flag [int, output]:
|
||||
0 = success
|
||||
<0 = an error occurred
|
||||
|
||||
(5) To solve the system, make the following call:
|
||||
|
||||
CALL FKINSOL (UU, GLOBALSTRAT, USCALE, FSCALE, IER)
|
||||
|
||||
The arguments are:
|
||||
UU = array containing the initial guess when called and the
|
||||
solution upon termination
|
||||
GLOBALSTRAT = (INTEGER) a number defining the global strategy choice:
|
||||
1 = inexact Newton, 2 = line search.
|
||||
USCALE = array of scaling factors for the UU vector
|
||||
FSCALE = array of scaling factors for the FVAL (function) vector
|
||||
IER = integer error flag as returned by KINSOL.
|
||||
|
||||
Note: See the KINSOL documentation for further information.
|
||||
|
||||
(6) Optional outputs: FKINBBDOPT
|
||||
|
||||
In addition to the optional inputs and outputs available with the FKINSOL
|
||||
interface package, there are optional outputs specific to the KINBBDPRE
|
||||
module. These are accessed by making the following call:
|
||||
|
||||
CALL FKINBBDOPT (LENRPW, LENIPW, NGE)
|
||||
|
||||
The arguments returned are:
|
||||
LENRPW = length of real preconditioner work space, in realtype words
|
||||
Note: This size is local to the current process.
|
||||
LENIPW = length of integer preconditioner work space, in integer words
|
||||
Note: This size is local to the current process.
|
||||
NGE = number of g(u) evaluations (calls to FKLOCFN)
|
||||
|
||||
(7) Memory freeing: FKINFREE
|
||||
|
||||
To the free the internal memory created by the calls to FNVINITP
|
||||
and FKINMALLOC, make the following call:
|
||||
|
||||
CALL FKINFREE
|
||||
|
||||
*******************************************************************************/
|
||||
|
||||
#ifndef _FKINBBD_H
|
||||
#define _FKINBBD_H
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* header files
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
#include <sundials/sundials_nvector.h> /* definition of type N_Vector */
|
||||
#include <sundials/sundials_types.h> /* definition of type realtype */
|
||||
|
||||
#ifdef __cplusplus /* wrapper to enable C++ usage */
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* generic names are translated through the define statements below
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#if defined(SUNDIALS_F77_FUNC)
|
||||
|
||||
#define FKIN_BBDINIT SUNDIALS_F77_FUNC(fkinbbdinit, FKINBBDINIT)
|
||||
#define FKIN_BBDOPT SUNDIALS_F77_FUNC(fkinbbdopt, FKINBBDOPT)
|
||||
#define FK_COMMFN SUNDIALS_F77_FUNC(fkcommfn, FKCOMMFN)
|
||||
#define FK_LOCFN SUNDIALS_F77_FUNC(fklocfn, FKLOCFN)
|
||||
|
||||
#else
|
||||
|
||||
#define FKIN_BBDINIT fkinbbdinit_
|
||||
#define FKIN_BBDOPT fkinbbdopt_
|
||||
#define FK_COMMFN fkcommfn_
|
||||
#define FK_LOCFN fklocfn_
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Prototypes: exported functions
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void FKIN_BBDINIT(long int *nlocal, long int *mudq, long int *mldq,
|
||||
long int *mu, long int *ml, int *ier);
|
||||
void FKIN_BBDOPT(long int *lenrpw, long int *lenipw, long int *nge);
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Prototypes: FKINgloc and FKINgcomm
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
int FKINgloc(long int Nloc, N_Vector uu, N_Vector gval, void *user_data);
|
||||
int FKINgcomm(long int Nloc, N_Vector uu, void *user_data);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
783
bazaar/plugin/sundials/src/kinsol/fcmix/fkinsol.h
Normal file
783
bazaar/plugin/sundials/src/kinsol/fcmix/fkinsol.h
Normal file
|
|
@ -0,0 +1,783 @@
|
|||
/* -----------------------------------------------------------------
|
||||
* Programmer(s): Allan Taylor, Alan Hindmarsh, Radu Serban, and
|
||||
* Aaron Collier @ LLNL
|
||||
* Daniel R. Reynolds @ SMU
|
||||
* David J. Gardner @ LLNL
|
||||
* -----------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
* -----------------------------------------------------------------
|
||||
* This is the header file for the FKINSOL Interface Package.
|
||||
* See below for usage details.
|
||||
* -----------------------------------------------------------------*/
|
||||
|
||||
/***************************************************************************
|
||||
|
||||
FKINSOL Interface Package
|
||||
|
||||
The FKINSOL Interface Package is a package of C functions which support the
|
||||
use of the KINSOL solver for the solution of nonlinear systems f(u) = 0,
|
||||
in a mixed Fortran/C setting. While KINSOL is written in C, it is assumed
|
||||
here that the user's calling program and user-supplied problem-defining
|
||||
routines are written in Fortran. This package provides the necessary
|
||||
interface to KINSOL for the serial and parallel NVECTOR
|
||||
implementations.
|
||||
|
||||
The user-callable functions, with the corresponding KINSOL functions,
|
||||
are as follows:
|
||||
|
||||
FNVINITS, FNVINITP, FNVINITOMP, FNVINITPTS
|
||||
initialize serial, distributed memory parallel, or threaded
|
||||
vector computations
|
||||
FKINMALLOC interfaces to KINInit
|
||||
FKINCREATE interfaces to KINCreate
|
||||
FKININIT interfaces to KINInit
|
||||
FKINSETIIN, FKINSETRIN, FKINSETVIN interface to KINSet* functions
|
||||
FKINSOL interfaces to KINSol and KINGet* functions
|
||||
FKINFREE interfaces to KINFree
|
||||
FKINLSINIT interface to KINSetLinearSolver
|
||||
FKINDENSESETJAC interface to KINSetJacFn
|
||||
FKINBANDSETJAC interface to KINSetJacFn
|
||||
FKINSPARSESETJAC interface to KINSetJacFn
|
||||
FKINLSSETJAC interface to KINSetJacTimes
|
||||
FKINLSSETPREC interface to KINSetPreconditioner
|
||||
|
||||
The user-supplied functions, each with the corresponding interface function
|
||||
which calls it (and its type within KINSOL), are as follows:
|
||||
|
||||
FKFUN : called by the interface function FKINfunc of type KINSysFn
|
||||
FKDJAC : called by the interface function FKINDenseJac of type
|
||||
KINLsJacFn
|
||||
FKBJAC : called by the interface function FKINBandJac of type
|
||||
KINLsJacFn
|
||||
FKINSPJAC: called by the interface function FKINSparseJac of type
|
||||
KINLsJacFn
|
||||
FKJTIMES : called by the interface function FKINJtimes of type
|
||||
KINLsJacTimesVecFn
|
||||
FKPSOL : called by the interface function FKINPSol of type
|
||||
KINLsPrecSolveFn
|
||||
FKPSET : called by the interface function FKINPSet of type
|
||||
KINLsPrecSetupFn
|
||||
|
||||
In contrast to the case of direct use of KINSOL, the names of all
|
||||
user-supplied routines here are fixed, in order to maximize portability for
|
||||
the resulting mixed-language program.
|
||||
|
||||
Important note on portability:
|
||||
In this package, the names of the interface functions, and the names of
|
||||
the Fortran user routines called by them, appear as dummy names
|
||||
which are mapped to actual values by a series of definitions, in this
|
||||
and other header files.
|
||||
|
||||
=========================================================================
|
||||
|
||||
Usage of the FKINSOL Interface Package
|
||||
|
||||
The usage of FKINSOL requires calls to several interface functions, and
|
||||
to a few user-supplied routines which define the problem to be solved.
|
||||
These function calls and user routines are summarized separately below.
|
||||
|
||||
Some details are omitted, and the user is referred to the KINSOL manual
|
||||
for more complete documentation. Information on the arguments of any
|
||||
given user-callable interface routine, or of a given user-supplied
|
||||
function called by an interface function, can be found in the
|
||||
documentation on the corresponding function in the KINSOL package.
|
||||
|
||||
The number labels on the instructions below end with "s" for instructions
|
||||
that apply to the serial version of KINSOL only, and end with "p" for
|
||||
those that apply to the parallel version only.
|
||||
|
||||
(1) User-supplied system routine: FKFUN
|
||||
|
||||
The user must in all cases supply the following Fortran routine:
|
||||
|
||||
SUBROUTINE FKFUN (UU, FVAL, IER)
|
||||
DIMENSION UU(*), FVAL(*)
|
||||
|
||||
It must set the FVAL array to f(u), the system function, as a
|
||||
function of the array UU = u. Here UU and FVAL are arrays representing
|
||||
vectors, which are distributed vectors in the parallel case.
|
||||
IER is a return flag, which should be 0 if FKFUN was successful.
|
||||
Return IER > 0 if a recoverable error occurred (and KINSOL is to try
|
||||
to recover). Return IER < 0 if an unrecoverable error occurred.
|
||||
|
||||
(2s) Optional user-supplied dense Jacobian approximation routine: FKDJAC
|
||||
|
||||
As an option when using the DENSE linear solver, the user may supply a
|
||||
routine that computes a dense approximation of the system Jacobian
|
||||
J = df/dy. If supplied, it must have the following form:
|
||||
|
||||
SUBROUTINE FKDJAC(N, UU, FU, DJAC, WK1, WK2, IER)
|
||||
DIMENSION UU(*), FU(*), DJAC(N,*), WK1(*), WK2(*)
|
||||
|
||||
This routine must compute the Jacobian and store it columnwise in DJAC.
|
||||
FKDJAC should return IER = 0 if successful, or a nonzero IER otherwise.
|
||||
|
||||
(3s) Optional user-supplied band Jacobian approximation routine: FKBJAC
|
||||
|
||||
As an option when using the BAND linear solver, the user may supply a
|
||||
routine that computes a band approximation of the system Jacobian
|
||||
J = df/dy. If supplied, it must have the following form:
|
||||
|
||||
SUBROUTINE FKBJAC(N, MU, ML, MDIM, UU, FU, BJAC, WK1, WK2, IER)
|
||||
DIMENSION UU(*), FU(*), BJAC(MDIM,*), WK1(*), WK2(*)
|
||||
|
||||
This routine must load the MDIM by N array BJAC with the Jacobian matrix.
|
||||
FKBJAC should return IER = 0 if successful, or a nonzero IER otherwise.
|
||||
|
||||
(4) Optional user-supplied Jacobian-vector product routine: FKJTIMES
|
||||
|
||||
As an option, the user may supply a routine that computes the product
|
||||
of the system Jacobian and a given vector. This has the following form:
|
||||
|
||||
SUBROUTINE FKJTIMES(V, Z, NEWU, UU, IER)
|
||||
DIMENSION V(*), Z(*), UU(*)
|
||||
|
||||
This must set the array Z to the product J*V, where J is the Jacobian
|
||||
matrix J = dF/du, and V is a given array. Here UU is an array containing
|
||||
the current value of the unknown vector u. NEWU is an input integer
|
||||
indicating whether UU has changed since FKJTIMES was last called
|
||||
(1 = yes, 0 = no). If FKJTIMES computes and saves Jacobian data, then
|
||||
no such computation is necessary when NEWU = 0. Here V, Z, and UU are
|
||||
arrays of length NEQ, the problem size, or the local length of all
|
||||
distributed vectors in the parallel case. FKJTIMES should return IER = 0
|
||||
if successful, or a nonzero IER otherwise.
|
||||
|
||||
(4.1s) User-supplied sparse Jacobian approximation routine: FKINSPJAC
|
||||
|
||||
Required when using the KINKLU or KINSuperLUMT linear solvers, the
|
||||
user must supply a routine that computes a compressed-sparse-column
|
||||
[or compressed-sparse-row] approximation of the system Jacobian
|
||||
J = dF(y)/dy. If supplied, it must have the following form:
|
||||
|
||||
SUBROUTINE FKINSPJAC(Y, FY, N, NNZ, JDATA, JRVALS,
|
||||
& JCPTRS, WK1, WK2, IER)
|
||||
|
||||
Typically this routine will use only N, NNZ, JDATA, JRVALS and
|
||||
JCPTRS. It must load the N by N compressed sparse column [or compressed
|
||||
sparse row] matrix with storage for NNZ nonzeros, stored in the arrays
|
||||
JDATA (nonzero values), JRVALS (row [or column] indices for each nonzero),
|
||||
JCOLPTRS (indices for start of each column [or row]), with the Jacobian
|
||||
matrix at the current (y) in CSC [or CSR] form (see sunmatrix_sparse.h for
|
||||
more information).
|
||||
|
||||
The arguments are:
|
||||
Y -- array containing state variables [realtype, input]
|
||||
FY -- array containing residual values [realtype, input]
|
||||
N -- number of matrix rows/columns in Jacobian [int, input]
|
||||
NNZ -- allocated length of nonzero storage [int, input]
|
||||
JDATA -- nonzero values in Jacobian
|
||||
[realtype of length NNZ, output]
|
||||
JRVALS -- row [or column] indices for each nonzero in Jacobian
|
||||
[int of length NNZ, output]
|
||||
JCPTRS -- pointers to each Jacobian column [or row] in preceding arrays
|
||||
[int of length N+1, output]
|
||||
WK* -- array containing temporary workspace of same size as Y
|
||||
[realtype, input]
|
||||
IER -- return flag [int, output]:
|
||||
0 if successful,
|
||||
>0 if a recoverable error occurred,
|
||||
<0 if an unrecoverable error ocurred.
|
||||
|
||||
(5) Initialization: FNVINITS/FNVINITP/FNVINITOMP/FNVINITPTS and
|
||||
FKINCREATE and FKININIT
|
||||
|
||||
(5.1s) To initialize the serial machine environment, the user must make
|
||||
the following call:
|
||||
|
||||
CALL FNVINITS (3, NEQ, IER)
|
||||
|
||||
The arguments are:
|
||||
NEQ = size of vectors
|
||||
IER = return completion flag. Values are 0 = success, -1 = failure.
|
||||
|
||||
(5.1p) To initialize the distributed memory parallel machine environment,
|
||||
the user must make the following call:
|
||||
|
||||
CALL FNVINITP (3, NLOCAL, NGLOBAL, IER)
|
||||
|
||||
The arguments are:
|
||||
NLOCAL = local size of vectors for this process
|
||||
NGLOBAL = the system size, and the global size of vectors
|
||||
(the sum of all values of NLOCAL)
|
||||
IER = return completion flag. Values are 0 = success,
|
||||
-1 = failure.
|
||||
|
||||
(5.1omp) To initialize the openMP threaded vector kernel,
|
||||
the user must make the following call:
|
||||
|
||||
CALL FNVINITOMP (3, NEQ, NUM_THREADS, IER)
|
||||
|
||||
The arguments are:
|
||||
NEQ = size of vectors
|
||||
NUM_THREADS = number of threads
|
||||
IER = return completion flag. Values are 0 = success, -1 = failure.
|
||||
|
||||
(5.1pts) To initialize the Pthreads threaded vector kernel,
|
||||
the user must make the following call:
|
||||
|
||||
CALL FNVINITOMP (3, NEQ, NUM_THREADS, IER)
|
||||
|
||||
The arguments are:
|
||||
NEQ = size of vectors
|
||||
NUM_THREADS = number of threads
|
||||
IER = return completion flag. Values are 0 = success, -1 = failure.
|
||||
|
||||
(5.2) To create the internal memory structure, make the following call:
|
||||
|
||||
CALL FKINCREATE(IER)
|
||||
|
||||
The arguments are:
|
||||
IER = return completion flag. Values are 0 = success, and
|
||||
-1 = failure.
|
||||
|
||||
Note: See printed message for details in case of failure.
|
||||
|
||||
(5.3) To set various integer optional inputs, make the folowing call:
|
||||
|
||||
CALL FKINSETIIN(KEY, VALUE, IER)
|
||||
|
||||
to set the optional input specified by the character key KEY to the
|
||||
integer value VALUE.
|
||||
KEY is one of the following: 'PRNT_LEVEL', 'MAX_NITERS', 'ETA_FORM', 'MAA',
|
||||
'MAX_SETUPS', 'MAX_SP_SETUPS', 'NO_INIT_SETUP', 'NO_MIN_EPS', 'NO_RES_MON'.
|
||||
|
||||
To set various real optional inputs, make the folowing call:
|
||||
|
||||
CALL FKINSETRIN(KEY, VALUE, IER)
|
||||
|
||||
to set the optional input specified by the character key KEY to the
|
||||
real value VALUE.
|
||||
KEY is one of the following: 'FNORM_TOL', 'SSTEP_TOL', 'MAX_STEP',
|
||||
'RERR_FUNC', 'ETA_CONST', 'ETA_PARAMS', 'RMON_CONST', 'RMON_PARAMS'.
|
||||
Note that if KEY is 'ETA_PARAMS' or 'RMON_PARAMS', then VALUE must be an
|
||||
array of dimension 2.
|
||||
|
||||
To set the vector of constraints on the solution, make the following call:
|
||||
|
||||
CALL FKINSETVIN(KEY, ARRAY, IER)
|
||||
|
||||
where ARRAY is an array of reals and KEY is 'CONSTR_VEC'.
|
||||
|
||||
FKINSETIIN, FKINSETRIN, and FKINSETVIN return IER=0 if successful and
|
||||
IER<0 if an error occured.
|
||||
|
||||
(5.4) To allocate and initialize the internal memory structure,
|
||||
make the following call:
|
||||
|
||||
CALL FKININIT(IOUT, ROUT, IER)
|
||||
|
||||
The arguments are:
|
||||
IOUT = array of length at least 16 for integer optional outputs
|
||||
(declare as INTEGER*8)
|
||||
ROUT = array of length at least 2 for real optional outputs
|
||||
IER = return completion flag. Values are 0 = success, and
|
||||
-1 = failure.
|
||||
|
||||
Note: See printed message for details in case of failure.
|
||||
|
||||
(6) Specification of linear system solution method:
|
||||
|
||||
The solution method in KINSOL involves the solution of linear systems
|
||||
related to the Jacobian J = dF/du of the nonlinear system.
|
||||
|
||||
(6.1s) DENSE treatment of the linear systems (NVECTOR_SERIAL only):
|
||||
|
||||
To initialize a dense matrix structure for storing the system Jacobian
|
||||
and for use within a direct linear solver, the user must call:
|
||||
|
||||
CALL FSUNDENSEMATINIT(3, M, N, IER)
|
||||
|
||||
The integer 3 is the KINSOL solver ID and the other arguments are:
|
||||
M = the number of rows of the matrix [long int, input]
|
||||
N = the number of columns of the matrix [long int, input]
|
||||
IER = return completion flag [int, output]:
|
||||
0 = success,
|
||||
-1 = failure.
|
||||
|
||||
To initialize a dense linear solver structure the user must call
|
||||
the following to use the SUNDIALS or LAPACK dense solvers:
|
||||
|
||||
CALL FSUNDENSELINSOLINIT(3, IER)
|
||||
|
||||
OR
|
||||
|
||||
CALL FSUNLAPACKDENSEINIT(3, IER)
|
||||
|
||||
In the above routines, 3 is the KINSOL solver ID and IER is the return
|
||||
return completion flag (0 = success and -1 = failure).
|
||||
|
||||
To attach the dense linear solver structure the user must call
|
||||
the following:
|
||||
|
||||
CALL FKINLSINIT(IER)
|
||||
|
||||
The arguments are:
|
||||
IER = return completion flag [int, output]:
|
||||
0 = SUCCESS,
|
||||
-1 = failure (see printed message for failure details).
|
||||
|
||||
If the user program includes the FKDJAC routine for the evaluation
|
||||
of the dense approximation to the system Jacobian, the following call
|
||||
must be made:
|
||||
|
||||
CALL FKINDENSESETJAC(FLAG, IER)
|
||||
|
||||
with FLAG = 1 to specify that FKDJAC is provided. (FLAG = 0 specifies
|
||||
using the internal finite difference approximation to the Jacobian.)
|
||||
|
||||
(6.2s) BAND treatment of the linear systems (NVECTOR_SERIAL only):
|
||||
|
||||
To initialize a banded matrix structure for stroing the system Jacobian
|
||||
and for use within a banded linear solver, the user must call:
|
||||
|
||||
CALL FSUNBANDMATINIT(3, N, MU, ML, SMU, IER)
|
||||
|
||||
The integer 3 is the KINSOL solver ID and the other arguments are:
|
||||
N = the number of columns of the matrix [long int, input]
|
||||
MU = the number of upper bands (diagonal not included) in a banded
|
||||
matrix [long int, input]
|
||||
ML = the number of lower bands (diagonal not included) in a banded
|
||||
matrix [long int, input]
|
||||
SMU = the number of upper bands to store (diagonal not included)
|
||||
for factorization of a banded matrix [long int, input]
|
||||
|
||||
To initialize a banded linear solver structure the user must call
|
||||
the following to use the SUNDIALS or LAPACK banded solvers:
|
||||
|
||||
CALL FSUNBANDLINSOLINIT(3, IER)
|
||||
|
||||
OR
|
||||
|
||||
CALL FSUNLAPACKBANDINIT(3, IER)
|
||||
|
||||
In the above routines, 3 is the KINSOL solver ID and IER is the return
|
||||
return completion flag (0 = success and -1 = failure).
|
||||
|
||||
To attach the banded linear solver structure the user must call
|
||||
the following:
|
||||
|
||||
CALL FKINLSINIT(IER)
|
||||
|
||||
The arguments are:
|
||||
IER = return completion flag [int, output]:
|
||||
0 = SUCCESS,
|
||||
-1 = failure (see printed message for failure details).
|
||||
|
||||
If the user program includes the FKBJAC routine for the evaluation
|
||||
of the band approximation to the system Jacobian, the following call
|
||||
must be made:
|
||||
|
||||
CALL FKINBANDSETJAC(FLAG, IER)
|
||||
|
||||
with FLAG = 1 to specify that FKBJAC is provided. (FLAG = 0 specifies
|
||||
using the internal finite difference approximation to the Jacobian.)
|
||||
|
||||
(6.3s) SPARSE treatment of the linear system using the KLU or SuperLU_MT solver.
|
||||
|
||||
To initialize a sparse matrix structure for stroing the system Jacobian
|
||||
and for use within a sparse linear solver, the user must call:
|
||||
|
||||
CALL FSUNSPARSEMATINIT(3, M, N, NNZ, SPARSETYPE, IER)
|
||||
|
||||
The integer 3 is the KINSOL solver ID and the other arguments are:
|
||||
M = the number of rows of the matrix [long int, input]
|
||||
N = the number of columns of the matrix [long int, input]
|
||||
NNZ = the storage size (upper bound on the number of nonzeros) for
|
||||
a sparse matrix [long int, input]
|
||||
SPARSETYPE = integer denoting use of CSC (0) vs CSR (1) storage
|
||||
for a sparse matrix [int, input]
|
||||
IER = return completion flag [int, output]:
|
||||
0 = success,
|
||||
-1 = failure.
|
||||
|
||||
To initialize a sparse linear solver structure the user must call
|
||||
the following to use the KLU or SuperLU_MT sparse solvers:
|
||||
|
||||
CALL FSUNKLUINIT(3, IER)
|
||||
|
||||
OR
|
||||
|
||||
CALL FSUNSUPERLUMTINIT(3, NUM_THREADS, IER)
|
||||
|
||||
In the above routines, 3 is the KINSOL solver ID, NUM_THREADS is the number
|
||||
of threads, and IER is the return completion flag (0 = success and
|
||||
-1 = failure).
|
||||
|
||||
To attach the sparse linear solver structure the user must call
|
||||
the following:
|
||||
|
||||
CALL FKINLSINIT(IER)
|
||||
|
||||
The arguments are:
|
||||
IER = return completion flag [int, output]:
|
||||
0 = SUCCESS,
|
||||
-1 = failure (see printed message for failure details).
|
||||
|
||||
When using a sparse solver the user must provide the FKINSPJAC routine for the
|
||||
evalution of the sparse approximation to the Jacobian. To indicate that this
|
||||
routine has been provided, after the call to FKINKLU, the following call must
|
||||
be made
|
||||
|
||||
CALL FKINSPARSESETJAC(IER)
|
||||
|
||||
The int return flag IER=0 if successful, and nonzero otherwise.
|
||||
|
||||
The KLU solver will reuse much of the factorization information from one
|
||||
nonlinear iteration to the next. If at any time the user wants to force a full
|
||||
refactorization or if the number of nonzeros in the Jacobian matrix changes, the
|
||||
user should make the call:
|
||||
|
||||
CALL FKINKLUREINIT(NEQ, NNZ, REINIT_TYPE)
|
||||
|
||||
The arguments are:
|
||||
NEQ = the problem size [int; input]
|
||||
NNZ = the maximum number of nonzeros [int; input]
|
||||
REINIT_TYPE = 1 or 2. For a value of 1, the matrix will be destroyed and
|
||||
a new one will be allocated with NNZ nonzeros. For a value of 2,
|
||||
only symbolic and numeric factorizations will be completed.
|
||||
|
||||
At this time, there is no reinitialization capability for the SUNDIALS
|
||||
interface to the SuperLUMT solver.
|
||||
|
||||
Once these the solvers have been initialized, their solver parameters may be
|
||||
modified via calls to the functions:
|
||||
|
||||
CALL FSUNKLUSETORDERING(3, ORD_CHOICE, IER)
|
||||
CALL FSUNSUPERLUMTSETORDERING(3, ORD_CHOICE, IER)
|
||||
|
||||
In the above routines, 3 is the KINSOL solver ID and ORD_CHOICE is an integer
|
||||
denoting ordering choice (see SUNKLUSetOrdering and SUNSuperLUMTSetOrdering
|
||||
documentation for details), and IER is the return completion flag (0 = success
|
||||
and -1 = failure).
|
||||
|
||||
(6.4) Scaled Preconditioned Iterative linear Solvers (SPILS):
|
||||
|
||||
To initialize a SPILS treatment of the linear system, the user must call one
|
||||
of the following:
|
||||
|
||||
CALL FSUNPCGINIT(3, PRETYPE, MAXL, IER)
|
||||
CALL FSUNSPBCGSINIT(3, PRETYPE, MAXL, IER)
|
||||
CALL FSUNSPFGMRINIT(3, PRETYPE, MAXL, IER)
|
||||
CALL FSUNSPGMRINIT(3, PRETYPE, MAXL, IER)
|
||||
CALL FSUNSPTFQMRINIT(3, PRETYPE, MAXL, IER)
|
||||
|
||||
The integer 3 is the KINSOL solver ID and the other arguments are:
|
||||
PRETYPE = type of preconditioning to perform (0=none, 1=left,
|
||||
2=right, 3=both) [int, input]
|
||||
MAXL = maximum Krylov subspace dimension [int, input]
|
||||
IER = return completion flag [int, output]:
|
||||
0 = success,
|
||||
-1 = failure.
|
||||
|
||||
To attach the iterative linear solver structure the user must call
|
||||
the following:
|
||||
|
||||
CALL FKINLSINIT(IER)
|
||||
|
||||
The arguments are:
|
||||
IER = return completion flag [int, output]:
|
||||
0 = SUCCESS,
|
||||
-1 = failure (see printed message for failure details).
|
||||
|
||||
Once these the solvers have been initialized, their solver parameters may be
|
||||
modified via calls to the functions:
|
||||
|
||||
CALL FSUNPCGSETPRECTYPE(3, PRETYPE, IER)
|
||||
CALL FSUNPCGSETMAXL(3, MAXL, IER)
|
||||
|
||||
CALL FSUNSPBCGSSETPRECTYPE(3, PRETYPE, IER)
|
||||
CALL FSUNSPBCGSSETMAXL(3, MAXL, IER)
|
||||
|
||||
CALL FSUNSPFGMRSETGSTYPE(3, GSTYPE, IER)
|
||||
CALL FSUNSPFGMRSETPRECTYPE(3, PRETYPE, IER)
|
||||
|
||||
CALL FSUNSPGMRSETGSTYPE(3, GSTYPE, IER)
|
||||
CALL FSUNSPGMRSETPRECTYPE(3, PRETYPE, IER)
|
||||
|
||||
CALL FSUNSPTFQMRSETPRECTYPE(3, PRETYPE, IER)
|
||||
CALL FSUNSPTFQMRSETMAXL(3, MAXL, IER)
|
||||
|
||||
The integer 3 is the KINSOL solver ID and the other arguments are:
|
||||
PRETYPE = type of preconditioning to perform (0=none, 1=left,
|
||||
2=right, 3=both) [int, input]
|
||||
GSTYPE = choice of Gram-Schmidt orthogonalization algorithm
|
||||
(0=modified, 1=classical) [int, input]
|
||||
IER = return completion flag [int, output]:
|
||||
0 = success,
|
||||
-1 = failure.
|
||||
|
||||
(6.5) Specifying user-provided functions for the iterative linear solvers (SPILS)
|
||||
|
||||
If the user program includes the FKJTIMES routine for the evaluation
|
||||
of the Jacobian-vector product, the following call must be made:
|
||||
|
||||
CALL FKINLSSETJAC(FLAG, IER)
|
||||
|
||||
The argument FLAG = 0 specifies using the internal finite differences
|
||||
approximation to the Jacobian-vector product, while FLAG = 1 specifies
|
||||
that FKJTIMES is provided.
|
||||
|
||||
Usage of the user-supplied routines FKPSET and FKPSOL for the setup and
|
||||
solution of the preconditioned linear system is specified by calling:
|
||||
|
||||
CALL FKINLSSETPREC(FLAG, IER)
|
||||
|
||||
where FLAG = 0 indicates no FKPSET or FKPSOL (default) and FLAG = 1
|
||||
specifies using FKPSET and FKPSOL. The user-supplied routines FKPSET
|
||||
and FKPSOL must be of the form:
|
||||
|
||||
SUBROUTINE FKPSET (UU, USCALE, FVAL, FSCALE, IER)
|
||||
DIMENSION UU(*), USCALE(*), FVAL(*), FSCALE(*)
|
||||
|
||||
It must perform any evaluation of Jacobian-related data and
|
||||
preprocessing needed for the solution of the preconditioned linear
|
||||
systems by FKPSOL. The variables UU through FSCALE are for use in the
|
||||
preconditioning setup process. Typically, the system function FKFUN is
|
||||
called, so that FVAL will have been updated. UU is the current solution
|
||||
iterate. If scaling is being used, USCALE and FSCALE are available for
|
||||
those operatins requiring scaling.
|
||||
|
||||
On return, set IER = 0 if FKPSET was successful, set IER = 1 if
|
||||
an error occurred.
|
||||
|
||||
SUBROUTINE FKPSOL (UU, USCALE, FVAL, FSCALE, VTEM, IER)
|
||||
DIMENSION UU(*), USCALE(*), FVAL(*), FSCALE(*), VTEM(*)
|
||||
|
||||
Typically this routine will use only UU, FVAL, and VTEM.
|
||||
It must solve the preconditioned linear system Pz = r, where
|
||||
r = VTEM is input, and store the solution z in VTEM as well. Here
|
||||
P is the right preconditioner. If scaling is being used, the
|
||||
routine supplied must also account for scaling on either coordinate
|
||||
or function value.
|
||||
|
||||
(7) The solver: FKINSOL
|
||||
|
||||
Solving the nonlinear system is accomplished by making the following
|
||||
call:
|
||||
|
||||
CALL FKINSOL (UU, GLOBALSTRAT, USCALE, FSCALE, IER)
|
||||
|
||||
The arguments are:
|
||||
UU = array containing the initial guess on input, and the
|
||||
solution on return
|
||||
GLOBALSTRAT = (INTEGER) a number defining the global strategy choice:
|
||||
0 = No globalization, 1 = LineSearch, 2 = Picard,
|
||||
3 = Fixed Point
|
||||
USCALE = array of scaling factors for the UU vector
|
||||
FSCALE = array of scaling factors for the FVAL (function) vector
|
||||
IER = INTEGER error flag as returned by KINSOL:
|
||||
0 means success,
|
||||
1 means initial guess satisfies f(u) = 0 (approx.),
|
||||
2 means apparent stalling (small step),
|
||||
a value < 0 means other error or failure.
|
||||
|
||||
Note: See KINSOL documentation for detailed information.
|
||||
|
||||
(8) Memory freeing: FKINFREE
|
||||
|
||||
To the free the internal memory created by the calls to FKINCREATE and
|
||||
FKININIT and any FNVINIT**, make the following call:
|
||||
|
||||
CALL FKINFREE
|
||||
|
||||
(9) Optional outputs: IOUT/ROUT
|
||||
|
||||
The optional outputs available by way of IOUT and ROUT have the
|
||||
following names, locations, and descriptions. For further details see
|
||||
the KINSOL documentation.
|
||||
|
||||
LENRW = IOUT(1) = real workspace size
|
||||
LENRW = IOUT(2) = real workspace size
|
||||
NNI = IOUT(3) = number of Newton iterations
|
||||
NFE = IOUT(4) = number of f evaluations
|
||||
NBCF = IOUT(5) = number of line search beta condition failures
|
||||
NBKTRK = IOUT(6) = number of line search backtracks
|
||||
|
||||
FNORM = ROUT(1) = final scaled norm of f(u)
|
||||
STEPL = ROUT(2) = scaled last step length
|
||||
|
||||
The following optional outputs arise from the KINLS module:
|
||||
|
||||
LRW = IOUT( 7) = real workspace size for the linear solver module
|
||||
LIW = IOUT( 8) = integer workspace size for the linear solver module
|
||||
LSTF = IOUT( 9) = last flag returned by linear solver
|
||||
NFE = IOUT(10) = number of f evaluations for DQ Jacobian or
|
||||
Jacobian*vector approximation
|
||||
NJE = IOUT(11) = number of Jacobian evaluations
|
||||
NJT = IOUT(12) = number of Jacobian-vector product evaluations
|
||||
NPE = IOUT(13) = number of preconditioner evaluations
|
||||
NPS = IOUT(14) = number of preconditioner solves
|
||||
NLI = IOUT(15) = number of linear (Krylov) iterations
|
||||
NCFL = IOUT(16) = number of linear convergence failures
|
||||
|
||||
*******************************************************************************/
|
||||
|
||||
#ifndef _FKINSOL_H
|
||||
#define _FKINSOL_H
|
||||
|
||||
/*------------------------------------------------------------------
|
||||
header files
|
||||
------------------------------------------------------------------*/
|
||||
|
||||
#include <kinsol/kinsol.h>
|
||||
#include <sundials/sundials_linearsolver.h> /* definition of SUNLinearSolver */
|
||||
#include <sundials/sundials_matrix.h> /* definition of SUNMatrix */
|
||||
#include <sundials/sundials_nvector.h> /* definition of type N_Vector */
|
||||
#include <sundials/sundials_types.h> /* definition of type realtype */
|
||||
|
||||
#ifdef __cplusplus /* wrapper to enable C++ usage */
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*------------------------------------------------------------------
|
||||
generic names are translated through the define statements below
|
||||
------------------------------------------------------------------*/
|
||||
|
||||
#if defined(SUNDIALS_F77_FUNC)
|
||||
|
||||
#define FKIN_MALLOC SUNDIALS_F77_FUNC(fkinmalloc, FKINMALLOC)
|
||||
#define FKIN_CREATE SUNDIALS_F77_FUNC(fkincreate, FKINCREATE)
|
||||
#define FKIN_INIT SUNDIALS_F77_FUNC(fkininit, FKININIT)
|
||||
#define FKIN_SETIIN SUNDIALS_F77_FUNC(fkinsetiin, FKINSETIIN)
|
||||
#define FKIN_SETRIN SUNDIALS_F77_FUNC(fkinsetrin, FKINSETRIN)
|
||||
#define FKIN_SETVIN SUNDIALS_F77_FUNC(fkinsetvin, FKINSETVIN)
|
||||
#define FKIN_SOL SUNDIALS_F77_FUNC(fkinsol, FKINSOL)
|
||||
#define FKIN_FREE SUNDIALS_F77_FUNC(fkinfree, FKINFREE)
|
||||
#define FKIN_LSINIT SUNDIALS_F77_FUNC(fkinlsinit, FKINLSINIT)
|
||||
#define FKIN_LSSETJAC SUNDIALS_F77_FUNC(fkinlssetjac, FKINLSSETJAC)
|
||||
#define FKIN_LSSETPREC SUNDIALS_F77_FUNC(fkinlssetprec, FKINLSSETPREC)
|
||||
#define FK_PSET SUNDIALS_F77_FUNC(fkpset, FKPSET)
|
||||
#define FK_PSOL SUNDIALS_F77_FUNC(fkpsol, FKPSOL)
|
||||
#define FKIN_DENSESETJAC SUNDIALS_F77_FUNC(fkindensesetjac, FKINDENSESETJAC)
|
||||
#define FK_DJAC SUNDIALS_F77_FUNC(fkdjac, FKDJAC)
|
||||
#define FKIN_BANDSETJAC SUNDIALS_F77_FUNC(fkinbandsetjac, FKINBANDSETJAC)
|
||||
#define FK_BJAC SUNDIALS_F77_FUNC(fkbjac, FKBJAC)
|
||||
#define FKIN_SPARSESETJAC SUNDIALS_F77_FUNC(fkinsparsesetjac, FKINSPARSESETJAC)
|
||||
#define FKIN_SPJAC SUNDIALS_F77_FUNC(fkinspjac, FKINSPJAC)
|
||||
#define FK_JTIMES SUNDIALS_F77_FUNC(fkjtimes, FKJTIMES)
|
||||
#define FK_FUN SUNDIALS_F77_FUNC(fkfun, FKFUN)
|
||||
|
||||
/*---DEPRECATED---*/
|
||||
#define FKIN_DLSINIT SUNDIALS_F77_FUNC(fkindlsinit, FKINDLSINIT)
|
||||
#define FKIN_SPILSINIT SUNDIALS_F77_FUNC(fkinspilsinit, FKINSPILSINIT)
|
||||
#define FKIN_SPILSSETJAC SUNDIALS_F77_FUNC(fkinspilssetjac, FKINSPILSSETJAC)
|
||||
#define FKIN_SPILSSETPREC SUNDIALS_F77_FUNC(fkinspilssetprec, FKINSPILSSETPREC)
|
||||
/*----------------*/
|
||||
|
||||
#else
|
||||
|
||||
#define FKIN_MALLOC fkinmalloc_
|
||||
#define FKIN_CREATE fkincreate_
|
||||
#define FKIN_INIT fkininit_
|
||||
#define FKIN_SETIIN fkinsetiin_
|
||||
#define FKIN_SETRIN fkinsetrin_
|
||||
#define FKIN_SETVIN fkinsetvin_
|
||||
#define FKIN_SOL fkinsol_
|
||||
#define FKIN_FREE fkinfree_
|
||||
#define FKIN_LSINIT fkinlsinit_
|
||||
#define FKIN_LSSETJAC fkinlssetjac_
|
||||
#define FK_JTIMES fkjtimes_
|
||||
#define FKIN_LSSETPREC fkinlssetprec_
|
||||
#define FKIN_DENSESETJAC fkindensesetjac_
|
||||
#define FK_DJAC fkdjac_
|
||||
#define FKIN_BANDSETJAC fkinbandsetjac_
|
||||
#define FK_BJAC fkbjac_
|
||||
#define FKIN_SPARSESETJAC fkinsparsesetjac_
|
||||
#define FKIN_SPJAC fkinspjac_
|
||||
#define FK_PSET fkpset_
|
||||
#define FK_PSOL fkpsol_
|
||||
#define FK_FUN fkfun_
|
||||
|
||||
/*---DEPRECATED---*/
|
||||
#define FKIN_DLSINIT fkindlsinit_
|
||||
#define FKIN_SPILSINIT fkinspilsinit_
|
||||
#define FKIN_SPILSSETJAC fkinspilssetjac_
|
||||
#define FKIN_SPILSSETPREC fkinspilssetprec_
|
||||
/*----------------*/
|
||||
|
||||
#endif
|
||||
|
||||
/*------------------------------------------------------------------
|
||||
Prototypes : exported functions
|
||||
------------------------------------------------------------------*/
|
||||
|
||||
void FKIN_MALLOC(long int *iout, realtype *rout, int *ier);
|
||||
void FKIN_CREATE(int *ier);
|
||||
void FKIN_INIT(long int *iout, realtype *rout, int *ier);
|
||||
|
||||
void FKIN_SETIIN(char key_name[], long int *ival, int *ier);
|
||||
void FKIN_SETRIN(char key_name[], realtype *rval, int *ier);
|
||||
void FKIN_SETVIN(char key_name[], realtype *vval, int *ier);
|
||||
|
||||
void FKIN_LSINIT(int *ier);
|
||||
void FKIN_LSSETJAC(int *flag, int *ier);
|
||||
void FKIN_LSSETPREC(int *flag, int *ier);
|
||||
void FKIN_DENSESETJAC(int *flag, int *ier);
|
||||
void FKIN_BANDSETJAC(int *flag, int *ier);
|
||||
void FKIN_SPARSESETJAC(int *ier);
|
||||
|
||||
/*---DEPRECATED---*/
|
||||
void FKIN_DLSINIT(int *ier);
|
||||
void FKIN_SPILSINIT(int *ier);
|
||||
void FKIN_SPILSSETJAC(int *flag, int *ier);
|
||||
void FKIN_SPILSSETPREC(int *flag, int *ier);
|
||||
/*----------------*/
|
||||
|
||||
void FKIN_SOL(realtype *uu, int *globalstrategy,
|
||||
realtype *uscale , realtype *fscale, int *ier);
|
||||
|
||||
void FKIN_FREE(void);
|
||||
|
||||
/*------------------------------------------------------------------
|
||||
Prototypes : functions called by the solver
|
||||
------------------------------------------------------------------*/
|
||||
|
||||
int FKINfunc(N_Vector uu, N_Vector fval, void *user_data);
|
||||
|
||||
int FKINDenseJac(N_Vector uu, N_Vector fval, SUNMatrix J,
|
||||
void *user_data, N_Vector vtemp1, N_Vector vtemp2);
|
||||
|
||||
int FKINBandJac(N_Vector uu, N_Vector fval, SUNMatrix J,
|
||||
void *user_data, N_Vector vtemp1, N_Vector vtemp2);
|
||||
|
||||
int FKINSparseJac(N_Vector uu, N_Vector fval, SUNMatrix J,
|
||||
void *user_data, N_Vector vtemp1, N_Vector vtemp2);
|
||||
|
||||
int FKINJtimes(N_Vector v, N_Vector Jv, N_Vector uu,
|
||||
booleantype *new_uu, void *user_data);
|
||||
|
||||
int FKINPSet(N_Vector uu, N_Vector uscale,
|
||||
N_Vector fval, N_Vector fscale,
|
||||
void *user_data);
|
||||
|
||||
int FKINPSol(N_Vector uu, N_Vector uscale,
|
||||
N_Vector fval, N_Vector fscale,
|
||||
N_Vector vv, void *user_data);
|
||||
|
||||
void FKINNullMatrix();
|
||||
void FKINNullLinsol();
|
||||
|
||||
/*------------------------------------------------------------------
|
||||
declarations for global variables shared amongst various routines
|
||||
------------------------------------------------------------------*/
|
||||
|
||||
extern N_Vector F2C_KINSOL_vec; /* defined in FNVECTOR module */
|
||||
extern SUNMatrix F2C_KINSOL_matrix; /* defined in FSUNMATRIX module */
|
||||
extern SUNLinearSolver F2C_KINSOL_linsol; /* defined in FSUNLINSOL module */
|
||||
extern void *KIN_kinmem; /* defined in fkinsol.c */
|
||||
extern long int *KIN_iout; /* defined in fkinsol.c */
|
||||
extern realtype *KIN_rout; /* defined in fkinsol.c */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
1036
bazaar/plugin/sundials/src/kinsol/fmod/fkinsol_mod.c
Normal file
1036
bazaar/plugin/sundials/src/kinsol/fmod/fkinsol_mod.c
Normal file
File diff suppressed because it is too large
Load diff
2702
bazaar/plugin/sundials/src/kinsol/kinsol.c
Normal file
2702
bazaar/plugin/sundials/src/kinsol/kinsol.c
Normal file
File diff suppressed because it is too large
Load diff
582
bazaar/plugin/sundials/src/kinsol/kinsol_bbdpre.c
Normal file
582
bazaar/plugin/sundials/src/kinsol/kinsol_bbdpre.c
Normal file
|
|
@ -0,0 +1,582 @@
|
|||
/* -----------------------------------------------------------------
|
||||
* Programmer(s): David J. Gardner @ LLNL
|
||||
* Allan Taylor, Alan Hindmarsh, Radu Serban, and
|
||||
* Aaron Collier @ LLNL
|
||||
* -----------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
* -----------------------------------------------------------------
|
||||
* This file contains implementations of routines for a
|
||||
* band-block-diagonal preconditioner, i.e. a block-diagonal
|
||||
* matrix with banded blocks, for use with KINSol and the
|
||||
* KINLS linear solver interface.
|
||||
*
|
||||
* Note: With only one process, a banded matrix results
|
||||
* rather than a b-b-d matrix with banded blocks. Diagonal
|
||||
* blocking occurs at the process level.
|
||||
* -----------------------------------------------------------------*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "kinsol_impl.h"
|
||||
#include "kinsol_ls_impl.h"
|
||||
#include "kinsol_bbdpre_impl.h"
|
||||
|
||||
#include <sundials/sundials_math.h>
|
||||
#include <nvector/nvector_serial.h>
|
||||
|
||||
#define ZERO RCONST(0.0)
|
||||
#define ONE RCONST(1.0)
|
||||
|
||||
/* Prototypes of functions KINBBDPrecSetup and KINBBDPrecSolve */
|
||||
static int KINBBDPrecSetup(N_Vector uu, N_Vector uscale,
|
||||
N_Vector fval, N_Vector fscale,
|
||||
void *pdata);
|
||||
|
||||
static int KINBBDPrecSolve(N_Vector uu, N_Vector uscale,
|
||||
N_Vector fval, N_Vector fscale,
|
||||
N_Vector vv, void *pdata);
|
||||
|
||||
/* Prototype for KINBBDPrecFree */
|
||||
static int KINBBDPrecFree(KINMem kin_mem);
|
||||
|
||||
/* Prototype for difference quotient jacobian calculation routine */
|
||||
static int KBBDDQJac(KBBDPrecData pdata,
|
||||
N_Vector uu, N_Vector uscale,
|
||||
N_Vector gu, N_Vector gtemp, N_Vector utemp);
|
||||
|
||||
/*------------------------------------------------------------------
|
||||
user-callable functions
|
||||
------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------
|
||||
KINBBDPrecInit
|
||||
------------------------------------------------------------------*/
|
||||
int KINBBDPrecInit(void *kinmem, sunindextype Nlocal,
|
||||
sunindextype mudq, sunindextype mldq,
|
||||
sunindextype mukeep, sunindextype mlkeep,
|
||||
realtype dq_rel_uu,
|
||||
KINBBDLocalFn gloc, KINBBDCommFn gcomm)
|
||||
{
|
||||
KINMem kin_mem;
|
||||
KINLsMem kinls_mem;
|
||||
KBBDPrecData pdata;
|
||||
sunindextype muk, mlk, storage_mu, lrw1, liw1;
|
||||
long int lrw, liw;
|
||||
int flag;
|
||||
|
||||
if (kinmem == NULL) {
|
||||
KINProcessError(NULL, KINLS_MEM_NULL, "KINBBDPRE",
|
||||
"KINBBDPrecInit", MSGBBD_MEM_NULL);
|
||||
return(KINLS_MEM_NULL);
|
||||
}
|
||||
kin_mem = (KINMem) kinmem;
|
||||
|
||||
/* Test if the LS linear solver interface has been created */
|
||||
if (kin_mem->kin_lmem == NULL) {
|
||||
KINProcessError(kin_mem, KINLS_LMEM_NULL, "KINBBDPRE",
|
||||
"KINBBDPrecInit", MSGBBD_LMEM_NULL);
|
||||
return(KINLS_LMEM_NULL);
|
||||
}
|
||||
kinls_mem = (KINLsMem) kin_mem->kin_lmem;
|
||||
|
||||
/* Test compatibility of NVECTOR package with the BBD preconditioner */
|
||||
/* Note: Do NOT need to check for N_VScale since has already been checked for in KINSOL */
|
||||
if (kin_mem->kin_vtemp1->ops->nvgetarraypointer == NULL) {
|
||||
KINProcessError(kin_mem, KINLS_ILL_INPUT, "KINBBDPRE",
|
||||
"KINBBDPrecInit", MSGBBD_BAD_NVECTOR);
|
||||
return(KINLS_ILL_INPUT);
|
||||
}
|
||||
|
||||
/* Allocate data memory */
|
||||
pdata = NULL;
|
||||
pdata = (KBBDPrecData) malloc(sizeof *pdata);
|
||||
if (pdata == NULL) {
|
||||
KINProcessError(kin_mem, KINLS_MEM_FAIL,
|
||||
"KINBBDPRE", "KINBBDPrecInit", MSGBBD_MEM_FAIL);
|
||||
return(KINLS_MEM_FAIL);
|
||||
}
|
||||
|
||||
/* Set pointers to gloc and gcomm; load half-bandwidths */
|
||||
pdata->kin_mem = kinmem;
|
||||
pdata->gloc = gloc;
|
||||
pdata->gcomm = gcomm;
|
||||
pdata->mudq = SUNMIN(Nlocal-1, SUNMAX(0, mudq));
|
||||
pdata->mldq = SUNMIN(Nlocal-1, SUNMAX(0, mldq));
|
||||
muk = SUNMIN(Nlocal-1, SUNMAX(0, mukeep));
|
||||
mlk = SUNMIN(Nlocal-1, SUNMAX(0, mlkeep));
|
||||
pdata->mukeep = muk;
|
||||
pdata->mlkeep = mlk;
|
||||
|
||||
/* Set extended upper half-bandwidth for PP (required for pivoting) */
|
||||
storage_mu = SUNMIN(Nlocal-1, muk+mlk);
|
||||
|
||||
/* Allocate memory for preconditioner matrix */
|
||||
pdata->PP = NULL;
|
||||
pdata->PP = SUNBandMatrixStorage(Nlocal, muk, mlk, storage_mu);
|
||||
if (pdata->PP == NULL) {
|
||||
free(pdata); pdata = NULL;
|
||||
KINProcessError(kin_mem, KINLS_MEM_FAIL, "KINBBDPRE",
|
||||
"KINBBDPrecInit", MSGBBD_MEM_FAIL);
|
||||
return(KINLS_MEM_FAIL);
|
||||
}
|
||||
|
||||
/* Allocate memory for temporary N_Vectors */
|
||||
pdata->zlocal = NULL;
|
||||
pdata->zlocal = N_VNew_Serial(Nlocal);
|
||||
if (pdata->zlocal == NULL) {
|
||||
SUNMatDestroy(pdata->PP);
|
||||
free(pdata); pdata = NULL;
|
||||
KINProcessError(kin_mem, KINLS_MEM_FAIL, "KINBBDPRE",
|
||||
"KINBBDPrecInit", MSGBBD_MEM_FAIL);
|
||||
return(KINLS_MEM_FAIL);
|
||||
}
|
||||
|
||||
pdata->rlocal = NULL;
|
||||
pdata->rlocal = N_VNewEmpty_Serial(Nlocal); /* empty vector */
|
||||
if (pdata->rlocal == NULL) {
|
||||
N_VDestroy(pdata->zlocal);
|
||||
SUNMatDestroy(pdata->PP);
|
||||
free(pdata); pdata = NULL;
|
||||
KINProcessError(kin_mem, KINLS_MEM_FAIL, "KINBBDPRE",
|
||||
"KINBBDPrecInit", MSGBBD_MEM_FAIL);
|
||||
return(KINLS_MEM_FAIL);
|
||||
}
|
||||
|
||||
pdata->tempv1 = NULL;
|
||||
pdata->tempv1 = N_VClone(kin_mem->kin_vtemp1);
|
||||
if (pdata->tempv1 == NULL) {
|
||||
N_VDestroy(pdata->zlocal);
|
||||
N_VDestroy(pdata->rlocal);
|
||||
SUNMatDestroy(pdata->PP);
|
||||
free(pdata); pdata = NULL;
|
||||
KINProcessError(kin_mem, KINLS_MEM_FAIL, "KINBBDPRE",
|
||||
"KINBBDPrecInit", MSGBBD_MEM_FAIL);
|
||||
return(KINLS_MEM_FAIL);
|
||||
}
|
||||
|
||||
pdata->tempv2 = NULL;
|
||||
pdata->tempv2 = N_VClone(kin_mem->kin_vtemp1);
|
||||
if (pdata->tempv2 == NULL) {
|
||||
N_VDestroy(pdata->zlocal);
|
||||
N_VDestroy(pdata->rlocal);
|
||||
N_VDestroy(pdata->tempv1);
|
||||
SUNMatDestroy(pdata->PP);
|
||||
free(pdata); pdata = NULL;
|
||||
KINProcessError(kin_mem, KINLS_MEM_FAIL, "KINBBDPRE",
|
||||
"KINBBDPrecInit", MSGBBD_MEM_FAIL);
|
||||
return(KINLS_MEM_FAIL);
|
||||
}
|
||||
|
||||
pdata->tempv3 = NULL;
|
||||
pdata->tempv3 = N_VClone(kin_mem->kin_vtemp1);
|
||||
if (pdata->tempv3 == NULL) {
|
||||
N_VDestroy(pdata->zlocal);
|
||||
N_VDestroy(pdata->rlocal);
|
||||
N_VDestroy(pdata->tempv1);
|
||||
N_VDestroy(pdata->tempv2);
|
||||
SUNMatDestroy(pdata->PP);
|
||||
free(pdata); pdata = NULL;
|
||||
KINProcessError(kin_mem, KINLS_MEM_FAIL, "KINBBDPRE",
|
||||
"KINBBDPrecInit", MSGBBD_MEM_FAIL);
|
||||
return(KINLS_MEM_FAIL);
|
||||
}
|
||||
|
||||
/* Allocate memory for banded linear solver */
|
||||
pdata->LS = NULL;
|
||||
pdata->LS = SUNLinSol_Band(pdata->zlocal, pdata->PP);
|
||||
if (pdata->LS == NULL) {
|
||||
N_VDestroy(pdata->zlocal);
|
||||
N_VDestroy(pdata->rlocal);
|
||||
N_VDestroy(pdata->tempv1);
|
||||
N_VDestroy(pdata->tempv2);
|
||||
N_VDestroy(pdata->tempv3);
|
||||
SUNMatDestroy(pdata->PP);
|
||||
free(pdata); pdata = NULL;
|
||||
KINProcessError(kin_mem, KINLS_MEM_FAIL, "KINBBDPRE",
|
||||
"KINBBDPrecInit", MSGBBD_MEM_FAIL);
|
||||
return(KINLS_MEM_FAIL);
|
||||
}
|
||||
|
||||
/* initialize band linear solver object */
|
||||
flag = SUNLinSolInitialize(pdata->LS);
|
||||
if (flag != SUNLS_SUCCESS) {
|
||||
N_VDestroy(pdata->zlocal);
|
||||
N_VDestroy(pdata->rlocal);
|
||||
N_VDestroy(pdata->tempv1);
|
||||
N_VDestroy(pdata->tempv2);
|
||||
N_VDestroy(pdata->tempv3);
|
||||
SUNMatDestroy(pdata->PP);
|
||||
SUNLinSolFree(pdata->LS);
|
||||
free(pdata); pdata = NULL;
|
||||
KINProcessError(kin_mem, KINLS_SUNLS_FAIL, "KINBBDPRE",
|
||||
"KINBBDPrecInit", MSGBBD_SUNLS_FAIL);
|
||||
return(KINLS_SUNLS_FAIL);
|
||||
}
|
||||
|
||||
/* Set rel_uu based on input value dq_rel_uu (0 implies default) */
|
||||
pdata->rel_uu = (dq_rel_uu > ZERO) ? dq_rel_uu : SUNRsqrt(kin_mem->kin_uround);
|
||||
|
||||
/* Store Nlocal to be used in KINBBDPrecSetup */
|
||||
pdata->n_local = Nlocal;
|
||||
|
||||
/* Set work space sizes and initialize nge */
|
||||
pdata->rpwsize = 0;
|
||||
pdata->ipwsize = 0;
|
||||
if (kin_mem->kin_vtemp1->ops->nvspace) {
|
||||
N_VSpace(kin_mem->kin_vtemp1, &lrw1, &liw1);
|
||||
pdata->rpwsize += 3*lrw1;
|
||||
pdata->ipwsize += 3*liw1;
|
||||
}
|
||||
if (pdata->zlocal->ops->nvspace) {
|
||||
N_VSpace(pdata->zlocal, &lrw1, &liw1);
|
||||
pdata->rpwsize += lrw1;
|
||||
pdata->ipwsize += liw1;
|
||||
}
|
||||
if (pdata->rlocal->ops->nvspace) {
|
||||
N_VSpace(pdata->rlocal, &lrw1, &liw1);
|
||||
pdata->rpwsize += lrw1;
|
||||
pdata->ipwsize += liw1;
|
||||
}
|
||||
if (pdata->PP->ops->space) {
|
||||
flag = SUNMatSpace(pdata->PP, &lrw, &liw);
|
||||
pdata->rpwsize += lrw;
|
||||
pdata->ipwsize += liw;
|
||||
}
|
||||
if (pdata->LS->ops->space) {
|
||||
flag = SUNLinSolSpace(pdata->LS, &lrw, &liw);
|
||||
pdata->rpwsize += lrw;
|
||||
pdata->ipwsize += liw;
|
||||
}
|
||||
pdata->nge = 0;
|
||||
|
||||
/* make sure pdata is free from any previous allocations */
|
||||
if (kinls_mem->pfree != NULL)
|
||||
kinls_mem->pfree(kin_mem);
|
||||
|
||||
/* Point to the new pdata field in the LS memory */
|
||||
kinls_mem->pdata = pdata;
|
||||
|
||||
/* Attach the pfree function */
|
||||
kinls_mem->pfree = KINBBDPrecFree;
|
||||
|
||||
/* Attach preconditioner solve and setup functions */
|
||||
flag = KINSetPreconditioner(kinmem, KINBBDPrecSetup,
|
||||
KINBBDPrecSolve);
|
||||
|
||||
return(flag);
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------
|
||||
KINBBDPrecGetWorkSpace
|
||||
------------------------------------------------------------------*/
|
||||
int KINBBDPrecGetWorkSpace(void *kinmem,
|
||||
long int *lenrwBBDP,
|
||||
long int *leniwBBDP)
|
||||
{
|
||||
KINMem kin_mem;
|
||||
KINLsMem kinls_mem;
|
||||
KBBDPrecData pdata;
|
||||
|
||||
if (kinmem == NULL) {
|
||||
KINProcessError(NULL, KINLS_MEM_NULL, "KINBBDPRE",
|
||||
"KINBBDPrecGetWorkSpace", MSGBBD_MEM_NULL);
|
||||
return(KINLS_MEM_NULL);
|
||||
}
|
||||
kin_mem = (KINMem) kinmem;
|
||||
|
||||
if (kin_mem->kin_lmem == NULL) {
|
||||
KINProcessError(kin_mem, KINLS_LMEM_NULL, "KINBBDPRE",
|
||||
"KINBBDPrecGetWorkSpace", MSGBBD_LMEM_NULL);
|
||||
return(KINLS_LMEM_NULL);
|
||||
}
|
||||
kinls_mem = (KINLsMem) kin_mem->kin_lmem;
|
||||
|
||||
if (kinls_mem->pdata == NULL) {
|
||||
KINProcessError(kin_mem, KINLS_PMEM_NULL, "KINBBDPRE",
|
||||
"KINBBDPrecGetWorkSpace", MSGBBD_PMEM_NULL);
|
||||
return(KINLS_PMEM_NULL);
|
||||
}
|
||||
pdata = (KBBDPrecData) kinls_mem->pdata;
|
||||
|
||||
*lenrwBBDP = pdata->rpwsize;
|
||||
*leniwBBDP = pdata->ipwsize;
|
||||
|
||||
return(KINLS_SUCCESS);
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------
|
||||
KINBBDPrecGetNumGfnEvals
|
||||
-------------------------------------------------------------------*/
|
||||
int KINBBDPrecGetNumGfnEvals(void *kinmem,
|
||||
long int *ngevalsBBDP)
|
||||
{
|
||||
KINMem kin_mem;
|
||||
KINLsMem kinls_mem;
|
||||
KBBDPrecData pdata;
|
||||
|
||||
if (kinmem == NULL) {
|
||||
KINProcessError(NULL, KINLS_MEM_NULL, "KINBBDPRE",
|
||||
"KINBBDPrecGetNumGfnEvals", MSGBBD_MEM_NULL);
|
||||
return(KINLS_MEM_NULL);
|
||||
}
|
||||
kin_mem = (KINMem) kinmem;
|
||||
|
||||
if (kin_mem->kin_lmem == NULL) {
|
||||
KINProcessError(kin_mem, KINLS_LMEM_NULL, "KINBBDPRE",
|
||||
"KINBBDPrecGetNumGfnEvals", MSGBBD_LMEM_NULL);
|
||||
return(KINLS_LMEM_NULL);
|
||||
}
|
||||
kinls_mem = (KINLsMem) kin_mem->kin_lmem;
|
||||
|
||||
if (kinls_mem->pdata == NULL) {
|
||||
KINProcessError(kin_mem, KINLS_PMEM_NULL, "KINBBDPRE",
|
||||
"KINBBDPrecGetNumGfnEvals", MSGBBD_PMEM_NULL);
|
||||
return(KINLS_PMEM_NULL);
|
||||
}
|
||||
pdata = (KBBDPrecData) kinls_mem->pdata;
|
||||
|
||||
*ngevalsBBDP = pdata->nge;
|
||||
|
||||
return(KINLS_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------
|
||||
KINBBDPrecSetup
|
||||
|
||||
KINBBDPrecSetup generates and factors a banded block of the
|
||||
preconditioner matrix on each processor, via calls to the
|
||||
user-supplied gloc and gcomm functions. It uses difference
|
||||
quotient approximations to the Jacobian elements.
|
||||
|
||||
KINBBDPrecSetup calculates a new Jacobian, stored in banded
|
||||
matrix PP and does an LU factorization of P in place in PP.
|
||||
|
||||
The parameters of KINBBDPrecSetup are as follows:
|
||||
|
||||
uu is the current value of the dependent variable vector,
|
||||
namely the solutin to func(uu)=0
|
||||
|
||||
uscale is the dependent variable scaling vector (i.e. uu)
|
||||
|
||||
fval is the vector f(u)
|
||||
|
||||
fscale is the function scaling vector
|
||||
|
||||
bbd_data is the pointer to BBD data set by KINBBDInit.
|
||||
|
||||
Note: The value to be returned by the KINBBDPrecSetup function
|
||||
is a flag indicating whether it was successful. This value is:
|
||||
0 if successful,
|
||||
> 0 for a recoverable error - step will be retried.
|
||||
------------------------------------------------------------------*/
|
||||
static int KINBBDPrecSetup(N_Vector uu, N_Vector uscale,
|
||||
N_Vector fval, N_Vector fscale,
|
||||
void *bbd_data)
|
||||
{
|
||||
KBBDPrecData pdata;
|
||||
KINMem kin_mem;
|
||||
int retval;
|
||||
|
||||
pdata = (KBBDPrecData) bbd_data;
|
||||
|
||||
kin_mem = (KINMem) pdata->kin_mem;
|
||||
|
||||
/* Call KBBDDQJac for a new Jacobian calculation and store in PP */
|
||||
retval = SUNMatZero(pdata->PP);
|
||||
if (retval != 0) {
|
||||
KINProcessError(kin_mem, -1, "KINBBDPRE", "KINBBDPrecSetup",
|
||||
MSGBBD_SUNMAT_FAIL);
|
||||
return(-1);
|
||||
}
|
||||
|
||||
retval = KBBDDQJac(pdata, uu, uscale,
|
||||
pdata->tempv1, pdata->tempv2, pdata->tempv3);
|
||||
if (retval != 0) {
|
||||
KINProcessError(kin_mem, -1, "KINBBDPRE", "KINBBDPrecSetup",
|
||||
MSGBBD_FUNC_FAILED);
|
||||
return(-1);
|
||||
}
|
||||
|
||||
/* Do LU factorization of P and return error flag */
|
||||
retval = SUNLinSolSetup_Band(pdata->LS, pdata->PP);
|
||||
return(retval);
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------
|
||||
INBBDPrecSolve
|
||||
|
||||
KINBBDPrecSolve solves a linear system P z = r, with the
|
||||
banded blocked preconditioner matrix P generated and factored
|
||||
by KINBBDPrecSetup. Here, r comes in as vv and z is
|
||||
returned in vv as well.
|
||||
|
||||
The parameters for KINBBDPrecSolve are as follows:
|
||||
|
||||
uu an N_Vector giving the current iterate for the system
|
||||
|
||||
uscale an N_Vector giving the diagonal entries of the
|
||||
uu scaling matrix
|
||||
|
||||
fval an N_Vector giving the current function value
|
||||
|
||||
fscale an N_Vector giving the diagonal entries of the
|
||||
function scaling matrix
|
||||
|
||||
vv vector initially set to the right-hand side vector r, but
|
||||
which upon return contains a solution of the linear system
|
||||
P*z = r
|
||||
|
||||
bbd_data is the pointer to BBD data set by KINBBDInit.
|
||||
|
||||
Note: The value returned by the KINBBDPrecSolve function is a
|
||||
flag returned from the lienar solver object.
|
||||
------------------------------------------------------------------*/
|
||||
|
||||
static int KINBBDPrecSolve(N_Vector uu, N_Vector uscale,
|
||||
N_Vector fval, N_Vector fscale,
|
||||
N_Vector vv, void *bbd_data)
|
||||
{
|
||||
KBBDPrecData pdata;
|
||||
realtype *vd;
|
||||
realtype *zd;
|
||||
int i, retval;
|
||||
|
||||
pdata = (KBBDPrecData) bbd_data;
|
||||
|
||||
/* Get data pointers */
|
||||
vd = N_VGetArrayPointer(vv);
|
||||
zd = N_VGetArrayPointer(pdata->zlocal);
|
||||
|
||||
/* Attach local data array for vv to rlocal */
|
||||
N_VSetArrayPointer(vd, pdata->rlocal);
|
||||
|
||||
/* Call banded solver object to do the work */
|
||||
retval = SUNLinSolSolve(pdata->LS, pdata->PP, pdata->zlocal,
|
||||
pdata->rlocal, ZERO);
|
||||
|
||||
/* Copy result into vv */
|
||||
for (i=0; i<pdata->n_local; i++)
|
||||
vd[i] = zd[i];
|
||||
|
||||
return(retval);
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------
|
||||
KINBBDPrecFree
|
||||
------------------------------------------------------------------*/
|
||||
static int KINBBDPrecFree(KINMem kin_mem)
|
||||
{
|
||||
KINLsMem kinls_mem;
|
||||
KBBDPrecData pdata;
|
||||
|
||||
if (kin_mem->kin_lmem == NULL) return(0);
|
||||
kinls_mem = (KINLsMem) kin_mem->kin_lmem;
|
||||
|
||||
if (kinls_mem->pdata == NULL) return(0);
|
||||
pdata = (KBBDPrecData) kinls_mem->pdata;
|
||||
|
||||
SUNLinSolFree(pdata->LS);
|
||||
N_VDestroy(pdata->zlocal);
|
||||
N_VDestroy(pdata->rlocal);
|
||||
N_VDestroy(pdata->tempv1);
|
||||
N_VDestroy(pdata->tempv2);
|
||||
N_VDestroy(pdata->tempv3);
|
||||
SUNMatDestroy(pdata->PP);
|
||||
|
||||
free(pdata);
|
||||
pdata = NULL;
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------
|
||||
KBBDDQJac
|
||||
|
||||
This routine generates a banded difference quotient
|
||||
approximation to the Jacobian of f(u). It assumes that a band
|
||||
matrix of type SUNMatrix is stored column-wise, and that elements
|
||||
within each column are contiguous. All matrix elements are
|
||||
generated as difference quotients, by way of calls to the user
|
||||
routine gloc. By virtue of the band structure, the number of
|
||||
these calls is bandwidth + 1, where bandwidth = ml + mu + 1.
|
||||
This routine also assumes that the local elements of a vector
|
||||
are stored contiguously.
|
||||
------------------------------------------------------------------*/
|
||||
static int KBBDDQJac(KBBDPrecData pdata,
|
||||
N_Vector uu, N_Vector uscale,
|
||||
N_Vector gu, N_Vector gtemp, N_Vector utemp)
|
||||
{
|
||||
KINMem kin_mem;
|
||||
realtype inc, inc_inv;
|
||||
int retval;
|
||||
sunindextype group, i, j, width, ngroups, i1, i2;
|
||||
realtype *udata, *uscdata, *gudata, *gtempdata, *utempdata, *col_j;
|
||||
|
||||
kin_mem = (KINMem) pdata->kin_mem;
|
||||
|
||||
/* load utemp with uu = predicted solution vector */
|
||||
N_VScale(ONE, uu, utemp);
|
||||
|
||||
/* set pointers to the data for all vectors */
|
||||
udata = N_VGetArrayPointer(uu);
|
||||
uscdata = N_VGetArrayPointer(uscale);
|
||||
gudata = N_VGetArrayPointer(gu);
|
||||
gtempdata = N_VGetArrayPointer(gtemp);
|
||||
utempdata = N_VGetArrayPointer(utemp);
|
||||
|
||||
/* Call gcomm and gloc to get base value of g(uu) */
|
||||
if (pdata->gcomm != NULL) {
|
||||
retval = pdata->gcomm(pdata->n_local, uu, kin_mem->kin_user_data);
|
||||
if (retval != 0) return(retval);
|
||||
}
|
||||
|
||||
retval = pdata->gloc(pdata->n_local, uu, gu, kin_mem->kin_user_data);
|
||||
pdata->nge++;
|
||||
if (retval != 0) return(retval);
|
||||
|
||||
/* Set bandwidth and number of column groups for band differencing */
|
||||
width = pdata->mldq + pdata->mudq + 1;
|
||||
ngroups = SUNMIN(width, pdata->n_local);
|
||||
|
||||
/* Loop over groups */
|
||||
for(group = 1; group <= ngroups; group++) {
|
||||
|
||||
/* increment all u_j in group */
|
||||
for(j = group - 1; j < pdata->n_local; j += width) {
|
||||
inc = pdata->rel_uu * SUNMAX(SUNRabs(udata[j]), (ONE / uscdata[j]));
|
||||
utempdata[j] += inc;
|
||||
}
|
||||
|
||||
/* Evaluate g with incremented u */
|
||||
retval = pdata->gloc(pdata->n_local, utemp, gtemp, kin_mem->kin_user_data);
|
||||
pdata->nge++;
|
||||
if (retval != 0) return(retval);
|
||||
|
||||
/* restore utemp, then form and load difference quotients */
|
||||
for (j = group - 1; j < pdata->n_local; j += width) {
|
||||
utempdata[j] = udata[j];
|
||||
col_j = SUNBandMatrix_Column(pdata->PP,j);
|
||||
inc = pdata->rel_uu * SUNMAX(SUNRabs(udata[j]) , (ONE / uscdata[j]));
|
||||
inc_inv = ONE / inc;
|
||||
i1 = SUNMAX(0, (j - pdata->mukeep));
|
||||
i2 = SUNMIN((j + pdata->mlkeep), (pdata->n_local - 1));
|
||||
for (i = i1; i <= i2; i++)
|
||||
SM_COLUMN_ELEMENT_B(col_j, i, j) = inc_inv * (gtempdata[i] - gudata[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
82
bazaar/plugin/sundials/src/kinsol/kinsol_bbdpre_impl.h
Normal file
82
bazaar/plugin/sundials/src/kinsol/kinsol_bbdpre_impl.h
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
/* -----------------------------------------------------------------
|
||||
* Programmer(s): David J. Gardner @ LLNL
|
||||
* Allan Taylor, Alan Hindmarsh, Radu Serban, and
|
||||
* Aaron Collier @ LLNL
|
||||
* -----------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
* -----------------------------------------------------------------
|
||||
* KINBBDPRE module header file (private version)
|
||||
* -----------------------------------------------------------------*/
|
||||
|
||||
#ifndef _KINBBDPRE_IMPL_H
|
||||
#define _KINBBDPRE_IMPL_H
|
||||
|
||||
#include <kinsol/kinsol_bbdpre.h>
|
||||
#include <sunmatrix/sunmatrix_band.h>
|
||||
#include <sunlinsol/sunlinsol_band.h>
|
||||
|
||||
#ifdef __cplusplus /* wrapper to enable C++ usage */
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*------------------------------------------------------------------
|
||||
Definition of KBBDData
|
||||
------------------------------------------------------------------*/
|
||||
|
||||
typedef struct KBBDPrecDataRec {
|
||||
|
||||
/* passed by user to KINBBDPrecAlloc, used by pset/psolve functions */
|
||||
sunindextype mudq, mldq, mukeep, mlkeep;
|
||||
realtype rel_uu; /* relative error for the Jacobian DQ routine */
|
||||
KINBBDLocalFn gloc;
|
||||
KINBBDCommFn gcomm;
|
||||
|
||||
/* set by KINBBDPrecSetup and used by KINBBDPrecSetup and
|
||||
KINBBDPrecSolve functions */
|
||||
sunindextype n_local;
|
||||
SUNMatrix PP;
|
||||
SUNLinearSolver LS;
|
||||
N_Vector rlocal;
|
||||
N_Vector zlocal;
|
||||
N_Vector tempv1;
|
||||
N_Vector tempv2;
|
||||
N_Vector tempv3;
|
||||
|
||||
/* available for optional output */
|
||||
long int rpwsize;
|
||||
long int ipwsize;
|
||||
long int nge;
|
||||
|
||||
/* pointer to KINSol memory */
|
||||
void *kin_mem;
|
||||
|
||||
} *KBBDPrecData;
|
||||
|
||||
/*
|
||||
*-----------------------------------------------------------------
|
||||
* KINBBDPRE error messages
|
||||
*-----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#define MSGBBD_MEM_NULL "KINSOL Memory is NULL."
|
||||
#define MSGBBD_LMEM_NULL "Linear solver memory is NULL. One of the SPILS linear solvers must be attached."
|
||||
#define MSGBBD_MEM_FAIL "A memory request failed."
|
||||
#define MSGBBD_BAD_NVECTOR "A required vector operation is not implemented."
|
||||
#define MSGBBD_SUNMAT_FAIL "An error arose from a SUNBandMatrix routine."
|
||||
#define MSGBBD_SUNLS_FAIL "An error arose from a SUNBandLinearSolver routine."
|
||||
#define MSGBBD_PMEM_NULL "BBD peconditioner memory is NULL. IDABBDPrecInit must be called."
|
||||
#define MSGBBD_FUNC_FAILED "The gloc or gcomm routine failed in an unrecoverable manner."
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
55
bazaar/plugin/sundials/src/kinsol/kinsol_direct.c
Normal file
55
bazaar/plugin/sundials/src/kinsol/kinsol_direct.c
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
/*-----------------------------------------------------------------
|
||||
* Programmer(s): Daniel R. Reynolds @ SMU
|
||||
* Radu Serban @ LLNL
|
||||
*-----------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
*-----------------------------------------------------------------
|
||||
* Implementation file for the deprecated direct linear solver interface in
|
||||
* KINSOL; these routines now just wrap the updated KINSOL generic
|
||||
* linear solver interface in kinsol_ls.h.
|
||||
*-----------------------------------------------------------------*/
|
||||
|
||||
#include <kinsol/kinsol_ls.h>
|
||||
#include <kinsol/kinsol_direct.h>
|
||||
|
||||
#ifdef __cplusplus /* wrapper to enable C++ usage */
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*=================================================================
|
||||
Exported Functions (wrappers for equivalent routines in kinsol_ls.h)
|
||||
=================================================================*/
|
||||
|
||||
int KINDlsSetLinearSolver(void *kinmem, SUNLinearSolver LS, SUNMatrix A)
|
||||
{ return(KINSetLinearSolver(kinmem, LS, A)); }
|
||||
|
||||
int KINDlsSetJacFn(void *kinmem, KINDlsJacFn jac)
|
||||
{ return(KINSetJacFn(kinmem, jac)); }
|
||||
|
||||
int KINDlsGetWorkSpace(void *kinmem, long int *lenrw, long int *leniw)
|
||||
{ return(KINGetLinWorkSpace(kinmem, lenrw, leniw)); }
|
||||
|
||||
int KINDlsGetNumJacEvals(void *kinmem, long int *njevals)
|
||||
{ return(KINGetNumJacEvals(kinmem, njevals)); }
|
||||
|
||||
int KINDlsGetNumFuncEvals(void *kinmem, long int *nfevals)
|
||||
{ return(KINGetNumLinFuncEvals(kinmem, nfevals)); }
|
||||
|
||||
int KINDlsGetLastFlag(void *kinmem, long int *flag)
|
||||
{ return(KINGetLastLinFlag(kinmem, flag)); }
|
||||
|
||||
char *KINDlsGetReturnFlagName(long int flag)
|
||||
{ return(KINGetLinReturnFlagName(flag)); }
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
489
bazaar/plugin/sundials/src/kinsol/kinsol_impl.h
Normal file
489
bazaar/plugin/sundials/src/kinsol/kinsol_impl.h
Normal file
|
|
@ -0,0 +1,489 @@
|
|||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Programmer(s): Allan Taylor, Alan Hindmarsh, Radu Serban, and
|
||||
* Aaron Collier @ LLNL
|
||||
* -----------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
* -----------------------------------------------------------------
|
||||
* KINSOL solver module header file (private version)
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef _KINSOL_IMPL_H
|
||||
#define _KINSOL_IMPL_H
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#include <kinsol/kinsol.h>
|
||||
|
||||
#ifdef __cplusplus /* wrapper to enable C++ usage */
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* =================================================================
|
||||
* M A I N S O L V E R M E M O R Y B L O C K
|
||||
* =================================================================
|
||||
*/
|
||||
|
||||
/* KINSOL default constants */
|
||||
|
||||
#define PRINTFL_DEFAULT 0
|
||||
#define MXITER_DEFAULT 200
|
||||
#define MXNBCF_DEFAULT 10
|
||||
#define MSBSET_DEFAULT 10
|
||||
#define MSBSET_SUB_DEFAULT 5
|
||||
|
||||
#define OMEGA_MIN RCONST(0.00001)
|
||||
#define OMEGA_MAX RCONST(0.9)
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Types : struct KINMemRec and struct *KINMem
|
||||
* -----------------------------------------------------------------
|
||||
* A variable declaration of type struct *KINMem denotes a
|
||||
* pointer to a data structure of type struct KINMemRec. The
|
||||
* KINMemRec structure contains numerous fields that must be
|
||||
* accessible by KINSOL solver module routines.
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
typedef struct KINMemRec {
|
||||
|
||||
realtype kin_uround; /* machine epsilon (or unit roundoff error)
|
||||
(defined in sundials_types.h) */
|
||||
|
||||
/* problem specification data */
|
||||
|
||||
KINSysFn kin_func; /* nonlinear system function implementation */
|
||||
void *kin_user_data; /* work space available to func routine */
|
||||
realtype kin_fnormtol; /* stopping tolerance on L2-norm of function
|
||||
value */
|
||||
realtype kin_scsteptol; /* scaled step length tolerance */
|
||||
int kin_globalstrategy; /* choices are KIN_NONE, KIN_LINESEARCH
|
||||
KIN_PICARD and KIN_FP */
|
||||
int kin_printfl; /* level of verbosity of output */
|
||||
long int kin_mxiter; /* maximum number of nonlinear iterations */
|
||||
long int kin_msbset; /* maximum number of nonlinear iterations that
|
||||
may be performed between calls to the
|
||||
linear solver setup routine (lsetup) */
|
||||
long int kin_msbset_sub; /* subinterval length for residual monitoring */
|
||||
long int kin_mxnbcf; /* maximum number of beta condition failures */
|
||||
int kin_etaflag; /* choices are KIN_ETACONSTANT, KIN_ETACHOICE1
|
||||
and KIN_ETACHOICE2 */
|
||||
booleantype kin_noMinEps; /* flag controlling whether or not the value
|
||||
of eps is bounded below */
|
||||
booleantype kin_constraintsSet; /* flag indicating if constraints are being
|
||||
used */
|
||||
booleantype kin_jacCurrent; /* flag indicating if the Jacobian info.
|
||||
used by the linear solver is current */
|
||||
booleantype kin_callForcingTerm; /* flag set if using either KIN_ETACHOICE1
|
||||
or KIN_ETACHOICE2 */
|
||||
booleantype kin_noResMon; /* flag indicating if the nonlinear
|
||||
residual monitoring scheme should be
|
||||
used */
|
||||
booleantype kin_retry_nni; /* flag indicating if nonlinear iteration
|
||||
should be retried (set by residual
|
||||
monitoring algorithm) */
|
||||
booleantype kin_update_fnorm_sub; /* flag indicating if the fnorm associated
|
||||
with the subinterval needs to be
|
||||
updated (set by residual monitoring
|
||||
algorithm) */
|
||||
|
||||
realtype kin_mxnewtstep; /* maximum allowable scaled step length */
|
||||
realtype kin_mxnstepin; /* input (or preset) value for mxnewtstep */
|
||||
realtype kin_sqrt_relfunc; /* relative error bound for func(u) */
|
||||
realtype kin_stepl; /* scaled length of current step */
|
||||
realtype kin_stepmul; /* step scaling factor */
|
||||
realtype kin_eps; /* current value of eps */
|
||||
realtype kin_eta; /* current value of eta */
|
||||
realtype kin_eta_gamma; /* gamma value used in eta calculation
|
||||
(choice #2) */
|
||||
realtype kin_eta_alpha; /* alpha value used in eta calculation
|
||||
(choice #2) */
|
||||
booleantype kin_noInitSetup; /* flag controlling whether or not the KINSol
|
||||
routine makes an initial call to the
|
||||
linear solver setup routine (lsetup) */
|
||||
realtype kin_sthrsh; /* threshold value for calling the linear
|
||||
solver setup routine */
|
||||
|
||||
/* counters */
|
||||
|
||||
long int kin_nni; /* number of nonlinear iterations */
|
||||
long int kin_nfe; /* number of calls made to func routine */
|
||||
long int kin_nnilset; /* value of nni counter when the linear solver
|
||||
setup was last called */
|
||||
long int kin_nnilset_sub; /* value of nni counter when the linear solver
|
||||
setup was last called (subinterval) */
|
||||
long int kin_nbcf; /* number of times the beta-condition could not
|
||||
be met in KINLineSearch */
|
||||
long int kin_nbktrk; /* number of backtracks performed by
|
||||
KINLineSearch */
|
||||
long int kin_ncscmx; /* number of consecutive steps of size
|
||||
mxnewtstep taken */
|
||||
|
||||
/* vectors */
|
||||
|
||||
N_Vector kin_uu; /* solution vector/current iterate (initially
|
||||
contains initial guess, but holds approximate
|
||||
solution upon completion if no errors occurred) */
|
||||
N_Vector kin_unew; /* next iterate (unew = uu+pp) */
|
||||
N_Vector kin_fval; /* vector containing result of nonlinear system
|
||||
function evaluated at a given iterate
|
||||
(fval = func(uu)) */
|
||||
N_Vector kin_gval; /* vector containing result of the fixed point
|
||||
function evaluated at a given iterate;
|
||||
used in KIN_PICARD strategy only.
|
||||
(gval = uu - L^{-1}fval(uu)) */
|
||||
N_Vector kin_uscale; /* iterate scaling vector */
|
||||
N_Vector kin_fscale; /* fval scaling vector */
|
||||
N_Vector kin_pp; /* incremental change vector (pp = unew-uu) */
|
||||
N_Vector kin_constraints; /* constraints vector */
|
||||
N_Vector kin_vtemp1; /* scratch vector #1 */
|
||||
N_Vector kin_vtemp2; /* scratch vector #2 */
|
||||
|
||||
/* space requirements for AA, Broyden and NLEN */
|
||||
N_Vector kin_fold_aa; /* vector needed for AA, Broyden, and NLEN */
|
||||
N_Vector kin_gold_aa; /* vector needed for AA, Broyden, and NLEN */
|
||||
N_Vector *kin_df_aa; /* vector array needed for AA, Broyden, and NLEN */
|
||||
N_Vector *kin_dg_aa; /* vector array needed for AA, Broyden and NLEN */
|
||||
N_Vector *kin_q_aa; /* vector array needed for AA */
|
||||
realtype kin_beta_aa; /* beta damping parameter for AA */
|
||||
realtype *kin_gamma_aa; /* array of size maa used in AA */
|
||||
realtype *kin_R_aa; /* array of size maa*maa used in AA */
|
||||
long int *kin_ipt_map; /* array of size maa used in AA */
|
||||
long int kin_m_aa; /* parameter for AA, Broyden or NLEN */
|
||||
booleantype kin_aamem_aa; /* sets additional memory needed for Anderson Acc */
|
||||
booleantype kin_setstop_aa; /* determines whether user will set stopping criterion */
|
||||
booleantype kin_damping_aa; /* flag to apply damping in AA */
|
||||
realtype *kin_cv; /* scalar array for fused vector operations */
|
||||
N_Vector *kin_Xv; /* vector array for fused vector operations */
|
||||
|
||||
/* space requirements for vector storage */
|
||||
|
||||
sunindextype kin_lrw1; /* number of realtype-sized memory blocks needed
|
||||
for a single N_Vector */
|
||||
sunindextype kin_liw1; /* number of int-sized memory blocks needed for
|
||||
a single N_Vecotr */
|
||||
long int kin_lrw; /* total number of realtype-sized memory blocks
|
||||
needed for all KINSOL work vectors */
|
||||
long int kin_liw; /* total number of int-sized memory blocks needed
|
||||
for all KINSOL work vectors */
|
||||
|
||||
/* linear solver data */
|
||||
|
||||
/* function prototypes (pointers) */
|
||||
|
||||
int (*kin_linit)(struct KINMemRec *kin_mem);
|
||||
|
||||
int (*kin_lsetup)(struct KINMemRec *kin_mem);
|
||||
|
||||
int (*kin_lsolve)(struct KINMemRec *kin_mem, N_Vector xx, N_Vector bb,
|
||||
realtype *sJpnorm, realtype *sFdotJp);
|
||||
|
||||
int (*kin_lfree)(struct KINMemRec *kin_mem);
|
||||
|
||||
booleantype kin_inexact_ls; /* flag set by the linear solver module
|
||||
(in linit) indicating whether this is an
|
||||
iterative linear solver (SUNTRUE), or a direct
|
||||
linear solver (SUNFALSE) */
|
||||
|
||||
void *kin_lmem; /* pointer to linear solver memory block */
|
||||
|
||||
realtype kin_fnorm; /* value of L2-norm of fscale*fval */
|
||||
realtype kin_f1norm; /* f1norm = 0.5*(fnorm)^2 */
|
||||
realtype kin_sFdotJp; /* value of scaled F(u) vector (fscale*fval)
|
||||
dotted with scaled J(u)*pp vector (set by lsolve) */
|
||||
realtype kin_sJpnorm; /* value of L2-norm of fscale*(J(u)*pp)
|
||||
(set by lsolve) */
|
||||
|
||||
realtype kin_fnorm_sub; /* value of L2-norm of fscale*fval (subinterval) */
|
||||
booleantype kin_eval_omega; /* flag indicating that omega must be evaluated. */
|
||||
realtype kin_omega; /* constant value for real scalar used in test to
|
||||
determine if reduction of norm of nonlinear
|
||||
residual is sufficient. Unless a valid constant
|
||||
value is specified by the user, omega is estimated
|
||||
from omega_min and omega_max at each iteration. */
|
||||
realtype kin_omega_min; /* lower bound on omega */
|
||||
realtype kin_omega_max; /* upper bound on omega */
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Note: The KINLineSearch subroutine scales the values of the
|
||||
* variables sFdotJp and sJpnorm by a factor rl (lambda) that is
|
||||
* chosen by the line search algorithm such that the sclaed Newton
|
||||
* step satisfies the following conditions:
|
||||
*
|
||||
* F(u_k+1) <= F(u_k) + alpha*(F(u_k)^T * J(u_k))*p*rl
|
||||
*
|
||||
* F(u_k+1) >= F(u_k) + beta*(F(u_k)^T * J(u_k))*p*rl
|
||||
*
|
||||
* where alpha = 1.0e-4, beta = 0.9, u_k+1 = u_k + rl*p,
|
||||
* 0 < rl <= 1, J denotes the system Jacobian, and F represents
|
||||
* the nonliner system function.
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
booleantype kin_MallocDone; /* flag indicating if KINMalloc has been
|
||||
called yet */
|
||||
|
||||
/* message files */
|
||||
/*-------------------------------------------
|
||||
Error handler function and error ouput file
|
||||
-------------------------------------------*/
|
||||
|
||||
KINErrHandlerFn kin_ehfun; /* Error messages are handled by ehfun */
|
||||
void *kin_eh_data; /* dats pointer passed to ehfun */
|
||||
FILE *kin_errfp; /* KINSOL error messages are sent to errfp */
|
||||
|
||||
KINInfoHandlerFn kin_ihfun; /* Info messages are handled by ihfun */
|
||||
void *kin_ih_data; /* dats pointer passed to ihfun */
|
||||
FILE *kin_infofp; /* where KINSol info messages are sent */
|
||||
|
||||
} *KINMem;
|
||||
|
||||
/*
|
||||
* =================================================================
|
||||
* I N T E R F A C E T O L I N E A R S O L V E R
|
||||
* =================================================================
|
||||
*/
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Function : int (*kin_linit)(KINMem kin_mem)
|
||||
* -----------------------------------------------------------------
|
||||
* kin_linit initializes solver-specific data structures (including
|
||||
* variables used as counters or for storing statistical information),
|
||||
* but system memory allocation should be done by the subroutine
|
||||
* that actually initializes the environment for liner solver
|
||||
* package. If the linear system is to be preconditioned, then the
|
||||
* variable setupNonNull (type booleantype) should be set to SUNTRUE
|
||||
* (predefined constant) and the kin_lsetup routine should be
|
||||
* appropriately defined.
|
||||
*
|
||||
* kinmem pointer to an internal memory block allocated during
|
||||
* prior calls to KINCreate and KINMalloc
|
||||
*
|
||||
* If the necessary variables have been successfully initialized,
|
||||
* then the kin_linit function should return 0 (zero). Otherwise,
|
||||
* the subroutine should indicate a failure has occurred by
|
||||
* returning a non-zero integer value.
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Function : int (*kin_lsetup)(KINMem kin_mem)
|
||||
* -----------------------------------------------------------------
|
||||
* kin_lsetup interfaces with the user-supplied pset subroutine (the
|
||||
* preconditioner setup routine), and updates relevant variable
|
||||
* values (see KINSpgmrSetup/KINSpbcgSetup). Simply stated, the
|
||||
* kin_lsetup routine prepares the linear solver for a subsequent
|
||||
* call to the user-supplied kin_lsolve function.
|
||||
*
|
||||
* kinmem pointer to an internal memory block allocated during
|
||||
* prior calls to KINCreate and KINMalloc
|
||||
*
|
||||
* If successful, the kin_lsetup routine should return 0 (zero).
|
||||
* Otherwise it should return a non-zero value.
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Function : int (*kin_lsolve)(KINMem kin_mem, N_Vector xx,
|
||||
* N_Vector bb, realtype *sJpnorm, realtype *sFdotJp)
|
||||
* -----------------------------------------------------------------
|
||||
* kin_lsolve interfaces with the subroutine implementing the
|
||||
* numerical method to be used to solve the linear system J*xx = bb,
|
||||
* and must increment the relevant counter variable values in
|
||||
* addition to computing certain values used by the global strategy
|
||||
* and forcing term routines (see KINInexactNewton, KINLineSearch,
|
||||
* KINForcingTerm, and KINSpgmrSolve/KINSpbcgSolve).
|
||||
*
|
||||
* kinmem pointer to an internal memory block allocated during
|
||||
* prior calls to KINCreate and KINMalloc
|
||||
*
|
||||
* xx vector (type N_Vector) set to initial guess by kin_lsolve
|
||||
* routine prior to calling the linear solver, but which upon
|
||||
* return contains an approximate solution of the linear
|
||||
* system J*xx = bb, where J denotes the system Jacobian
|
||||
*
|
||||
* bb vector (type N_Vector) set to -func(u) (negative of the
|
||||
* value of the system function evaluated at the current
|
||||
* iterate) by KINLinSolDrv before kin_lsolve is called
|
||||
*
|
||||
* sJpnorm holds the value of the L2-norm (Euclidean norm) of
|
||||
* fscale*(J(u)*pp) upon return
|
||||
*
|
||||
* sFdotJp holds the value of the scaled F(u) (fscale*F) dotted
|
||||
* with the scaled J(u)*pp vector upon return
|
||||
*
|
||||
* If successful, the kin_lsolve routine should return 0 (zero).
|
||||
* Otherwise it should return a positive value if a re-evaluation
|
||||
* of the lsetup function could recover, or a negative value if
|
||||
* no such recovery is possible.
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Function : int (*kin_lfree)(KINMem kin_mem)
|
||||
* -----------------------------------------------------------------
|
||||
* kin_lfree is called by KINFree and should free (deallocate) all
|
||||
* system memory resources allocated for the linear solver module
|
||||
* (see KINSpgmrFree/KINSpbcgFree). It should return 0 upon
|
||||
* success, nonzero on failure.
|
||||
*
|
||||
* kinmem pointer to an internal memory block allocated during
|
||||
* prior calls to KINCreate and KINMalloc
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
* =================================================================
|
||||
* K I N S O L I N T E R N A L F U N C T I O N S
|
||||
* =================================================================
|
||||
*/
|
||||
|
||||
|
||||
/* High level error handler */
|
||||
|
||||
void KINProcessError(KINMem kin_mem,
|
||||
int error_code, const char *module, const char *fname,
|
||||
const char *msgfmt, ...);
|
||||
|
||||
/* Prototype of internal errHandler function */
|
||||
|
||||
void KINErrHandler(int error_code, const char *module, const char *function,
|
||||
char *msg, void *user_data);
|
||||
|
||||
|
||||
/* High level info handler */
|
||||
|
||||
void KINPrintInfo(KINMem kin_mem,
|
||||
int info_code, const char *module, const char *fname,
|
||||
const char *msgfmt, ...);
|
||||
|
||||
/* Prototype of internal infoHandler function */
|
||||
|
||||
void KINInfoHandler(const char *module, const char *function,
|
||||
char *msg, void *user_data);
|
||||
|
||||
/*
|
||||
* =================================================================
|
||||
* K I N S O L E R R O R M E S S A G E S
|
||||
* =================================================================
|
||||
*/
|
||||
|
||||
#define MSG_MEM_FAIL "A memory request failed."
|
||||
#define MSG_NO_MEM "kinsol_mem = NULL illegal."
|
||||
#define MSG_BAD_NVECTOR "A required vector operation is not implemented."
|
||||
#define MSG_FUNC_NULL "func = NULL illegal."
|
||||
#define MSG_NO_MALLOC "Attempt to call before KINMalloc illegal."
|
||||
|
||||
#define MSG_BAD_PRINTFL "Illegal value for printfl."
|
||||
#define MSG_BAD_MXITER "Illegal value for mxiter."
|
||||
#define MSG_BAD_MSBSET "Illegal msbset < 0."
|
||||
#define MSG_BAD_MSBSETSUB "Illegal msbsetsub < 0."
|
||||
#define MSG_BAD_ETACHOICE "Illegal value for etachoice."
|
||||
#define MSG_BAD_ETACONST "eta out of range."
|
||||
#define MSG_BAD_GAMMA "gamma out of range."
|
||||
#define MSG_BAD_ALPHA "alpha out of range."
|
||||
#define MSG_BAD_MXNEWTSTEP "Illegal mxnewtstep < 0."
|
||||
#define MSG_BAD_RELFUNC "relfunc < 0 illegal."
|
||||
#define MSG_BAD_FNORMTOL "fnormtol < 0 illegal."
|
||||
#define MSG_BAD_SCSTEPTOL "scsteptol < 0 illegal."
|
||||
#define MSG_BAD_MXNBCF "mxbcf < 0 illegal."
|
||||
#define MSG_BAD_CONSTRAINTS "Illegal values in constraints vector."
|
||||
#define MSG_BAD_OMEGA "scalars < 0 illegal."
|
||||
#define MSG_BAD_MAA "maa < 0 illegal."
|
||||
#define MSG_ZERO_MAA "maa = 0 illegal."
|
||||
|
||||
#define MSG_LSOLV_NO_MEM "The linear solver memory pointer is NULL."
|
||||
#define MSG_UU_NULL "uu = NULL illegal."
|
||||
#define MSG_BAD_GLSTRAT "Illegal value for global strategy."
|
||||
#define MSG_BAD_USCALE "uscale = NULL illegal."
|
||||
#define MSG_USCALE_NONPOSITIVE "uscale has nonpositive elements."
|
||||
#define MSG_BAD_FSCALE "fscale = NULL illegal."
|
||||
#define MSG_FSCALE_NONPOSITIVE "fscale has nonpositive elements."
|
||||
#define MSG_CONSTRAINTS_NOTOK "Constraints not allowed with fixed point or Picard iterations"
|
||||
#define MSG_INITIAL_CNSTRNT "Initial guess does NOT meet constraints."
|
||||
#define MSG_LINIT_FAIL "The linear solver's init routine failed."
|
||||
|
||||
#define MSG_SYSFUNC_FAILED "The system function failed in an unrecoverable manner."
|
||||
#define MSG_SYSFUNC_FIRST "The system function failed at the first call."
|
||||
#define MSG_LSETUP_FAILED "The linear solver's setup function failed in an unrecoverable manner."
|
||||
#define MSG_LSOLVE_FAILED "The linear solver's solve function failed in an unrecoverable manner."
|
||||
#define MSG_LINSOLV_NO_RECOVERY "The linear solver's solve function failed recoverably, but the Jacobian data is already current."
|
||||
#define MSG_LINESEARCH_NONCONV "The line search algorithm was unable to find an iterate sufficiently distinct from the current iterate."
|
||||
#define MSG_LINESEARCH_BCFAIL "The line search algorithm was unable to satisfy the beta-condition for nbcfails iterations."
|
||||
#define MSG_MAXITER_REACHED "The maximum number of iterations was reached before convergence."
|
||||
#define MSG_MXNEWT_5X_EXCEEDED "Five consecutive steps have been taken that satisfy a scaled step length test."
|
||||
#define MSG_SYSFUNC_REPTD "Unable to correct repeated recoverable system function errors."
|
||||
#define MSG_NOL_FAIL "Unable to find user's Linear Jacobian, which is required for the KIN_PICARD Strategy"
|
||||
|
||||
/*
|
||||
* =================================================================
|
||||
* K I N S O L I N F O M E S S A G E S
|
||||
* =================================================================
|
||||
*/
|
||||
|
||||
#define INFO_RETVAL "Return value: %d"
|
||||
#define INFO_ADJ "no. of lambda adjustments = %ld"
|
||||
|
||||
#if defined(SUNDIALS_EXTENDED_PRECISION)
|
||||
|
||||
#define INFO_NNI "nni = %4ld nfe = %6ld fnorm = %26.16Lg"
|
||||
#define INFO_TOL "scsteptol = %12.3Lg fnormtol = %12.3Lg"
|
||||
#define INFO_FMAX "scaled f norm (for stopping) = %12.3Lg"
|
||||
#define INFO_PNORM "pnorm = %12.4Le"
|
||||
#define INFO_PNORM1 "(ivio=1) pnorm = %12.4Le"
|
||||
#define INFO_FNORM "fnorm(L2) = %20.8Le"
|
||||
#define INFO_LAM "min_lam = %11.4Le f1norm = %11.4Le pnorm = %11.4Le"
|
||||
#define INFO_ALPHA "fnorm = %15.8Le f1norm = %15.8Le alpha_cond = %15.8Le lam = %15.8Le"
|
||||
#define INFO_BETA "f1norm = %15.8Le beta_cond = %15.8Le lam = %15.8Le"
|
||||
#define INFO_ALPHABETA "f1norm = %15.8Le alpha_cond = %15.8Le beta_cond = %15.8Le lam = %15.8Le"
|
||||
|
||||
#elif defined(SUNDIALS_DOUBLE_PRECISION)
|
||||
|
||||
#define INFO_NNI "nni = %4ld nfe = %6ld fnorm = %26.16lg"
|
||||
#define INFO_TOL "scsteptol = %12.3lg fnormtol = %12.3lg"
|
||||
#define INFO_FMAX "scaled f norm (for stopping) = %12.3lg"
|
||||
#define INFO_PNORM "pnorm = %12.4le"
|
||||
#define INFO_PNORM1 "(ivio=1) pnorm = %12.4le"
|
||||
#define INFO_FNORM "fnorm(L2) = %20.8le"
|
||||
#define INFO_LAM "min_lam = %11.4le f1norm = %11.4le pnorm = %11.4le"
|
||||
#define INFO_ALPHA "fnorm = %15.8le f1norm = %15.8le alpha_cond = %15.8le lam = %15.8le"
|
||||
#define INFO_BETA "f1norm = %15.8le beta_cond = %15.8le lam = %15.8le"
|
||||
#define INFO_ALPHABETA "f1norm = %15.8le alpha_cond = %15.8le beta_cond = %15.8le lam = %15.8le"
|
||||
|
||||
#else
|
||||
|
||||
#define INFO_NNI "nni = %4ld nfe = %6ld fnorm = %26.16g"
|
||||
#define INFO_TOL "scsteptol = %12.3g fnormtol = %12.3g"
|
||||
#define INFO_FMAX "scaled f norm (for stopping) = %12.3g"
|
||||
#define INFO_PNORM "pnorm = %12.4e"
|
||||
#define INFO_PNORM1 "(ivio=1) pnorm = %12.4e"
|
||||
#define INFO_FNORM "fnorm(L2) = %20.8e"
|
||||
#define INFO_LAM "min_lam = %11.4e f1norm = %11.4e pnorm = %11.4e"
|
||||
#define INFO_ALPHA "fnorm = %15.8e f1norm = %15.8e alpha_cond = %15.8e lam = %15.8e"
|
||||
#define INFO_BETA "f1norm = %15.8e beta_cond = %15.8e lam = %15.8e"
|
||||
#define INFO_ALPHABETA "f1norm = %15.8e alpha_cond = %15.8e beta_cond = %15.8e lam = %15.8e"
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
1073
bazaar/plugin/sundials/src/kinsol/kinsol_io.c
Normal file
1073
bazaar/plugin/sundials/src/kinsol/kinsol_io.c
Normal file
File diff suppressed because it is too large
Load diff
1332
bazaar/plugin/sundials/src/kinsol/kinsol_ls.c
Normal file
1332
bazaar/plugin/sundials/src/kinsol/kinsol_ls.c
Normal file
File diff suppressed because it is too large
Load diff
184
bazaar/plugin/sundials/src/kinsol/kinsol_ls_impl.h
Normal file
184
bazaar/plugin/sundials/src/kinsol/kinsol_ls_impl.h
Normal file
|
|
@ -0,0 +1,184 @@
|
|||
/*-----------------------------------------------------------------
|
||||
* Programmer(s): Daniel R. Reynolds @ SMU
|
||||
* David J. Gardner, Radu Serban and Aaron Collier @ LLNL
|
||||
*-----------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
*-----------------------------------------------------------------
|
||||
* Implementation header file for KINSOL's linear solver interface.
|
||||
*-----------------------------------------------------------------*/
|
||||
|
||||
#ifndef _KINLS_IMPL_H
|
||||
#define _KINLS_IMPL_H
|
||||
|
||||
#include <kinsol/kinsol_ls.h>
|
||||
#include "kinsol_impl.h"
|
||||
|
||||
#ifdef __cplusplus /* wrapper to enable C++ usage */
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*------------------------------------------------------------------
|
||||
keys for KINPrintInfo (do not use 1 -> conflict with PRNT_RETVAL)
|
||||
------------------------------------------------------------------*/
|
||||
#define PRNT_NLI 101
|
||||
#define PRNT_EPS 102
|
||||
|
||||
|
||||
/*------------------------------------------------------------------
|
||||
Types : struct KINLsMemRec, struct *KINLsMem
|
||||
|
||||
The type KINLsMem is a pointer to a KINLsMemRec, which is a
|
||||
structure containing fields that must be accessible by LS module
|
||||
routines.
|
||||
------------------------------------------------------------------*/
|
||||
typedef struct KINLsMemRec {
|
||||
|
||||
/* Linear solver type information */
|
||||
booleantype iterative; /* is the solver iterative? */
|
||||
booleantype matrixbased; /* is a matrix structure used? */
|
||||
|
||||
/* Jacobian construction & storage */
|
||||
booleantype jacDQ; /* SUNTRUE if using internal DQ Jacobian approx. */
|
||||
KINLsJacFn jac; /* Jacobian routine to be called */
|
||||
void *J_data; /* J_data is passed to jac */
|
||||
|
||||
/* Linear solver, matrix and vector objects/pointers */
|
||||
SUNLinearSolver LS; /* generic iterative linear solver object */
|
||||
SUNMatrix J; /* problem Jacobian */
|
||||
|
||||
/* Solver tolerance adjustment factor (if needed, see kinLsSolve) */
|
||||
realtype tol_fac;
|
||||
|
||||
/* Statistics and associated parameters */
|
||||
long int nje; /* no. of calls to jac */
|
||||
long int nfeDQ; /* no. of calls to F due to DQ Jacobian or J*v
|
||||
approximations */
|
||||
long int npe; /* npe = total number of precond calls */
|
||||
long int nli; /* nli = total number of linear iterations */
|
||||
long int nps; /* nps = total number of psolve calls */
|
||||
long int ncfl; /* ncfl = total number of convergence failures */
|
||||
long int njtimes; /* njtimes = total number of calls to jtimes */
|
||||
|
||||
booleantype new_uu; /* flag indicating if the iterate has been
|
||||
updated - the Jacobian must be updated or
|
||||
reevaluated (meant to be used by a
|
||||
user-supplied jtimes function */
|
||||
|
||||
int last_flag; /* last error return flag */
|
||||
|
||||
/* Preconditioner computation
|
||||
(a) user-provided:
|
||||
- pdata == user_data
|
||||
- pfree == NULL (the user dealocates memory)
|
||||
(b) internal preconditioner module
|
||||
- pdata == kin_mem
|
||||
- pfree == set by the prec. module and called in kinLsFree */
|
||||
KINLsPrecSetupFn pset;
|
||||
KINLsPrecSolveFn psolve;
|
||||
int (*pfree)(KINMem kin_mem);
|
||||
void *pdata;
|
||||
|
||||
/* Jacobian times vector compuation
|
||||
(a) jtimes function provided by the user:
|
||||
- jt_data == user_data
|
||||
- jtimesDQ == SUNFALSE
|
||||
(b) internal jtimes
|
||||
- jt_data == kin_mem
|
||||
- jtimesDQ == SUNTRUE */
|
||||
booleantype jtimesDQ;
|
||||
KINLsJacTimesVecFn jtimes;
|
||||
void *jt_data;
|
||||
|
||||
} *KINLsMem;
|
||||
|
||||
|
||||
/*------------------------------------------------------------------
|
||||
Prototypes of internal functions
|
||||
------------------------------------------------------------------*/
|
||||
|
||||
/* Interface routines called by system SUNLinearSolvers */
|
||||
int kinLsATimes(void *kinmem, N_Vector v, N_Vector z);
|
||||
int kinLsPSetup(void *kinmem);
|
||||
int kinLsPSolve(void *kinmem, N_Vector r, N_Vector z,
|
||||
realtype tol, int lr);
|
||||
|
||||
/* Difference quotient approximation for Jacobian times vector */
|
||||
int kinLsDQJtimes(N_Vector v, N_Vector Jv, N_Vector u,
|
||||
booleantype *new_u, void *data);
|
||||
|
||||
/* Difference-quotient Jacobian approximation routines */
|
||||
int kinLsDQJac(N_Vector u, N_Vector fu, SUNMatrix Jac,
|
||||
void *data, N_Vector tmp1, N_Vector tmp2);
|
||||
|
||||
int kinLsDenseDQJac(N_Vector u, N_Vector fu, SUNMatrix Jac,
|
||||
KINMem kin_mem, N_Vector tmp1, N_Vector tmp2);
|
||||
|
||||
int kinLsBandDQJac(N_Vector u, N_Vector fu, SUNMatrix Jac,
|
||||
KINMem kin_mem, N_Vector tmp1, N_Vector tmp2);
|
||||
|
||||
/* Generic linit/lsetup/lsolve/lfree interface routines for KINSOL to call */
|
||||
int kinLsInitialize(KINMem kin_mem);
|
||||
int kinLsSetup(KINMem kin_mem);
|
||||
int kinLsSolve(KINMem kin_mem, N_Vector x, N_Vector b,
|
||||
realtype *sJpnorm, realtype *sFdotJp);
|
||||
int kinLsFree(KINMem kin_mem);
|
||||
|
||||
/* Auxilliary functions */
|
||||
int kinLsInitializeCounters(KINLsMem kinls_mem);
|
||||
int kinLs_AccessLMem(void* kinmem, const char *fname,
|
||||
KINMem* kin_mem, KINLsMem *kinls_mem);
|
||||
|
||||
|
||||
/*------------------------------------------------------------------
|
||||
Error messages
|
||||
------------------------------------------------------------------*/
|
||||
|
||||
#define MSG_LS_KINMEM_NULL "KINSOL memory is NULL."
|
||||
#define MSG_LS_MEM_FAIL "A memory request failed."
|
||||
#define MSG_LS_BAD_NVECTOR "A required vector operation is not implemented."
|
||||
#define MSG_LS_LMEM_NULL "Linear solver memory is NULL."
|
||||
#define MSG_LS_NEG_MAXRS "maxrs < 0 illegal."
|
||||
#define MSG_LS_BAD_SIZES "Illegal bandwidth parameter(s). Must have 0 <= ml, mu <= N-1."
|
||||
|
||||
#define MSG_LS_JACFUNC_FAILED "The Jacobian routine failed in an unrecoverable manner."
|
||||
#define MSG_LS_PSET_FAILED "The preconditioner setup routine failed in an unrecoverable manner."
|
||||
#define MSG_LS_PSOLVE_FAILED "The preconditioner solve routine failed in an unrecoverable manner."
|
||||
#define MSG_LS_JTIMES_FAILED "The Jacobian x vector routine failed in an unrecoverable manner."
|
||||
#define MSG_LS_MATZERO_FAILED "The SUNMatZero routine failed in an unrecoverable manner."
|
||||
|
||||
|
||||
/*------------------------------------------------------------------
|
||||
Info messages
|
||||
------------------------------------------------------------------*/
|
||||
|
||||
#define INFO_NLI "nli_inc = %d"
|
||||
|
||||
#if defined(SUNDIALS_EXTENDED_PRECISION)
|
||||
|
||||
#define INFO_EPS "residual norm = %12.3Lg eps = %12.3Lg"
|
||||
|
||||
#elif defined(SUNDIALS_DOUBLE_PRECISION)
|
||||
|
||||
#define INFO_EPS "residual norm = %12.3lg eps = %12.3lg"
|
||||
|
||||
#else
|
||||
|
||||
#define INFO_EPS "residual norm = %12.3g eps = %12.3g"
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
73
bazaar/plugin/sundials/src/kinsol/kinsol_spils.c
Normal file
73
bazaar/plugin/sundials/src/kinsol/kinsol_spils.c
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
/*-----------------------------------------------------------------
|
||||
* Programmer(s): Daniel R. Reynolds @ SMU
|
||||
* Scott Cohen, Alan Hindmarsh, Radu Serban,
|
||||
* and Aaron Collier @ LLNL
|
||||
*-----------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
*-----------------------------------------------------------------
|
||||
* Header file for the deprecated Scaled Preconditioned Iterative
|
||||
* Linear Solver interface in KINSOL; these routines now just wrap
|
||||
* the updated KINSOL generic linear solver interface in kinsol_ls.h.
|
||||
*-----------------------------------------------------------------*/
|
||||
|
||||
#include <kinsol/kinsol_ls.h>
|
||||
#include <kinsol/kinsol_spils.h>
|
||||
|
||||
#ifdef __cplusplus /* wrapper to enable C++ usage */
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*=================================================================
|
||||
Exported Functions (wrappers for equivalent routines in kinsol_ls.h)
|
||||
=================================================================*/
|
||||
|
||||
int KINSpilsSetLinearSolver(void *kinmem, SUNLinearSolver LS)
|
||||
{ return(KINSetLinearSolver(kinmem, LS, NULL)); }
|
||||
|
||||
int KINSpilsSetPreconditioner(void *kinmem, KINSpilsPrecSetupFn psetup,
|
||||
KINSpilsPrecSolveFn psolve)
|
||||
{ return(KINSetPreconditioner(kinmem, psetup, psolve)); }
|
||||
|
||||
int KINSpilsSetJacTimesVecFn(void *kinmem, KINSpilsJacTimesVecFn jtv)
|
||||
{ return(KINSetJacTimesVecFn(kinmem, jtv)); }
|
||||
|
||||
int KINSpilsGetWorkSpace(void *kinmem, long int *lenrwLS, long int *leniwLS)
|
||||
{ return(KINGetLinWorkSpace(kinmem, lenrwLS, leniwLS)); }
|
||||
|
||||
int KINSpilsGetNumPrecEvals(void *kinmem, long int *npevals)
|
||||
{ return(KINGetNumPrecEvals(kinmem, npevals)); }
|
||||
|
||||
int KINSpilsGetNumPrecSolves(void *kinmem, long int *npsolves)
|
||||
{ return(KINGetNumPrecSolves(kinmem, npsolves)); }
|
||||
|
||||
int KINSpilsGetNumLinIters(void *kinmem, long int *nliters)
|
||||
{ return(KINGetNumLinIters(kinmem, nliters)); }
|
||||
|
||||
int KINSpilsGetNumConvFails(void *kinmem, long int *nlcfails)
|
||||
{ return(KINGetNumLinConvFails(kinmem, nlcfails)); }
|
||||
|
||||
int KINSpilsGetNumJtimesEvals(void *kinmem, long int *njvevals)
|
||||
{ return(KINGetNumJtimesEvals(kinmem, njvevals)); }
|
||||
|
||||
int KINSpilsGetNumFuncEvals(void *kinmem, long int *nfevals)
|
||||
{ return(KINGetNumLinFuncEvals(kinmem, nfevals)); }
|
||||
|
||||
int KINSpilsGetLastFlag(void *kinmem, long int *flag)
|
||||
{ return(KINGetLastLinFlag(kinmem, flag)); }
|
||||
|
||||
char *KINSpilsGetReturnFlagName(long int flag)
|
||||
{ return(KINGetLinReturnFlagName(flag)); }
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -0,0 +1,899 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
* This file was automatically generated by SWIG (http://www.swig.org).
|
||||
* Version 4.0.0
|
||||
*
|
||||
* This file is not intended to be easily readable and contains a number of
|
||||
* coding conventions designed to improve portability and efficiency. Do not make
|
||||
* changes to this file unless you know what you are doing--modify the SWIG
|
||||
* interface file instead.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
/* ---------------------------------------------------------------
|
||||
* Programmer(s): Auto-generated by swig.
|
||||
* ---------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
* -------------------------------------------------------------*/
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* This section contains generic SWIG labels for method/variable
|
||||
* declarations/attributes, and other compiler dependent labels.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
/* template workaround for compilers that cannot correctly implement the C++ standard */
|
||||
#ifndef SWIGTEMPLATEDISAMBIGUATOR
|
||||
# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560)
|
||||
# define SWIGTEMPLATEDISAMBIGUATOR template
|
||||
# elif defined(__HP_aCC)
|
||||
/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */
|
||||
/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */
|
||||
# define SWIGTEMPLATEDISAMBIGUATOR template
|
||||
# else
|
||||
# define SWIGTEMPLATEDISAMBIGUATOR
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* inline attribute */
|
||||
#ifndef SWIGINLINE
|
||||
# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__))
|
||||
# define SWIGINLINE inline
|
||||
# else
|
||||
# define SWIGINLINE
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* attribute recognised by some compilers to avoid 'unused' warnings */
|
||||
#ifndef SWIGUNUSED
|
||||
# if defined(__GNUC__)
|
||||
# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
|
||||
# define SWIGUNUSED __attribute__ ((__unused__))
|
||||
# else
|
||||
# define SWIGUNUSED
|
||||
# endif
|
||||
# elif defined(__ICC)
|
||||
# define SWIGUNUSED __attribute__ ((__unused__))
|
||||
# else
|
||||
# define SWIGUNUSED
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef SWIG_MSC_UNSUPPRESS_4505
|
||||
# if defined(_MSC_VER)
|
||||
# pragma warning(disable : 4505) /* unreferenced local function has been removed */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef SWIGUNUSEDPARM
|
||||
# ifdef __cplusplus
|
||||
# define SWIGUNUSEDPARM(p)
|
||||
# else
|
||||
# define SWIGUNUSEDPARM(p) p SWIGUNUSED
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* internal SWIG method */
|
||||
#ifndef SWIGINTERN
|
||||
# define SWIGINTERN static SWIGUNUSED
|
||||
#endif
|
||||
|
||||
/* internal inline SWIG method */
|
||||
#ifndef SWIGINTERNINLINE
|
||||
# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE
|
||||
#endif
|
||||
|
||||
/* qualifier for exported *const* global data variables*/
|
||||
#ifndef SWIGEXTERN
|
||||
# ifdef __cplusplus
|
||||
# define SWIGEXTERN extern
|
||||
# else
|
||||
# define SWIGEXTERN
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* exporting methods */
|
||||
#if defined(__GNUC__)
|
||||
# if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
|
||||
# ifndef GCC_HASCLASSVISIBILITY
|
||||
# define GCC_HASCLASSVISIBILITY
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef SWIGEXPORT
|
||||
# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
|
||||
# if defined(STATIC_LINKED)
|
||||
# define SWIGEXPORT
|
||||
# else
|
||||
# define SWIGEXPORT __declspec(dllexport)
|
||||
# endif
|
||||
# else
|
||||
# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY)
|
||||
# define SWIGEXPORT __attribute__ ((visibility("default")))
|
||||
# else
|
||||
# define SWIGEXPORT
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* calling conventions for Windows */
|
||||
#ifndef SWIGSTDCALL
|
||||
# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
|
||||
# define SWIGSTDCALL __stdcall
|
||||
# else
|
||||
# define SWIGSTDCALL
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
|
||||
#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
|
||||
# define _CRT_SECURE_NO_DEPRECATE
|
||||
#endif
|
||||
|
||||
/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */
|
||||
#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE)
|
||||
# define _SCL_SECURE_NO_DEPRECATE
|
||||
#endif
|
||||
|
||||
/* Deal with Apple's deprecated 'AssertMacros.h' from Carbon-framework */
|
||||
#if defined(__APPLE__) && !defined(__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES)
|
||||
# define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0
|
||||
#endif
|
||||
|
||||
/* Intel's compiler complains if a variable which was never initialised is
|
||||
* cast to void, which is a common idiom which we use to indicate that we
|
||||
* are aware a variable isn't used. So we just silence that warning.
|
||||
* See: https://github.com/swig/swig/issues/192 for more discussion.
|
||||
*/
|
||||
#ifdef __INTEL_COMPILER
|
||||
# pragma warning disable 592
|
||||
#endif
|
||||
|
||||
/* Errors in SWIG */
|
||||
#define SWIG_UnknownError -1
|
||||
#define SWIG_IOError -2
|
||||
#define SWIG_RuntimeError -3
|
||||
#define SWIG_IndexError -4
|
||||
#define SWIG_TypeError -5
|
||||
#define SWIG_DivisionByZero -6
|
||||
#define SWIG_OverflowError -7
|
||||
#define SWIG_SyntaxError -8
|
||||
#define SWIG_ValueError -9
|
||||
#define SWIG_SystemError -10
|
||||
#define SWIG_AttributeError -11
|
||||
#define SWIG_MemoryError -12
|
||||
#define SWIG_NullReferenceError -13
|
||||
|
||||
|
||||
|
||||
|
||||
#include <assert.h>
|
||||
#define SWIG_exception_impl(DECL, CODE, MSG, RETURNNULL) \
|
||||
{ printf("In " DECL ": " MSG); assert(0); RETURNNULL; }
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM)
|
||||
# ifndef snprintf
|
||||
# define snprintf _snprintf
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
/* Support for the `contract` feature.
|
||||
*
|
||||
* Note that RETURNNULL is first because it's inserted via a 'Replaceall' in
|
||||
* the fortran.cxx file.
|
||||
*/
|
||||
#define SWIG_contract_assert(RETURNNULL, EXPR, MSG) \
|
||||
if (!(EXPR)) { SWIG_exception_impl("$decl", SWIG_ValueError, MSG, RETURNNULL); }
|
||||
|
||||
|
||||
#define SWIGVERSION 0x040000
|
||||
#define SWIG_VERSION SWIGVERSION
|
||||
|
||||
|
||||
#define SWIG_as_voidptr(a) (void *)((const void *)(a))
|
||||
#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a))
|
||||
|
||||
|
||||
#include "sundials/sundials_nvector.h"
|
||||
|
||||
|
||||
#include "nvector/nvector_manyvector.h"
|
||||
|
||||
SWIGEXPORT N_Vector _wrap_FN_VNew_ManyVector(int64_t const *farg1, void *farg2) {
|
||||
N_Vector fresult ;
|
||||
sunindextype arg1 ;
|
||||
N_Vector *arg2 = (N_Vector *) 0 ;
|
||||
N_Vector result;
|
||||
|
||||
arg1 = (sunindextype)(*farg1);
|
||||
arg2 = (N_Vector *)(farg2);
|
||||
result = (N_Vector)N_VNew_ManyVector(arg1,arg2);
|
||||
fresult = result;
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT N_Vector _wrap_FN_VGetSubvector_ManyVector(N_Vector farg1, int64_t const *farg2) {
|
||||
N_Vector fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
sunindextype arg2 ;
|
||||
N_Vector result;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
arg2 = (sunindextype)(*farg2);
|
||||
result = (N_Vector)N_VGetSubvector_ManyVector(arg1,arg2);
|
||||
fresult = result;
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT double * _wrap_FN_VGetSubvectorArrayPointer_ManyVector(N_Vector farg1, int64_t const *farg2) {
|
||||
double * fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
sunindextype arg2 ;
|
||||
realtype *result = 0 ;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
arg2 = (sunindextype)(*farg2);
|
||||
result = (realtype *)N_VGetSubvectorArrayPointer_ManyVector(arg1,arg2);
|
||||
fresult = result;
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FN_VSetSubvectorArrayPointer_ManyVector(double *farg1, N_Vector farg2, int64_t const *farg3) {
|
||||
int fresult ;
|
||||
realtype *arg1 = (realtype *) 0 ;
|
||||
N_Vector arg2 = (N_Vector) 0 ;
|
||||
sunindextype arg3 ;
|
||||
int result;
|
||||
|
||||
arg1 = (realtype *)(farg1);
|
||||
arg2 = (N_Vector)(farg2);
|
||||
arg3 = (sunindextype)(*farg3);
|
||||
result = (int)N_VSetSubvectorArrayPointer_ManyVector(arg1,arg2,arg3);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int64_t _wrap_FN_VGetNumSubvectors_ManyVector(N_Vector farg1) {
|
||||
int64_t fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
sunindextype result;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
result = N_VGetNumSubvectors_ManyVector(arg1);
|
||||
fresult = (sunindextype)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FN_VGetVectorID_ManyVector(N_Vector farg1) {
|
||||
int fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
N_Vector_ID result;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
result = (N_Vector_ID)N_VGetVectorID_ManyVector(arg1);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT N_Vector _wrap_FN_VCloneEmpty_ManyVector(N_Vector farg1) {
|
||||
N_Vector fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
N_Vector result;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
result = (N_Vector)N_VCloneEmpty_ManyVector(arg1);
|
||||
fresult = result;
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT N_Vector _wrap_FN_VClone_ManyVector(N_Vector farg1) {
|
||||
N_Vector fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
N_Vector result;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
result = (N_Vector)N_VClone_ManyVector(arg1);
|
||||
fresult = result;
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void _wrap_FN_VDestroy_ManyVector(N_Vector farg1) {
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
N_VDestroy_ManyVector(arg1);
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void _wrap_FN_VSpace_ManyVector(N_Vector farg1, int64_t *farg2, int64_t *farg3) {
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
sunindextype *arg2 = (sunindextype *) 0 ;
|
||||
sunindextype *arg3 = (sunindextype *) 0 ;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
arg2 = (sunindextype *)(farg2);
|
||||
arg3 = (sunindextype *)(farg3);
|
||||
N_VSpace_ManyVector(arg1,arg2,arg3);
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int64_t _wrap_FN_VGetLength_ManyVector(N_Vector farg1) {
|
||||
int64_t fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
sunindextype result;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
result = N_VGetLength_ManyVector(arg1);
|
||||
fresult = (sunindextype)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void _wrap_FN_VLinearSum_ManyVector(double const *farg1, N_Vector farg2, double const *farg3, N_Vector farg4, N_Vector farg5) {
|
||||
realtype arg1 ;
|
||||
N_Vector arg2 = (N_Vector) 0 ;
|
||||
realtype arg3 ;
|
||||
N_Vector arg4 = (N_Vector) 0 ;
|
||||
N_Vector arg5 = (N_Vector) 0 ;
|
||||
|
||||
arg1 = (realtype)(*farg1);
|
||||
arg2 = (N_Vector)(farg2);
|
||||
arg3 = (realtype)(*farg3);
|
||||
arg4 = (N_Vector)(farg4);
|
||||
arg5 = (N_Vector)(farg5);
|
||||
N_VLinearSum_ManyVector(arg1,arg2,arg3,arg4,arg5);
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void _wrap_FN_VConst_ManyVector(double const *farg1, N_Vector farg2) {
|
||||
realtype arg1 ;
|
||||
N_Vector arg2 = (N_Vector) 0 ;
|
||||
|
||||
arg1 = (realtype)(*farg1);
|
||||
arg2 = (N_Vector)(farg2);
|
||||
N_VConst_ManyVector(arg1,arg2);
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void _wrap_FN_VProd_ManyVector(N_Vector farg1, N_Vector farg2, N_Vector farg3) {
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
N_Vector arg2 = (N_Vector) 0 ;
|
||||
N_Vector arg3 = (N_Vector) 0 ;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
arg2 = (N_Vector)(farg2);
|
||||
arg3 = (N_Vector)(farg3);
|
||||
N_VProd_ManyVector(arg1,arg2,arg3);
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void _wrap_FN_VDiv_ManyVector(N_Vector farg1, N_Vector farg2, N_Vector farg3) {
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
N_Vector arg2 = (N_Vector) 0 ;
|
||||
N_Vector arg3 = (N_Vector) 0 ;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
arg2 = (N_Vector)(farg2);
|
||||
arg3 = (N_Vector)(farg3);
|
||||
N_VDiv_ManyVector(arg1,arg2,arg3);
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void _wrap_FN_VScale_ManyVector(double const *farg1, N_Vector farg2, N_Vector farg3) {
|
||||
realtype arg1 ;
|
||||
N_Vector arg2 = (N_Vector) 0 ;
|
||||
N_Vector arg3 = (N_Vector) 0 ;
|
||||
|
||||
arg1 = (realtype)(*farg1);
|
||||
arg2 = (N_Vector)(farg2);
|
||||
arg3 = (N_Vector)(farg3);
|
||||
N_VScale_ManyVector(arg1,arg2,arg3);
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void _wrap_FN_VAbs_ManyVector(N_Vector farg1, N_Vector farg2) {
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
N_Vector arg2 = (N_Vector) 0 ;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
arg2 = (N_Vector)(farg2);
|
||||
N_VAbs_ManyVector(arg1,arg2);
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void _wrap_FN_VInv_ManyVector(N_Vector farg1, N_Vector farg2) {
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
N_Vector arg2 = (N_Vector) 0 ;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
arg2 = (N_Vector)(farg2);
|
||||
N_VInv_ManyVector(arg1,arg2);
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void _wrap_FN_VAddConst_ManyVector(N_Vector farg1, double const *farg2, N_Vector farg3) {
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
realtype arg2 ;
|
||||
N_Vector arg3 = (N_Vector) 0 ;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
arg2 = (realtype)(*farg2);
|
||||
arg3 = (N_Vector)(farg3);
|
||||
N_VAddConst_ManyVector(arg1,arg2,arg3);
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT double _wrap_FN_VWrmsNorm_ManyVector(N_Vector farg1, N_Vector farg2) {
|
||||
double fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
N_Vector arg2 = (N_Vector) 0 ;
|
||||
realtype result;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
arg2 = (N_Vector)(farg2);
|
||||
result = (realtype)N_VWrmsNorm_ManyVector(arg1,arg2);
|
||||
fresult = (realtype)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT double _wrap_FN_VWrmsNormMask_ManyVector(N_Vector farg1, N_Vector farg2, N_Vector farg3) {
|
||||
double fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
N_Vector arg2 = (N_Vector) 0 ;
|
||||
N_Vector arg3 = (N_Vector) 0 ;
|
||||
realtype result;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
arg2 = (N_Vector)(farg2);
|
||||
arg3 = (N_Vector)(farg3);
|
||||
result = (realtype)N_VWrmsNormMask_ManyVector(arg1,arg2,arg3);
|
||||
fresult = (realtype)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT double _wrap_FN_VWL2Norm_ManyVector(N_Vector farg1, N_Vector farg2) {
|
||||
double fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
N_Vector arg2 = (N_Vector) 0 ;
|
||||
realtype result;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
arg2 = (N_Vector)(farg2);
|
||||
result = (realtype)N_VWL2Norm_ManyVector(arg1,arg2);
|
||||
fresult = (realtype)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void _wrap_FN_VCompare_ManyVector(double const *farg1, N_Vector farg2, N_Vector farg3) {
|
||||
realtype arg1 ;
|
||||
N_Vector arg2 = (N_Vector) 0 ;
|
||||
N_Vector arg3 = (N_Vector) 0 ;
|
||||
|
||||
arg1 = (realtype)(*farg1);
|
||||
arg2 = (N_Vector)(farg2);
|
||||
arg3 = (N_Vector)(farg3);
|
||||
N_VCompare_ManyVector(arg1,arg2,arg3);
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FN_VLinearCombination_ManyVector(int const *farg1, double *farg2, void *farg3, N_Vector farg4) {
|
||||
int fresult ;
|
||||
int arg1 ;
|
||||
realtype *arg2 = (realtype *) 0 ;
|
||||
N_Vector *arg3 = (N_Vector *) 0 ;
|
||||
N_Vector arg4 = (N_Vector) 0 ;
|
||||
int result;
|
||||
|
||||
arg1 = (int)(*farg1);
|
||||
arg2 = (realtype *)(farg2);
|
||||
arg3 = (N_Vector *)(farg3);
|
||||
arg4 = (N_Vector)(farg4);
|
||||
result = (int)N_VLinearCombination_ManyVector(arg1,arg2,arg3,arg4);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FN_VScaleAddMulti_ManyVector(int const *farg1, double *farg2, N_Vector farg3, void *farg4, void *farg5) {
|
||||
int fresult ;
|
||||
int arg1 ;
|
||||
realtype *arg2 = (realtype *) 0 ;
|
||||
N_Vector arg3 = (N_Vector) 0 ;
|
||||
N_Vector *arg4 = (N_Vector *) 0 ;
|
||||
N_Vector *arg5 = (N_Vector *) 0 ;
|
||||
int result;
|
||||
|
||||
arg1 = (int)(*farg1);
|
||||
arg2 = (realtype *)(farg2);
|
||||
arg3 = (N_Vector)(farg3);
|
||||
arg4 = (N_Vector *)(farg4);
|
||||
arg5 = (N_Vector *)(farg5);
|
||||
result = (int)N_VScaleAddMulti_ManyVector(arg1,arg2,arg3,arg4,arg5);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FN_VDotProdMulti_ManyVector(int const *farg1, N_Vector farg2, void *farg3, double *farg4) {
|
||||
int fresult ;
|
||||
int arg1 ;
|
||||
N_Vector arg2 = (N_Vector) 0 ;
|
||||
N_Vector *arg3 = (N_Vector *) 0 ;
|
||||
realtype *arg4 = (realtype *) 0 ;
|
||||
int result;
|
||||
|
||||
arg1 = (int)(*farg1);
|
||||
arg2 = (N_Vector)(farg2);
|
||||
arg3 = (N_Vector *)(farg3);
|
||||
arg4 = (realtype *)(farg4);
|
||||
result = (int)N_VDotProdMulti_ManyVector(arg1,arg2,arg3,arg4);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FN_VLinearSumVectorArray_ManyVector(int const *farg1, double const *farg2, void *farg3, double const *farg4, void *farg5, void *farg6) {
|
||||
int fresult ;
|
||||
int arg1 ;
|
||||
realtype arg2 ;
|
||||
N_Vector *arg3 = (N_Vector *) 0 ;
|
||||
realtype arg4 ;
|
||||
N_Vector *arg5 = (N_Vector *) 0 ;
|
||||
N_Vector *arg6 = (N_Vector *) 0 ;
|
||||
int result;
|
||||
|
||||
arg1 = (int)(*farg1);
|
||||
arg2 = (realtype)(*farg2);
|
||||
arg3 = (N_Vector *)(farg3);
|
||||
arg4 = (realtype)(*farg4);
|
||||
arg5 = (N_Vector *)(farg5);
|
||||
arg6 = (N_Vector *)(farg6);
|
||||
result = (int)N_VLinearSumVectorArray_ManyVector(arg1,arg2,arg3,arg4,arg5,arg6);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FN_VScaleVectorArray_ManyVector(int const *farg1, double *farg2, void *farg3, void *farg4) {
|
||||
int fresult ;
|
||||
int arg1 ;
|
||||
realtype *arg2 = (realtype *) 0 ;
|
||||
N_Vector *arg3 = (N_Vector *) 0 ;
|
||||
N_Vector *arg4 = (N_Vector *) 0 ;
|
||||
int result;
|
||||
|
||||
arg1 = (int)(*farg1);
|
||||
arg2 = (realtype *)(farg2);
|
||||
arg3 = (N_Vector *)(farg3);
|
||||
arg4 = (N_Vector *)(farg4);
|
||||
result = (int)N_VScaleVectorArray_ManyVector(arg1,arg2,arg3,arg4);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FN_VConstVectorArray_ManyVector(int const *farg1, double const *farg2, void *farg3) {
|
||||
int fresult ;
|
||||
int arg1 ;
|
||||
realtype arg2 ;
|
||||
N_Vector *arg3 = (N_Vector *) 0 ;
|
||||
int result;
|
||||
|
||||
arg1 = (int)(*farg1);
|
||||
arg2 = (realtype)(*farg2);
|
||||
arg3 = (N_Vector *)(farg3);
|
||||
result = (int)N_VConstVectorArray_ManyVector(arg1,arg2,arg3);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FN_VWrmsNormVectorArray_ManyVector(int const *farg1, void *farg2, void *farg3, double *farg4) {
|
||||
int fresult ;
|
||||
int arg1 ;
|
||||
N_Vector *arg2 = (N_Vector *) 0 ;
|
||||
N_Vector *arg3 = (N_Vector *) 0 ;
|
||||
realtype *arg4 = (realtype *) 0 ;
|
||||
int result;
|
||||
|
||||
arg1 = (int)(*farg1);
|
||||
arg2 = (N_Vector *)(farg2);
|
||||
arg3 = (N_Vector *)(farg3);
|
||||
arg4 = (realtype *)(farg4);
|
||||
result = (int)N_VWrmsNormVectorArray_ManyVector(arg1,arg2,arg3,arg4);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FN_VWrmsNormMaskVectorArray_ManyVector(int const *farg1, void *farg2, void *farg3, N_Vector farg4, double *farg5) {
|
||||
int fresult ;
|
||||
int arg1 ;
|
||||
N_Vector *arg2 = (N_Vector *) 0 ;
|
||||
N_Vector *arg3 = (N_Vector *) 0 ;
|
||||
N_Vector arg4 = (N_Vector) 0 ;
|
||||
realtype *arg5 = (realtype *) 0 ;
|
||||
int result;
|
||||
|
||||
arg1 = (int)(*farg1);
|
||||
arg2 = (N_Vector *)(farg2);
|
||||
arg3 = (N_Vector *)(farg3);
|
||||
arg4 = (N_Vector)(farg4);
|
||||
arg5 = (realtype *)(farg5);
|
||||
result = (int)N_VWrmsNormMaskVectorArray_ManyVector(arg1,arg2,arg3,arg4,arg5);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT double _wrap_FN_VDotProdLocal_ManyVector(N_Vector farg1, N_Vector farg2) {
|
||||
double fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
N_Vector arg2 = (N_Vector) 0 ;
|
||||
realtype result;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
arg2 = (N_Vector)(farg2);
|
||||
result = (realtype)N_VDotProdLocal_ManyVector(arg1,arg2);
|
||||
fresult = (realtype)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT double _wrap_FN_VMaxNormLocal_ManyVector(N_Vector farg1) {
|
||||
double fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
realtype result;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
result = (realtype)N_VMaxNormLocal_ManyVector(arg1);
|
||||
fresult = (realtype)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT double _wrap_FN_VMinLocal_ManyVector(N_Vector farg1) {
|
||||
double fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
realtype result;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
result = (realtype)N_VMinLocal_ManyVector(arg1);
|
||||
fresult = (realtype)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT double _wrap_FN_VL1NormLocal_ManyVector(N_Vector farg1) {
|
||||
double fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
realtype result;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
result = (realtype)N_VL1NormLocal_ManyVector(arg1);
|
||||
fresult = (realtype)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT double _wrap_FN_VWSqrSumLocal_ManyVector(N_Vector farg1, N_Vector farg2) {
|
||||
double fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
N_Vector arg2 = (N_Vector) 0 ;
|
||||
realtype result;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
arg2 = (N_Vector)(farg2);
|
||||
result = (realtype)N_VWSqrSumLocal_ManyVector(arg1,arg2);
|
||||
fresult = (realtype)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT double _wrap_FN_VWSqrSumMaskLocal_ManyVector(N_Vector farg1, N_Vector farg2, N_Vector farg3) {
|
||||
double fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
N_Vector arg2 = (N_Vector) 0 ;
|
||||
N_Vector arg3 = (N_Vector) 0 ;
|
||||
realtype result;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
arg2 = (N_Vector)(farg2);
|
||||
arg3 = (N_Vector)(farg3);
|
||||
result = (realtype)N_VWSqrSumMaskLocal_ManyVector(arg1,arg2,arg3);
|
||||
fresult = (realtype)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FN_VInvTestLocal_ManyVector(N_Vector farg1, N_Vector farg2) {
|
||||
int fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
N_Vector arg2 = (N_Vector) 0 ;
|
||||
int result;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
arg2 = (N_Vector)(farg2);
|
||||
result = (int)N_VInvTestLocal_ManyVector(arg1,arg2);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FN_VConstrMaskLocal_ManyVector(N_Vector farg1, N_Vector farg2, N_Vector farg3) {
|
||||
int fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
N_Vector arg2 = (N_Vector) 0 ;
|
||||
N_Vector arg3 = (N_Vector) 0 ;
|
||||
int result;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
arg2 = (N_Vector)(farg2);
|
||||
arg3 = (N_Vector)(farg3);
|
||||
result = (int)N_VConstrMaskLocal_ManyVector(arg1,arg2,arg3);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT double _wrap_FN_VMinQuotientLocal_ManyVector(N_Vector farg1, N_Vector farg2) {
|
||||
double fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
N_Vector arg2 = (N_Vector) 0 ;
|
||||
realtype result;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
arg2 = (N_Vector)(farg2);
|
||||
result = (realtype)N_VMinQuotientLocal_ManyVector(arg1,arg2);
|
||||
fresult = (realtype)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FN_VEnableFusedOps_ManyVector(N_Vector farg1, int const *farg2) {
|
||||
int fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
int arg2 ;
|
||||
int result;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
arg2 = (int)(*farg2);
|
||||
result = (int)N_VEnableFusedOps_ManyVector(arg1,arg2);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FN_VEnableLinearCombination_ManyVector(N_Vector farg1, int const *farg2) {
|
||||
int fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
int arg2 ;
|
||||
int result;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
arg2 = (int)(*farg2);
|
||||
result = (int)N_VEnableLinearCombination_ManyVector(arg1,arg2);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FN_VEnableScaleAddMulti_ManyVector(N_Vector farg1, int const *farg2) {
|
||||
int fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
int arg2 ;
|
||||
int result;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
arg2 = (int)(*farg2);
|
||||
result = (int)N_VEnableScaleAddMulti_ManyVector(arg1,arg2);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FN_VEnableDotProdMulti_ManyVector(N_Vector farg1, int const *farg2) {
|
||||
int fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
int arg2 ;
|
||||
int result;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
arg2 = (int)(*farg2);
|
||||
result = (int)N_VEnableDotProdMulti_ManyVector(arg1,arg2);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FN_VEnableLinearSumVectorArray_ManyVector(N_Vector farg1, int const *farg2) {
|
||||
int fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
int arg2 ;
|
||||
int result;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
arg2 = (int)(*farg2);
|
||||
result = (int)N_VEnableLinearSumVectorArray_ManyVector(arg1,arg2);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FN_VEnableScaleVectorArray_ManyVector(N_Vector farg1, int const *farg2) {
|
||||
int fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
int arg2 ;
|
||||
int result;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
arg2 = (int)(*farg2);
|
||||
result = (int)N_VEnableScaleVectorArray_ManyVector(arg1,arg2);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FN_VEnableConstVectorArray_ManyVector(N_Vector farg1, int const *farg2) {
|
||||
int fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
int arg2 ;
|
||||
int result;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
arg2 = (int)(*farg2);
|
||||
result = (int)N_VEnableConstVectorArray_ManyVector(arg1,arg2);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FN_VEnableWrmsNormVectorArray_ManyVector(N_Vector farg1, int const *farg2) {
|
||||
int fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
int arg2 ;
|
||||
int result;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
arg2 = (int)(*farg2);
|
||||
result = (int)N_VEnableWrmsNormVectorArray_ManyVector(arg1,arg2);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FN_VEnableWrmsNormMaskVectorArray_ManyVector(N_Vector farg1, int const *farg2) {
|
||||
int fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
int arg2 ;
|
||||
int result;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
arg2 = (int)(*farg2);
|
||||
result = (int)N_VEnableWrmsNormMaskVectorArray_ManyVector(arg1,arg2);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
|
||||
1837
bazaar/plugin/sundials/src/nvector/manyvector/nvector_manyvector.c
Normal file
1837
bazaar/plugin/sundials/src/nvector/manyvector/nvector_manyvector.c
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,945 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
* This file was automatically generated by SWIG (http://www.swig.org).
|
||||
* Version 4.0.0
|
||||
*
|
||||
* This file is not intended to be easily readable and contains a number of
|
||||
* coding conventions designed to improve portability and efficiency. Do not make
|
||||
* changes to this file unless you know what you are doing--modify the SWIG
|
||||
* interface file instead.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
/* ---------------------------------------------------------------
|
||||
* Programmer(s): Auto-generated by swig.
|
||||
* ---------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
* -------------------------------------------------------------*/
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* This section contains generic SWIG labels for method/variable
|
||||
* declarations/attributes, and other compiler dependent labels.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
/* template workaround for compilers that cannot correctly implement the C++ standard */
|
||||
#ifndef SWIGTEMPLATEDISAMBIGUATOR
|
||||
# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560)
|
||||
# define SWIGTEMPLATEDISAMBIGUATOR template
|
||||
# elif defined(__HP_aCC)
|
||||
/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */
|
||||
/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */
|
||||
# define SWIGTEMPLATEDISAMBIGUATOR template
|
||||
# else
|
||||
# define SWIGTEMPLATEDISAMBIGUATOR
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* inline attribute */
|
||||
#ifndef SWIGINLINE
|
||||
# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__))
|
||||
# define SWIGINLINE inline
|
||||
# else
|
||||
# define SWIGINLINE
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* attribute recognised by some compilers to avoid 'unused' warnings */
|
||||
#ifndef SWIGUNUSED
|
||||
# if defined(__GNUC__)
|
||||
# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
|
||||
# define SWIGUNUSED __attribute__ ((__unused__))
|
||||
# else
|
||||
# define SWIGUNUSED
|
||||
# endif
|
||||
# elif defined(__ICC)
|
||||
# define SWIGUNUSED __attribute__ ((__unused__))
|
||||
# else
|
||||
# define SWIGUNUSED
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef SWIG_MSC_UNSUPPRESS_4505
|
||||
# if defined(_MSC_VER)
|
||||
# pragma warning(disable : 4505) /* unreferenced local function has been removed */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef SWIGUNUSEDPARM
|
||||
# ifdef __cplusplus
|
||||
# define SWIGUNUSEDPARM(p)
|
||||
# else
|
||||
# define SWIGUNUSEDPARM(p) p SWIGUNUSED
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* internal SWIG method */
|
||||
#ifndef SWIGINTERN
|
||||
# define SWIGINTERN static SWIGUNUSED
|
||||
#endif
|
||||
|
||||
/* internal inline SWIG method */
|
||||
#ifndef SWIGINTERNINLINE
|
||||
# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE
|
||||
#endif
|
||||
|
||||
/* qualifier for exported *const* global data variables*/
|
||||
#ifndef SWIGEXTERN
|
||||
# ifdef __cplusplus
|
||||
# define SWIGEXTERN extern
|
||||
# else
|
||||
# define SWIGEXTERN
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* exporting methods */
|
||||
#if defined(__GNUC__)
|
||||
# if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
|
||||
# ifndef GCC_HASCLASSVISIBILITY
|
||||
# define GCC_HASCLASSVISIBILITY
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef SWIGEXPORT
|
||||
# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
|
||||
# if defined(STATIC_LINKED)
|
||||
# define SWIGEXPORT
|
||||
# else
|
||||
# define SWIGEXPORT __declspec(dllexport)
|
||||
# endif
|
||||
# else
|
||||
# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY)
|
||||
# define SWIGEXPORT __attribute__ ((visibility("default")))
|
||||
# else
|
||||
# define SWIGEXPORT
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* calling conventions for Windows */
|
||||
#ifndef SWIGSTDCALL
|
||||
# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
|
||||
# define SWIGSTDCALL __stdcall
|
||||
# else
|
||||
# define SWIGSTDCALL
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
|
||||
#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
|
||||
# define _CRT_SECURE_NO_DEPRECATE
|
||||
#endif
|
||||
|
||||
/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */
|
||||
#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE)
|
||||
# define _SCL_SECURE_NO_DEPRECATE
|
||||
#endif
|
||||
|
||||
/* Deal with Apple's deprecated 'AssertMacros.h' from Carbon-framework */
|
||||
#if defined(__APPLE__) && !defined(__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES)
|
||||
# define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0
|
||||
#endif
|
||||
|
||||
/* Intel's compiler complains if a variable which was never initialised is
|
||||
* cast to void, which is a common idiom which we use to indicate that we
|
||||
* are aware a variable isn't used. So we just silence that warning.
|
||||
* See: https://github.com/swig/swig/issues/192 for more discussion.
|
||||
*/
|
||||
#ifdef __INTEL_COMPILER
|
||||
# pragma warning disable 592
|
||||
#endif
|
||||
|
||||
/* Errors in SWIG */
|
||||
#define SWIG_UnknownError -1
|
||||
#define SWIG_IOError -2
|
||||
#define SWIG_RuntimeError -3
|
||||
#define SWIG_IndexError -4
|
||||
#define SWIG_TypeError -5
|
||||
#define SWIG_DivisionByZero -6
|
||||
#define SWIG_OverflowError -7
|
||||
#define SWIG_SyntaxError -8
|
||||
#define SWIG_ValueError -9
|
||||
#define SWIG_SystemError -10
|
||||
#define SWIG_AttributeError -11
|
||||
#define SWIG_MemoryError -12
|
||||
#define SWIG_NullReferenceError -13
|
||||
|
||||
|
||||
|
||||
|
||||
#include <assert.h>
|
||||
#define SWIG_exception_impl(DECL, CODE, MSG, RETURNNULL) \
|
||||
{ printf("In " DECL ": " MSG); assert(0); RETURNNULL; }
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM)
|
||||
# ifndef snprintf
|
||||
# define snprintf _snprintf
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
/* Support for the `contract` feature.
|
||||
*
|
||||
* Note that RETURNNULL is first because it's inserted via a 'Replaceall' in
|
||||
* the fortran.cxx file.
|
||||
*/
|
||||
#define SWIG_contract_assert(RETURNNULL, EXPR, MSG) \
|
||||
if (!(EXPR)) { SWIG_exception_impl("$decl", SWIG_ValueError, MSG, RETURNNULL); }
|
||||
|
||||
|
||||
#define SWIGVERSION 0x040000
|
||||
#define SWIG_VERSION SWIGVERSION
|
||||
|
||||
|
||||
#define SWIG_as_voidptr(a) (void *)((const void *)(a))
|
||||
#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a))
|
||||
|
||||
|
||||
#include "sundials/sundials_nvector.h"
|
||||
|
||||
|
||||
#include "nvector/nvector_serial.h"
|
||||
|
||||
SWIGEXPORT N_Vector _wrap_FN_VNew_Serial(int64_t const *farg1) {
|
||||
N_Vector fresult ;
|
||||
sunindextype arg1 ;
|
||||
N_Vector result;
|
||||
|
||||
arg1 = (sunindextype)(*farg1);
|
||||
result = (N_Vector)N_VNew_Serial(arg1);
|
||||
fresult = result;
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT N_Vector _wrap_FN_VNewEmpty_Serial(int64_t const *farg1) {
|
||||
N_Vector fresult ;
|
||||
sunindextype arg1 ;
|
||||
N_Vector result;
|
||||
|
||||
arg1 = (sunindextype)(*farg1);
|
||||
result = (N_Vector)N_VNewEmpty_Serial(arg1);
|
||||
fresult = result;
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT N_Vector _wrap_FN_VMake_Serial(int64_t const *farg1, double *farg2) {
|
||||
N_Vector fresult ;
|
||||
sunindextype arg1 ;
|
||||
realtype *arg2 = (realtype *) 0 ;
|
||||
N_Vector result;
|
||||
|
||||
arg1 = (sunindextype)(*farg1);
|
||||
arg2 = (realtype *)(farg2);
|
||||
result = (N_Vector)N_VMake_Serial(arg1,arg2);
|
||||
fresult = result;
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void * _wrap_FN_VCloneVectorArray_Serial(int const *farg1, N_Vector farg2) {
|
||||
void * fresult ;
|
||||
int arg1 ;
|
||||
N_Vector arg2 = (N_Vector) 0 ;
|
||||
N_Vector *result = 0 ;
|
||||
|
||||
arg1 = (int)(*farg1);
|
||||
arg2 = (N_Vector)(farg2);
|
||||
result = (N_Vector *)N_VCloneVectorArray_Serial(arg1,arg2);
|
||||
fresult = result;
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void * _wrap_FN_VCloneVectorArrayEmpty_Serial(int const *farg1, N_Vector farg2) {
|
||||
void * fresult ;
|
||||
int arg1 ;
|
||||
N_Vector arg2 = (N_Vector) 0 ;
|
||||
N_Vector *result = 0 ;
|
||||
|
||||
arg1 = (int)(*farg1);
|
||||
arg2 = (N_Vector)(farg2);
|
||||
result = (N_Vector *)N_VCloneVectorArrayEmpty_Serial(arg1,arg2);
|
||||
fresult = result;
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void _wrap_FN_VDestroyVectorArray_Serial(void *farg1, int const *farg2) {
|
||||
N_Vector *arg1 = (N_Vector *) 0 ;
|
||||
int arg2 ;
|
||||
|
||||
arg1 = (N_Vector *)(farg1);
|
||||
arg2 = (int)(*farg2);
|
||||
N_VDestroyVectorArray_Serial(arg1,arg2);
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int64_t _wrap_FN_VGetLength_Serial(N_Vector farg1) {
|
||||
int64_t fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
sunindextype result;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
result = N_VGetLength_Serial(arg1);
|
||||
fresult = (sunindextype)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void _wrap_FN_VPrint_Serial(N_Vector farg1) {
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
N_VPrint_Serial(arg1);
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void _wrap_FN_VPrintFile_Serial(N_Vector farg1, void *farg2) {
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
FILE *arg2 = (FILE *) 0 ;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
arg2 = (FILE *)(farg2);
|
||||
N_VPrintFile_Serial(arg1,arg2);
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FN_VGetVectorID_Serial(N_Vector farg1) {
|
||||
int fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
N_Vector_ID result;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
result = (N_Vector_ID)N_VGetVectorID_Serial(arg1);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT N_Vector _wrap_FN_VCloneEmpty_Serial(N_Vector farg1) {
|
||||
N_Vector fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
N_Vector result;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
result = (N_Vector)N_VCloneEmpty_Serial(arg1);
|
||||
fresult = result;
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT N_Vector _wrap_FN_VClone_Serial(N_Vector farg1) {
|
||||
N_Vector fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
N_Vector result;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
result = (N_Vector)N_VClone_Serial(arg1);
|
||||
fresult = result;
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void _wrap_FN_VDestroy_Serial(N_Vector farg1) {
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
N_VDestroy_Serial(arg1);
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void _wrap_FN_VSpace_Serial(N_Vector farg1, int64_t *farg2, int64_t *farg3) {
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
sunindextype *arg2 = (sunindextype *) 0 ;
|
||||
sunindextype *arg3 = (sunindextype *) 0 ;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
arg2 = (sunindextype *)(farg2);
|
||||
arg3 = (sunindextype *)(farg3);
|
||||
N_VSpace_Serial(arg1,arg2,arg3);
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT double * _wrap_FN_VGetArrayPointer_Serial(N_Vector farg1) {
|
||||
double * fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
realtype *result = 0 ;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
result = (realtype *)N_VGetArrayPointer_Serial(arg1);
|
||||
fresult = result;
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void _wrap_FN_VSetArrayPointer_Serial(double *farg1, N_Vector farg2) {
|
||||
realtype *arg1 = (realtype *) 0 ;
|
||||
N_Vector arg2 = (N_Vector) 0 ;
|
||||
|
||||
arg1 = (realtype *)(farg1);
|
||||
arg2 = (N_Vector)(farg2);
|
||||
N_VSetArrayPointer_Serial(arg1,arg2);
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void _wrap_FN_VLinearSum_Serial(double const *farg1, N_Vector farg2, double const *farg3, N_Vector farg4, N_Vector farg5) {
|
||||
realtype arg1 ;
|
||||
N_Vector arg2 = (N_Vector) 0 ;
|
||||
realtype arg3 ;
|
||||
N_Vector arg4 = (N_Vector) 0 ;
|
||||
N_Vector arg5 = (N_Vector) 0 ;
|
||||
|
||||
arg1 = (realtype)(*farg1);
|
||||
arg2 = (N_Vector)(farg2);
|
||||
arg3 = (realtype)(*farg3);
|
||||
arg4 = (N_Vector)(farg4);
|
||||
arg5 = (N_Vector)(farg5);
|
||||
N_VLinearSum_Serial(arg1,arg2,arg3,arg4,arg5);
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void _wrap_FN_VConst_Serial(double const *farg1, N_Vector farg2) {
|
||||
realtype arg1 ;
|
||||
N_Vector arg2 = (N_Vector) 0 ;
|
||||
|
||||
arg1 = (realtype)(*farg1);
|
||||
arg2 = (N_Vector)(farg2);
|
||||
N_VConst_Serial(arg1,arg2);
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void _wrap_FN_VProd_Serial(N_Vector farg1, N_Vector farg2, N_Vector farg3) {
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
N_Vector arg2 = (N_Vector) 0 ;
|
||||
N_Vector arg3 = (N_Vector) 0 ;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
arg2 = (N_Vector)(farg2);
|
||||
arg3 = (N_Vector)(farg3);
|
||||
N_VProd_Serial(arg1,arg2,arg3);
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void _wrap_FN_VDiv_Serial(N_Vector farg1, N_Vector farg2, N_Vector farg3) {
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
N_Vector arg2 = (N_Vector) 0 ;
|
||||
N_Vector arg3 = (N_Vector) 0 ;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
arg2 = (N_Vector)(farg2);
|
||||
arg3 = (N_Vector)(farg3);
|
||||
N_VDiv_Serial(arg1,arg2,arg3);
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void _wrap_FN_VScale_Serial(double const *farg1, N_Vector farg2, N_Vector farg3) {
|
||||
realtype arg1 ;
|
||||
N_Vector arg2 = (N_Vector) 0 ;
|
||||
N_Vector arg3 = (N_Vector) 0 ;
|
||||
|
||||
arg1 = (realtype)(*farg1);
|
||||
arg2 = (N_Vector)(farg2);
|
||||
arg3 = (N_Vector)(farg3);
|
||||
N_VScale_Serial(arg1,arg2,arg3);
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void _wrap_FN_VAbs_Serial(N_Vector farg1, N_Vector farg2) {
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
N_Vector arg2 = (N_Vector) 0 ;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
arg2 = (N_Vector)(farg2);
|
||||
N_VAbs_Serial(arg1,arg2);
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void _wrap_FN_VInv_Serial(N_Vector farg1, N_Vector farg2) {
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
N_Vector arg2 = (N_Vector) 0 ;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
arg2 = (N_Vector)(farg2);
|
||||
N_VInv_Serial(arg1,arg2);
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void _wrap_FN_VAddConst_Serial(N_Vector farg1, double const *farg2, N_Vector farg3) {
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
realtype arg2 ;
|
||||
N_Vector arg3 = (N_Vector) 0 ;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
arg2 = (realtype)(*farg2);
|
||||
arg3 = (N_Vector)(farg3);
|
||||
N_VAddConst_Serial(arg1,arg2,arg3);
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT double _wrap_FN_VDotProd_Serial(N_Vector farg1, N_Vector farg2) {
|
||||
double fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
N_Vector arg2 = (N_Vector) 0 ;
|
||||
realtype result;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
arg2 = (N_Vector)(farg2);
|
||||
result = (realtype)N_VDotProd_Serial(arg1,arg2);
|
||||
fresult = (realtype)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT double _wrap_FN_VMaxNorm_Serial(N_Vector farg1) {
|
||||
double fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
realtype result;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
result = (realtype)N_VMaxNorm_Serial(arg1);
|
||||
fresult = (realtype)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT double _wrap_FN_VWrmsNorm_Serial(N_Vector farg1, N_Vector farg2) {
|
||||
double fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
N_Vector arg2 = (N_Vector) 0 ;
|
||||
realtype result;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
arg2 = (N_Vector)(farg2);
|
||||
result = (realtype)N_VWrmsNorm_Serial(arg1,arg2);
|
||||
fresult = (realtype)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT double _wrap_FN_VWrmsNormMask_Serial(N_Vector farg1, N_Vector farg2, N_Vector farg3) {
|
||||
double fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
N_Vector arg2 = (N_Vector) 0 ;
|
||||
N_Vector arg3 = (N_Vector) 0 ;
|
||||
realtype result;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
arg2 = (N_Vector)(farg2);
|
||||
arg3 = (N_Vector)(farg3);
|
||||
result = (realtype)N_VWrmsNormMask_Serial(arg1,arg2,arg3);
|
||||
fresult = (realtype)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT double _wrap_FN_VMin_Serial(N_Vector farg1) {
|
||||
double fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
realtype result;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
result = (realtype)N_VMin_Serial(arg1);
|
||||
fresult = (realtype)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT double _wrap_FN_VWL2Norm_Serial(N_Vector farg1, N_Vector farg2) {
|
||||
double fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
N_Vector arg2 = (N_Vector) 0 ;
|
||||
realtype result;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
arg2 = (N_Vector)(farg2);
|
||||
result = (realtype)N_VWL2Norm_Serial(arg1,arg2);
|
||||
fresult = (realtype)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT double _wrap_FN_VL1Norm_Serial(N_Vector farg1) {
|
||||
double fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
realtype result;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
result = (realtype)N_VL1Norm_Serial(arg1);
|
||||
fresult = (realtype)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void _wrap_FN_VCompare_Serial(double const *farg1, N_Vector farg2, N_Vector farg3) {
|
||||
realtype arg1 ;
|
||||
N_Vector arg2 = (N_Vector) 0 ;
|
||||
N_Vector arg3 = (N_Vector) 0 ;
|
||||
|
||||
arg1 = (realtype)(*farg1);
|
||||
arg2 = (N_Vector)(farg2);
|
||||
arg3 = (N_Vector)(farg3);
|
||||
N_VCompare_Serial(arg1,arg2,arg3);
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FN_VInvTest_Serial(N_Vector farg1, N_Vector farg2) {
|
||||
int fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
N_Vector arg2 = (N_Vector) 0 ;
|
||||
int result;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
arg2 = (N_Vector)(farg2);
|
||||
result = (int)N_VInvTest_Serial(arg1,arg2);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FN_VConstrMask_Serial(N_Vector farg1, N_Vector farg2, N_Vector farg3) {
|
||||
int fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
N_Vector arg2 = (N_Vector) 0 ;
|
||||
N_Vector arg3 = (N_Vector) 0 ;
|
||||
int result;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
arg2 = (N_Vector)(farg2);
|
||||
arg3 = (N_Vector)(farg3);
|
||||
result = (int)N_VConstrMask_Serial(arg1,arg2,arg3);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT double _wrap_FN_VMinQuotient_Serial(N_Vector farg1, N_Vector farg2) {
|
||||
double fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
N_Vector arg2 = (N_Vector) 0 ;
|
||||
realtype result;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
arg2 = (N_Vector)(farg2);
|
||||
result = (realtype)N_VMinQuotient_Serial(arg1,arg2);
|
||||
fresult = (realtype)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FN_VLinearCombination_Serial(int const *farg1, double *farg2, void *farg3, N_Vector farg4) {
|
||||
int fresult ;
|
||||
int arg1 ;
|
||||
realtype *arg2 = (realtype *) 0 ;
|
||||
N_Vector *arg3 = (N_Vector *) 0 ;
|
||||
N_Vector arg4 = (N_Vector) 0 ;
|
||||
int result;
|
||||
|
||||
arg1 = (int)(*farg1);
|
||||
arg2 = (realtype *)(farg2);
|
||||
arg3 = (N_Vector *)(farg3);
|
||||
arg4 = (N_Vector)(farg4);
|
||||
result = (int)N_VLinearCombination_Serial(arg1,arg2,arg3,arg4);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FN_VScaleAddMulti_Serial(int const *farg1, double *farg2, N_Vector farg3, void *farg4, void *farg5) {
|
||||
int fresult ;
|
||||
int arg1 ;
|
||||
realtype *arg2 = (realtype *) 0 ;
|
||||
N_Vector arg3 = (N_Vector) 0 ;
|
||||
N_Vector *arg4 = (N_Vector *) 0 ;
|
||||
N_Vector *arg5 = (N_Vector *) 0 ;
|
||||
int result;
|
||||
|
||||
arg1 = (int)(*farg1);
|
||||
arg2 = (realtype *)(farg2);
|
||||
arg3 = (N_Vector)(farg3);
|
||||
arg4 = (N_Vector *)(farg4);
|
||||
arg5 = (N_Vector *)(farg5);
|
||||
result = (int)N_VScaleAddMulti_Serial(arg1,arg2,arg3,arg4,arg5);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FN_VDotProdMulti_Serial(int const *farg1, N_Vector farg2, void *farg3, double *farg4) {
|
||||
int fresult ;
|
||||
int arg1 ;
|
||||
N_Vector arg2 = (N_Vector) 0 ;
|
||||
N_Vector *arg3 = (N_Vector *) 0 ;
|
||||
realtype *arg4 = (realtype *) 0 ;
|
||||
int result;
|
||||
|
||||
arg1 = (int)(*farg1);
|
||||
arg2 = (N_Vector)(farg2);
|
||||
arg3 = (N_Vector *)(farg3);
|
||||
arg4 = (realtype *)(farg4);
|
||||
result = (int)N_VDotProdMulti_Serial(arg1,arg2,arg3,arg4);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FN_VLinearSumVectorArray_Serial(int const *farg1, double const *farg2, void *farg3, double const *farg4, void *farg5, void *farg6) {
|
||||
int fresult ;
|
||||
int arg1 ;
|
||||
realtype arg2 ;
|
||||
N_Vector *arg3 = (N_Vector *) 0 ;
|
||||
realtype arg4 ;
|
||||
N_Vector *arg5 = (N_Vector *) 0 ;
|
||||
N_Vector *arg6 = (N_Vector *) 0 ;
|
||||
int result;
|
||||
|
||||
arg1 = (int)(*farg1);
|
||||
arg2 = (realtype)(*farg2);
|
||||
arg3 = (N_Vector *)(farg3);
|
||||
arg4 = (realtype)(*farg4);
|
||||
arg5 = (N_Vector *)(farg5);
|
||||
arg6 = (N_Vector *)(farg6);
|
||||
result = (int)N_VLinearSumVectorArray_Serial(arg1,arg2,arg3,arg4,arg5,arg6);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FN_VScaleVectorArray_Serial(int const *farg1, double *farg2, void *farg3, void *farg4) {
|
||||
int fresult ;
|
||||
int arg1 ;
|
||||
realtype *arg2 = (realtype *) 0 ;
|
||||
N_Vector *arg3 = (N_Vector *) 0 ;
|
||||
N_Vector *arg4 = (N_Vector *) 0 ;
|
||||
int result;
|
||||
|
||||
arg1 = (int)(*farg1);
|
||||
arg2 = (realtype *)(farg2);
|
||||
arg3 = (N_Vector *)(farg3);
|
||||
arg4 = (N_Vector *)(farg4);
|
||||
result = (int)N_VScaleVectorArray_Serial(arg1,arg2,arg3,arg4);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FN_VConstVectorArray_Serial(int const *farg1, double const *farg2, void *farg3) {
|
||||
int fresult ;
|
||||
int arg1 ;
|
||||
realtype arg2 ;
|
||||
N_Vector *arg3 = (N_Vector *) 0 ;
|
||||
int result;
|
||||
|
||||
arg1 = (int)(*farg1);
|
||||
arg2 = (realtype)(*farg2);
|
||||
arg3 = (N_Vector *)(farg3);
|
||||
result = (int)N_VConstVectorArray_Serial(arg1,arg2,arg3);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FN_VWrmsNormVectorArray_Serial(int const *farg1, void *farg2, void *farg3, double *farg4) {
|
||||
int fresult ;
|
||||
int arg1 ;
|
||||
N_Vector *arg2 = (N_Vector *) 0 ;
|
||||
N_Vector *arg3 = (N_Vector *) 0 ;
|
||||
realtype *arg4 = (realtype *) 0 ;
|
||||
int result;
|
||||
|
||||
arg1 = (int)(*farg1);
|
||||
arg2 = (N_Vector *)(farg2);
|
||||
arg3 = (N_Vector *)(farg3);
|
||||
arg4 = (realtype *)(farg4);
|
||||
result = (int)N_VWrmsNormVectorArray_Serial(arg1,arg2,arg3,arg4);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FN_VWrmsNormMaskVectorArray_Serial(int const *farg1, void *farg2, void *farg3, N_Vector farg4, double *farg5) {
|
||||
int fresult ;
|
||||
int arg1 ;
|
||||
N_Vector *arg2 = (N_Vector *) 0 ;
|
||||
N_Vector *arg3 = (N_Vector *) 0 ;
|
||||
N_Vector arg4 = (N_Vector) 0 ;
|
||||
realtype *arg5 = (realtype *) 0 ;
|
||||
int result;
|
||||
|
||||
arg1 = (int)(*farg1);
|
||||
arg2 = (N_Vector *)(farg2);
|
||||
arg3 = (N_Vector *)(farg3);
|
||||
arg4 = (N_Vector)(farg4);
|
||||
arg5 = (realtype *)(farg5);
|
||||
result = (int)N_VWrmsNormMaskVectorArray_Serial(arg1,arg2,arg3,arg4,arg5);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT double _wrap_FN_VWSqrSumLocal_Serial(N_Vector farg1, N_Vector farg2) {
|
||||
double fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
N_Vector arg2 = (N_Vector) 0 ;
|
||||
realtype result;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
arg2 = (N_Vector)(farg2);
|
||||
result = (realtype)N_VWSqrSumLocal_Serial(arg1,arg2);
|
||||
fresult = (realtype)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT double _wrap_FN_VWSqrSumMaskLocal_Serial(N_Vector farg1, N_Vector farg2, N_Vector farg3) {
|
||||
double fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
N_Vector arg2 = (N_Vector) 0 ;
|
||||
N_Vector arg3 = (N_Vector) 0 ;
|
||||
realtype result;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
arg2 = (N_Vector)(farg2);
|
||||
arg3 = (N_Vector)(farg3);
|
||||
result = (realtype)N_VWSqrSumMaskLocal_Serial(arg1,arg2,arg3);
|
||||
fresult = (realtype)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FN_VEnableFusedOps_Serial(N_Vector farg1, int const *farg2) {
|
||||
int fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
int arg2 ;
|
||||
int result;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
arg2 = (int)(*farg2);
|
||||
result = (int)N_VEnableFusedOps_Serial(arg1,arg2);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FN_VEnableLinearCombination_Serial(N_Vector farg1, int const *farg2) {
|
||||
int fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
int arg2 ;
|
||||
int result;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
arg2 = (int)(*farg2);
|
||||
result = (int)N_VEnableLinearCombination_Serial(arg1,arg2);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FN_VEnableScaleAddMulti_Serial(N_Vector farg1, int const *farg2) {
|
||||
int fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
int arg2 ;
|
||||
int result;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
arg2 = (int)(*farg2);
|
||||
result = (int)N_VEnableScaleAddMulti_Serial(arg1,arg2);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FN_VEnableDotProdMulti_Serial(N_Vector farg1, int const *farg2) {
|
||||
int fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
int arg2 ;
|
||||
int result;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
arg2 = (int)(*farg2);
|
||||
result = (int)N_VEnableDotProdMulti_Serial(arg1,arg2);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FN_VEnableLinearSumVectorArray_Serial(N_Vector farg1, int const *farg2) {
|
||||
int fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
int arg2 ;
|
||||
int result;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
arg2 = (int)(*farg2);
|
||||
result = (int)N_VEnableLinearSumVectorArray_Serial(arg1,arg2);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FN_VEnableScaleVectorArray_Serial(N_Vector farg1, int const *farg2) {
|
||||
int fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
int arg2 ;
|
||||
int result;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
arg2 = (int)(*farg2);
|
||||
result = (int)N_VEnableScaleVectorArray_Serial(arg1,arg2);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FN_VEnableConstVectorArray_Serial(N_Vector farg1, int const *farg2) {
|
||||
int fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
int arg2 ;
|
||||
int result;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
arg2 = (int)(*farg2);
|
||||
result = (int)N_VEnableConstVectorArray_Serial(arg1,arg2);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FN_VEnableWrmsNormVectorArray_Serial(N_Vector farg1, int const *farg2) {
|
||||
int fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
int arg2 ;
|
||||
int result;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
arg2 = (int)(*farg2);
|
||||
result = (int)N_VEnableWrmsNormVectorArray_Serial(arg1,arg2);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FN_VEnableWrmsNormMaskVectorArray_Serial(N_Vector farg1, int const *farg2) {
|
||||
int fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
int arg2 ;
|
||||
int result;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
arg2 = (int)(*farg2);
|
||||
result = (int)N_VEnableWrmsNormMaskVectorArray_Serial(arg1,arg2);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
|
||||
154
bazaar/plugin/sundials/src/nvector/serial/fnvector_serial.c
Normal file
154
bazaar/plugin/sundials/src/nvector/serial/fnvector_serial.c
Normal file
|
|
@ -0,0 +1,154 @@
|
|||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Programmer(s): Radu Serban @ LLNL
|
||||
* -----------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
* -----------------------------------------------------------------
|
||||
* This file (companion of nvector_serial.h) contains the
|
||||
* implementation needed for the Fortran initialization of serial
|
||||
* vector operations.
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "fnvector_serial.h"
|
||||
|
||||
/* Define global vector variables */
|
||||
|
||||
N_Vector F2C_CVODE_vec;
|
||||
N_Vector F2C_CVODE_vecQ;
|
||||
N_Vector *F2C_CVODE_vecS;
|
||||
N_Vector F2C_CVODE_vecB;
|
||||
N_Vector F2C_CVODE_vecQB;
|
||||
|
||||
N_Vector F2C_IDA_vec;
|
||||
N_Vector F2C_IDA_vecQ;
|
||||
N_Vector *F2C_IDA_vecS;
|
||||
N_Vector F2C_IDA_vecB;
|
||||
N_Vector F2C_IDA_vecQB;
|
||||
|
||||
N_Vector F2C_KINSOL_vec;
|
||||
|
||||
N_Vector F2C_ARKODE_vec;
|
||||
|
||||
/* Fortran callable interfaces */
|
||||
|
||||
void FNV_INITS(int *code, long int *N, int *ier)
|
||||
{
|
||||
*ier = 0;
|
||||
|
||||
switch(*code) {
|
||||
case FCMIX_CVODE:
|
||||
F2C_CVODE_vec = NULL;
|
||||
F2C_CVODE_vec = N_VNewEmpty_Serial((sunindextype)(*N));
|
||||
if (F2C_CVODE_vec == NULL) *ier = -1;
|
||||
break;
|
||||
case FCMIX_IDA:
|
||||
F2C_IDA_vec = NULL;
|
||||
F2C_IDA_vec = N_VNewEmpty_Serial((sunindextype)(*N));
|
||||
if (F2C_IDA_vec == NULL) *ier = -1;
|
||||
break;
|
||||
case FCMIX_KINSOL:
|
||||
F2C_KINSOL_vec = NULL;
|
||||
F2C_KINSOL_vec = N_VNewEmpty_Serial((sunindextype)(*N));
|
||||
if (F2C_KINSOL_vec == NULL) *ier = -1;
|
||||
break;
|
||||
case FCMIX_ARKODE:
|
||||
F2C_ARKODE_vec = NULL;
|
||||
F2C_ARKODE_vec = N_VNewEmpty_Serial((sunindextype)(*N));
|
||||
if (F2C_ARKODE_vec == NULL) *ier = -1;
|
||||
break;
|
||||
default:
|
||||
*ier = -1;
|
||||
}
|
||||
}
|
||||
|
||||
void FNV_INITS_Q(int *code, long int *Nq, int *ier)
|
||||
{
|
||||
*ier = 0;
|
||||
|
||||
switch(*code) {
|
||||
case FCMIX_CVODE:
|
||||
F2C_CVODE_vecQ = NULL;
|
||||
F2C_CVODE_vecQ = N_VNewEmpty_Serial((sunindextype)(*Nq));
|
||||
if (F2C_CVODE_vecQ == NULL) *ier = -1;
|
||||
break;
|
||||
case FCMIX_IDA:
|
||||
F2C_IDA_vecQ = NULL;
|
||||
F2C_IDA_vecQ = N_VNewEmpty_Serial((sunindextype)(*Nq));
|
||||
if (F2C_IDA_vecQ == NULL) *ier = -1;
|
||||
break;
|
||||
default:
|
||||
*ier = -1;
|
||||
}
|
||||
}
|
||||
|
||||
void FNV_INITS_B(int *code, long int *NB, int *ier)
|
||||
{
|
||||
*ier = 0;
|
||||
|
||||
switch(*code) {
|
||||
case FCMIX_CVODE:
|
||||
F2C_CVODE_vecB = NULL;
|
||||
F2C_CVODE_vecB = N_VNewEmpty_Serial((sunindextype)(*NB));
|
||||
if (F2C_CVODE_vecB == NULL) *ier = -1;
|
||||
break;
|
||||
case FCMIX_IDA:
|
||||
F2C_IDA_vecB = NULL;
|
||||
F2C_IDA_vecB = N_VNewEmpty_Serial((sunindextype)(*NB));
|
||||
if (F2C_IDA_vecB == NULL) *ier = -1;
|
||||
break;
|
||||
default:
|
||||
*ier = -1;
|
||||
}
|
||||
}
|
||||
|
||||
void FNV_INITS_QB(int *code, long int *NqB, int *ier)
|
||||
{
|
||||
*ier = 0;
|
||||
|
||||
switch(*code) {
|
||||
case FCMIX_CVODE:
|
||||
F2C_CVODE_vecQB = NULL;
|
||||
F2C_CVODE_vecQB = N_VNewEmpty_Serial((sunindextype)(*NqB));
|
||||
if (F2C_CVODE_vecQB == NULL) *ier = -1;
|
||||
break;
|
||||
case FCMIX_IDA:
|
||||
F2C_IDA_vecQB = NULL;
|
||||
F2C_IDA_vecQB = N_VNewEmpty_Serial((sunindextype)(*NqB));
|
||||
if (F2C_IDA_vecQB == NULL) *ier = -1;
|
||||
break;
|
||||
default:
|
||||
*ier = -1;
|
||||
}
|
||||
}
|
||||
|
||||
void FNV_INITS_S(int *code, int *Ns, int *ier)
|
||||
{
|
||||
*ier = 0;
|
||||
|
||||
switch(*code) {
|
||||
case FCMIX_CVODE:
|
||||
F2C_CVODE_vecS = NULL;
|
||||
F2C_CVODE_vecS = (N_Vector *) N_VCloneVectorArrayEmpty_Serial(*Ns, F2C_CVODE_vec);
|
||||
if (F2C_CVODE_vecS == NULL) *ier = -1;
|
||||
break;
|
||||
case FCMIX_IDA:
|
||||
F2C_IDA_vecS = NULL;
|
||||
F2C_IDA_vecS = (N_Vector *) N_VCloneVectorArrayEmpty_Serial(*Ns, F2C_IDA_vec);
|
||||
if (F2C_IDA_vecS == NULL) *ier = -1;
|
||||
break;
|
||||
default:
|
||||
*ier = -1;
|
||||
}
|
||||
}
|
||||
92
bazaar/plugin/sundials/src/nvector/serial/fnvector_serial.h
Normal file
92
bazaar/plugin/sundials/src/nvector/serial/fnvector_serial.h
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Programmer(s): Radu Serban and Aaron Collier @ LLNL
|
||||
* -----------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
* -----------------------------------------------------------------
|
||||
* This file (companion of nvector_serial.h) contains the
|
||||
* definitions needed for the initialization of serial
|
||||
* vector operations in Fortran.
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef _FNVECTOR_SERIAL_H
|
||||
#define _FNVECTOR_SERIAL_H
|
||||
|
||||
#include <nvector/nvector_serial.h>
|
||||
#include <sundials/sundials_fnvector.h>
|
||||
|
||||
#ifdef __cplusplus /* wrapper to enable C++ usage */
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(SUNDIALS_F77_FUNC)
|
||||
#define FNV_INITS SUNDIALS_F77_FUNC(fnvinits, FNVINITS)
|
||||
#else
|
||||
#define FNV_INITS fnvinits_
|
||||
#endif
|
||||
|
||||
#if defined(SUNDIALS_F77_FUNC_)
|
||||
|
||||
#define FNV_INITS_Q SUNDIALS_F77_FUNC_(fnvinits_q, FNVINITS_Q)
|
||||
#define FNV_INITS_S SUNDIALS_F77_FUNC_(fnvinits_s, FNVINITS_S)
|
||||
#define FNV_INITS_B SUNDIALS_F77_FUNC_(fnvinits_b, FNVINITS_B)
|
||||
#define FNV_INITS_QB SUNDIALS_F77_FUNC_(fnvinits_qb, FNVINITS_QB)
|
||||
|
||||
#else
|
||||
|
||||
#define FNV_INITS_Q fnvinits_q_
|
||||
#define FNV_INITS_S fnvinits_s_
|
||||
#define FNV_INITS_B fnvinits_b_
|
||||
#define FNV_INITS_QB fnvinits_qb_
|
||||
|
||||
#endif
|
||||
|
||||
/* Declarations of global variables */
|
||||
|
||||
extern N_Vector F2C_CVODE_vec;
|
||||
extern N_Vector F2C_CVODE_vecQ;
|
||||
extern N_Vector *F2C_CVODE_vecS;
|
||||
extern N_Vector F2C_CVODE_vecB;
|
||||
extern N_Vector F2C_CVODE_vecQB;
|
||||
|
||||
extern N_Vector F2C_IDA_vec;
|
||||
extern N_Vector F2C_IDA_vecQ;
|
||||
extern N_Vector *F2C_IDA_vecS;
|
||||
extern N_Vector F2C_IDA_vecB;
|
||||
extern N_Vector F2C_IDA_vecQB;
|
||||
|
||||
extern N_Vector F2C_KINSOL_vec;
|
||||
|
||||
extern N_Vector F2C_ARKODE_vec;
|
||||
|
||||
/*
|
||||
* Prototypes of exported functions
|
||||
*
|
||||
* FNV_INITS - initializes serial vector operations for main problem
|
||||
* FNV_INITS_Q - initializes serial vector operations for quadratures
|
||||
* FNV_INITS_S - initializes serial vector operations for sensitivities
|
||||
* FNV_INITS_B - initializes serial vector operations for adjoint problem
|
||||
* FNV_INITS_QB - initializes serial vector operations for adjoint quadratures
|
||||
*
|
||||
*/
|
||||
|
||||
void FNV_INITS(int *code, long int *neq, int *ier);
|
||||
void FNV_INITS_Q(int *code, long int *Nq, int *ier);
|
||||
void FNV_INITS_S(int *code, int *Ns, int *ier);
|
||||
void FNV_INITS_B(int *code, long int *NB, int *ier);
|
||||
void FNV_INITS_QB(int *code, long int *NqB, int *ier);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
2117
bazaar/plugin/sundials/src/nvector/serial/nvector_serial.c
Normal file
2117
bazaar/plugin/sundials/src/nvector/serial/nvector_serial.c
Normal file
File diff suppressed because it is too large
Load diff
255
bazaar/plugin/sundials/src/sundials/fmod/fsundials_futils_mod.c
Normal file
255
bazaar/plugin/sundials/src/sundials/fmod/fsundials_futils_mod.c
Normal file
|
|
@ -0,0 +1,255 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
* This file was automatically generated by SWIG (http://www.swig.org).
|
||||
* Version 4.0.0
|
||||
*
|
||||
* This file is not intended to be easily readable and contains a number of
|
||||
* coding conventions designed to improve portability and efficiency. Do not make
|
||||
* changes to this file unless you know what you are doing--modify the SWIG
|
||||
* interface file instead.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
/* ---------------------------------------------------------------
|
||||
* Programmer(s): Auto-generated by swig.
|
||||
* ---------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
* -------------------------------------------------------------*/
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* This section contains generic SWIG labels for method/variable
|
||||
* declarations/attributes, and other compiler dependent labels.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
/* template workaround for compilers that cannot correctly implement the C++ standard */
|
||||
#ifndef SWIGTEMPLATEDISAMBIGUATOR
|
||||
# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560)
|
||||
# define SWIGTEMPLATEDISAMBIGUATOR template
|
||||
# elif defined(__HP_aCC)
|
||||
/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */
|
||||
/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */
|
||||
# define SWIGTEMPLATEDISAMBIGUATOR template
|
||||
# else
|
||||
# define SWIGTEMPLATEDISAMBIGUATOR
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* inline attribute */
|
||||
#ifndef SWIGINLINE
|
||||
# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__))
|
||||
# define SWIGINLINE inline
|
||||
# else
|
||||
# define SWIGINLINE
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* attribute recognised by some compilers to avoid 'unused' warnings */
|
||||
#ifndef SWIGUNUSED
|
||||
# if defined(__GNUC__)
|
||||
# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
|
||||
# define SWIGUNUSED __attribute__ ((__unused__))
|
||||
# else
|
||||
# define SWIGUNUSED
|
||||
# endif
|
||||
# elif defined(__ICC)
|
||||
# define SWIGUNUSED __attribute__ ((__unused__))
|
||||
# else
|
||||
# define SWIGUNUSED
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef SWIG_MSC_UNSUPPRESS_4505
|
||||
# if defined(_MSC_VER)
|
||||
# pragma warning(disable : 4505) /* unreferenced local function has been removed */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef SWIGUNUSEDPARM
|
||||
# ifdef __cplusplus
|
||||
# define SWIGUNUSEDPARM(p)
|
||||
# else
|
||||
# define SWIGUNUSEDPARM(p) p SWIGUNUSED
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* internal SWIG method */
|
||||
#ifndef SWIGINTERN
|
||||
# define SWIGINTERN static SWIGUNUSED
|
||||
#endif
|
||||
|
||||
/* internal inline SWIG method */
|
||||
#ifndef SWIGINTERNINLINE
|
||||
# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE
|
||||
#endif
|
||||
|
||||
/* qualifier for exported *const* global data variables*/
|
||||
#ifndef SWIGEXTERN
|
||||
# ifdef __cplusplus
|
||||
# define SWIGEXTERN extern
|
||||
# else
|
||||
# define SWIGEXTERN
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* exporting methods */
|
||||
#if defined(__GNUC__)
|
||||
# if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
|
||||
# ifndef GCC_HASCLASSVISIBILITY
|
||||
# define GCC_HASCLASSVISIBILITY
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef SWIGEXPORT
|
||||
# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
|
||||
# if defined(STATIC_LINKED)
|
||||
# define SWIGEXPORT
|
||||
# else
|
||||
# define SWIGEXPORT __declspec(dllexport)
|
||||
# endif
|
||||
# else
|
||||
# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY)
|
||||
# define SWIGEXPORT __attribute__ ((visibility("default")))
|
||||
# else
|
||||
# define SWIGEXPORT
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* calling conventions for Windows */
|
||||
#ifndef SWIGSTDCALL
|
||||
# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
|
||||
# define SWIGSTDCALL __stdcall
|
||||
# else
|
||||
# define SWIGSTDCALL
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
|
||||
#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
|
||||
# define _CRT_SECURE_NO_DEPRECATE
|
||||
#endif
|
||||
|
||||
/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */
|
||||
#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE)
|
||||
# define _SCL_SECURE_NO_DEPRECATE
|
||||
#endif
|
||||
|
||||
/* Deal with Apple's deprecated 'AssertMacros.h' from Carbon-framework */
|
||||
#if defined(__APPLE__) && !defined(__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES)
|
||||
# define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0
|
||||
#endif
|
||||
|
||||
/* Intel's compiler complains if a variable which was never initialised is
|
||||
* cast to void, which is a common idiom which we use to indicate that we
|
||||
* are aware a variable isn't used. So we just silence that warning.
|
||||
* See: https://github.com/swig/swig/issues/192 for more discussion.
|
||||
*/
|
||||
#ifdef __INTEL_COMPILER
|
||||
# pragma warning disable 592
|
||||
#endif
|
||||
|
||||
/* Errors in SWIG */
|
||||
#define SWIG_UnknownError -1
|
||||
#define SWIG_IOError -2
|
||||
#define SWIG_RuntimeError -3
|
||||
#define SWIG_IndexError -4
|
||||
#define SWIG_TypeError -5
|
||||
#define SWIG_DivisionByZero -6
|
||||
#define SWIG_OverflowError -7
|
||||
#define SWIG_SyntaxError -8
|
||||
#define SWIG_ValueError -9
|
||||
#define SWIG_SystemError -10
|
||||
#define SWIG_AttributeError -11
|
||||
#define SWIG_MemoryError -12
|
||||
#define SWIG_NullReferenceError -13
|
||||
|
||||
|
||||
|
||||
|
||||
#include <assert.h>
|
||||
#define SWIG_exception_impl(DECL, CODE, MSG, RETURNNULL) \
|
||||
{ printf("In " DECL ": " MSG); assert(0); RETURNNULL; }
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM)
|
||||
# ifndef snprintf
|
||||
# define snprintf _snprintf
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
/* Support for the `contract` feature.
|
||||
*
|
||||
* Note that RETURNNULL is first because it's inserted via a 'Replaceall' in
|
||||
* the fortran.cxx file.
|
||||
*/
|
||||
#define SWIG_contract_assert(RETURNNULL, EXPR, MSG) \
|
||||
if (!(EXPR)) { SWIG_exception_impl("$decl", SWIG_ValueError, MSG, RETURNNULL); }
|
||||
|
||||
|
||||
#define SWIGVERSION 0x040000
|
||||
#define SWIG_VERSION SWIGVERSION
|
||||
|
||||
|
||||
#define SWIG_as_voidptr(a) (void *)((const void *)(a))
|
||||
#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a))
|
||||
|
||||
|
||||
#include "sundials/sundials_futils.h"
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#ifdef _MSC_VER
|
||||
# ifndef strtoull
|
||||
# define strtoull _strtoui64
|
||||
# endif
|
||||
# ifndef strtoll
|
||||
# define strtoll _strtoi64
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct {
|
||||
void* data;
|
||||
size_t size;
|
||||
} SwigArrayWrapper;
|
||||
|
||||
|
||||
SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() {
|
||||
SwigArrayWrapper result;
|
||||
result.data = NULL;
|
||||
result.size = 0;
|
||||
return result;
|
||||
}
|
||||
|
||||
SWIGEXPORT void * _wrap_FSUNDIALSFileOpen(SwigArrayWrapper *farg1, SwigArrayWrapper *farg2) {
|
||||
void * fresult ;
|
||||
char *arg1 = (char *) 0 ;
|
||||
char *arg2 = (char *) 0 ;
|
||||
FILE *result = 0 ;
|
||||
|
||||
arg1 = (char *)(farg1->data);
|
||||
arg2 = (char *)(farg2->data);
|
||||
result = (FILE *)SUNDIALSFileOpen((char const *)arg1,(char const *)arg2);
|
||||
fresult = result;
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void _wrap_FSUNDIALSFileClose(void *farg1) {
|
||||
FILE *arg1 = (FILE *) 0 ;
|
||||
|
||||
arg1 = (FILE *)(farg1);
|
||||
SUNDIALSFileClose(arg1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,488 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
* This file was automatically generated by SWIG (http://www.swig.org).
|
||||
* Version 4.0.0
|
||||
*
|
||||
* This file is not intended to be easily readable and contains a number of
|
||||
* coding conventions designed to improve portability and efficiency. Do not make
|
||||
* changes to this file unless you know what you are doing--modify the SWIG
|
||||
* interface file instead.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
/* -----------------------------------------------------------------------------
|
||||
* This section contains generic SWIG labels for method/variable
|
||||
* declarations/attributes, and other compiler dependent labels.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
/* template workaround for compilers that cannot correctly implement the C++ standard */
|
||||
#ifndef SWIGTEMPLATEDISAMBIGUATOR
|
||||
# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560)
|
||||
# define SWIGTEMPLATEDISAMBIGUATOR template
|
||||
# elif defined(__HP_aCC)
|
||||
/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */
|
||||
/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */
|
||||
# define SWIGTEMPLATEDISAMBIGUATOR template
|
||||
# else
|
||||
# define SWIGTEMPLATEDISAMBIGUATOR
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* inline attribute */
|
||||
#ifndef SWIGINLINE
|
||||
# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__))
|
||||
# define SWIGINLINE inline
|
||||
# else
|
||||
# define SWIGINLINE
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* attribute recognised by some compilers to avoid 'unused' warnings */
|
||||
#ifndef SWIGUNUSED
|
||||
# if defined(__GNUC__)
|
||||
# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
|
||||
# define SWIGUNUSED __attribute__ ((__unused__))
|
||||
# else
|
||||
# define SWIGUNUSED
|
||||
# endif
|
||||
# elif defined(__ICC)
|
||||
# define SWIGUNUSED __attribute__ ((__unused__))
|
||||
# else
|
||||
# define SWIGUNUSED
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef SWIG_MSC_UNSUPPRESS_4505
|
||||
# if defined(_MSC_VER)
|
||||
# pragma warning(disable : 4505) /* unreferenced local function has been removed */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef SWIGUNUSEDPARM
|
||||
# ifdef __cplusplus
|
||||
# define SWIGUNUSEDPARM(p)
|
||||
# else
|
||||
# define SWIGUNUSEDPARM(p) p SWIGUNUSED
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* internal SWIG method */
|
||||
#ifndef SWIGINTERN
|
||||
# define SWIGINTERN static SWIGUNUSED
|
||||
#endif
|
||||
|
||||
/* internal inline SWIG method */
|
||||
#ifndef SWIGINTERNINLINE
|
||||
# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE
|
||||
#endif
|
||||
|
||||
/* qualifier for exported *const* global data variables*/
|
||||
#ifndef SWIGEXTERN
|
||||
# ifdef __cplusplus
|
||||
# define SWIGEXTERN extern
|
||||
# else
|
||||
# define SWIGEXTERN
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* exporting methods */
|
||||
#if defined(__GNUC__)
|
||||
# if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
|
||||
# ifndef GCC_HASCLASSVISIBILITY
|
||||
# define GCC_HASCLASSVISIBILITY
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef SWIGEXPORT
|
||||
# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
|
||||
# if defined(STATIC_LINKED)
|
||||
# define SWIGEXPORT
|
||||
# else
|
||||
# define SWIGEXPORT __declspec(dllexport)
|
||||
# endif
|
||||
# else
|
||||
# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY)
|
||||
# define SWIGEXPORT __attribute__ ((visibility("default")))
|
||||
# else
|
||||
# define SWIGEXPORT
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* calling conventions for Windows */
|
||||
#ifndef SWIGSTDCALL
|
||||
# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
|
||||
# define SWIGSTDCALL __stdcall
|
||||
# else
|
||||
# define SWIGSTDCALL
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
|
||||
#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
|
||||
# define _CRT_SECURE_NO_DEPRECATE
|
||||
#endif
|
||||
|
||||
/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */
|
||||
#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE)
|
||||
# define _SCL_SECURE_NO_DEPRECATE
|
||||
#endif
|
||||
|
||||
/* Deal with Apple's deprecated 'AssertMacros.h' from Carbon-framework */
|
||||
#if defined(__APPLE__) && !defined(__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES)
|
||||
# define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0
|
||||
#endif
|
||||
|
||||
/* Intel's compiler complains if a variable which was never initialised is
|
||||
* cast to void, which is a common idiom which we use to indicate that we
|
||||
* are aware a variable isn't used. So we just silence that warning.
|
||||
* See: https://github.com/swig/swig/issues/192 for more discussion.
|
||||
*/
|
||||
#ifdef __INTEL_COMPILER
|
||||
# pragma warning disable 592
|
||||
#endif
|
||||
|
||||
/* Errors in SWIG */
|
||||
#define SWIG_UnknownError -1
|
||||
#define SWIG_IOError -2
|
||||
#define SWIG_RuntimeError -3
|
||||
#define SWIG_IndexError -4
|
||||
#define SWIG_TypeError -5
|
||||
#define SWIG_DivisionByZero -6
|
||||
#define SWIG_OverflowError -7
|
||||
#define SWIG_SyntaxError -8
|
||||
#define SWIG_ValueError -9
|
||||
#define SWIG_SystemError -10
|
||||
#define SWIG_AttributeError -11
|
||||
#define SWIG_MemoryError -12
|
||||
#define SWIG_NullReferenceError -13
|
||||
|
||||
|
||||
|
||||
|
||||
#include <assert.h>
|
||||
#define SWIG_exception_impl(DECL, CODE, MSG, RETURNNULL) \
|
||||
{ printf("In " DECL ": " MSG); assert(0); RETURNNULL; }
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM)
|
||||
# ifndef snprintf
|
||||
# define snprintf _snprintf
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
/* Support for the `contract` feature.
|
||||
*
|
||||
* Note that RETURNNULL is first because it's inserted via a 'Replaceall' in
|
||||
* the fortran.cxx file.
|
||||
*/
|
||||
#define SWIG_contract_assert(RETURNNULL, EXPR, MSG) \
|
||||
if (!(EXPR)) { SWIG_exception_impl("$decl", SWIG_ValueError, MSG, RETURNNULL); }
|
||||
|
||||
|
||||
#define SWIGVERSION 0x040000
|
||||
#define SWIG_VERSION SWIGVERSION
|
||||
|
||||
|
||||
#define SWIG_as_voidptr(a) (void *)((const void *)(a))
|
||||
#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a))
|
||||
|
||||
|
||||
#include "sundials/sundials_iterative.h"
|
||||
#include "sundials/sundials_linearsolver.h"
|
||||
|
||||
SWIGEXPORT int _wrap_FModifiedGS(void *farg1, void *farg2, int const *farg3, int const *farg4, double *farg5) {
|
||||
int fresult ;
|
||||
N_Vector *arg1 = (N_Vector *) 0 ;
|
||||
realtype **arg2 = (realtype **) 0 ;
|
||||
int arg3 ;
|
||||
int arg4 ;
|
||||
realtype *arg5 = (realtype *) 0 ;
|
||||
int result;
|
||||
|
||||
arg1 = (N_Vector *)(farg1);
|
||||
arg2 = (realtype **)(farg2);
|
||||
arg3 = (int)(*farg3);
|
||||
arg4 = (int)(*farg4);
|
||||
arg5 = (realtype *)(farg5);
|
||||
result = (int)ModifiedGS(arg1,arg2,arg3,arg4,arg5);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FClassicalGS(void *farg1, void *farg2, int const *farg3, int const *farg4, double *farg5, double *farg6, void *farg7) {
|
||||
int fresult ;
|
||||
N_Vector *arg1 = (N_Vector *) 0 ;
|
||||
realtype **arg2 = (realtype **) 0 ;
|
||||
int arg3 ;
|
||||
int arg4 ;
|
||||
realtype *arg5 = (realtype *) 0 ;
|
||||
realtype *arg6 = (realtype *) 0 ;
|
||||
N_Vector *arg7 = (N_Vector *) 0 ;
|
||||
int result;
|
||||
|
||||
arg1 = (N_Vector *)(farg1);
|
||||
arg2 = (realtype **)(farg2);
|
||||
arg3 = (int)(*farg3);
|
||||
arg4 = (int)(*farg4);
|
||||
arg5 = (realtype *)(farg5);
|
||||
arg6 = (realtype *)(farg6);
|
||||
arg7 = (N_Vector *)(farg7);
|
||||
result = (int)ClassicalGS(arg1,arg2,arg3,arg4,arg5,arg6,arg7);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FQRfact(int const *farg1, void *farg2, double *farg3, int const *farg4) {
|
||||
int fresult ;
|
||||
int arg1 ;
|
||||
realtype **arg2 = (realtype **) 0 ;
|
||||
realtype *arg3 = (realtype *) 0 ;
|
||||
int arg4 ;
|
||||
int result;
|
||||
|
||||
arg1 = (int)(*farg1);
|
||||
arg2 = (realtype **)(farg2);
|
||||
arg3 = (realtype *)(farg3);
|
||||
arg4 = (int)(*farg4);
|
||||
result = (int)QRfact(arg1,arg2,arg3,arg4);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FQRsol(int const *farg1, void *farg2, double *farg3, double *farg4) {
|
||||
int fresult ;
|
||||
int arg1 ;
|
||||
realtype **arg2 = (realtype **) 0 ;
|
||||
realtype *arg3 = (realtype *) 0 ;
|
||||
realtype *arg4 = (realtype *) 0 ;
|
||||
int result;
|
||||
|
||||
arg1 = (int)(*farg1);
|
||||
arg2 = (realtype **)(farg2);
|
||||
arg3 = (realtype *)(farg3);
|
||||
arg4 = (realtype *)(farg4);
|
||||
result = (int)QRsol(arg1,arg2,arg3,arg4);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT SUNLinearSolver _wrap_FSUNLinSolNewEmpty() {
|
||||
SUNLinearSolver fresult ;
|
||||
SUNLinearSolver result;
|
||||
|
||||
result = (SUNLinearSolver)SUNLinSolNewEmpty();
|
||||
fresult = result;
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void _wrap_FSUNLinSolFreeEmpty(SUNLinearSolver farg1) {
|
||||
SUNLinearSolver arg1 = (SUNLinearSolver) 0 ;
|
||||
|
||||
arg1 = (SUNLinearSolver)(farg1);
|
||||
SUNLinSolFreeEmpty(arg1);
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FSUNLinSolGetType(SUNLinearSolver farg1) {
|
||||
int fresult ;
|
||||
SUNLinearSolver arg1 = (SUNLinearSolver) 0 ;
|
||||
SUNLinearSolver_Type result;
|
||||
|
||||
arg1 = (SUNLinearSolver)(farg1);
|
||||
result = (SUNLinearSolver_Type)SUNLinSolGetType(arg1);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FSUNLinSolGetID(SUNLinearSolver farg1) {
|
||||
int fresult ;
|
||||
SUNLinearSolver arg1 = (SUNLinearSolver) 0 ;
|
||||
SUNLinearSolver_ID result;
|
||||
|
||||
arg1 = (SUNLinearSolver)(farg1);
|
||||
result = (SUNLinearSolver_ID)SUNLinSolGetID(arg1);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FSUNLinSolSetATimes(SUNLinearSolver farg1, void *farg2, ATimesFn farg3) {
|
||||
int fresult ;
|
||||
SUNLinearSolver arg1 = (SUNLinearSolver) 0 ;
|
||||
void *arg2 = (void *) 0 ;
|
||||
ATimesFn arg3 = (ATimesFn) 0 ;
|
||||
int result;
|
||||
|
||||
arg1 = (SUNLinearSolver)(farg1);
|
||||
arg2 = (void *)(farg2);
|
||||
arg3 = (ATimesFn)(farg3);
|
||||
result = (int)SUNLinSolSetATimes(arg1,arg2,arg3);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FSUNLinSolSetPreconditioner(SUNLinearSolver farg1, void *farg2, PSetupFn farg3, PSolveFn farg4) {
|
||||
int fresult ;
|
||||
SUNLinearSolver arg1 = (SUNLinearSolver) 0 ;
|
||||
void *arg2 = (void *) 0 ;
|
||||
PSetupFn arg3 = (PSetupFn) 0 ;
|
||||
PSolveFn arg4 = (PSolveFn) 0 ;
|
||||
int result;
|
||||
|
||||
arg1 = (SUNLinearSolver)(farg1);
|
||||
arg2 = (void *)(farg2);
|
||||
arg3 = (PSetupFn)(farg3);
|
||||
arg4 = (PSolveFn)(farg4);
|
||||
result = (int)SUNLinSolSetPreconditioner(arg1,arg2,arg3,arg4);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FSUNLinSolSetScalingVectors(SUNLinearSolver farg1, N_Vector farg2, N_Vector farg3) {
|
||||
int fresult ;
|
||||
SUNLinearSolver arg1 = (SUNLinearSolver) 0 ;
|
||||
N_Vector arg2 = (N_Vector) 0 ;
|
||||
N_Vector arg3 = (N_Vector) 0 ;
|
||||
int result;
|
||||
|
||||
arg1 = (SUNLinearSolver)(farg1);
|
||||
arg2 = (N_Vector)(farg2);
|
||||
arg3 = (N_Vector)(farg3);
|
||||
result = (int)SUNLinSolSetScalingVectors(arg1,arg2,arg3);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FSUNLinSolInitialize(SUNLinearSolver farg1) {
|
||||
int fresult ;
|
||||
SUNLinearSolver arg1 = (SUNLinearSolver) 0 ;
|
||||
int result;
|
||||
|
||||
arg1 = (SUNLinearSolver)(farg1);
|
||||
result = (int)SUNLinSolInitialize(arg1);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FSUNLinSolSetup(SUNLinearSolver farg1, SUNMatrix farg2) {
|
||||
int fresult ;
|
||||
SUNLinearSolver arg1 = (SUNLinearSolver) 0 ;
|
||||
SUNMatrix arg2 = (SUNMatrix) 0 ;
|
||||
int result;
|
||||
|
||||
arg1 = (SUNLinearSolver)(farg1);
|
||||
arg2 = (SUNMatrix)(farg2);
|
||||
result = (int)SUNLinSolSetup(arg1,arg2);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FSUNLinSolSolve(SUNLinearSolver farg1, SUNMatrix farg2, N_Vector farg3, N_Vector farg4, double const *farg5) {
|
||||
int fresult ;
|
||||
SUNLinearSolver arg1 = (SUNLinearSolver) 0 ;
|
||||
SUNMatrix arg2 = (SUNMatrix) 0 ;
|
||||
N_Vector arg3 = (N_Vector) 0 ;
|
||||
N_Vector arg4 = (N_Vector) 0 ;
|
||||
realtype arg5 ;
|
||||
int result;
|
||||
|
||||
arg1 = (SUNLinearSolver)(farg1);
|
||||
arg2 = (SUNMatrix)(farg2);
|
||||
arg3 = (N_Vector)(farg3);
|
||||
arg4 = (N_Vector)(farg4);
|
||||
arg5 = (realtype)(*farg5);
|
||||
result = (int)SUNLinSolSolve(arg1,arg2,arg3,arg4,arg5);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FSUNLinSolNumIters(SUNLinearSolver farg1) {
|
||||
int fresult ;
|
||||
SUNLinearSolver arg1 = (SUNLinearSolver) 0 ;
|
||||
int result;
|
||||
|
||||
arg1 = (SUNLinearSolver)(farg1);
|
||||
result = (int)SUNLinSolNumIters(arg1);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT double _wrap_FSUNLinSolResNorm(SUNLinearSolver farg1) {
|
||||
double fresult ;
|
||||
SUNLinearSolver arg1 = (SUNLinearSolver) 0 ;
|
||||
realtype result;
|
||||
|
||||
arg1 = (SUNLinearSolver)(farg1);
|
||||
result = (realtype)SUNLinSolResNorm(arg1);
|
||||
fresult = (realtype)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT N_Vector _wrap_FSUNLinSolResid(SUNLinearSolver farg1) {
|
||||
N_Vector fresult ;
|
||||
SUNLinearSolver arg1 = (SUNLinearSolver) 0 ;
|
||||
N_Vector result;
|
||||
|
||||
arg1 = (SUNLinearSolver)(farg1);
|
||||
result = (N_Vector)SUNLinSolResid(arg1);
|
||||
fresult = result;
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int64_t _wrap_FSUNLinSolLastFlag(SUNLinearSolver farg1) {
|
||||
int64_t fresult ;
|
||||
SUNLinearSolver arg1 = (SUNLinearSolver) 0 ;
|
||||
sunindextype result;
|
||||
|
||||
arg1 = (SUNLinearSolver)(farg1);
|
||||
result = SUNLinSolLastFlag(arg1);
|
||||
fresult = (sunindextype)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FSUNLinSolSpace(SUNLinearSolver farg1, long *farg2, long *farg3) {
|
||||
int fresult ;
|
||||
SUNLinearSolver arg1 = (SUNLinearSolver) 0 ;
|
||||
long *arg2 = (long *) 0 ;
|
||||
long *arg3 = (long *) 0 ;
|
||||
int result;
|
||||
|
||||
arg1 = (SUNLinearSolver)(farg1);
|
||||
arg2 = (long *)(farg2);
|
||||
arg3 = (long *)(farg3);
|
||||
result = (int)SUNLinSolSpace(arg1,arg2,arg3);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FSUNLinSolFree(SUNLinearSolver farg1) {
|
||||
int fresult ;
|
||||
SUNLinearSolver arg1 = (SUNLinearSolver) 0 ;
|
||||
int result;
|
||||
|
||||
arg1 = (SUNLinearSolver)(farg1);
|
||||
result = (int)SUNLinSolFree(arg1);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
|
||||
357
bazaar/plugin/sundials/src/sundials/fmod/fsundials_matrix_mod.c
Normal file
357
bazaar/plugin/sundials/src/sundials/fmod/fsundials_matrix_mod.c
Normal file
|
|
@ -0,0 +1,357 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
* This file was automatically generated by SWIG (http://www.swig.org).
|
||||
* Version 4.0.0
|
||||
*
|
||||
* This file is not intended to be easily readable and contains a number of
|
||||
* coding conventions designed to improve portability and efficiency. Do not make
|
||||
* changes to this file unless you know what you are doing--modify the SWIG
|
||||
* interface file instead.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
/* -----------------------------------------------------------------------------
|
||||
* This section contains generic SWIG labels for method/variable
|
||||
* declarations/attributes, and other compiler dependent labels.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
/* template workaround for compilers that cannot correctly implement the C++ standard */
|
||||
#ifndef SWIGTEMPLATEDISAMBIGUATOR
|
||||
# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560)
|
||||
# define SWIGTEMPLATEDISAMBIGUATOR template
|
||||
# elif defined(__HP_aCC)
|
||||
/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */
|
||||
/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */
|
||||
# define SWIGTEMPLATEDISAMBIGUATOR template
|
||||
# else
|
||||
# define SWIGTEMPLATEDISAMBIGUATOR
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* inline attribute */
|
||||
#ifndef SWIGINLINE
|
||||
# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__))
|
||||
# define SWIGINLINE inline
|
||||
# else
|
||||
# define SWIGINLINE
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* attribute recognised by some compilers to avoid 'unused' warnings */
|
||||
#ifndef SWIGUNUSED
|
||||
# if defined(__GNUC__)
|
||||
# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
|
||||
# define SWIGUNUSED __attribute__ ((__unused__))
|
||||
# else
|
||||
# define SWIGUNUSED
|
||||
# endif
|
||||
# elif defined(__ICC)
|
||||
# define SWIGUNUSED __attribute__ ((__unused__))
|
||||
# else
|
||||
# define SWIGUNUSED
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef SWIG_MSC_UNSUPPRESS_4505
|
||||
# if defined(_MSC_VER)
|
||||
# pragma warning(disable : 4505) /* unreferenced local function has been removed */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef SWIGUNUSEDPARM
|
||||
# ifdef __cplusplus
|
||||
# define SWIGUNUSEDPARM(p)
|
||||
# else
|
||||
# define SWIGUNUSEDPARM(p) p SWIGUNUSED
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* internal SWIG method */
|
||||
#ifndef SWIGINTERN
|
||||
# define SWIGINTERN static SWIGUNUSED
|
||||
#endif
|
||||
|
||||
/* internal inline SWIG method */
|
||||
#ifndef SWIGINTERNINLINE
|
||||
# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE
|
||||
#endif
|
||||
|
||||
/* qualifier for exported *const* global data variables*/
|
||||
#ifndef SWIGEXTERN
|
||||
# ifdef __cplusplus
|
||||
# define SWIGEXTERN extern
|
||||
# else
|
||||
# define SWIGEXTERN
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* exporting methods */
|
||||
#if defined(__GNUC__)
|
||||
# if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
|
||||
# ifndef GCC_HASCLASSVISIBILITY
|
||||
# define GCC_HASCLASSVISIBILITY
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef SWIGEXPORT
|
||||
# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
|
||||
# if defined(STATIC_LINKED)
|
||||
# define SWIGEXPORT
|
||||
# else
|
||||
# define SWIGEXPORT __declspec(dllexport)
|
||||
# endif
|
||||
# else
|
||||
# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY)
|
||||
# define SWIGEXPORT __attribute__ ((visibility("default")))
|
||||
# else
|
||||
# define SWIGEXPORT
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* calling conventions for Windows */
|
||||
#ifndef SWIGSTDCALL
|
||||
# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
|
||||
# define SWIGSTDCALL __stdcall
|
||||
# else
|
||||
# define SWIGSTDCALL
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
|
||||
#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
|
||||
# define _CRT_SECURE_NO_DEPRECATE
|
||||
#endif
|
||||
|
||||
/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */
|
||||
#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE)
|
||||
# define _SCL_SECURE_NO_DEPRECATE
|
||||
#endif
|
||||
|
||||
/* Deal with Apple's deprecated 'AssertMacros.h' from Carbon-framework */
|
||||
#if defined(__APPLE__) && !defined(__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES)
|
||||
# define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0
|
||||
#endif
|
||||
|
||||
/* Intel's compiler complains if a variable which was never initialised is
|
||||
* cast to void, which is a common idiom which we use to indicate that we
|
||||
* are aware a variable isn't used. So we just silence that warning.
|
||||
* See: https://github.com/swig/swig/issues/192 for more discussion.
|
||||
*/
|
||||
#ifdef __INTEL_COMPILER
|
||||
# pragma warning disable 592
|
||||
#endif
|
||||
|
||||
/* Errors in SWIG */
|
||||
#define SWIG_UnknownError -1
|
||||
#define SWIG_IOError -2
|
||||
#define SWIG_RuntimeError -3
|
||||
#define SWIG_IndexError -4
|
||||
#define SWIG_TypeError -5
|
||||
#define SWIG_DivisionByZero -6
|
||||
#define SWIG_OverflowError -7
|
||||
#define SWIG_SyntaxError -8
|
||||
#define SWIG_ValueError -9
|
||||
#define SWIG_SystemError -10
|
||||
#define SWIG_AttributeError -11
|
||||
#define SWIG_MemoryError -12
|
||||
#define SWIG_NullReferenceError -13
|
||||
|
||||
|
||||
|
||||
|
||||
#include <assert.h>
|
||||
#define SWIG_exception_impl(DECL, CODE, MSG, RETURNNULL) \
|
||||
{ printf("In " DECL ": " MSG); assert(0); RETURNNULL; }
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM)
|
||||
# ifndef snprintf
|
||||
# define snprintf _snprintf
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
/* Support for the `contract` feature.
|
||||
*
|
||||
* Note that RETURNNULL is first because it's inserted via a 'Replaceall' in
|
||||
* the fortran.cxx file.
|
||||
*/
|
||||
#define SWIG_contract_assert(RETURNNULL, EXPR, MSG) \
|
||||
if (!(EXPR)) { SWIG_exception_impl("$decl", SWIG_ValueError, MSG, RETURNNULL); }
|
||||
|
||||
|
||||
#define SWIGVERSION 0x040000
|
||||
#define SWIG_VERSION SWIGVERSION
|
||||
|
||||
|
||||
#define SWIG_as_voidptr(a) (void *)((const void *)(a))
|
||||
#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a))
|
||||
|
||||
|
||||
#include "sundials/sundials_matrix.h"
|
||||
|
||||
SWIGEXPORT SUNMatrix _wrap_FSUNMatNewEmpty() {
|
||||
SUNMatrix fresult ;
|
||||
SUNMatrix result;
|
||||
|
||||
result = (SUNMatrix)SUNMatNewEmpty();
|
||||
fresult = result;
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void _wrap_FSUNMatFreeEmpty(SUNMatrix farg1) {
|
||||
SUNMatrix arg1 = (SUNMatrix) 0 ;
|
||||
|
||||
arg1 = (SUNMatrix)(farg1);
|
||||
SUNMatFreeEmpty(arg1);
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FSUNMatCopyOps(SUNMatrix farg1, SUNMatrix farg2) {
|
||||
int fresult ;
|
||||
SUNMatrix arg1 = (SUNMatrix) 0 ;
|
||||
SUNMatrix arg2 = (SUNMatrix) 0 ;
|
||||
int result;
|
||||
|
||||
arg1 = (SUNMatrix)(farg1);
|
||||
arg2 = (SUNMatrix)(farg2);
|
||||
result = (int)SUNMatCopyOps(arg1,arg2);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FSUNMatGetID(SUNMatrix farg1) {
|
||||
int fresult ;
|
||||
SUNMatrix arg1 = (SUNMatrix) 0 ;
|
||||
SUNMatrix_ID result;
|
||||
|
||||
arg1 = (SUNMatrix)(farg1);
|
||||
result = (SUNMatrix_ID)SUNMatGetID(arg1);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT SUNMatrix _wrap_FSUNMatClone(SUNMatrix farg1) {
|
||||
SUNMatrix fresult ;
|
||||
SUNMatrix arg1 = (SUNMatrix) 0 ;
|
||||
SUNMatrix result;
|
||||
|
||||
arg1 = (SUNMatrix)(farg1);
|
||||
result = (SUNMatrix)SUNMatClone(arg1);
|
||||
fresult = result;
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void _wrap_FSUNMatDestroy(SUNMatrix farg1) {
|
||||
SUNMatrix arg1 = (SUNMatrix) 0 ;
|
||||
|
||||
arg1 = (SUNMatrix)(farg1);
|
||||
SUNMatDestroy(arg1);
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FSUNMatZero(SUNMatrix farg1) {
|
||||
int fresult ;
|
||||
SUNMatrix arg1 = (SUNMatrix) 0 ;
|
||||
int result;
|
||||
|
||||
arg1 = (SUNMatrix)(farg1);
|
||||
result = (int)SUNMatZero(arg1);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FSUNMatCopy(SUNMatrix farg1, SUNMatrix farg2) {
|
||||
int fresult ;
|
||||
SUNMatrix arg1 = (SUNMatrix) 0 ;
|
||||
SUNMatrix arg2 = (SUNMatrix) 0 ;
|
||||
int result;
|
||||
|
||||
arg1 = (SUNMatrix)(farg1);
|
||||
arg2 = (SUNMatrix)(farg2);
|
||||
result = (int)SUNMatCopy(arg1,arg2);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FSUNMatScaleAdd(double const *farg1, SUNMatrix farg2, SUNMatrix farg3) {
|
||||
int fresult ;
|
||||
realtype arg1 ;
|
||||
SUNMatrix arg2 = (SUNMatrix) 0 ;
|
||||
SUNMatrix arg3 = (SUNMatrix) 0 ;
|
||||
int result;
|
||||
|
||||
arg1 = (realtype)(*farg1);
|
||||
arg2 = (SUNMatrix)(farg2);
|
||||
arg3 = (SUNMatrix)(farg3);
|
||||
result = (int)SUNMatScaleAdd(arg1,arg2,arg3);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FSUNMatScaleAddI(double const *farg1, SUNMatrix farg2) {
|
||||
int fresult ;
|
||||
realtype arg1 ;
|
||||
SUNMatrix arg2 = (SUNMatrix) 0 ;
|
||||
int result;
|
||||
|
||||
arg1 = (realtype)(*farg1);
|
||||
arg2 = (SUNMatrix)(farg2);
|
||||
result = (int)SUNMatScaleAddI(arg1,arg2);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FSUNMatMatvecSetup(SUNMatrix farg1) {
|
||||
int fresult ;
|
||||
SUNMatrix arg1 = (SUNMatrix) 0 ;
|
||||
int result;
|
||||
|
||||
arg1 = (SUNMatrix)(farg1);
|
||||
result = (int)SUNMatMatvecSetup(arg1);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FSUNMatMatvec(SUNMatrix farg1, N_Vector farg2, N_Vector farg3) {
|
||||
int fresult ;
|
||||
SUNMatrix arg1 = (SUNMatrix) 0 ;
|
||||
N_Vector arg2 = (N_Vector) 0 ;
|
||||
N_Vector arg3 = (N_Vector) 0 ;
|
||||
int result;
|
||||
|
||||
arg1 = (SUNMatrix)(farg1);
|
||||
arg2 = (N_Vector)(farg2);
|
||||
arg3 = (N_Vector)(farg3);
|
||||
result = (int)SUNMatMatvec(arg1,arg2,arg3);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FSUNMatSpace(SUNMatrix farg1, long *farg2, long *farg3) {
|
||||
int fresult ;
|
||||
SUNMatrix arg1 = (SUNMatrix) 0 ;
|
||||
long *arg2 = (long *) 0 ;
|
||||
long *arg3 = (long *) 0 ;
|
||||
int result;
|
||||
|
||||
arg1 = (SUNMatrix)(farg1);
|
||||
arg2 = (long *)(farg2);
|
||||
arg3 = (long *)(farg3);
|
||||
result = (int)SUNMatSpace(arg1,arg2,arg3);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,401 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
* This file was automatically generated by SWIG (http://www.swig.org).
|
||||
* Version 4.0.0
|
||||
*
|
||||
* This file is not intended to be easily readable and contains a number of
|
||||
* coding conventions designed to improve portability and efficiency. Do not make
|
||||
* changes to this file unless you know what you are doing--modify the SWIG
|
||||
* interface file instead.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
/* -----------------------------------------------------------------------------
|
||||
* This section contains generic SWIG labels for method/variable
|
||||
* declarations/attributes, and other compiler dependent labels.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
/* template workaround for compilers that cannot correctly implement the C++ standard */
|
||||
#ifndef SWIGTEMPLATEDISAMBIGUATOR
|
||||
# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560)
|
||||
# define SWIGTEMPLATEDISAMBIGUATOR template
|
||||
# elif defined(__HP_aCC)
|
||||
/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */
|
||||
/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */
|
||||
# define SWIGTEMPLATEDISAMBIGUATOR template
|
||||
# else
|
||||
# define SWIGTEMPLATEDISAMBIGUATOR
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* inline attribute */
|
||||
#ifndef SWIGINLINE
|
||||
# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__))
|
||||
# define SWIGINLINE inline
|
||||
# else
|
||||
# define SWIGINLINE
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* attribute recognised by some compilers to avoid 'unused' warnings */
|
||||
#ifndef SWIGUNUSED
|
||||
# if defined(__GNUC__)
|
||||
# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
|
||||
# define SWIGUNUSED __attribute__ ((__unused__))
|
||||
# else
|
||||
# define SWIGUNUSED
|
||||
# endif
|
||||
# elif defined(__ICC)
|
||||
# define SWIGUNUSED __attribute__ ((__unused__))
|
||||
# else
|
||||
# define SWIGUNUSED
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef SWIG_MSC_UNSUPPRESS_4505
|
||||
# if defined(_MSC_VER)
|
||||
# pragma warning(disable : 4505) /* unreferenced local function has been removed */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef SWIGUNUSEDPARM
|
||||
# ifdef __cplusplus
|
||||
# define SWIGUNUSEDPARM(p)
|
||||
# else
|
||||
# define SWIGUNUSEDPARM(p) p SWIGUNUSED
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* internal SWIG method */
|
||||
#ifndef SWIGINTERN
|
||||
# define SWIGINTERN static SWIGUNUSED
|
||||
#endif
|
||||
|
||||
/* internal inline SWIG method */
|
||||
#ifndef SWIGINTERNINLINE
|
||||
# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE
|
||||
#endif
|
||||
|
||||
/* qualifier for exported *const* global data variables*/
|
||||
#ifndef SWIGEXTERN
|
||||
# ifdef __cplusplus
|
||||
# define SWIGEXTERN extern
|
||||
# else
|
||||
# define SWIGEXTERN
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* exporting methods */
|
||||
#if defined(__GNUC__)
|
||||
# if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
|
||||
# ifndef GCC_HASCLASSVISIBILITY
|
||||
# define GCC_HASCLASSVISIBILITY
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef SWIGEXPORT
|
||||
# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
|
||||
# if defined(STATIC_LINKED)
|
||||
# define SWIGEXPORT
|
||||
# else
|
||||
# define SWIGEXPORT __declspec(dllexport)
|
||||
# endif
|
||||
# else
|
||||
# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY)
|
||||
# define SWIGEXPORT __attribute__ ((visibility("default")))
|
||||
# else
|
||||
# define SWIGEXPORT
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* calling conventions for Windows */
|
||||
#ifndef SWIGSTDCALL
|
||||
# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
|
||||
# define SWIGSTDCALL __stdcall
|
||||
# else
|
||||
# define SWIGSTDCALL
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
|
||||
#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
|
||||
# define _CRT_SECURE_NO_DEPRECATE
|
||||
#endif
|
||||
|
||||
/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */
|
||||
#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE)
|
||||
# define _SCL_SECURE_NO_DEPRECATE
|
||||
#endif
|
||||
|
||||
/* Deal with Apple's deprecated 'AssertMacros.h' from Carbon-framework */
|
||||
#if defined(__APPLE__) && !defined(__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES)
|
||||
# define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0
|
||||
#endif
|
||||
|
||||
/* Intel's compiler complains if a variable which was never initialised is
|
||||
* cast to void, which is a common idiom which we use to indicate that we
|
||||
* are aware a variable isn't used. So we just silence that warning.
|
||||
* See: https://github.com/swig/swig/issues/192 for more discussion.
|
||||
*/
|
||||
#ifdef __INTEL_COMPILER
|
||||
# pragma warning disable 592
|
||||
#endif
|
||||
|
||||
/* Errors in SWIG */
|
||||
#define SWIG_UnknownError -1
|
||||
#define SWIG_IOError -2
|
||||
#define SWIG_RuntimeError -3
|
||||
#define SWIG_IndexError -4
|
||||
#define SWIG_TypeError -5
|
||||
#define SWIG_DivisionByZero -6
|
||||
#define SWIG_OverflowError -7
|
||||
#define SWIG_SyntaxError -8
|
||||
#define SWIG_ValueError -9
|
||||
#define SWIG_SystemError -10
|
||||
#define SWIG_AttributeError -11
|
||||
#define SWIG_MemoryError -12
|
||||
#define SWIG_NullReferenceError -13
|
||||
|
||||
|
||||
|
||||
|
||||
#include <assert.h>
|
||||
#define SWIG_exception_impl(DECL, CODE, MSG, RETURNNULL) \
|
||||
{ printf("In " DECL ": " MSG); assert(0); RETURNNULL; }
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM)
|
||||
# ifndef snprintf
|
||||
# define snprintf _snprintf
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
/* Support for the `contract` feature.
|
||||
*
|
||||
* Note that RETURNNULL is first because it's inserted via a 'Replaceall' in
|
||||
* the fortran.cxx file.
|
||||
*/
|
||||
#define SWIG_contract_assert(RETURNNULL, EXPR, MSG) \
|
||||
if (!(EXPR)) { SWIG_exception_impl("$decl", SWIG_ValueError, MSG, RETURNNULL); }
|
||||
|
||||
|
||||
#define SWIGVERSION 0x040000
|
||||
#define SWIG_VERSION SWIGVERSION
|
||||
|
||||
|
||||
#define SWIG_as_voidptr(a) (void *)((const void *)(a))
|
||||
#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a))
|
||||
|
||||
|
||||
#include "sundials/sundials_nonlinearsolver.h"
|
||||
|
||||
SWIGEXPORT SUNNonlinearSolver _wrap_FSUNNonlinSolNewEmpty() {
|
||||
SUNNonlinearSolver fresult ;
|
||||
SUNNonlinearSolver result;
|
||||
|
||||
result = (SUNNonlinearSolver)SUNNonlinSolNewEmpty();
|
||||
fresult = result;
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void _wrap_FSUNNonlinSolFreeEmpty(SUNNonlinearSolver farg1) {
|
||||
SUNNonlinearSolver arg1 = (SUNNonlinearSolver) 0 ;
|
||||
|
||||
arg1 = (SUNNonlinearSolver)(farg1);
|
||||
SUNNonlinSolFreeEmpty(arg1);
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FSUNNonlinSolGetType(SUNNonlinearSolver farg1) {
|
||||
int fresult ;
|
||||
SUNNonlinearSolver arg1 = (SUNNonlinearSolver) 0 ;
|
||||
SUNNonlinearSolver_Type result;
|
||||
|
||||
arg1 = (SUNNonlinearSolver)(farg1);
|
||||
result = (SUNNonlinearSolver_Type)SUNNonlinSolGetType(arg1);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FSUNNonlinSolInitialize(SUNNonlinearSolver farg1) {
|
||||
int fresult ;
|
||||
SUNNonlinearSolver arg1 = (SUNNonlinearSolver) 0 ;
|
||||
int result;
|
||||
|
||||
arg1 = (SUNNonlinearSolver)(farg1);
|
||||
result = (int)SUNNonlinSolInitialize(arg1);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FSUNNonlinSolSetup(SUNNonlinearSolver farg1, N_Vector farg2, void *farg3) {
|
||||
int fresult ;
|
||||
SUNNonlinearSolver arg1 = (SUNNonlinearSolver) 0 ;
|
||||
N_Vector arg2 = (N_Vector) 0 ;
|
||||
void *arg3 = (void *) 0 ;
|
||||
int result;
|
||||
|
||||
arg1 = (SUNNonlinearSolver)(farg1);
|
||||
arg2 = (N_Vector)(farg2);
|
||||
arg3 = (void *)(farg3);
|
||||
result = (int)SUNNonlinSolSetup(arg1,arg2,arg3);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FSUNNonlinSolSolve(SUNNonlinearSolver farg1, N_Vector farg2, N_Vector farg3, N_Vector farg4, double const *farg5, int const *farg6, void *farg7) {
|
||||
int fresult ;
|
||||
SUNNonlinearSolver arg1 = (SUNNonlinearSolver) 0 ;
|
||||
N_Vector arg2 = (N_Vector) 0 ;
|
||||
N_Vector arg3 = (N_Vector) 0 ;
|
||||
N_Vector arg4 = (N_Vector) 0 ;
|
||||
realtype arg5 ;
|
||||
int arg6 ;
|
||||
void *arg7 = (void *) 0 ;
|
||||
int result;
|
||||
|
||||
arg1 = (SUNNonlinearSolver)(farg1);
|
||||
arg2 = (N_Vector)(farg2);
|
||||
arg3 = (N_Vector)(farg3);
|
||||
arg4 = (N_Vector)(farg4);
|
||||
arg5 = (realtype)(*farg5);
|
||||
arg6 = (int)(*farg6);
|
||||
arg7 = (void *)(farg7);
|
||||
result = (int)SUNNonlinSolSolve(arg1,arg2,arg3,arg4,arg5,arg6,arg7);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FSUNNonlinSolFree(SUNNonlinearSolver farg1) {
|
||||
int fresult ;
|
||||
SUNNonlinearSolver arg1 = (SUNNonlinearSolver) 0 ;
|
||||
int result;
|
||||
|
||||
arg1 = (SUNNonlinearSolver)(farg1);
|
||||
result = (int)SUNNonlinSolFree(arg1);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FSUNNonlinSolSetSysFn(SUNNonlinearSolver farg1, SUNNonlinSolSysFn farg2) {
|
||||
int fresult ;
|
||||
SUNNonlinearSolver arg1 = (SUNNonlinearSolver) 0 ;
|
||||
SUNNonlinSolSysFn arg2 = (SUNNonlinSolSysFn) 0 ;
|
||||
int result;
|
||||
|
||||
arg1 = (SUNNonlinearSolver)(farg1);
|
||||
arg2 = (SUNNonlinSolSysFn)(farg2);
|
||||
result = (int)SUNNonlinSolSetSysFn(arg1,arg2);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FSUNNonlinSolSetLSetupFn(SUNNonlinearSolver farg1, SUNNonlinSolLSetupFn farg2) {
|
||||
int fresult ;
|
||||
SUNNonlinearSolver arg1 = (SUNNonlinearSolver) 0 ;
|
||||
SUNNonlinSolLSetupFn arg2 = (SUNNonlinSolLSetupFn) 0 ;
|
||||
int result;
|
||||
|
||||
arg1 = (SUNNonlinearSolver)(farg1);
|
||||
arg2 = (SUNNonlinSolLSetupFn)(farg2);
|
||||
result = (int)SUNNonlinSolSetLSetupFn(arg1,arg2);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FSUNNonlinSolSetLSolveFn(SUNNonlinearSolver farg1, SUNNonlinSolLSolveFn farg2) {
|
||||
int fresult ;
|
||||
SUNNonlinearSolver arg1 = (SUNNonlinearSolver) 0 ;
|
||||
SUNNonlinSolLSolveFn arg2 = (SUNNonlinSolLSolveFn) 0 ;
|
||||
int result;
|
||||
|
||||
arg1 = (SUNNonlinearSolver)(farg1);
|
||||
arg2 = (SUNNonlinSolLSolveFn)(farg2);
|
||||
result = (int)SUNNonlinSolSetLSolveFn(arg1,arg2);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FSUNNonlinSolSetConvTestFn(SUNNonlinearSolver farg1, SUNNonlinSolConvTestFn farg2, void *farg3) {
|
||||
int fresult ;
|
||||
SUNNonlinearSolver arg1 = (SUNNonlinearSolver) 0 ;
|
||||
SUNNonlinSolConvTestFn arg2 = (SUNNonlinSolConvTestFn) 0 ;
|
||||
void *arg3 = (void *) 0 ;
|
||||
int result;
|
||||
|
||||
arg1 = (SUNNonlinearSolver)(farg1);
|
||||
arg2 = (SUNNonlinSolConvTestFn)(farg2);
|
||||
arg3 = (void *)(farg3);
|
||||
result = (int)SUNNonlinSolSetConvTestFn(arg1,arg2,arg3);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FSUNNonlinSolSetMaxIters(SUNNonlinearSolver farg1, int const *farg2) {
|
||||
int fresult ;
|
||||
SUNNonlinearSolver arg1 = (SUNNonlinearSolver) 0 ;
|
||||
int arg2 ;
|
||||
int result;
|
||||
|
||||
arg1 = (SUNNonlinearSolver)(farg1);
|
||||
arg2 = (int)(*farg2);
|
||||
result = (int)SUNNonlinSolSetMaxIters(arg1,arg2);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FSUNNonlinSolGetNumIters(SUNNonlinearSolver farg1, long *farg2) {
|
||||
int fresult ;
|
||||
SUNNonlinearSolver arg1 = (SUNNonlinearSolver) 0 ;
|
||||
long *arg2 = (long *) 0 ;
|
||||
int result;
|
||||
|
||||
arg1 = (SUNNonlinearSolver)(farg1);
|
||||
arg2 = (long *)(farg2);
|
||||
result = (int)SUNNonlinSolGetNumIters(arg1,arg2);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FSUNNonlinSolGetCurIter(SUNNonlinearSolver farg1, int *farg2) {
|
||||
int fresult ;
|
||||
SUNNonlinearSolver arg1 = (SUNNonlinearSolver) 0 ;
|
||||
int *arg2 = (int *) 0 ;
|
||||
int result;
|
||||
|
||||
arg1 = (SUNNonlinearSolver)(farg1);
|
||||
arg2 = (int *)(farg2);
|
||||
result = (int)SUNNonlinSolGetCurIter(arg1,arg2);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FSUNNonlinSolGetNumConvFails(SUNNonlinearSolver farg1, long *farg2) {
|
||||
int fresult ;
|
||||
SUNNonlinearSolver arg1 = (SUNNonlinearSolver) 0 ;
|
||||
long *arg2 = (long *) 0 ;
|
||||
int result;
|
||||
|
||||
arg1 = (SUNNonlinearSolver)(farg1);
|
||||
arg2 = (long *)(farg2);
|
||||
result = (int)SUNNonlinSolGetNumConvFails(arg1,arg2);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
|
||||
921
bazaar/plugin/sundials/src/sundials/fmod/fsundials_nvector_mod.c
Normal file
921
bazaar/plugin/sundials/src/sundials/fmod/fsundials_nvector_mod.c
Normal file
|
|
@ -0,0 +1,921 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
* This file was automatically generated by SWIG (http://www.swig.org).
|
||||
* Version 4.0.0
|
||||
*
|
||||
* This file is not intended to be easily readable and contains a number of
|
||||
* coding conventions designed to improve portability and efficiency. Do not make
|
||||
* changes to this file unless you know what you are doing--modify the SWIG
|
||||
* interface file instead.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
/* -----------------------------------------------------------------------------
|
||||
* This section contains generic SWIG labels for method/variable
|
||||
* declarations/attributes, and other compiler dependent labels.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
/* template workaround for compilers that cannot correctly implement the C++ standard */
|
||||
#ifndef SWIGTEMPLATEDISAMBIGUATOR
|
||||
# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560)
|
||||
# define SWIGTEMPLATEDISAMBIGUATOR template
|
||||
# elif defined(__HP_aCC)
|
||||
/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */
|
||||
/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */
|
||||
# define SWIGTEMPLATEDISAMBIGUATOR template
|
||||
# else
|
||||
# define SWIGTEMPLATEDISAMBIGUATOR
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* inline attribute */
|
||||
#ifndef SWIGINLINE
|
||||
# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__))
|
||||
# define SWIGINLINE inline
|
||||
# else
|
||||
# define SWIGINLINE
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* attribute recognised by some compilers to avoid 'unused' warnings */
|
||||
#ifndef SWIGUNUSED
|
||||
# if defined(__GNUC__)
|
||||
# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
|
||||
# define SWIGUNUSED __attribute__ ((__unused__))
|
||||
# else
|
||||
# define SWIGUNUSED
|
||||
# endif
|
||||
# elif defined(__ICC)
|
||||
# define SWIGUNUSED __attribute__ ((__unused__))
|
||||
# else
|
||||
# define SWIGUNUSED
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef SWIG_MSC_UNSUPPRESS_4505
|
||||
# if defined(_MSC_VER)
|
||||
# pragma warning(disable : 4505) /* unreferenced local function has been removed */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef SWIGUNUSEDPARM
|
||||
# ifdef __cplusplus
|
||||
# define SWIGUNUSEDPARM(p)
|
||||
# else
|
||||
# define SWIGUNUSEDPARM(p) p SWIGUNUSED
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* internal SWIG method */
|
||||
#ifndef SWIGINTERN
|
||||
# define SWIGINTERN static SWIGUNUSED
|
||||
#endif
|
||||
|
||||
/* internal inline SWIG method */
|
||||
#ifndef SWIGINTERNINLINE
|
||||
# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE
|
||||
#endif
|
||||
|
||||
/* qualifier for exported *const* global data variables*/
|
||||
#ifndef SWIGEXTERN
|
||||
# ifdef __cplusplus
|
||||
# define SWIGEXTERN extern
|
||||
# else
|
||||
# define SWIGEXTERN
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* exporting methods */
|
||||
#if defined(__GNUC__)
|
||||
# if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
|
||||
# ifndef GCC_HASCLASSVISIBILITY
|
||||
# define GCC_HASCLASSVISIBILITY
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef SWIGEXPORT
|
||||
# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
|
||||
# if defined(STATIC_LINKED)
|
||||
# define SWIGEXPORT
|
||||
# else
|
||||
# define SWIGEXPORT __declspec(dllexport)
|
||||
# endif
|
||||
# else
|
||||
# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY)
|
||||
# define SWIGEXPORT __attribute__ ((visibility("default")))
|
||||
# else
|
||||
# define SWIGEXPORT
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* calling conventions for Windows */
|
||||
#ifndef SWIGSTDCALL
|
||||
# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
|
||||
# define SWIGSTDCALL __stdcall
|
||||
# else
|
||||
# define SWIGSTDCALL
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
|
||||
#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
|
||||
# define _CRT_SECURE_NO_DEPRECATE
|
||||
#endif
|
||||
|
||||
/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */
|
||||
#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE)
|
||||
# define _SCL_SECURE_NO_DEPRECATE
|
||||
#endif
|
||||
|
||||
/* Deal with Apple's deprecated 'AssertMacros.h' from Carbon-framework */
|
||||
#if defined(__APPLE__) && !defined(__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES)
|
||||
# define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0
|
||||
#endif
|
||||
|
||||
/* Intel's compiler complains if a variable which was never initialised is
|
||||
* cast to void, which is a common idiom which we use to indicate that we
|
||||
* are aware a variable isn't used. So we just silence that warning.
|
||||
* See: https://github.com/swig/swig/issues/192 for more discussion.
|
||||
*/
|
||||
#ifdef __INTEL_COMPILER
|
||||
# pragma warning disable 592
|
||||
#endif
|
||||
|
||||
/* Errors in SWIG */
|
||||
#define SWIG_UnknownError -1
|
||||
#define SWIG_IOError -2
|
||||
#define SWIG_RuntimeError -3
|
||||
#define SWIG_IndexError -4
|
||||
#define SWIG_TypeError -5
|
||||
#define SWIG_DivisionByZero -6
|
||||
#define SWIG_OverflowError -7
|
||||
#define SWIG_SyntaxError -8
|
||||
#define SWIG_ValueError -9
|
||||
#define SWIG_SystemError -10
|
||||
#define SWIG_AttributeError -11
|
||||
#define SWIG_MemoryError -12
|
||||
#define SWIG_NullReferenceError -13
|
||||
|
||||
|
||||
|
||||
|
||||
#include <assert.h>
|
||||
#define SWIG_exception_impl(DECL, CODE, MSG, RETURNNULL) \
|
||||
{ printf("In " DECL ": " MSG); assert(0); RETURNNULL; }
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM)
|
||||
# ifndef snprintf
|
||||
# define snprintf _snprintf
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
/* Support for the `contract` feature.
|
||||
*
|
||||
* Note that RETURNNULL is first because it's inserted via a 'Replaceall' in
|
||||
* the fortran.cxx file.
|
||||
*/
|
||||
#define SWIG_contract_assert(RETURNNULL, EXPR, MSG) \
|
||||
if (!(EXPR)) { SWIG_exception_impl("$decl", SWIG_ValueError, MSG, RETURNNULL); }
|
||||
|
||||
|
||||
#define SWIGVERSION 0x040000
|
||||
#define SWIG_VERSION SWIGVERSION
|
||||
|
||||
|
||||
#define SWIG_as_voidptr(a) (void *)((const void *)(a))
|
||||
#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a))
|
||||
|
||||
|
||||
#include "sundials/sundials_nvector.h"
|
||||
|
||||
SWIGEXPORT N_Vector _wrap_FN_VNewEmpty() {
|
||||
N_Vector fresult ;
|
||||
N_Vector result;
|
||||
|
||||
result = (N_Vector)N_VNewEmpty();
|
||||
fresult = result;
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void _wrap_FN_VFreeEmpty(N_Vector farg1) {
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
N_VFreeEmpty(arg1);
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FN_VCopyOps(N_Vector farg1, N_Vector farg2) {
|
||||
int fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
N_Vector arg2 = (N_Vector) 0 ;
|
||||
int result;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
arg2 = (N_Vector)(farg2);
|
||||
result = (int)N_VCopyOps(arg1,arg2);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FN_VGetVectorID(N_Vector farg1) {
|
||||
int fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
N_Vector_ID result;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
result = (N_Vector_ID)N_VGetVectorID(arg1);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT N_Vector _wrap_FN_VClone(N_Vector farg1) {
|
||||
N_Vector fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
N_Vector result;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
result = (N_Vector)N_VClone(arg1);
|
||||
fresult = result;
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT N_Vector _wrap_FN_VCloneEmpty(N_Vector farg1) {
|
||||
N_Vector fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
N_Vector result;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
result = (N_Vector)N_VCloneEmpty(arg1);
|
||||
fresult = result;
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void _wrap_FN_VDestroy(N_Vector farg1) {
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
N_VDestroy(arg1);
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void _wrap_FN_VSpace(N_Vector farg1, int64_t *farg2, int64_t *farg3) {
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
sunindextype *arg2 = (sunindextype *) 0 ;
|
||||
sunindextype *arg3 = (sunindextype *) 0 ;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
arg2 = (sunindextype *)(farg2);
|
||||
arg3 = (sunindextype *)(farg3);
|
||||
N_VSpace(arg1,arg2,arg3);
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT double * _wrap_FN_VGetArrayPointer(N_Vector farg1) {
|
||||
double * fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
realtype *result = 0 ;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
result = (realtype *)N_VGetArrayPointer(arg1);
|
||||
fresult = result;
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void _wrap_FN_VSetArrayPointer(double *farg1, N_Vector farg2) {
|
||||
realtype *arg1 = (realtype *) 0 ;
|
||||
N_Vector arg2 = (N_Vector) 0 ;
|
||||
|
||||
arg1 = (realtype *)(farg1);
|
||||
arg2 = (N_Vector)(farg2);
|
||||
N_VSetArrayPointer(arg1,arg2);
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void * _wrap_FN_VGetCommunicator(N_Vector farg1) {
|
||||
void * fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
void *result = 0 ;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
result = (void *)N_VGetCommunicator(arg1);
|
||||
fresult = result;
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int64_t _wrap_FN_VGetLength(N_Vector farg1) {
|
||||
int64_t fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
sunindextype result;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
result = N_VGetLength(arg1);
|
||||
fresult = (sunindextype)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void _wrap_FN_VLinearSum(double const *farg1, N_Vector farg2, double const *farg3, N_Vector farg4, N_Vector farg5) {
|
||||
realtype arg1 ;
|
||||
N_Vector arg2 = (N_Vector) 0 ;
|
||||
realtype arg3 ;
|
||||
N_Vector arg4 = (N_Vector) 0 ;
|
||||
N_Vector arg5 = (N_Vector) 0 ;
|
||||
|
||||
arg1 = (realtype)(*farg1);
|
||||
arg2 = (N_Vector)(farg2);
|
||||
arg3 = (realtype)(*farg3);
|
||||
arg4 = (N_Vector)(farg4);
|
||||
arg5 = (N_Vector)(farg5);
|
||||
N_VLinearSum(arg1,arg2,arg3,arg4,arg5);
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void _wrap_FN_VConst(double const *farg1, N_Vector farg2) {
|
||||
realtype arg1 ;
|
||||
N_Vector arg2 = (N_Vector) 0 ;
|
||||
|
||||
arg1 = (realtype)(*farg1);
|
||||
arg2 = (N_Vector)(farg2);
|
||||
N_VConst(arg1,arg2);
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void _wrap_FN_VProd(N_Vector farg1, N_Vector farg2, N_Vector farg3) {
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
N_Vector arg2 = (N_Vector) 0 ;
|
||||
N_Vector arg3 = (N_Vector) 0 ;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
arg2 = (N_Vector)(farg2);
|
||||
arg3 = (N_Vector)(farg3);
|
||||
N_VProd(arg1,arg2,arg3);
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void _wrap_FN_VDiv(N_Vector farg1, N_Vector farg2, N_Vector farg3) {
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
N_Vector arg2 = (N_Vector) 0 ;
|
||||
N_Vector arg3 = (N_Vector) 0 ;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
arg2 = (N_Vector)(farg2);
|
||||
arg3 = (N_Vector)(farg3);
|
||||
N_VDiv(arg1,arg2,arg3);
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void _wrap_FN_VScale(double const *farg1, N_Vector farg2, N_Vector farg3) {
|
||||
realtype arg1 ;
|
||||
N_Vector arg2 = (N_Vector) 0 ;
|
||||
N_Vector arg3 = (N_Vector) 0 ;
|
||||
|
||||
arg1 = (realtype)(*farg1);
|
||||
arg2 = (N_Vector)(farg2);
|
||||
arg3 = (N_Vector)(farg3);
|
||||
N_VScale(arg1,arg2,arg3);
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void _wrap_FN_VAbs(N_Vector farg1, N_Vector farg2) {
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
N_Vector arg2 = (N_Vector) 0 ;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
arg2 = (N_Vector)(farg2);
|
||||
N_VAbs(arg1,arg2);
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void _wrap_FN_VInv(N_Vector farg1, N_Vector farg2) {
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
N_Vector arg2 = (N_Vector) 0 ;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
arg2 = (N_Vector)(farg2);
|
||||
N_VInv(arg1,arg2);
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void _wrap_FN_VAddConst(N_Vector farg1, double const *farg2, N_Vector farg3) {
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
realtype arg2 ;
|
||||
N_Vector arg3 = (N_Vector) 0 ;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
arg2 = (realtype)(*farg2);
|
||||
arg3 = (N_Vector)(farg3);
|
||||
N_VAddConst(arg1,arg2,arg3);
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT double _wrap_FN_VDotProd(N_Vector farg1, N_Vector farg2) {
|
||||
double fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
N_Vector arg2 = (N_Vector) 0 ;
|
||||
realtype result;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
arg2 = (N_Vector)(farg2);
|
||||
result = (realtype)N_VDotProd(arg1,arg2);
|
||||
fresult = (realtype)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT double _wrap_FN_VMaxNorm(N_Vector farg1) {
|
||||
double fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
realtype result;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
result = (realtype)N_VMaxNorm(arg1);
|
||||
fresult = (realtype)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT double _wrap_FN_VWrmsNorm(N_Vector farg1, N_Vector farg2) {
|
||||
double fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
N_Vector arg2 = (N_Vector) 0 ;
|
||||
realtype result;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
arg2 = (N_Vector)(farg2);
|
||||
result = (realtype)N_VWrmsNorm(arg1,arg2);
|
||||
fresult = (realtype)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT double _wrap_FN_VWrmsNormMask(N_Vector farg1, N_Vector farg2, N_Vector farg3) {
|
||||
double fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
N_Vector arg2 = (N_Vector) 0 ;
|
||||
N_Vector arg3 = (N_Vector) 0 ;
|
||||
realtype result;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
arg2 = (N_Vector)(farg2);
|
||||
arg3 = (N_Vector)(farg3);
|
||||
result = (realtype)N_VWrmsNormMask(arg1,arg2,arg3);
|
||||
fresult = (realtype)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT double _wrap_FN_VMin(N_Vector farg1) {
|
||||
double fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
realtype result;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
result = (realtype)N_VMin(arg1);
|
||||
fresult = (realtype)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT double _wrap_FN_VWL2Norm(N_Vector farg1, N_Vector farg2) {
|
||||
double fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
N_Vector arg2 = (N_Vector) 0 ;
|
||||
realtype result;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
arg2 = (N_Vector)(farg2);
|
||||
result = (realtype)N_VWL2Norm(arg1,arg2);
|
||||
fresult = (realtype)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT double _wrap_FN_VL1Norm(N_Vector farg1) {
|
||||
double fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
realtype result;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
result = (realtype)N_VL1Norm(arg1);
|
||||
fresult = (realtype)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void _wrap_FN_VCompare(double const *farg1, N_Vector farg2, N_Vector farg3) {
|
||||
realtype arg1 ;
|
||||
N_Vector arg2 = (N_Vector) 0 ;
|
||||
N_Vector arg3 = (N_Vector) 0 ;
|
||||
|
||||
arg1 = (realtype)(*farg1);
|
||||
arg2 = (N_Vector)(farg2);
|
||||
arg3 = (N_Vector)(farg3);
|
||||
N_VCompare(arg1,arg2,arg3);
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FN_VInvTest(N_Vector farg1, N_Vector farg2) {
|
||||
int fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
N_Vector arg2 = (N_Vector) 0 ;
|
||||
int result;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
arg2 = (N_Vector)(farg2);
|
||||
result = (int)N_VInvTest(arg1,arg2);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FN_VConstrMask(N_Vector farg1, N_Vector farg2, N_Vector farg3) {
|
||||
int fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
N_Vector arg2 = (N_Vector) 0 ;
|
||||
N_Vector arg3 = (N_Vector) 0 ;
|
||||
int result;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
arg2 = (N_Vector)(farg2);
|
||||
arg3 = (N_Vector)(farg3);
|
||||
result = (int)N_VConstrMask(arg1,arg2,arg3);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT double _wrap_FN_VMinQuotient(N_Vector farg1, N_Vector farg2) {
|
||||
double fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
N_Vector arg2 = (N_Vector) 0 ;
|
||||
realtype result;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
arg2 = (N_Vector)(farg2);
|
||||
result = (realtype)N_VMinQuotient(arg1,arg2);
|
||||
fresult = (realtype)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FN_VLinearCombination(int const *farg1, double *farg2, void *farg3, N_Vector farg4) {
|
||||
int fresult ;
|
||||
int arg1 ;
|
||||
realtype *arg2 = (realtype *) 0 ;
|
||||
N_Vector *arg3 = (N_Vector *) 0 ;
|
||||
N_Vector arg4 = (N_Vector) 0 ;
|
||||
int result;
|
||||
|
||||
arg1 = (int)(*farg1);
|
||||
arg2 = (realtype *)(farg2);
|
||||
arg3 = (N_Vector *)(farg3);
|
||||
arg4 = (N_Vector)(farg4);
|
||||
result = (int)N_VLinearCombination(arg1,arg2,arg3,arg4);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FN_VScaleAddMulti(int const *farg1, double *farg2, N_Vector farg3, void *farg4, void *farg5) {
|
||||
int fresult ;
|
||||
int arg1 ;
|
||||
realtype *arg2 = (realtype *) 0 ;
|
||||
N_Vector arg3 = (N_Vector) 0 ;
|
||||
N_Vector *arg4 = (N_Vector *) 0 ;
|
||||
N_Vector *arg5 = (N_Vector *) 0 ;
|
||||
int result;
|
||||
|
||||
arg1 = (int)(*farg1);
|
||||
arg2 = (realtype *)(farg2);
|
||||
arg3 = (N_Vector)(farg3);
|
||||
arg4 = (N_Vector *)(farg4);
|
||||
arg5 = (N_Vector *)(farg5);
|
||||
result = (int)N_VScaleAddMulti(arg1,arg2,arg3,arg4,arg5);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FN_VDotProdMulti(int const *farg1, N_Vector farg2, void *farg3, double *farg4) {
|
||||
int fresult ;
|
||||
int arg1 ;
|
||||
N_Vector arg2 = (N_Vector) 0 ;
|
||||
N_Vector *arg3 = (N_Vector *) 0 ;
|
||||
realtype *arg4 = (realtype *) 0 ;
|
||||
int result;
|
||||
|
||||
arg1 = (int)(*farg1);
|
||||
arg2 = (N_Vector)(farg2);
|
||||
arg3 = (N_Vector *)(farg3);
|
||||
arg4 = (realtype *)(farg4);
|
||||
result = (int)N_VDotProdMulti(arg1,arg2,arg3,arg4);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FN_VLinearSumVectorArray(int const *farg1, double const *farg2, void *farg3, double const *farg4, void *farg5, void *farg6) {
|
||||
int fresult ;
|
||||
int arg1 ;
|
||||
realtype arg2 ;
|
||||
N_Vector *arg3 = (N_Vector *) 0 ;
|
||||
realtype arg4 ;
|
||||
N_Vector *arg5 = (N_Vector *) 0 ;
|
||||
N_Vector *arg6 = (N_Vector *) 0 ;
|
||||
int result;
|
||||
|
||||
arg1 = (int)(*farg1);
|
||||
arg2 = (realtype)(*farg2);
|
||||
arg3 = (N_Vector *)(farg3);
|
||||
arg4 = (realtype)(*farg4);
|
||||
arg5 = (N_Vector *)(farg5);
|
||||
arg6 = (N_Vector *)(farg6);
|
||||
result = (int)N_VLinearSumVectorArray(arg1,arg2,arg3,arg4,arg5,arg6);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FN_VScaleVectorArray(int const *farg1, double *farg2, void *farg3, void *farg4) {
|
||||
int fresult ;
|
||||
int arg1 ;
|
||||
realtype *arg2 = (realtype *) 0 ;
|
||||
N_Vector *arg3 = (N_Vector *) 0 ;
|
||||
N_Vector *arg4 = (N_Vector *) 0 ;
|
||||
int result;
|
||||
|
||||
arg1 = (int)(*farg1);
|
||||
arg2 = (realtype *)(farg2);
|
||||
arg3 = (N_Vector *)(farg3);
|
||||
arg4 = (N_Vector *)(farg4);
|
||||
result = (int)N_VScaleVectorArray(arg1,arg2,arg3,arg4);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FN_VConstVectorArray(int const *farg1, double const *farg2, void *farg3) {
|
||||
int fresult ;
|
||||
int arg1 ;
|
||||
realtype arg2 ;
|
||||
N_Vector *arg3 = (N_Vector *) 0 ;
|
||||
int result;
|
||||
|
||||
arg1 = (int)(*farg1);
|
||||
arg2 = (realtype)(*farg2);
|
||||
arg3 = (N_Vector *)(farg3);
|
||||
result = (int)N_VConstVectorArray(arg1,arg2,arg3);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FN_VWrmsNormVectorArray(int const *farg1, void *farg2, void *farg3, double *farg4) {
|
||||
int fresult ;
|
||||
int arg1 ;
|
||||
N_Vector *arg2 = (N_Vector *) 0 ;
|
||||
N_Vector *arg3 = (N_Vector *) 0 ;
|
||||
realtype *arg4 = (realtype *) 0 ;
|
||||
int result;
|
||||
|
||||
arg1 = (int)(*farg1);
|
||||
arg2 = (N_Vector *)(farg2);
|
||||
arg3 = (N_Vector *)(farg3);
|
||||
arg4 = (realtype *)(farg4);
|
||||
result = (int)N_VWrmsNormVectorArray(arg1,arg2,arg3,arg4);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FN_VWrmsNormMaskVectorArray(int const *farg1, void *farg2, void *farg3, N_Vector farg4, double *farg5) {
|
||||
int fresult ;
|
||||
int arg1 ;
|
||||
N_Vector *arg2 = (N_Vector *) 0 ;
|
||||
N_Vector *arg3 = (N_Vector *) 0 ;
|
||||
N_Vector arg4 = (N_Vector) 0 ;
|
||||
realtype *arg5 = (realtype *) 0 ;
|
||||
int result;
|
||||
|
||||
arg1 = (int)(*farg1);
|
||||
arg2 = (N_Vector *)(farg2);
|
||||
arg3 = (N_Vector *)(farg3);
|
||||
arg4 = (N_Vector)(farg4);
|
||||
arg5 = (realtype *)(farg5);
|
||||
result = (int)N_VWrmsNormMaskVectorArray(arg1,arg2,arg3,arg4,arg5);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT double _wrap_FN_VDotProdLocal(N_Vector farg1, N_Vector farg2) {
|
||||
double fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
N_Vector arg2 = (N_Vector) 0 ;
|
||||
realtype result;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
arg2 = (N_Vector)(farg2);
|
||||
result = (realtype)N_VDotProdLocal(arg1,arg2);
|
||||
fresult = (realtype)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT double _wrap_FN_VMaxNormLocal(N_Vector farg1) {
|
||||
double fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
realtype result;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
result = (realtype)N_VMaxNormLocal(arg1);
|
||||
fresult = (realtype)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT double _wrap_FN_VMinLocal(N_Vector farg1) {
|
||||
double fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
realtype result;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
result = (realtype)N_VMinLocal(arg1);
|
||||
fresult = (realtype)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT double _wrap_FN_VL1NormLocal(N_Vector farg1) {
|
||||
double fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
realtype result;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
result = (realtype)N_VL1NormLocal(arg1);
|
||||
fresult = (realtype)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT double _wrap_FN_VWSqrSumLocal(N_Vector farg1, N_Vector farg2) {
|
||||
double fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
N_Vector arg2 = (N_Vector) 0 ;
|
||||
realtype result;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
arg2 = (N_Vector)(farg2);
|
||||
result = (realtype)N_VWSqrSumLocal(arg1,arg2);
|
||||
fresult = (realtype)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT double _wrap_FN_VWSqrSumMaskLocal(N_Vector farg1, N_Vector farg2, N_Vector farg3) {
|
||||
double fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
N_Vector arg2 = (N_Vector) 0 ;
|
||||
N_Vector arg3 = (N_Vector) 0 ;
|
||||
realtype result;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
arg2 = (N_Vector)(farg2);
|
||||
arg3 = (N_Vector)(farg3);
|
||||
result = (realtype)N_VWSqrSumMaskLocal(arg1,arg2,arg3);
|
||||
fresult = (realtype)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FN_VInvTestLocal(N_Vector farg1, N_Vector farg2) {
|
||||
int fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
N_Vector arg2 = (N_Vector) 0 ;
|
||||
int result;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
arg2 = (N_Vector)(farg2);
|
||||
result = (int)N_VInvTestLocal(arg1,arg2);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int _wrap_FN_VConstrMaskLocal(N_Vector farg1, N_Vector farg2, N_Vector farg3) {
|
||||
int fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
N_Vector arg2 = (N_Vector) 0 ;
|
||||
N_Vector arg3 = (N_Vector) 0 ;
|
||||
int result;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
arg2 = (N_Vector)(farg2);
|
||||
arg3 = (N_Vector)(farg3);
|
||||
result = (int)N_VConstrMaskLocal(arg1,arg2,arg3);
|
||||
fresult = (int)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT double _wrap_FN_VMinQuotientLocal(N_Vector farg1, N_Vector farg2) {
|
||||
double fresult ;
|
||||
N_Vector arg1 = (N_Vector) 0 ;
|
||||
N_Vector arg2 = (N_Vector) 0 ;
|
||||
realtype result;
|
||||
|
||||
arg1 = (N_Vector)(farg1);
|
||||
arg2 = (N_Vector)(farg2);
|
||||
result = (realtype)N_VMinQuotientLocal(arg1,arg2);
|
||||
fresult = (realtype)(result);
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void * _wrap_FN_VNewVectorArray(int const *farg1) {
|
||||
void * fresult ;
|
||||
int arg1 ;
|
||||
N_Vector *result = 0 ;
|
||||
|
||||
arg1 = (int)(*farg1);
|
||||
result = (N_Vector *)N_VNewVectorArray(arg1);
|
||||
fresult = result;
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void * _wrap_FN_VCloneEmptyVectorArray(int const *farg1, N_Vector farg2) {
|
||||
void * fresult ;
|
||||
int arg1 ;
|
||||
N_Vector arg2 = (N_Vector) 0 ;
|
||||
N_Vector *result = 0 ;
|
||||
|
||||
arg1 = (int)(*farg1);
|
||||
arg2 = (N_Vector)(farg2);
|
||||
result = (N_Vector *)N_VCloneEmptyVectorArray(arg1,arg2);
|
||||
fresult = result;
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void * _wrap_FN_VCloneVectorArray(int const *farg1, N_Vector farg2) {
|
||||
void * fresult ;
|
||||
int arg1 ;
|
||||
N_Vector arg2 = (N_Vector) 0 ;
|
||||
N_Vector *result = 0 ;
|
||||
|
||||
arg1 = (int)(*farg1);
|
||||
arg2 = (N_Vector)(farg2);
|
||||
result = (N_Vector *)N_VCloneVectorArray(arg1,arg2);
|
||||
fresult = result;
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void _wrap_FN_VDestroyVectorArray(void *farg1, int const *farg2) {
|
||||
N_Vector *arg1 = (N_Vector *) 0 ;
|
||||
int arg2 ;
|
||||
|
||||
arg1 = (N_Vector *)(farg1);
|
||||
arg2 = (int)(*farg2);
|
||||
N_VDestroyVectorArray(arg1,arg2);
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT N_Vector _wrap_FN_VGetVecAtIndexVectorArray(void *farg1, int const *farg2) {
|
||||
N_Vector fresult ;
|
||||
N_Vector *arg1 = (N_Vector *) 0 ;
|
||||
int arg2 ;
|
||||
N_Vector result;
|
||||
|
||||
arg1 = (N_Vector *)(farg1);
|
||||
arg2 = (int)(*farg2);
|
||||
result = (N_Vector)N_VGetVecAtIndexVectorArray(arg1,arg2);
|
||||
fresult = result;
|
||||
return fresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT void _wrap_FN_VSetVecAtIndexVectorArray(void *farg1, int const *farg2, N_Vector farg3) {
|
||||
N_Vector *arg1 = (N_Vector *) 0 ;
|
||||
int arg2 ;
|
||||
N_Vector arg3 = (N_Vector) 0 ;
|
||||
|
||||
arg1 = (N_Vector *)(farg1);
|
||||
arg2 = (int)(*farg2);
|
||||
arg3 = (N_Vector)(farg3);
|
||||
N_VSetVecAtIndexVectorArray(arg1,arg2,arg3);
|
||||
}
|
||||
|
||||
|
||||
|
||||
219
bazaar/plugin/sundials/src/sundials/fmod/fsundials_types_mod.c
Normal file
219
bazaar/plugin/sundials/src/sundials/fmod/fsundials_types_mod.c
Normal file
|
|
@ -0,0 +1,219 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
* This file was automatically generated by SWIG (http://www.swig.org).
|
||||
* Version 4.0.0
|
||||
*
|
||||
* This file is not intended to be easily readable and contains a number of
|
||||
* coding conventions designed to improve portability and efficiency. Do not make
|
||||
* changes to this file unless you know what you are doing--modify the SWIG
|
||||
* interface file instead.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
/* ---------------------------------------------------------------
|
||||
* Programmer(s): Auto-generated by swig.
|
||||
* ---------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
* -------------------------------------------------------------*/
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* This section contains generic SWIG labels for method/variable
|
||||
* declarations/attributes, and other compiler dependent labels.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
/* template workaround for compilers that cannot correctly implement the C++ standard */
|
||||
#ifndef SWIGTEMPLATEDISAMBIGUATOR
|
||||
# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560)
|
||||
# define SWIGTEMPLATEDISAMBIGUATOR template
|
||||
# elif defined(__HP_aCC)
|
||||
/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */
|
||||
/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */
|
||||
# define SWIGTEMPLATEDISAMBIGUATOR template
|
||||
# else
|
||||
# define SWIGTEMPLATEDISAMBIGUATOR
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* inline attribute */
|
||||
#ifndef SWIGINLINE
|
||||
# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__))
|
||||
# define SWIGINLINE inline
|
||||
# else
|
||||
# define SWIGINLINE
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* attribute recognised by some compilers to avoid 'unused' warnings */
|
||||
#ifndef SWIGUNUSED
|
||||
# if defined(__GNUC__)
|
||||
# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
|
||||
# define SWIGUNUSED __attribute__ ((__unused__))
|
||||
# else
|
||||
# define SWIGUNUSED
|
||||
# endif
|
||||
# elif defined(__ICC)
|
||||
# define SWIGUNUSED __attribute__ ((__unused__))
|
||||
# else
|
||||
# define SWIGUNUSED
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef SWIG_MSC_UNSUPPRESS_4505
|
||||
# if defined(_MSC_VER)
|
||||
# pragma warning(disable : 4505) /* unreferenced local function has been removed */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef SWIGUNUSEDPARM
|
||||
# ifdef __cplusplus
|
||||
# define SWIGUNUSEDPARM(p)
|
||||
# else
|
||||
# define SWIGUNUSEDPARM(p) p SWIGUNUSED
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* internal SWIG method */
|
||||
#ifndef SWIGINTERN
|
||||
# define SWIGINTERN static SWIGUNUSED
|
||||
#endif
|
||||
|
||||
/* internal inline SWIG method */
|
||||
#ifndef SWIGINTERNINLINE
|
||||
# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE
|
||||
#endif
|
||||
|
||||
/* qualifier for exported *const* global data variables*/
|
||||
#ifndef SWIGEXTERN
|
||||
# ifdef __cplusplus
|
||||
# define SWIGEXTERN extern
|
||||
# else
|
||||
# define SWIGEXTERN
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* exporting methods */
|
||||
#if defined(__GNUC__)
|
||||
# if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
|
||||
# ifndef GCC_HASCLASSVISIBILITY
|
||||
# define GCC_HASCLASSVISIBILITY
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef SWIGEXPORT
|
||||
# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
|
||||
# if defined(STATIC_LINKED)
|
||||
# define SWIGEXPORT
|
||||
# else
|
||||
# define SWIGEXPORT __declspec(dllexport)
|
||||
# endif
|
||||
# else
|
||||
# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY)
|
||||
# define SWIGEXPORT __attribute__ ((visibility("default")))
|
||||
# else
|
||||
# define SWIGEXPORT
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* calling conventions for Windows */
|
||||
#ifndef SWIGSTDCALL
|
||||
# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
|
||||
# define SWIGSTDCALL __stdcall
|
||||
# else
|
||||
# define SWIGSTDCALL
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
|
||||
#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
|
||||
# define _CRT_SECURE_NO_DEPRECATE
|
||||
#endif
|
||||
|
||||
/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */
|
||||
#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE)
|
||||
# define _SCL_SECURE_NO_DEPRECATE
|
||||
#endif
|
||||
|
||||
/* Deal with Apple's deprecated 'AssertMacros.h' from Carbon-framework */
|
||||
#if defined(__APPLE__) && !defined(__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES)
|
||||
# define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0
|
||||
#endif
|
||||
|
||||
/* Intel's compiler complains if a variable which was never initialised is
|
||||
* cast to void, which is a common idiom which we use to indicate that we
|
||||
* are aware a variable isn't used. So we just silence that warning.
|
||||
* See: https://github.com/swig/swig/issues/192 for more discussion.
|
||||
*/
|
||||
#ifdef __INTEL_COMPILER
|
||||
# pragma warning disable 592
|
||||
#endif
|
||||
|
||||
/* Errors in SWIG */
|
||||
#define SWIG_UnknownError -1
|
||||
#define SWIG_IOError -2
|
||||
#define SWIG_RuntimeError -3
|
||||
#define SWIG_IndexError -4
|
||||
#define SWIG_TypeError -5
|
||||
#define SWIG_DivisionByZero -6
|
||||
#define SWIG_OverflowError -7
|
||||
#define SWIG_SyntaxError -8
|
||||
#define SWIG_ValueError -9
|
||||
#define SWIG_SystemError -10
|
||||
#define SWIG_AttributeError -11
|
||||
#define SWIG_MemoryError -12
|
||||
#define SWIG_NullReferenceError -13
|
||||
|
||||
|
||||
|
||||
|
||||
#include <assert.h>
|
||||
#define SWIG_exception_impl(DECL, CODE, MSG, RETURNNULL) \
|
||||
{ printf("In " DECL ": " MSG); assert(0); RETURNNULL; }
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM)
|
||||
# ifndef snprintf
|
||||
# define snprintf _snprintf
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
/* Support for the `contract` feature.
|
||||
*
|
||||
* Note that RETURNNULL is first because it's inserted via a 'Replaceall' in
|
||||
* the fortran.cxx file.
|
||||
*/
|
||||
#define SWIG_contract_assert(RETURNNULL, EXPR, MSG) \
|
||||
if (!(EXPR)) { SWIG_exception_impl("$decl", SWIG_ValueError, MSG, RETURNNULL); }
|
||||
|
||||
|
||||
#define SWIGVERSION 0x040000
|
||||
#define SWIG_VERSION SWIGVERSION
|
||||
|
||||
|
||||
#define SWIG_as_voidptr(a) (void *)((const void *)(a))
|
||||
#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a))
|
||||
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
#include "sundials/sundials_types.h"
|
||||
|
||||
#ifndef SUNDIALS_DOUBLE_PRECISION
|
||||
#error "The Fortran bindings are only targeted at double-precision"
|
||||
#endif
|
||||
|
||||
#ifndef SUNDIALS_INT64_T
|
||||
#error "The Fortran bindings are only targeted at 64-bit indices"
|
||||
#endif
|
||||
|
||||
|
||||
264
bazaar/plugin/sundials/src/sundials/sundials_band.c
Normal file
264
bazaar/plugin/sundials/src/sundials/sundials_band.c
Normal file
|
|
@ -0,0 +1,264 @@
|
|||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* $Revision$
|
||||
* $Date$
|
||||
* -----------------------------------------------------------------
|
||||
* Programmer(s): Alan C. Hindmarsh and Radu Serban @ LLNL
|
||||
* -----------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
* -----------------------------------------------------------------
|
||||
* This is the implementation file for a generic BAND linear
|
||||
* solver package.
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <sundials/sundials_band.h>
|
||||
#include <sundials/sundials_math.h>
|
||||
|
||||
#define ZERO RCONST(0.0)
|
||||
#define ONE RCONST(1.0)
|
||||
|
||||
#define ROW(i,j,smu) (i-j+smu)
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------
|
||||
* Functions working on DlsMat
|
||||
* -----------------------------------------------------
|
||||
*/
|
||||
|
||||
sunindextype BandGBTRF(DlsMat A, sunindextype *p)
|
||||
{
|
||||
return(bandGBTRF(A->cols, A->M, A->mu, A->ml, A->s_mu, p));
|
||||
}
|
||||
|
||||
void BandGBTRS(DlsMat A, sunindextype *p, realtype *b)
|
||||
{
|
||||
bandGBTRS(A->cols, A->M, A->s_mu, A->ml, p, b);
|
||||
}
|
||||
|
||||
void BandCopy(DlsMat A, DlsMat B, sunindextype copymu, sunindextype copyml)
|
||||
{
|
||||
bandCopy(A->cols, B->cols, A->M, A->s_mu, B->s_mu, copymu, copyml);
|
||||
}
|
||||
|
||||
void BandScale(realtype c, DlsMat A)
|
||||
{
|
||||
bandScale(c, A->cols, A->M, A->mu, A->ml, A->s_mu);
|
||||
}
|
||||
|
||||
void BandMatvec(DlsMat A, realtype *x, realtype *y)
|
||||
{
|
||||
bandMatvec(A->cols, x, y, A->M, A->mu, A->ml, A->s_mu);
|
||||
}
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------
|
||||
* Functions working on realtype**
|
||||
* -----------------------------------------------------
|
||||
*/
|
||||
|
||||
sunindextype bandGBTRF(realtype **a, sunindextype n, sunindextype mu, sunindextype ml, sunindextype smu, sunindextype *p)
|
||||
{
|
||||
sunindextype c, r, num_rows;
|
||||
sunindextype i, j, k, l, storage_l, storage_k, last_col_k, last_row_k;
|
||||
realtype *a_c, *col_k, *diag_k, *sub_diag_k, *col_j, *kptr, *jptr;
|
||||
realtype max, temp, mult, a_kj;
|
||||
booleantype swap;
|
||||
|
||||
/* zero out the first smu - mu rows of the rectangular array a */
|
||||
|
||||
num_rows = smu - mu;
|
||||
if (num_rows > 0) {
|
||||
for (c=0; c < n; c++) {
|
||||
a_c = a[c];
|
||||
for (r=0; r < num_rows; r++) {
|
||||
a_c[r] = ZERO;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* k = elimination step number */
|
||||
|
||||
for (k=0; k < n-1; k++, p++) {
|
||||
|
||||
col_k = a[k];
|
||||
diag_k = col_k + smu;
|
||||
sub_diag_k = diag_k + 1;
|
||||
last_row_k = SUNMIN(n-1,k+ml);
|
||||
|
||||
/* find l = pivot row number */
|
||||
|
||||
l=k;
|
||||
max = SUNRabs(*diag_k);
|
||||
for (i=k+1, kptr=sub_diag_k; i <= last_row_k; i++, kptr++) {
|
||||
if (SUNRabs(*kptr) > max) {
|
||||
l=i;
|
||||
max = SUNRabs(*kptr);
|
||||
}
|
||||
}
|
||||
storage_l = ROW(l, k, smu);
|
||||
*p = l;
|
||||
|
||||
/* check for zero pivot element */
|
||||
|
||||
if (col_k[storage_l] == ZERO) return(k+1);
|
||||
|
||||
/* swap a(l,k) and a(k,k) if necessary */
|
||||
|
||||
if ( (swap = (l != k) )) {
|
||||
temp = col_k[storage_l];
|
||||
col_k[storage_l] = *diag_k;
|
||||
*diag_k = temp;
|
||||
}
|
||||
|
||||
/* Scale the elements below the diagonal in */
|
||||
/* column k by -1.0 / a(k,k). After the above swap, */
|
||||
/* a(k,k) holds the pivot element. This scaling */
|
||||
/* stores the pivot row multipliers -a(i,k)/a(k,k) */
|
||||
/* in a(i,k), i=k+1, ..., SUNMIN(n-1,k+ml). */
|
||||
|
||||
mult = -ONE / (*diag_k);
|
||||
for (i=k+1, kptr = sub_diag_k; i <= last_row_k; i++, kptr++)
|
||||
(*kptr) *= mult;
|
||||
|
||||
/* row_i = row_i - [a(i,k)/a(k,k)] row_k, i=k+1, ..., SUNMIN(n-1,k+ml) */
|
||||
/* row k is the pivot row after swapping with row l. */
|
||||
/* The computation is done one column at a time, */
|
||||
/* column j=k+1, ..., SUNMIN(k+smu,n-1). */
|
||||
|
||||
last_col_k = SUNMIN(k+smu,n-1);
|
||||
for (j=k+1; j <= last_col_k; j++) {
|
||||
|
||||
col_j = a[j];
|
||||
storage_l = ROW(l,j,smu);
|
||||
storage_k = ROW(k,j,smu);
|
||||
a_kj = col_j[storage_l];
|
||||
|
||||
/* Swap the elements a(k,j) and a(k,l) if l!=k. */
|
||||
|
||||
if (swap) {
|
||||
col_j[storage_l] = col_j[storage_k];
|
||||
col_j[storage_k] = a_kj;
|
||||
}
|
||||
|
||||
/* a(i,j) = a(i,j) - [a(i,k)/a(k,k)]*a(k,j) */
|
||||
/* a_kj = a(k,j), *kptr = - a(i,k)/a(k,k), *jptr = a(i,j) */
|
||||
|
||||
if (a_kj != ZERO) {
|
||||
for (i=k+1, kptr=sub_diag_k, jptr=col_j+ROW(k+1,j,smu);
|
||||
i <= last_row_k;
|
||||
i++, kptr++, jptr++)
|
||||
(*jptr) += a_kj * (*kptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* set the last pivot row to be n-1 and check for a zero pivot */
|
||||
|
||||
*p = n-1;
|
||||
if (a[n-1][smu] == ZERO) return(n);
|
||||
|
||||
/* return 0 to indicate success */
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
void bandGBTRS(realtype **a, sunindextype n, sunindextype smu, sunindextype ml, sunindextype *p, realtype *b)
|
||||
{
|
||||
sunindextype k, l, i, first_row_k, last_row_k;
|
||||
realtype mult, *diag_k;
|
||||
|
||||
/* Solve Ly = Pb, store solution y in b */
|
||||
|
||||
for (k=0; k < n-1; k++) {
|
||||
l = p[k];
|
||||
mult = b[l];
|
||||
if (l != k) {
|
||||
b[l] = b[k];
|
||||
b[k] = mult;
|
||||
}
|
||||
diag_k = a[k]+smu;
|
||||
last_row_k = SUNMIN(n-1,k+ml);
|
||||
for (i=k+1; i <= last_row_k; i++)
|
||||
b[i] += mult * diag_k[i-k];
|
||||
}
|
||||
|
||||
/* Solve Ux = y, store solution x in b */
|
||||
|
||||
for (k=n-1; k >= 0; k--) {
|
||||
diag_k = a[k]+smu;
|
||||
first_row_k = SUNMAX(0,k-smu);
|
||||
b[k] /= (*diag_k);
|
||||
mult = -b[k];
|
||||
for (i=first_row_k; i <= k-1; i++)
|
||||
b[i] += mult*diag_k[i-k];
|
||||
}
|
||||
}
|
||||
|
||||
void bandCopy(realtype **a, realtype **b, sunindextype n, sunindextype a_smu, sunindextype b_smu,
|
||||
sunindextype copymu, sunindextype copyml)
|
||||
{
|
||||
sunindextype i, j, copySize;
|
||||
realtype *a_col_j, *b_col_j;
|
||||
|
||||
copySize = copymu + copyml + 1;
|
||||
|
||||
for (j=0; j < n; j++) {
|
||||
a_col_j = a[j]+a_smu-copymu;
|
||||
b_col_j = b[j]+b_smu-copymu;
|
||||
for (i=0; i < copySize; i++)
|
||||
b_col_j[i] = a_col_j[i];
|
||||
}
|
||||
}
|
||||
|
||||
void bandScale(realtype c, realtype **a, sunindextype n, sunindextype mu, sunindextype ml, sunindextype smu)
|
||||
{
|
||||
sunindextype i, j, colSize;
|
||||
realtype *col_j;
|
||||
|
||||
colSize = mu + ml + 1;
|
||||
|
||||
for(j=0; j < n; j++) {
|
||||
col_j = a[j]+smu-mu;
|
||||
for (i=0; i < colSize; i++)
|
||||
col_j[i] *= c;
|
||||
}
|
||||
}
|
||||
|
||||
void bandAddIdentity(realtype **a, sunindextype n, sunindextype smu)
|
||||
{
|
||||
sunindextype j;
|
||||
|
||||
for(j=0; j < n; j++)
|
||||
a[j][smu] += ONE;
|
||||
}
|
||||
|
||||
void bandMatvec(realtype **a, realtype *x, realtype *y, sunindextype n,
|
||||
sunindextype mu, sunindextype ml, sunindextype smu)
|
||||
{
|
||||
sunindextype i, j, is, ie;
|
||||
realtype *col_j;
|
||||
|
||||
for (i=0; i<n; i++)
|
||||
y[i] = 0.0;
|
||||
|
||||
for(j=0; j<n; j++) {
|
||||
col_j = a[j]+smu-mu;
|
||||
is = (0 > j-mu) ? 0 : j-mu;
|
||||
ie = (n-1 < j+ml) ? n-1 : j+ml;
|
||||
for (i=is; i<=ie; i++)
|
||||
y[i] += col_j[i-j+mu]*x[j];
|
||||
}
|
||||
}
|
||||
|
||||
101
bazaar/plugin/sundials/src/sundials/sundials_cuda.h
Normal file
101
bazaar/plugin/sundials/src/sundials/sundials_cuda.h
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Programmer(s): Cody J. Balos @ LLNL
|
||||
* -----------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
* -----------------------------------------------------------------
|
||||
* This header files defines internal utility functions and macros
|
||||
* for working with CUDA.
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <cuda_runtime.h>
|
||||
#include <cusolverSp.h>
|
||||
#include <cusparse.h>
|
||||
|
||||
#include <sundials/sundials_types.h>
|
||||
|
||||
#ifndef _SUNDIALS_CUDA_H
|
||||
#define _SUNDIALS_CUDA_H
|
||||
|
||||
#ifdef __cplusplus /* wrapper to enable C++ usage */
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Constants
|
||||
* ---------------------------------------------------------------------------*/
|
||||
|
||||
#define CUDA_WARP_SIZE 32
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Utility macros
|
||||
* ---------------------------------------------------------------------------*/
|
||||
|
||||
#define SUNDIALS_CUDA_VERIFY(cuerr) SUNDIALS_CUDA_Assert(cuerr, __FILE__, __LINE__)
|
||||
#define SUNDIALS_CUSPARSE_VERIFY(cuerr) SUNDIALS_CUSPARSE_Assert(cuerr, __FILE__, __LINE__)
|
||||
#define SUNDIALS_CUSOLVER_VERIFY(cuerr) SUNDIALS_CUSOLVER_Assert(cuerr, __FILE__, __LINE__)
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Utility functions
|
||||
* ---------------------------------------------------------------------------*/
|
||||
inline booleantype SUNDIALS_CUDA_Assert(cudaError_t cuerr, const char *file, int line)
|
||||
{
|
||||
if (cuerr != cudaSuccess)
|
||||
{
|
||||
#ifdef SUNDIALS_DEBUG
|
||||
fprintf(stderr,
|
||||
"ERROR in CUDA runtime operation: %s %s:%d\n",
|
||||
cudaGetErrorString(cuerr), file, line);
|
||||
#endif
|
||||
return SUNFALSE; /* Assert failed */
|
||||
}
|
||||
return SUNTRUE; /* Assert OK */
|
||||
}
|
||||
|
||||
inline booleantype SUNDIALS_CUSPARSE_Assert(cusparseStatus_t status, const char *file, int line)
|
||||
{
|
||||
if (status != CUSPARSE_STATUS_SUCCESS)
|
||||
{
|
||||
#ifdef SUNDIALS_DEBUG
|
||||
fprintf(stderr,
|
||||
"ERROR in cuSPARSE runtime operation: cusparseStatus_t = %d %s:%d\n",
|
||||
status, file, line);
|
||||
#endif
|
||||
return SUNFALSE; /* Assert failed */
|
||||
}
|
||||
return SUNTRUE; /* Assert OK */
|
||||
}
|
||||
|
||||
inline booleantype SUNDIALS_CUSOLVER_Assert(cusolverStatus_t status, const char *file, int line)
|
||||
{
|
||||
if (status != CUSOLVER_STATUS_SUCCESS)
|
||||
{
|
||||
#ifdef SUNDIALS_DEBUG
|
||||
fprintf(stderr,
|
||||
"ERROR in cuSOLVER runtime operation: cusolverStatus_t = %d %s:%d\n",
|
||||
status, file, line);
|
||||
#endif
|
||||
return SUNFALSE; /* Assert failed */
|
||||
}
|
||||
return SUNTRUE; /* Assert OK */
|
||||
}
|
||||
|
||||
|
||||
#ifdef __cplusplus /* wrapper to enable C++ usage */
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _SUNDIALS_CUDA_H */
|
||||
40
bazaar/plugin/sundials/src/sundials/sundials_debug.h
Normal file
40
bazaar/plugin/sundials/src/sundials/sundials_debug.h
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Programmer(s): Cody J. Balos @ LLNL
|
||||
* -----------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
* -----------------------------------------------------------------
|
||||
* This header files defines internal utility functions and macros
|
||||
* for SUNDIALS debugging.
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef _SUNDIALS_DEBUG_H
|
||||
#define _SUNDIALS_DEBUG_H
|
||||
|
||||
#ifdef __cplusplus /* wrapper to enable C++ usage */
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Macro which prints to stderr when in debug mode
|
||||
*/
|
||||
#ifdef SUNDIALS_DEBUG
|
||||
#define SUNDIALS_DEBUG_PRINT(str) fprintf(stderr, str)
|
||||
#else
|
||||
#define SUNDIALS_DEBUG_PRINT(str)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus /* wrapper to enable C++ usage */
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _SUNDIALS_DEBUG_H */
|
||||
400
bazaar/plugin/sundials/src/sundials/sundials_dense.c
Normal file
400
bazaar/plugin/sundials/src/sundials/sundials_dense.c
Normal file
|
|
@ -0,0 +1,400 @@
|
|||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* $Revision$
|
||||
* $Date$
|
||||
* -----------------------------------------------------------------
|
||||
* Programmer(s): Scott D. Cohen, Alan C. Hindmarsh and
|
||||
* Radu Serban @ LLNL
|
||||
* -----------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
* -----------------------------------------------------------------
|
||||
* This is the implementation file for a generic package of dense
|
||||
* matrix operations.
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <sundials/sundials_dense.h>
|
||||
#include <sundials/sundials_math.h>
|
||||
|
||||
#define ZERO RCONST(0.0)
|
||||
#define ONE RCONST(1.0)
|
||||
#define TWO RCONST(2.0)
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------
|
||||
* Functions working on DlsMat
|
||||
* -----------------------------------------------------
|
||||
*/
|
||||
|
||||
sunindextype DenseGETRF(DlsMat A, sunindextype *p)
|
||||
{
|
||||
return(denseGETRF(A->cols, A->M, A->N, p));
|
||||
}
|
||||
|
||||
void DenseGETRS(DlsMat A, sunindextype *p, realtype *b)
|
||||
{
|
||||
denseGETRS(A->cols, A->N, p, b);
|
||||
}
|
||||
|
||||
sunindextype DensePOTRF(DlsMat A)
|
||||
{
|
||||
return(densePOTRF(A->cols, A->M));
|
||||
}
|
||||
|
||||
void DensePOTRS(DlsMat A, realtype *b)
|
||||
{
|
||||
densePOTRS(A->cols, A->M, b);
|
||||
}
|
||||
|
||||
int DenseGEQRF(DlsMat A, realtype *beta, realtype *wrk)
|
||||
{
|
||||
return(denseGEQRF(A->cols, A->M, A->N, beta, wrk));
|
||||
}
|
||||
|
||||
int DenseORMQR(DlsMat A, realtype *beta, realtype *vn, realtype *vm, realtype *wrk)
|
||||
{
|
||||
return(denseORMQR(A->cols, A->M, A->N, beta, vn, vm, wrk));
|
||||
}
|
||||
|
||||
void DenseCopy(DlsMat A, DlsMat B)
|
||||
{
|
||||
denseCopy(A->cols, B->cols, A->M, A->N);
|
||||
}
|
||||
|
||||
void DenseScale(realtype c, DlsMat A)
|
||||
{
|
||||
denseScale(c, A->cols, A->M, A->N);
|
||||
}
|
||||
|
||||
void DenseMatvec(DlsMat A, realtype *x, realtype *y)
|
||||
{
|
||||
denseMatvec(A->cols, x, y, A->M, A->N);
|
||||
}
|
||||
|
||||
sunindextype denseGETRF(realtype **a, sunindextype m, sunindextype n, sunindextype *p)
|
||||
{
|
||||
sunindextype i, j, k, l;
|
||||
realtype *col_j, *col_k;
|
||||
realtype temp, mult, a_kj;
|
||||
|
||||
/* k-th elimination step number */
|
||||
for (k=0; k < n; k++) {
|
||||
|
||||
col_k = a[k];
|
||||
|
||||
/* find l = pivot row number */
|
||||
l=k;
|
||||
for (i=k+1; i < m; i++)
|
||||
if (SUNRabs(col_k[i]) > SUNRabs(col_k[l])) l=i;
|
||||
p[k] = l;
|
||||
|
||||
/* check for zero pivot element */
|
||||
if (col_k[l] == ZERO) return(k+1);
|
||||
|
||||
/* swap a(k,1:n) and a(l,1:n) if necessary */
|
||||
if ( l!= k ) {
|
||||
for (i=0; i<n; i++) {
|
||||
temp = a[i][l];
|
||||
a[i][l] = a[i][k];
|
||||
a[i][k] = temp;
|
||||
}
|
||||
}
|
||||
|
||||
/* Scale the elements below the diagonal in
|
||||
* column k by 1.0/a(k,k). After the above swap
|
||||
* a(k,k) holds the pivot element. This scaling
|
||||
* stores the pivot row multipliers a(i,k)/a(k,k)
|
||||
* in a(i,k), i=k+1, ..., m-1.
|
||||
*/
|
||||
mult = ONE/col_k[k];
|
||||
for(i=k+1; i < m; i++) col_k[i] *= mult;
|
||||
|
||||
/* row_i = row_i - [a(i,k)/a(k,k)] row_k, i=k+1, ..., m-1 */
|
||||
/* row k is the pivot row after swapping with row l. */
|
||||
/* The computation is done one column at a time, */
|
||||
/* column j=k+1, ..., n-1. */
|
||||
|
||||
for (j=k+1; j < n; j++) {
|
||||
|
||||
col_j = a[j];
|
||||
a_kj = col_j[k];
|
||||
|
||||
/* a(i,j) = a(i,j) - [a(i,k)/a(k,k)]*a(k,j) */
|
||||
/* a_kj = a(k,j), col_k[i] = - a(i,k)/a(k,k) */
|
||||
|
||||
if (a_kj != ZERO) {
|
||||
for (i=k+1; i < m; i++)
|
||||
col_j[i] -= a_kj * col_k[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* return 0 to indicate success */
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
void denseGETRS(realtype **a, sunindextype n, sunindextype *p, realtype *b)
|
||||
{
|
||||
sunindextype i, k, pk;
|
||||
realtype *col_k, tmp;
|
||||
|
||||
/* Permute b, based on pivot information in p */
|
||||
for (k=0; k<n; k++) {
|
||||
pk = p[k];
|
||||
if(pk != k) {
|
||||
tmp = b[k];
|
||||
b[k] = b[pk];
|
||||
b[pk] = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
/* Solve Ly = b, store solution y in b */
|
||||
for (k=0; k<n-1; k++) {
|
||||
col_k = a[k];
|
||||
for (i=k+1; i<n; i++) b[i] -= col_k[i]*b[k];
|
||||
}
|
||||
|
||||
/* Solve Ux = y, store solution x in b */
|
||||
for (k = n-1; k > 0; k--) {
|
||||
col_k = a[k];
|
||||
b[k] /= col_k[k];
|
||||
for (i=0; i<k; i++) b[i] -= col_k[i]*b[k];
|
||||
}
|
||||
b[0] /= a[0][0];
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Cholesky decomposition of a symmetric positive-definite matrix
|
||||
* A = C^T*C: gaxpy version.
|
||||
* Only the lower triangle of A is accessed and it is overwritten with
|
||||
* the lower triangle of C.
|
||||
*/
|
||||
sunindextype densePOTRF(realtype **a, sunindextype m)
|
||||
{
|
||||
realtype *a_col_j, *a_col_k;
|
||||
realtype a_diag;
|
||||
sunindextype i, j, k;
|
||||
|
||||
for (j=0; j<m; j++) {
|
||||
|
||||
a_col_j = a[j];
|
||||
|
||||
if (j>0) {
|
||||
for(i=j; i<m; i++) {
|
||||
for(k=0;k<j;k++) {
|
||||
a_col_k = a[k];
|
||||
a_col_j[i] -= a_col_k[i]*a_col_k[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
a_diag = a_col_j[j];
|
||||
if (a_diag <= ZERO) return(j+1);
|
||||
a_diag = SUNRsqrt(a_diag);
|
||||
|
||||
for(i=j; i<m; i++) a_col_j[i] /= a_diag;
|
||||
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Solution of Ax=b, with A s.p.d., based on the Cholesky decomposition
|
||||
* obtained with denPOTRF.; A = C*C^T, C lower triangular
|
||||
*
|
||||
*/
|
||||
void densePOTRS(realtype **a, sunindextype m, realtype *b)
|
||||
{
|
||||
realtype *col_j, *col_i;
|
||||
sunindextype i, j;
|
||||
|
||||
/* Solve C y = b, forward substitution - column version.
|
||||
Store solution y in b */
|
||||
for (j=0; j < m-1; j++) {
|
||||
col_j = a[j];
|
||||
b[j] /= col_j[j];
|
||||
for (i=j+1; i < m; i++)
|
||||
b[i] -= b[j]*col_j[i];
|
||||
}
|
||||
col_j = a[m-1];
|
||||
b[m-1] /= col_j[m-1];
|
||||
|
||||
/* Solve C^T x = y, backward substitution - row version.
|
||||
Store solution x in b */
|
||||
col_j = a[m-1];
|
||||
b[m-1] /= col_j[m-1];
|
||||
for (i=m-2; i>=0; i--) {
|
||||
col_i = a[i];
|
||||
for (j=i+1; j<m; j++)
|
||||
b[i] -= col_i[j]*b[j];
|
||||
b[i] /= col_i[i];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* QR factorization of a rectangular matrix A of size m by n (m >= n)
|
||||
* using Householder reflections.
|
||||
*
|
||||
* On exit, the elements on and above the diagonal of A contain the n by n
|
||||
* upper triangular matrix R; the elements below the diagonal, with the array beta,
|
||||
* represent the orthogonal matrix Q as a product of elementary reflectors .
|
||||
*
|
||||
* v (of length m) must be provided as workspace.
|
||||
*
|
||||
*/
|
||||
|
||||
int denseGEQRF(realtype **a, sunindextype m, sunindextype n, realtype *beta, realtype *v)
|
||||
{
|
||||
realtype ajj, s, mu, v1, v1_2;
|
||||
realtype *col_j, *col_k;
|
||||
sunindextype i, j, k;
|
||||
|
||||
/* For each column...*/
|
||||
for(j=0; j<n; j++) {
|
||||
|
||||
col_j = a[j];
|
||||
|
||||
ajj = col_j[j];
|
||||
|
||||
/* Compute the j-th Householder vector (of length m-j) */
|
||||
v[0] = ONE;
|
||||
s = ZERO;
|
||||
for(i=1; i<m-j; i++) {
|
||||
v[i] = col_j[i+j];
|
||||
s += v[i]*v[i];
|
||||
}
|
||||
|
||||
if(s != ZERO) {
|
||||
mu = SUNRsqrt(ajj*ajj+s);
|
||||
v1 = (ajj <= ZERO) ? ajj-mu : -s/(ajj+mu);
|
||||
v1_2 = v1*v1;
|
||||
beta[j] = TWO * v1_2 / (s + v1_2);
|
||||
for(i=1; i<m-j; i++) v[i] /= v1;
|
||||
} else {
|
||||
beta[j] = ZERO;
|
||||
}
|
||||
|
||||
/* Update upper triangle of A (load R) */
|
||||
for(k=j; k<n; k++) {
|
||||
col_k = a[k];
|
||||
s = ZERO;
|
||||
for(i=0; i<m-j; i++) s += col_k[i+j]*v[i];
|
||||
s *= beta[j];
|
||||
for(i=0; i<m-j; i++) col_k[i+j] -= s*v[i];
|
||||
}
|
||||
|
||||
/* Update A (load Householder vector) */
|
||||
if(j<m-1) {
|
||||
for(i=1; i<m-j; i++) col_j[i+j] = v[i];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Computes vm = Q * vn, where the orthogonal matrix Q is stored as
|
||||
* elementary reflectors in the m by n matrix A and in the vector beta.
|
||||
* (NOTE: It is assumed that an QR factorization has been previously
|
||||
* computed with denGEQRF).
|
||||
*
|
||||
* vn (IN) has length n, vm (OUT) has length m, and it's assumed that m >= n.
|
||||
*
|
||||
* v (of length m) must be provided as workspace.
|
||||
*/
|
||||
int denseORMQR(realtype **a, sunindextype m, sunindextype n, realtype *beta,
|
||||
realtype *vn, realtype *vm, realtype *v)
|
||||
{
|
||||
realtype *col_j, s;
|
||||
sunindextype i, j;
|
||||
|
||||
/* Initialize vm */
|
||||
for(i=0; i<n; i++) vm[i] = vn[i];
|
||||
for(i=n; i<m; i++) vm[i] = ZERO;
|
||||
|
||||
/* Accumulate (backwards) corrections into vm */
|
||||
for(j=n-1; j>=0; j--) {
|
||||
|
||||
col_j = a[j];
|
||||
|
||||
v[0] = ONE;
|
||||
s = vm[j];
|
||||
for(i=1; i<m-j; i++) {
|
||||
v[i] = col_j[i+j];
|
||||
s += v[i]*vm[i+j];
|
||||
}
|
||||
s *= beta[j];
|
||||
|
||||
for(i=0; i<m-j; i++) vm[i+j] -= s * v[i];
|
||||
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
void denseCopy(realtype **a, realtype **b, sunindextype m, sunindextype n)
|
||||
{
|
||||
sunindextype i, j;
|
||||
realtype *a_col_j, *b_col_j;
|
||||
|
||||
for (j=0; j < n; j++) {
|
||||
a_col_j = a[j];
|
||||
b_col_j = b[j];
|
||||
for (i=0; i < m; i++)
|
||||
b_col_j[i] = a_col_j[i];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void denseScale(realtype c, realtype **a, sunindextype m, sunindextype n)
|
||||
{
|
||||
sunindextype i, j;
|
||||
realtype *col_j;
|
||||
|
||||
for (j=0; j < n; j++) {
|
||||
col_j = a[j];
|
||||
for (i=0; i < m; i++)
|
||||
col_j[i] *= c;
|
||||
}
|
||||
}
|
||||
|
||||
void denseAddIdentity(realtype **a, sunindextype n)
|
||||
{
|
||||
sunindextype i;
|
||||
|
||||
for (i=0; i < n; i++) a[i][i] += ONE;
|
||||
}
|
||||
|
||||
void denseMatvec(realtype **a, realtype *x, realtype *y, sunindextype m, sunindextype n)
|
||||
{
|
||||
sunindextype i, j;
|
||||
realtype *col_j;
|
||||
|
||||
for (i=0; i<m; i++) {
|
||||
y[i] = 0.0;
|
||||
}
|
||||
|
||||
for (j=0; j<n; j++) {
|
||||
col_j = a[j];
|
||||
for (i=0; i<m; i++)
|
||||
y[i] += col_j[i]*x[j];
|
||||
}
|
||||
}
|
||||
|
||||
355
bazaar/plugin/sundials/src/sundials/sundials_direct.c
Normal file
355
bazaar/plugin/sundials/src/sundials/sundials_direct.c
Normal file
|
|
@ -0,0 +1,355 @@
|
|||
/* -----------------------------------------------------------------
|
||||
* Programmer: Radu Serban @ LLNL
|
||||
* -----------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
* -----------------------------------------------------------------
|
||||
* This is the implementation file for operations to be used by a
|
||||
* generic direct linear solver.
|
||||
* -----------------------------------------------------------------*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <sundials/sundials_direct.h>
|
||||
#include <sundials/sundials_math.h>
|
||||
|
||||
#define ZERO RCONST(0.0)
|
||||
#define ONE RCONST(1.0)
|
||||
|
||||
DlsMat NewDenseMat(sunindextype M, sunindextype N)
|
||||
{
|
||||
DlsMat A;
|
||||
sunindextype j;
|
||||
|
||||
if ( (M <= 0) || (N <= 0) ) return(NULL);
|
||||
|
||||
A = NULL;
|
||||
A = (DlsMat) malloc(sizeof *A);
|
||||
if (A==NULL) return (NULL);
|
||||
|
||||
A->data = (realtype *) malloc(M * N * sizeof(realtype));
|
||||
if (A->data == NULL) {
|
||||
free(A); A = NULL;
|
||||
return(NULL);
|
||||
}
|
||||
A->cols = (realtype **) malloc(N * sizeof(realtype *));
|
||||
if (A->cols == NULL) {
|
||||
free(A->data); A->data = NULL;
|
||||
free(A); A = NULL;
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
for (j=0; j < N; j++) A->cols[j] = A->data + j * M;
|
||||
|
||||
A->M = M;
|
||||
A->N = N;
|
||||
A->ldim = M;
|
||||
A->ldata = M*N;
|
||||
|
||||
A->type = SUNDIALS_DENSE;
|
||||
|
||||
return(A);
|
||||
}
|
||||
|
||||
realtype **newDenseMat(sunindextype m, sunindextype n)
|
||||
{
|
||||
sunindextype j;
|
||||
realtype **a;
|
||||
|
||||
if ( (n <= 0) || (m <= 0) ) return(NULL);
|
||||
|
||||
a = NULL;
|
||||
a = (realtype **) malloc(n * sizeof(realtype *));
|
||||
if (a == NULL) return(NULL);
|
||||
|
||||
a[0] = NULL;
|
||||
a[0] = (realtype *) malloc(m * n * sizeof(realtype));
|
||||
if (a[0] == NULL) {
|
||||
free(a); a = NULL;
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
for (j=1; j < n; j++) a[j] = a[0] + j * m;
|
||||
|
||||
return(a);
|
||||
}
|
||||
|
||||
|
||||
DlsMat NewBandMat(sunindextype N, sunindextype mu, sunindextype ml, sunindextype smu)
|
||||
{
|
||||
DlsMat A;
|
||||
sunindextype j, colSize;
|
||||
|
||||
if (N <= 0) return(NULL);
|
||||
|
||||
A = NULL;
|
||||
A = (DlsMat) malloc(sizeof *A);
|
||||
if (A == NULL) return (NULL);
|
||||
|
||||
colSize = smu + ml + 1;
|
||||
A->data = NULL;
|
||||
A->data = (realtype *) malloc(N * colSize * sizeof(realtype));
|
||||
if (A->data == NULL) {
|
||||
free(A); A = NULL;
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
A->cols = NULL;
|
||||
A->cols = (realtype **) malloc(N * sizeof(realtype *));
|
||||
if (A->cols == NULL) {
|
||||
free(A->data);
|
||||
free(A); A = NULL;
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
for (j=0; j < N; j++) A->cols[j] = A->data + j * colSize;
|
||||
|
||||
A->M = N;
|
||||
A->N = N;
|
||||
A->mu = mu;
|
||||
A->ml = ml;
|
||||
A->s_mu = smu;
|
||||
A->ldim = colSize;
|
||||
A->ldata = N * colSize;
|
||||
|
||||
A->type = SUNDIALS_BAND;
|
||||
|
||||
return(A);
|
||||
}
|
||||
|
||||
realtype **newBandMat(sunindextype n, sunindextype smu, sunindextype ml)
|
||||
{
|
||||
realtype **a;
|
||||
sunindextype j, colSize;
|
||||
|
||||
if (n <= 0) return(NULL);
|
||||
|
||||
a = NULL;
|
||||
a = (realtype **) malloc(n * sizeof(realtype *));
|
||||
if (a == NULL) return(NULL);
|
||||
|
||||
colSize = smu + ml + 1;
|
||||
a[0] = NULL;
|
||||
a[0] = (realtype *) malloc(n * colSize * sizeof(realtype));
|
||||
if (a[0] == NULL) {
|
||||
free(a); a = NULL;
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
for (j=1; j < n; j++) a[j] = a[0] + j * colSize;
|
||||
|
||||
return(a);
|
||||
}
|
||||
|
||||
void DestroyMat(DlsMat A)
|
||||
{
|
||||
free(A->data); A->data = NULL;
|
||||
free(A->cols);
|
||||
free(A); A = NULL;
|
||||
}
|
||||
|
||||
void destroyMat(realtype **a)
|
||||
{
|
||||
free(a[0]); a[0] = NULL;
|
||||
free(a); a = NULL;
|
||||
}
|
||||
|
||||
int *NewIntArray(int N)
|
||||
{
|
||||
int *vec;
|
||||
|
||||
if (N <= 0) return(NULL);
|
||||
|
||||
vec = NULL;
|
||||
vec = (int *) malloc(N * sizeof(int));
|
||||
|
||||
return(vec);
|
||||
}
|
||||
|
||||
int *newIntArray(int n)
|
||||
{
|
||||
int *v;
|
||||
|
||||
if (n <= 0) return(NULL);
|
||||
|
||||
v = NULL;
|
||||
v = (int *) malloc(n * sizeof(int));
|
||||
|
||||
return(v);
|
||||
}
|
||||
|
||||
sunindextype *NewIndexArray(sunindextype N)
|
||||
{
|
||||
sunindextype *vec;
|
||||
|
||||
if (N <= 0) return(NULL);
|
||||
|
||||
vec = NULL;
|
||||
vec = (sunindextype *) malloc(N * sizeof(sunindextype));
|
||||
|
||||
return(vec);
|
||||
}
|
||||
|
||||
sunindextype *newIndexArray(sunindextype n)
|
||||
{
|
||||
sunindextype *v;
|
||||
|
||||
if (n <= 0) return(NULL);
|
||||
|
||||
v = NULL;
|
||||
v = (sunindextype *) malloc(n * sizeof(sunindextype));
|
||||
|
||||
return(v);
|
||||
}
|
||||
|
||||
realtype *NewRealArray(sunindextype N)
|
||||
{
|
||||
realtype *vec;
|
||||
|
||||
if (N <= 0) return(NULL);
|
||||
|
||||
vec = NULL;
|
||||
vec = (realtype *) malloc(N * sizeof(realtype));
|
||||
|
||||
return(vec);
|
||||
}
|
||||
|
||||
realtype *newRealArray(sunindextype m)
|
||||
{
|
||||
realtype *v;
|
||||
|
||||
if (m <= 0) return(NULL);
|
||||
|
||||
v = NULL;
|
||||
v = (realtype *) malloc(m * sizeof(realtype));
|
||||
|
||||
return(v);
|
||||
}
|
||||
|
||||
void DestroyArray(void *V)
|
||||
{
|
||||
free(V);
|
||||
V = NULL;
|
||||
}
|
||||
|
||||
void destroyArray(void *v)
|
||||
{
|
||||
free(v);
|
||||
v = NULL;
|
||||
}
|
||||
|
||||
|
||||
void AddIdentity(DlsMat A)
|
||||
{
|
||||
sunindextype i;
|
||||
|
||||
switch (A->type) {
|
||||
|
||||
case SUNDIALS_DENSE:
|
||||
for (i=0; i<A->N; i++) A->cols[i][i] += ONE;
|
||||
break;
|
||||
|
||||
case SUNDIALS_BAND:
|
||||
for (i=0; i<A->M; i++) A->cols[i][A->s_mu] += ONE;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void SetToZero(DlsMat A)
|
||||
{
|
||||
sunindextype i, j, colSize;
|
||||
realtype *col_j;
|
||||
|
||||
switch (A->type) {
|
||||
|
||||
case SUNDIALS_DENSE:
|
||||
|
||||
for (j=0; j<A->N; j++) {
|
||||
col_j = A->cols[j];
|
||||
for (i=0; i<A->M; i++)
|
||||
col_j[i] = ZERO;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case SUNDIALS_BAND:
|
||||
|
||||
colSize = A->mu + A->ml + 1;
|
||||
for (j=0; j<A->M; j++) {
|
||||
col_j = A->cols[j] + A->s_mu - A->mu;
|
||||
for (i=0; i<colSize; i++)
|
||||
col_j[i] = ZERO;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void PrintMat(DlsMat A, FILE *outfile)
|
||||
{
|
||||
sunindextype i, j, start, finish;
|
||||
realtype **a;
|
||||
|
||||
switch (A->type) {
|
||||
|
||||
case SUNDIALS_DENSE:
|
||||
|
||||
fprintf(outfile, "\n");
|
||||
for (i=0; i < A->M; i++) {
|
||||
for (j=0; j < A->N; j++) {
|
||||
#if defined(SUNDIALS_EXTENDED_PRECISION)
|
||||
fprintf(outfile, "%12Lg ", DENSE_ELEM(A,i,j));
|
||||
#elif defined(SUNDIALS_DOUBLE_PRECISION)
|
||||
fprintf(outfile, "%12g ", DENSE_ELEM(A,i,j));
|
||||
#else
|
||||
fprintf(outfile, "%12g ", DENSE_ELEM(A,i,j));
|
||||
#endif
|
||||
}
|
||||
fprintf(outfile, "\n");
|
||||
}
|
||||
fprintf(outfile, "\n");
|
||||
|
||||
break;
|
||||
|
||||
case SUNDIALS_BAND:
|
||||
|
||||
a = A->cols;
|
||||
fprintf(outfile, "\n");
|
||||
for (i=0; i < A->N; i++) {
|
||||
start = SUNMAX(0,i-A->ml);
|
||||
finish = SUNMIN(A->N-1,i+A->mu);
|
||||
for (j=0; j < start; j++) fprintf(outfile, "%12s ","");
|
||||
for (j=start; j <= finish; j++) {
|
||||
#if defined(SUNDIALS_EXTENDED_PRECISION)
|
||||
fprintf(outfile, "%12Lg ", a[j][i-j+A->s_mu]);
|
||||
#elif defined(SUNDIALS_DOUBLE_PRECISION)
|
||||
fprintf(outfile, "%12g ", a[j][i-j+A->s_mu]);
|
||||
#else
|
||||
fprintf(outfile, "%12g ", a[j][i-j+A->s_mu]);
|
||||
#endif
|
||||
}
|
||||
fprintf(outfile, "\n");
|
||||
}
|
||||
fprintf(outfile, "\n");
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
29
bazaar/plugin/sundials/src/sundials/sundials_futils.c
Normal file
29
bazaar/plugin/sundials/src/sundials/sundials_futils.c
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/* -----------------------------------------------------------------
|
||||
* Programmer(s): Cody J. Balos
|
||||
* -----------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
* -----------------------------------------------------------------
|
||||
* SUNDIALS Fortran 2003 interface utility implementations.
|
||||
* -----------------------------------------------------------------*/
|
||||
|
||||
#include <sundials/sundials_futils.h>
|
||||
|
||||
/* Create a file pointer with the given file name and mode. */
|
||||
FILE* SUNDIALSFileOpen(const char* filename, const char* mode)
|
||||
{
|
||||
return fopen(filename, mode);
|
||||
}
|
||||
|
||||
/* Close a file pointer with the given file name. */
|
||||
void SUNDIALSFileClose(FILE* fp)
|
||||
{
|
||||
fclose(fp);
|
||||
}
|
||||
298
bazaar/plugin/sundials/src/sundials/sundials_iterative.c
Normal file
298
bazaar/plugin/sundials/src/sundials/sundials_iterative.c
Normal file
|
|
@ -0,0 +1,298 @@
|
|||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* $Revision$
|
||||
* $Date$
|
||||
* -----------------------------------------------------------------
|
||||
* Programmer(s): Scott D. Cohen, Alan C. Hindmarsh and
|
||||
* Radu Serban @ LLNL
|
||||
* -----------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
* -----------------------------------------------------------------
|
||||
* This is the implementation file for the iterative.h header
|
||||
* file. It contains the implementation of functions that may be
|
||||
* useful for many different iterative solvers of A x = b.
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <sundials/sundials_iterative.h>
|
||||
#include <sundials/sundials_math.h>
|
||||
|
||||
#define FACTOR RCONST(1000.0)
|
||||
#define ZERO RCONST(0.0)
|
||||
#define ONE RCONST(1.0)
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Function : ModifiedGS
|
||||
* -----------------------------------------------------------------
|
||||
* This implementation of ModifiedGS is a slight modification of a
|
||||
* previous modified Gram-Schmidt routine (called mgs) written by
|
||||
* Milo Dorr.
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
int ModifiedGS(N_Vector *v, realtype **h, int k, int p,
|
||||
realtype *new_vk_norm)
|
||||
{
|
||||
int i, k_minus_1, i0;
|
||||
realtype new_norm_2, new_product, vk_norm, temp;
|
||||
|
||||
vk_norm = SUNRsqrt(N_VDotProd(v[k],v[k]));
|
||||
k_minus_1 = k - 1;
|
||||
i0 = SUNMAX(k-p, 0);
|
||||
|
||||
/* Perform modified Gram-Schmidt */
|
||||
|
||||
for (i=i0; i < k; i++) {
|
||||
h[i][k_minus_1] = N_VDotProd(v[i], v[k]);
|
||||
N_VLinearSum(ONE, v[k], -h[i][k_minus_1], v[i], v[k]);
|
||||
}
|
||||
|
||||
/* Compute the norm of the new vector at v[k] */
|
||||
|
||||
*new_vk_norm = SUNRsqrt(N_VDotProd(v[k], v[k]));
|
||||
|
||||
/* If the norm of the new vector at v[k] is less than
|
||||
FACTOR (== 1000) times unit roundoff times the norm of the
|
||||
input vector v[k], then the vector will be reorthogonalized
|
||||
in order to ensure that nonorthogonality is not being masked
|
||||
by a very small vector length. */
|
||||
|
||||
temp = FACTOR * vk_norm;
|
||||
if ((temp + (*new_vk_norm)) != temp) return(0);
|
||||
|
||||
new_norm_2 = ZERO;
|
||||
|
||||
for (i=i0; i < k; i++) {
|
||||
new_product = N_VDotProd(v[i], v[k]);
|
||||
temp = FACTOR * h[i][k_minus_1];
|
||||
if ((temp + new_product) == temp) continue;
|
||||
h[i][k_minus_1] += new_product;
|
||||
N_VLinearSum(ONE, v[k],-new_product, v[i], v[k]);
|
||||
new_norm_2 += SUNSQR(new_product);
|
||||
}
|
||||
|
||||
if (new_norm_2 != ZERO) {
|
||||
new_product = SUNSQR(*new_vk_norm) - new_norm_2;
|
||||
*new_vk_norm = (new_product > ZERO) ? SUNRsqrt(new_product) : ZERO;
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Function : ClassicalGS
|
||||
* -----------------------------------------------------------------
|
||||
* This implementation of ClassicalGS was contributed by Homer Walker
|
||||
* and Peter Brown.
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
int ClassicalGS(N_Vector *v, realtype **h, int k, int p, realtype *new_vk_norm,
|
||||
realtype *stemp, N_Vector *vtemp)
|
||||
{
|
||||
int i, i0, k_minus_1, retval;
|
||||
realtype vk_norm;
|
||||
|
||||
k_minus_1 = k - 1;
|
||||
i0 = SUNMAX(k-p,0);
|
||||
|
||||
/* Perform Classical Gram-Schmidt */
|
||||
|
||||
retval = N_VDotProdMulti(k-i0+1, v[k], v+i0, stemp);
|
||||
if (retval != 0) return(-1);
|
||||
|
||||
vk_norm = SUNRsqrt(stemp[k-i0]);
|
||||
for (i=k-i0-1; i >= 0; i--) {
|
||||
h[i][k_minus_1] = stemp[i];
|
||||
stemp[i+1] = -stemp[i];
|
||||
vtemp[i+1] = v[i];
|
||||
}
|
||||
stemp[0] = ONE;
|
||||
vtemp[0] = v[k];
|
||||
|
||||
retval = N_VLinearCombination(k-i0+1, stemp, vtemp, v[k]);
|
||||
if (retval != 0) return(-1);
|
||||
|
||||
/* Compute the norm of the new vector at v[k] */
|
||||
|
||||
*new_vk_norm = SUNRsqrt(N_VDotProd(v[k], v[k]));
|
||||
|
||||
/* Reorthogonalize if necessary */
|
||||
|
||||
if ((FACTOR * (*new_vk_norm)) < vk_norm) {
|
||||
|
||||
retval = N_VDotProdMulti(k-i0, v[k], v+i0, stemp+1);
|
||||
if (retval != 0) return(-1);
|
||||
|
||||
stemp[0] = ONE;
|
||||
vtemp[0] = v[k];
|
||||
for (i=i0; i < k; i++) {
|
||||
h[i][k_minus_1] += stemp[i-i0+1];
|
||||
stemp[i-i0+1] = -stemp[i-i0+1];
|
||||
vtemp[i-i0+1] = v[i-i0];
|
||||
}
|
||||
|
||||
retval = N_VLinearCombination(k+1, stemp, vtemp, v[k]);
|
||||
if (retval != 0) return(-1);
|
||||
|
||||
*new_vk_norm = SUNRsqrt(N_VDotProd(v[k],v[k]));
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Function : QRfact
|
||||
* -----------------------------------------------------------------
|
||||
* This implementation of QRfact is a slight modification of a
|
||||
* previous routine (called qrfact) written by Milo Dorr.
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
int QRfact(int n, realtype **h, realtype *q, int job)
|
||||
{
|
||||
realtype c, s, temp1, temp2, temp3;
|
||||
int i, j, k, q_ptr, n_minus_1, code=0;
|
||||
|
||||
switch (job) {
|
||||
case 0:
|
||||
|
||||
/* Compute a new factorization of H */
|
||||
|
||||
code = 0;
|
||||
for (k=0; k < n; k++) {
|
||||
|
||||
/* Multiply column k by the previous k-1 Givens rotations */
|
||||
|
||||
for (j=0; j < k-1; j++) {
|
||||
i = 2*j;
|
||||
temp1 = h[j][k];
|
||||
temp2 = h[j+1][k];
|
||||
c = q[i];
|
||||
s = q[i+1];
|
||||
h[j][k] = c*temp1 - s*temp2;
|
||||
h[j+1][k] = s*temp1 + c*temp2;
|
||||
}
|
||||
|
||||
/* Compute the Givens rotation components c and s */
|
||||
|
||||
q_ptr = 2*k;
|
||||
temp1 = h[k][k];
|
||||
temp2 = h[k+1][k];
|
||||
if( temp2 == ZERO) {
|
||||
c = ONE;
|
||||
s = ZERO;
|
||||
} else if (SUNRabs(temp2) >= SUNRabs(temp1)) {
|
||||
temp3 = temp1/temp2;
|
||||
s = -ONE/SUNRsqrt(ONE+SUNSQR(temp3));
|
||||
c = -s*temp3;
|
||||
} else {
|
||||
temp3 = temp2/temp1;
|
||||
c = ONE/SUNRsqrt(ONE+SUNSQR(temp3));
|
||||
s = -c*temp3;
|
||||
}
|
||||
q[q_ptr] = c;
|
||||
q[q_ptr+1] = s;
|
||||
if( (h[k][k] = c*temp1 - s*temp2) == ZERO) code = k+1;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
/* Update the factored H to which a new column has been added */
|
||||
|
||||
n_minus_1 = n - 1;
|
||||
code = 0;
|
||||
|
||||
/* Multiply the new column by the previous n-1 Givens rotations */
|
||||
|
||||
for (k=0; k < n_minus_1; k++) {
|
||||
i = 2*k;
|
||||
temp1 = h[k][n_minus_1];
|
||||
temp2 = h[k+1][n_minus_1];
|
||||
c = q[i];
|
||||
s = q[i+1];
|
||||
h[k][n_minus_1] = c*temp1 - s*temp2;
|
||||
h[k+1][n_minus_1] = s*temp1 + c*temp2;
|
||||
}
|
||||
|
||||
/* Compute new Givens rotation and multiply it times the last two
|
||||
entries in the new column of H. Note that the second entry of
|
||||
this product will be 0, so it is not necessary to compute it. */
|
||||
|
||||
temp1 = h[n_minus_1][n_minus_1];
|
||||
temp2 = h[n][n_minus_1];
|
||||
if (temp2 == ZERO) {
|
||||
c = ONE;
|
||||
s = ZERO;
|
||||
} else if (SUNRabs(temp2) >= SUNRabs(temp1)) {
|
||||
temp3 = temp1/temp2;
|
||||
s = -ONE/SUNRsqrt(ONE+SUNSQR(temp3));
|
||||
c = -s*temp3;
|
||||
} else {
|
||||
temp3 = temp2/temp1;
|
||||
c = ONE/SUNRsqrt(ONE+SUNSQR(temp3));
|
||||
s = -c*temp3;
|
||||
}
|
||||
q_ptr = 2*n_minus_1;
|
||||
q[q_ptr] = c;
|
||||
q[q_ptr+1] = s;
|
||||
if ((h[n_minus_1][n_minus_1] = c*temp1 - s*temp2) == ZERO)
|
||||
code = n;
|
||||
}
|
||||
|
||||
return (code);
|
||||
}
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* Function : QRsol
|
||||
* -----------------------------------------------------------------
|
||||
* This implementation of QRsol is a slight modification of a
|
||||
* previous routine (called qrsol) written by Milo Dorr.
|
||||
* -----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
int QRsol(int n, realtype **h, realtype *q, realtype *b)
|
||||
{
|
||||
realtype c, s, temp1, temp2;
|
||||
int i, k, q_ptr, code=0;
|
||||
|
||||
/* Compute Q*b */
|
||||
|
||||
for (k=0; k < n; k++) {
|
||||
q_ptr = 2*k;
|
||||
c = q[q_ptr];
|
||||
s = q[q_ptr+1];
|
||||
temp1 = b[k];
|
||||
temp2 = b[k+1];
|
||||
b[k] = c*temp1 - s*temp2;
|
||||
b[k+1] = s*temp1 + c*temp2;
|
||||
}
|
||||
|
||||
/* Solve R*x = Q*b */
|
||||
|
||||
for (k=n-1; k >= 0; k--) {
|
||||
if (h[k][k] == ZERO) {
|
||||
code = k + 1;
|
||||
break;
|
||||
}
|
||||
b[k] /= h[k][k];
|
||||
for (i=0; i < k; i++) b[i] -= b[k]*h[i][k];
|
||||
}
|
||||
|
||||
return (code);
|
||||
}
|
||||
209
bazaar/plugin/sundials/src/sundials/sundials_linearsolver.c
Normal file
209
bazaar/plugin/sundials/src/sundials/sundials_linearsolver.c
Normal file
|
|
@ -0,0 +1,209 @@
|
|||
/* -----------------------------------------------------------------
|
||||
* Programmer(s): Daniel Reynolds @ SMU
|
||||
* David J. Gardner, Carol S. Woodward, and
|
||||
* Slaven Peles @ LLNL
|
||||
* -----------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
* -----------------------------------------------------------------
|
||||
* This is the implementation file for a generic SUNLINEARSOLVER
|
||||
* package. It contains the implementation of the SUNLinearSolver
|
||||
* operations listed in sundials_linearsolver.h
|
||||
* -----------------------------------------------------------------*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <sundials/sundials_linearsolver.h>
|
||||
|
||||
/* -----------------------------------------------------------------
|
||||
* Create a new empty SUNLinearSolver object
|
||||
* ----------------------------------------------------------------- */
|
||||
|
||||
SUNLinearSolver SUNLinSolNewEmpty()
|
||||
{
|
||||
SUNLinearSolver LS;
|
||||
SUNLinearSolver_Ops ops;
|
||||
|
||||
/* create linear solver object */
|
||||
LS = NULL;
|
||||
LS = (SUNLinearSolver) malloc(sizeof *LS);
|
||||
if (LS == NULL) return(NULL);
|
||||
|
||||
/* create linear solver ops structure */
|
||||
ops = NULL;
|
||||
ops = (SUNLinearSolver_Ops) malloc(sizeof *ops);
|
||||
if (ops == NULL) { free(LS); return(NULL); }
|
||||
|
||||
/* initialize operations to NULL */
|
||||
ops->gettype = NULL;
|
||||
ops->getid = NULL;
|
||||
ops->setatimes = NULL;
|
||||
ops->setpreconditioner = NULL;
|
||||
ops->setscalingvectors = NULL;
|
||||
ops->initialize = NULL;
|
||||
ops->setup = NULL;
|
||||
ops->solve = NULL;
|
||||
ops->numiters = NULL;
|
||||
ops->resnorm = NULL;
|
||||
ops->resid = NULL;
|
||||
ops->lastflag = NULL;
|
||||
ops->space = NULL;
|
||||
ops->free = NULL;
|
||||
|
||||
/* attach ops and initialize content to NULL */
|
||||
LS->ops = ops;
|
||||
LS->content = NULL;
|
||||
|
||||
return(LS);
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------
|
||||
* Free a generic SUNLinearSolver (assumes content is already empty)
|
||||
* ----------------------------------------------------------------- */
|
||||
|
||||
void SUNLinSolFreeEmpty(SUNLinearSolver S)
|
||||
{
|
||||
if (S == NULL) return;
|
||||
|
||||
/* free non-NULL ops structure */
|
||||
if (S->ops) free(S->ops);
|
||||
S->ops = NULL;
|
||||
|
||||
/* free overall N_Vector object and return */
|
||||
free(S);
|
||||
return;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------
|
||||
* Functions in the 'ops' structure
|
||||
* -----------------------------------------------------------------*/
|
||||
|
||||
SUNLinearSolver_Type SUNLinSolGetType(SUNLinearSolver S)
|
||||
{
|
||||
return(S->ops->gettype(S));
|
||||
}
|
||||
|
||||
SUNLinearSolver_ID SUNLinSolGetID(SUNLinearSolver S)
|
||||
{
|
||||
if (S->ops->getid)
|
||||
return(S->ops->getid(S));
|
||||
else
|
||||
return(SUNLINEARSOLVER_CUSTOM);
|
||||
}
|
||||
|
||||
int SUNLinSolSetATimes(SUNLinearSolver S, void* A_data,
|
||||
ATimesFn ATimes)
|
||||
{
|
||||
if (S->ops->setatimes)
|
||||
return ((int) S->ops->setatimes(S, A_data, ATimes));
|
||||
else
|
||||
return SUNLS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
int SUNLinSolSetPreconditioner(SUNLinearSolver S, void* P_data,
|
||||
PSetupFn Pset, PSolveFn Psol)
|
||||
{
|
||||
if (S->ops->setpreconditioner)
|
||||
return ((int) S->ops->setpreconditioner(S, P_data, Pset, Psol));
|
||||
else
|
||||
return SUNLS_SUCCESS;
|
||||
}
|
||||
|
||||
int SUNLinSolSetScalingVectors(SUNLinearSolver S,
|
||||
N_Vector s1, N_Vector s2)
|
||||
{
|
||||
if (S->ops->setscalingvectors)
|
||||
return ((int) S->ops->setscalingvectors(S, s1, s2));
|
||||
else
|
||||
return SUNLS_SUCCESS;
|
||||
}
|
||||
|
||||
int SUNLinSolInitialize(SUNLinearSolver S)
|
||||
{
|
||||
if (S->ops->initialize)
|
||||
return ((int) S->ops->initialize(S));
|
||||
else
|
||||
return SUNLS_SUCCESS;
|
||||
}
|
||||
|
||||
int SUNLinSolSetup(SUNLinearSolver S, SUNMatrix A)
|
||||
{
|
||||
if (S->ops->setup)
|
||||
return ((int) S->ops->setup(S, A));
|
||||
else
|
||||
return SUNLS_SUCCESS;
|
||||
}
|
||||
|
||||
int SUNLinSolSolve(SUNLinearSolver S, SUNMatrix A, N_Vector x,
|
||||
N_Vector b, realtype tol)
|
||||
{
|
||||
return ((int) S->ops->solve(S, A, x, b, tol));
|
||||
}
|
||||
|
||||
int SUNLinSolNumIters(SUNLinearSolver S)
|
||||
{
|
||||
if (S->ops->numiters)
|
||||
return ((int) S->ops->numiters(S));
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
realtype SUNLinSolResNorm(SUNLinearSolver S)
|
||||
{
|
||||
if (S->ops->resnorm)
|
||||
return ((realtype) S->ops->resnorm(S));
|
||||
else
|
||||
return RCONST(0.0);
|
||||
}
|
||||
|
||||
N_Vector SUNLinSolResid(SUNLinearSolver S)
|
||||
{
|
||||
if (S->ops->resid)
|
||||
return ((N_Vector) S->ops->resid(S));
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sunindextype SUNLinSolLastFlag(SUNLinearSolver S)
|
||||
{
|
||||
if (S->ops->lastflag)
|
||||
return ((sunindextype) S->ops->lastflag(S));
|
||||
else
|
||||
return SUNLS_SUCCESS;
|
||||
}
|
||||
|
||||
int SUNLinSolSpace(SUNLinearSolver S, long int *lenrwLS,
|
||||
long int *leniwLS)
|
||||
{
|
||||
if (S->ops->space)
|
||||
return ((int) S->ops->space(S, lenrwLS, leniwLS));
|
||||
else {
|
||||
*lenrwLS = 0;
|
||||
*leniwLS = 0;
|
||||
return SUNLS_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
int SUNLinSolFree(SUNLinearSolver S)
|
||||
{
|
||||
if (S == NULL) return SUNLS_SUCCESS;
|
||||
|
||||
/* if the free operation exists use it */
|
||||
if (S->ops)
|
||||
if (S->ops->free) return(S->ops->free(S));
|
||||
|
||||
/* if we reach this point, either ops == NULL or free == NULL,
|
||||
try to cleanup by freeing the content, ops, and solver */
|
||||
if (S->content) { free(S->content); S->content = NULL; }
|
||||
if (S->ops) { free(S->ops); S->ops = NULL; }
|
||||
free(S); S = NULL;
|
||||
|
||||
return(SUNLS_SUCCESS);
|
||||
}
|
||||
53
bazaar/plugin/sundials/src/sundials/sundials_math.c
Normal file
53
bazaar/plugin/sundials/src/sundials/sundials_math.c
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
/* -----------------------------------------------------------------
|
||||
* Programmer(s): Scott D. Cohen, Alan C. Hindmarsh and
|
||||
* Aaron Collier @ LLNL
|
||||
* -----------------------------------------------------------------
|
||||
* SUNDIALS Copyright Start
|
||||
* Copyright (c) 2002-2020, Lawrence Livermore National Security
|
||||
* and Southern Methodist University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* See the top-level LICENSE and NOTICE files for details.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* SUNDIALS Copyright End
|
||||
* -----------------------------------------------------------------
|
||||
* This is the implementation file for a simple C-language math
|
||||
* library.
|
||||
* -----------------------------------------------------------------*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
#include <sundials/sundials_math.h>
|
||||
|
||||
#define ZERO RCONST(0.0)
|
||||
#define ONE RCONST(1.0)
|
||||
|
||||
realtype SUNRpowerI(realtype base, int exponent)
|
||||
{
|
||||
int i, expt;
|
||||
realtype prod;
|
||||
|
||||
prod = ONE;
|
||||
expt = abs(exponent);
|
||||
for(i = 1; i <= expt; i++) prod *= base;
|
||||
if (exponent < 0) prod = ONE/prod;
|
||||
return(prod);
|
||||
}
|
||||
|
||||
realtype SUNRpowerR(realtype base, realtype exponent)
|
||||
{
|
||||
if (base <= ZERO) return(ZERO);
|
||||
|
||||
#if defined(SUNDIALS_USE_GENERIC_MATH)
|
||||
return((realtype) pow((double) base, (double) exponent));
|
||||
#elif defined(SUNDIALS_DOUBLE_PRECISION)
|
||||
return(pow(base, exponent));
|
||||
#elif defined(SUNDIALS_SINGLE_PRECISION)
|
||||
return(powf(base, exponent));
|
||||
#elif defined(SUNDIALS_EXTENDED_PRECISION)
|
||||
return(powl(base, exponent));
|
||||
#endif
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue