Skip to content

Commit

Permalink
more sundials
Browse files Browse the repository at this point in the history
  • Loading branch information
dweindl committed Sep 25, 2024
1 parent 4617086 commit e52d7e3
Show file tree
Hide file tree
Showing 35 changed files with 4,621 additions and 0 deletions.
57 changes: 57 additions & 0 deletions ThirdParty/sundials/include/cvodes/cvodes_proj.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/* -----------------------------------------------------------------------------
* Programmer(s): David J. Gardner @ LLNL
* -----------------------------------------------------------------------------
* Based on CPODES by Radu Serban @ LLNL
* -----------------------------------------------------------------------------
* SUNDIALS Copyright Start
* Copyright (c) 2002-2024, 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 CVODE's projection interface.
* ---------------------------------------------------------------------------*/

#ifndef _CVPROJ_H
#define _CVPROJ_H

#include <sundials/sundials_nvector.h>

#ifdef __cplusplus /* wrapper to enable C++ usage */
extern "C" {
#endif

/* -----------------------------------------------------------------------------
* CVProj user-supplied function prototypes
* ---------------------------------------------------------------------------*/

typedef int (*CVProjFn)(sunrealtype t, N_Vector ycur, N_Vector corr,
sunrealtype epsProj, N_Vector err, void* user_data);

/* -----------------------------------------------------------------------------
* CVProj Exported functions
* ---------------------------------------------------------------------------*/

/* Projection initialization functions */
SUNDIALS_EXPORT int CVodeSetProjFn(void* cvode_mem, CVProjFn pfun);

/* Optional input functions */
SUNDIALS_EXPORT int CVodeSetProjErrEst(void* cvode_mem, sunbooleantype onoff);
SUNDIALS_EXPORT int CVodeSetProjFrequency(void* cvode_mem, long int proj_freq);
SUNDIALS_EXPORT int CVodeSetMaxNumProjFails(void* cvode_mem, int max_fails);
SUNDIALS_EXPORT int CVodeSetEpsProj(void* cvode_mem, sunrealtype eps);
SUNDIALS_EXPORT int CVodeSetProjFailEta(void* cvode_mem, sunrealtype eta);

/* Optional output functions */
SUNDIALS_EXPORT int CVodeGetNumProjEvals(void* cvode_mem, long int* nproj);
SUNDIALS_EXPORT int CVodeGetNumProjFails(void* cvode_mem, long int* nprf);

#ifdef __cplusplus
}
#endif

#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/* -----------------------------------------------------------------
* Programmer(s): Daniel R. Reynolds @ SMU
* -----------------------------------------------------------------
* SUNDIALS Copyright Start
* Copyright (c) 2002-2024, 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 SUNAdaptController_ImExGus module.
* -----------------------------------------------------------------*/

#ifndef _SUNADAPTCONTROLLER_IMEXGUS_H
#define _SUNADAPTCONTROLLER_IMEXGUS_H

#include <stdio.h>
#include <sundials/sundials_adaptcontroller.h>

#ifdef __cplusplus /* wrapper to enable C++ usage */
extern "C" {
#endif

/* ----------------------------------------------------
* ImEx Gustafsson implementation of SUNAdaptController
* ---------------------------------------------------- */

struct _SUNAdaptControllerContent_ImExGus
{
sunrealtype k1i; /* internal controller parameters */
sunrealtype k2i;
sunrealtype k1e;
sunrealtype k2e;
sunrealtype bias; /* error bias factor */
sunrealtype ep; /* error from previous step */
sunrealtype hp; /* previous step size */
sunbooleantype firststep; /* flag indicating first step */
};

typedef struct _SUNAdaptControllerContent_ImExGus* SUNAdaptControllerContent_ImExGus;

/* ------------------
* Exported Functions
* ------------------ */

SUNDIALS_EXPORT
SUNAdaptController SUNAdaptController_ImExGus(SUNContext sunctx);

SUNDIALS_EXPORT
SUNErrCode SUNAdaptController_SetParams_ImExGus(SUNAdaptController C,
sunrealtype k1e, sunrealtype k2e,
sunrealtype k1i, sunrealtype k2i);
SUNDIALS_EXPORT
SUNAdaptController_Type SUNAdaptController_GetType_ImExGus(SUNAdaptController C);

SUNDIALS_EXPORT
SUNErrCode SUNAdaptController_EstimateStep_ImExGus(SUNAdaptController C,
sunrealtype h, int p,
sunrealtype dsm,
sunrealtype* hnew);
SUNDIALS_EXPORT
SUNErrCode SUNAdaptController_Reset_ImExGus(SUNAdaptController C);

SUNDIALS_EXPORT
SUNErrCode SUNAdaptController_SetDefaults_ImExGus(SUNAdaptController C);

SUNDIALS_EXPORT
SUNErrCode SUNAdaptController_Write_ImExGus(SUNAdaptController C, FILE* fptr);

SUNDIALS_EXPORT
SUNErrCode SUNAdaptController_SetErrorBias_ImExGus(SUNAdaptController C,
sunrealtype bias);
SUNDIALS_EXPORT
SUNErrCode SUNAdaptController_UpdateH_ImExGus(SUNAdaptController C,
sunrealtype h, sunrealtype dsm);

SUNDIALS_EXPORT
SUNErrCode SUNAdaptController_Space_ImExGus(SUNAdaptController C,
long int* lenrw, long int* leniw);

#ifdef __cplusplus
}
#endif

#endif /* _SUNADAPTCONTROLLER_IMEXGUS_H */
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
/* -----------------------------------------------------------------
* Programmer(s): Daniel R. Reynolds @ SMU
* -----------------------------------------------------------------
* SUNDIALS Copyright Start
* Copyright (c) 2002-2024, 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 SUNAdaptController_Soderlind
* module.
* -----------------------------------------------------------------*/

#ifndef _SUNADAPTCONTROLLER_SODERLIND_H
#define _SUNADAPTCONTROLLER_SODERLIND_H

#include <stdio.h>
#include <sundials/sundials_adaptcontroller.h>

#ifdef __cplusplus /* wrapper to enable C++ usage */
extern "C" {
#endif

/* ----------------------------------------------------
* Soderlind implementation of SUNAdaptController
* ---------------------------------------------------- */

struct _SUNAdaptControllerContent_Soderlind
{
sunrealtype k1; /* internal controller parameters */
sunrealtype k2;
sunrealtype k3;
sunrealtype k4;
sunrealtype k5;
sunrealtype bias; /* error bias factor */
sunrealtype ep; /* error from previous step */
sunrealtype epp; /* error from 2 steps ago */
sunrealtype hp; /* previous step size */
sunrealtype hpp; /* step size from 2 steps ago */
int firststeps; /* flag to handle first few steps */
};

typedef struct _SUNAdaptControllerContent_Soderlind* SUNAdaptControllerContent_Soderlind;

/* ------------------
* Exported Functions
* ------------------ */

SUNDIALS_EXPORT
SUNAdaptController SUNAdaptController_Soderlind(SUNContext sunctx);

SUNDIALS_EXPORT
SUNErrCode SUNAdaptController_SetParams_Soderlind(SUNAdaptController C,
sunrealtype k1, sunrealtype k2,
sunrealtype k3, sunrealtype k4,
sunrealtype k5);

SUNDIALS_EXPORT
SUNAdaptController_Type SUNAdaptController_GetType_Soderlind(SUNAdaptController C);

SUNDIALS_EXPORT
SUNErrCode SUNAdaptController_EstimateStep_Soderlind(SUNAdaptController C,
sunrealtype h, int p,
sunrealtype dsm,
sunrealtype* hnew);

SUNDIALS_EXPORT
SUNErrCode SUNAdaptController_Reset_Soderlind(SUNAdaptController C);

SUNDIALS_EXPORT
SUNErrCode SUNAdaptController_SetDefaults_Soderlind(SUNAdaptController C);

SUNDIALS_EXPORT
SUNErrCode SUNAdaptController_Write_Soderlind(SUNAdaptController C, FILE* fptr);

SUNDIALS_EXPORT
SUNErrCode SUNAdaptController_SetErrorBias_Soderlind(SUNAdaptController C,
sunrealtype bias);

SUNDIALS_EXPORT
SUNErrCode SUNAdaptController_UpdateH_Soderlind(SUNAdaptController C,
sunrealtype h, sunrealtype dsm);

SUNDIALS_EXPORT
SUNErrCode SUNAdaptController_Space_Soderlind(SUNAdaptController C,
long int* lenrw, long int* leniw);

/* Convenience routines to construct subsidiary controllers */

SUNDIALS_EXPORT
SUNAdaptController SUNAdaptController_PID(SUNContext sunctx);

SUNDIALS_EXPORT
SUNErrCode SUNAdaptController_SetParams_PID(SUNAdaptController C, sunrealtype k1,
sunrealtype k2, sunrealtype k3);

SUNDIALS_EXPORT
SUNAdaptController SUNAdaptController_PI(SUNContext sunctx);

SUNDIALS_EXPORT
SUNErrCode SUNAdaptController_SetParams_PI(SUNAdaptController C, sunrealtype k1,
sunrealtype k2);

SUNDIALS_EXPORT
SUNAdaptController SUNAdaptController_I(SUNContext sunctx);

SUNDIALS_EXPORT
SUNErrCode SUNAdaptController_SetParams_I(SUNAdaptController C, sunrealtype k1);

SUNDIALS_EXPORT
SUNAdaptController SUNAdaptController_ExpGus(SUNContext sunctx);

SUNDIALS_EXPORT
SUNErrCode SUNAdaptController_SetParams_ExpGus(SUNAdaptController C,
sunrealtype k1, sunrealtype k2);

SUNDIALS_EXPORT
SUNAdaptController SUNAdaptController_ImpGus(SUNContext sunctx);

SUNDIALS_EXPORT
SUNErrCode SUNAdaptController_SetParams_ImpGus(SUNAdaptController C,
sunrealtype k1, sunrealtype k2);

#ifdef __cplusplus
}
#endif

#endif /* _SUNADAPTCONTROLLER_SODERLIND_H */
45 changes: 45 additions & 0 deletions ThirdParty/sundials/include/sundials/priv/sundials_context_impl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/* -----------------------------------------------------------------
* Programmer(s): Cody J. Balos @ LLNL
* -----------------------------------------------------------------
* SUNDIALS Copyright Start
* Copyright (c) 2002-2024, 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
* -----------------------------------------------------------------
* !!!!!!!!!!!!!!!!!!!!!!!!! WARNING !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* This is a 'private' header file and should not be used in user
* code. It is subject to change without warning.
* !!!!!!!!!!!!!!!!!!!!!!!!! WARNING !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* -----------------------------------------------------------------
* SUNDIALS context class implementation.
* ----------------------------------------------------------------*/

#ifndef _SUNDIALS_CONTEXT_IMPL_H
#define _SUNDIALS_CONTEXT_IMPL_H

#include <sundials/sundials_types.h>

#ifdef __cplusplus /* wrapper to enable C++ usage */
extern "C" {
#endif

struct SUNContext_
{
SUNProfiler profiler;
sunbooleantype own_profiler;
SUNLogger logger;
sunbooleantype own_logger;
SUNErrCode last_err;
SUNErrHandler err_handler;
SUNComm comm;
};

#ifdef __cplusplus
}
#endif
#endif
Loading

0 comments on commit e52d7e3

Please sign in to comment.