14#ifdef MFEM_USE_SUNDIALS
22#include <nvector/nvector_serial.h>
23#if defined(MFEM_USE_CUDA)
24#include <nvector/nvector_cuda.h>
25#elif defined(MFEM_USE_HIP)
26#include <nvector/nvector_hip.h>
29#include <nvector/nvector_mpiplusx.h>
30#include <nvector/nvector_parallel.h>
34#include <sunlinsol/sunlinsol_spgmr.h>
35#include <sunlinsol/sunlinsol_spfgmr.h>
38#define GET_CONTENT(X) ( X->content )
40#if defined(MFEM_USE_CUDA)
41#define SUN_Hip_OR_Cuda(X) X##_Cuda
42#define SUN_HIP_OR_CUDA(X) X##_CUDA
43#elif defined(MFEM_USE_HIP)
44#define SUN_Hip_OR_Cuda(X) X##_Hip
45#define SUN_HIP_OR_CUDA(X) X##_HIP
50#if (SUNDIALS_VERSION_MAJOR < 6)
116 sunindextype local_length,
117 sunindextype global_length,
125#if defined(MFEM_USE_CUDA) || defined(MFEM_USE_HIP)
131 SUNMemoryHelper helper,
146#if defined(MFEM_USE_MPI) && (defined(MFEM_USE_CUDA) || defined(MFEM_USE_HIP))
160#if MFEM_SUNDIALS_VERSION < 70100
161#define MFEM_ARKode(FUNC) ARKStep##FUNC
163#define MFEM_ARKode(FUNC) ARKode##FUNC
168#define STR(s) STR1(s)
176 Sundials::Instance();
187 return Sundials::Instance().context;
192 return Sundials::Instance().memHelper;
195#if (SUNDIALS_VERSION_MAJOR >= 6)
200 int mpi_initialized = 0;
201 MPI_Initialized(&mpi_initialized);
202 MPI_Comm communicator = mpi_initialized ? MPI_COMM_WORLD : MPI_COMM_NULL;
203#if SUNDIALS_VERSION_MAJOR < 7
204 int return_val = SUNContext_Create((
void*) &communicator, &context);
206 int return_val = SUNContext_Create(communicator, &context);
209#if SUNDIALS_VERSION_MAJOR < 7
210 int return_val = SUNContext_Create(
nullptr, &context);
212 int return_val = SUNContext_Create((SUNComm)(0), &context);
215 MFEM_VERIFY(return_val == 0,
"Call to SUNContext_Create failed");
217 memHelper = std::move(actual_helper);
222 SUNContext_Free(&context);
239#if defined(MFEM_USE_CUDA) || defined(MFEM_USE_HIP)
248 h->ops->copy = SUN_Hip_OR_Cuda(SUNMemoryHelper_Copy);
249 h->ops->copyasync = SUN_Hip_OR_Cuda(SUNMemoryHelper_CopyAsync);
254 this->h = that_helper.h;
255 that_helper.h =
nullptr;
266 SUNMemory* memptr,
size_t memsize,
267 SUNMemoryType mem_type
268#
if (SUNDIALS_VERSION_MAJOR >= 6)
273#if (SUNDIALS_VERSION_MAJOR < 7)
274 SUNMemory sunmem = SUNMemoryNewEmpty();
276 SUNMemory sunmem = SUNMemoryNewEmpty(helper->sunctx);
280 sunmem->own = SUNTRUE;
283 if (mem_type == SUNMEMTYPE_HOST)
288 sunmem->type = SUNMEMTYPE_HOST;
291 else if (mem_type == SUNMEMTYPE_DEVICE || mem_type == SUNMEMTYPE_UVM)
296 sunmem->type = mem_type;
311#
if (SUNDIALS_VERSION_MAJOR >= 6)
316 if (sunmem->ptr && sunmem->own && !
mm.
IsKnown(sunmem->ptr))
318 if (sunmem->type == SUNMEMTYPE_HOST)
324 else if (sunmem->type == SUNMEMTYPE_DEVICE || sunmem->type == SUNMEMTYPE_UVM)
332 MFEM_ABORT(
"Invalid SUNMEMTYPE");
350 N_Vector local_x =
MPIPlusX() ? N_VGetLocalVector_MPIPlusX(
x) :
x;
352 N_Vector local_x =
x;
354 N_Vector_ID
id = N_VGetVectorID(local_x);
359 case SUNDIALS_NVEC_SERIAL:
361 MFEM_ASSERT(NV_OWN_DATA_S(local_x) == SUNFALSE,
"invalid serial N_Vector");
363 NV_LENGTH_S(local_x) =
size;
366#if defined(MFEM_USE_CUDA) || defined(MFEM_USE_HIP)
367 case SUN_HIP_OR_CUDA(SUNDIALS_NVEC):
369 SUN_Hip_OR_Cuda(N_VSetHostArrayPointer)(
HostReadWrite(), local_x);
370 SUN_Hip_OR_Cuda(N_VSetDeviceArrayPointer)(
ReadWrite(), local_x);
371 static_cast<SUN_Hip_OR_Cuda(N_VectorContent)
>(GET_CONTENT(
372 local_x))->length =
size;
377 case SUNDIALS_NVEC_PARALLEL:
379 MFEM_ASSERT(NV_OWN_DATA_P(
x) == SUNFALSE,
"invalid parallel N_Vector");
381 NV_LOCLENGTH_P(
x) =
size;
386 if (glob_size == 0 && glob_size !=
size)
388 long local_size =
size;
389 MPI_Allreduce(&local_size, &glob_size, 1, MPI_LONG,
393 NV_GLOBLENGTH_P(
x) = glob_size;
398 MFEM_ABORT(
"N_Vector type " <<
id <<
" is not supported");
408 if (glob_size == 0 && glob_size !=
size)
410 long local_size =
size;
411 MPI_Allreduce(&local_size, &glob_size, 1, MPI_LONG,
415 static_cast<N_VectorContent_MPIManyVector
>(GET_CONTENT(
x))->global_length =
424 N_Vector local_x =
MPIPlusX() ? N_VGetLocalVector_MPIPlusX(
x) :
x;
426 N_Vector local_x =
x;
428 N_Vector_ID
id = N_VGetVectorID(local_x);
433 case SUNDIALS_NVEC_SERIAL:
435 const bool known =
mm.
IsKnown(NV_DATA_S(local_x));
436 size = NV_LENGTH_S(local_x);
441#if defined(MFEM_USE_CUDA) || defined(MFEM_USE_HIP)
442 case SUN_HIP_OR_CUDA(SUNDIALS_NVEC):
444 double *h_ptr = SUN_Hip_OR_Cuda(N_VGetHostArrayPointer)(local_x);
445 double *d_ptr = SUN_Hip_OR_Cuda(N_VGetDeviceArrayPointer)(local_x);
447 size = SUN_Hip_OR_Cuda(N_VGetLength)(local_x);
455 case SUNDIALS_NVEC_PARALLEL:
458 size = NV_LENGTH_S(
x);
459 data.
Wrap(NV_DATA_P(
x), NV_LOCLENGTH_P(
x),
false);
465 MFEM_ABORT(
"N_Vector type " <<
id <<
" is not supported");
524 :
SundialsNVector(vec.GetComm(), vec.GetData(), vec.Size(), vec.GlobalSize())
535 N_VDestroy(N_VGetLocalVector_MPIPlusX(
x));
563#if defined(MFEM_USE_CUDA) || defined(MFEM_USE_HIP)
578 MFEM_VERIFY(
x,
"Error in SundialsNVector::MakeNVector.");
588 if (comm == MPI_COMM_NULL)
594#if defined(MFEM_USE_CUDA) || defined(MFEM_USE_HIP)
612 MFEM_VERIFY(
x,
"Error in SundialsNVector::MakeNVector.");
624static SUNMatrix_ID MatGetID(SUNMatrix)
626 return (SUNMATRIX_CUSTOM);
629static void MatDestroy(SUNMatrix A)
631 if (A->content) { A->content = NULL; }
632 if (A->ops) { free(A->ops); A->ops = NULL; }
642static SUNLinearSolver_Type LSGetType(SUNLinearSolver)
644 return (SUNLINEARSOLVER_MATRIX_ITERATIVE);
647static int LSFree(SUNLinearSolver LS)
649 if (LS->content) { LS->content = NULL; }
650 if (LS->ops) { free(LS->ops); LS->ops = NULL; }
669 self->
f->
Mult(mfem_y, mfem_ydot);
680 if (!self->
root_func) {
return CV_RTFUNC_FAIL; }
685 return self->
root_func(t, mfem_y, mfem_gout, self);
693 MFEM_VERIFY(
flag == CV_SUCCESS,
"error in SetRootFinder()");
699 void*, N_Vector, N_Vector, N_Vector)
722 : lmm_type(lmm), step_mode(CV_NORMAL)
729 : lmm_type(lmm), step_mode(CV_NORMAL)
741 long local_size = f_.
Height();
744 long global_size = 0;
747 MPI_Allreduce(&local_size, &global_size, 1, MPI_LONG, MPI_SUM,
761 resize = (
Y->
Size() != local_size);
766 int l_resize = (
Y->
Size() != local_size) ||
768 MPI_Allreduce(&l_resize, &resize, 1, MPI_INT, MPI_LOR,
794 Y->
SetSize(local_size, global_size);
805 MFEM_VERIFY(
flag == CV_SUCCESS,
"error in CVodeInit()");
809 MFEM_VERIFY(
flag == CV_SUCCESS,
"error in CVodeSetUserData()");
813 MFEM_VERIFY(
flag == CV_SUCCESS,
"error in CVodeSetSStolerances()");
826 MFEM_VERIFY(
Y->
Size() == x.
Size(),
"size mismatch");
832 MFEM_VERIFY(
flag == CV_SUCCESS,
"error in CVodeReInit()");
838 double tout = t + dt;
840 MFEM_VERIFY(
flag >= 0,
"error in CVode()");
847 MFEM_VERIFY(
flag == CV_SUCCESS,
"error in CVodeGetLastStep()");
853 if (
A != NULL) { SUNMatDestroy(
A);
A = NULL; }
854 if (
LSA != NULL) { SUNLinSolFree(
LSA);
LSA = NULL; }
858 MFEM_VERIFY(
LSA,
"error in SUNLinSolNewEmpty()");
861 LSA->ops->gettype = LSGetType;
863 LSA->ops->free = LSFree;
866 MFEM_VERIFY(
A,
"error in SUNMatNewEmpty()");
869 A->ops->getid = MatGetID;
870 A->ops->destroy = MatDestroy;
874 MFEM_VERIFY(
flag == CV_SUCCESS,
"error in CVodeSetLinearSolver()");
878 MFEM_VERIFY(
flag == CV_SUCCESS,
"error in CVodeSetLinSysFn()");
884 if (
A != NULL) { SUNMatDestroy(
A);
A = NULL; }
885 if (
LSA != NULL) { SUNLinSolFree(
LSA);
LSA = NULL; }
889 MFEM_VERIFY(
LSA,
"error in SUNLinSol_SPGMR()");
893 MFEM_VERIFY(
flag == CV_SUCCESS,
"error in CVodeSetLinearSolver()");
904 MFEM_VERIFY(
flag == CV_SUCCESS,
"error in CVodeSStolerances()");
910 "abs tolerance is not the same size.");
916 MFEM_VERIFY(
flag == CV_SUCCESS,
"error in CVodeSVtolerances()");
922 MFEM_VERIFY(
flag == CV_SUCCESS,
"error in CVodeSetMaxStep()");
928 MFEM_VERIFY(
flag == CV_SUCCESS,
"error in CVodeSetMaxNumSteps()");
935 MFEM_VERIFY(
flag == CV_SUCCESS,
"error in CVodeGetNumSteps()");
942 MFEM_VERIFY(
flag == CV_SUCCESS,
"error in CVodeSetMaxOrd()");
947 long int nsteps, nfevals, nlinsetups, netfails;
949 double hinused, hlast, hcur, tcur;
950 long int nniters, nncfails;
964 MFEM_VERIFY(
flag == CV_SUCCESS,
"error in CVodeGetIntegratorStats()");
970 MFEM_VERIFY(
flag == CV_SUCCESS,
"error in CVodeGetNonlinSolvStats()");
974 "num steps: " << nsteps <<
"\n"
975 "num rhs evals: " << nfevals <<
"\n"
976 "num lin setups: " << nlinsetups <<
"\n"
977 "num nonlin sol iters: " << nniters <<
"\n"
978 "num nonlin conv fail: " << nncfails <<
"\n"
979 "num error test fails: " << netfails <<
"\n"
980 "last order: " << qlast <<
"\n"
981 "current order: " << qcur <<
"\n"
982 "initial dt: " << hinused <<
"\n"
983 "last dt: " << hlast <<
"\n"
984 "current dt: " << hcur <<
"\n"
985 "current t: " << tcur <<
"\n" << endl;
995 SUNNonlinSolFree(
NLS);
1033 MFEM_VERIFY(t <= f->GetTime(),
"t > current forward solver time");
1036 MFEM_VERIFY(
flag == CV_SUCCESS,
"error in CVodeGetQuad()");
1043 MFEM_VERIFY(t <= f->GetTime(),
"t > current forward solver time");
1046 MFEM_VERIFY(
flag == CV_SUCCESS,
"error in CVodeGetQuadB()");
1048 dG_dp.
Set(-1., *
qB);
1056 MFEM_VERIFY(
flag >= 0,
"error in CVodeGetAdjY()");
1076 MFEM_VERIFY(
flag == CV_SUCCESS,
"error in CVodeCreateB()");
1080 MFEM_VERIFY(
flag == CV_SUCCESS,
"error in CVodeInit()");
1084 MFEM_VERIFY(
flag == CV_SUCCESS,
"error in CVodeSetUserDataB()");
1089 MFEM_VERIFY(
flag == CV_SUCCESS,
"error in CVodeSetSStolerancesB()");
1101 MFEM_VERIFY(
flag == CV_SUCCESS,
"Error in CVodeAdjInit");
1107 MFEM_VERIFY(
flag == CV_SUCCESS,
"Error in CVodeSetMaxNumStepsB()");
1116 MFEM_VERIFY(
flag == CV_SUCCESS,
"Error in CVodeQuadInit()");
1119 MFEM_VERIFY(
flag == CV_SUCCESS,
"Error in CVodeSetQuadErrCon");
1122 MFEM_VERIFY(
flag == CV_SUCCESS,
"Error in CVodeQuadSStolerances");
1131 MFEM_VERIFY(
flag == CV_SUCCESS,
"Error in CVodeQuadInitB()");
1134 MFEM_VERIFY(
flag == CV_SUCCESS,
"Error in CVodeSetQuadErrConB");
1137 MFEM_VERIFY(
flag == CV_SUCCESS,
"Error in CVodeQuadSStolerancesB");
1143 if (
AB != NULL) { SUNMatDestroy(
AB);
AB = NULL; }
1144 if (
LSB != NULL) { SUNLinSolFree(
LSB);
LSB = NULL; }
1148 MFEM_VERIFY(
LSB,
"error in SUNLinSolNewEmpty()");
1150 LSB->content =
this;
1151 LSB->ops->gettype = LSGetType;
1153 LSB->ops->free = LSFree;
1156 MFEM_VERIFY(
AB,
"error in SUNMatNewEmpty()");
1159 AB->ops->getid = MatGetID;
1160 AB->ops->destroy = MatDestroy;
1164 MFEM_VERIFY(
flag == CV_SUCCESS,
"error in CVodeSetLinearSolverB()");
1169 MFEM_VERIFY(
flag == CV_SUCCESS,
"error in CVodeSetLinSysFn()");
1175 if (
AB != NULL) { SUNMatDestroy(
AB);
AB = NULL; }
1176 if (
LSB != NULL) { SUNLinSolFree(
LSB);
LSB = NULL; }
1180 MFEM_VERIFY(
LSB,
"error in SUNLinSol_SPGMR()");
1184 MFEM_VERIFY(
flag == CV_SUCCESS,
"error in CVodeSetLinearSolverB()");
1188 N_Vector fyB, SUNMatrix AB,
1191 N_Vector tmp1, N_Vector tmp2, N_Vector tmp3)
1202 return (
f->SUNImplicitSetupB(t, mfem_y, mfem_yB, mfem_fyB, jokB, jcurB,
1215 int ret =
f->SUNImplicitSolveB(mfem_yB, mfem_Rb, tol);
1222 MFEM_VERIFY(
flag == CV_SUCCESS,
"error in CVodeSStolerancesB()");
1228 "abs tolerance is not the same size.");
1234 MFEM_VERIFY(
flag == CV_SUCCESS,
"error in CVodeSVtolerancesB()");
1254 f->QuadratureIntegration(mfem_y, mfem_qdot);
1268 f->QuadratureSensitivityMult(mfem_y, mfem_yB, mfem_qBdot);
1284 f->AdjointRateMult(mfem_y, mfem_yB, mfem_yBdot);
1295 return self->
ewt_func(mfem_y, mfem_w, self);
1302 MFEM_VERIFY(
Y->
Size() == x.
Size(),
"size mismatch");
1308 MFEM_VERIFY(
flag == CV_SUCCESS,
"error in CVodeReInit()");
1315 double tout = t + dt;
1317 MFEM_VERIFY(
flag >= 0,
"error in CVodeF()");
1324 MFEM_VERIFY(
flag == CV_SUCCESS,
"error in CVodeGetLastStep()");
1336 MFEM_VERIFY(
flag == CV_SUCCESS,
"error in CVodeReInit()");
1343 double tout = tB - dtB;
1345 MFEM_VERIFY(
flag >= 0,
"error in CVodeB()");
1349 MFEM_VERIFY(
flag >= 0,
"error in CVodeGetB()");
1391 self->
f->
Mult(mfem_y, mfem_result);
1417 self->
f->
Mult(mfem_y, mfem_result);
1431 void*, N_Vector, N_Vector, N_Vector)
1463 void*, N_Vector, N_Vector, N_Vector)
1506 : rk_type(type), step_mode(ARK_NORMAL),
1507 use_implicit(type == IMPLICIT || type == IMEX)
1514 : rk_type(type), step_mode(ARK_NORMAL),
1515 use_implicit(type == IMPLICIT || type == IMEX)
1527 long local_size = f_.
Height();
1535 MPI_Allreduce(&local_size, &global_size, 1, MPI_LONG, MPI_SUM,
1549 resize = (
Y->
Size() != local_size);
1554 int l_resize = (
Y->
Size() != local_size) ||
1556 MPI_Allreduce(&l_resize, &resize, 1, MPI_INT, MPI_LOR,
1578 Y->
SetSize(local_size, global_size);
1603 MFEM_VERIFY(
flag == ARK_SUCCESS,
1604 "error in " STR(MFEM_ARKode(SetUserData))
"()");
1609 MFEM_VERIFY(
flag == ARK_SUCCESS,
1610 "error in " STR(MFEM_ARKode(SStolerances))
"()");
1623 MFEM_VERIFY(
Y->
Size() == x.
Size(),
"size mismatch");
1641 MFEM_VERIFY(
flag == ARK_SUCCESS,
"error in ARKStepReInit()");
1648 double tout = t + dt;
1650 MFEM_VERIFY(
flag >= 0,
"error in " STR(MFEM_ARKode(Evolve))
"()");
1657 MFEM_VERIFY(
flag == ARK_SUCCESS,
1658 "error in " STR(MFEM_ARKode(GetLastStep))
"()");
1664 if (
A != NULL) { SUNMatDestroy(
A);
A = NULL; }
1665 if (
LSA != NULL) { SUNLinSolFree(
LSA);
LSA = NULL; }
1669 MFEM_VERIFY(
LSA,
"error in SUNLinSolNewEmpty()");
1671 LSA->content =
this;
1672 LSA->ops->gettype = LSGetType;
1674 LSA->ops->free = LSFree;
1677 MFEM_VERIFY(
A,
"error in SUNMatNewEmpty()");
1680 A->ops->getid = MatGetID;
1681 A->ops->destroy = MatDestroy;
1685 MFEM_VERIFY(
flag == ARK_SUCCESS,
1686 "error in " STR(MFEM_ARKode(SetLinearSolver))
"()");
1690 MFEM_VERIFY(
flag == ARK_SUCCESS,
1691 "error in " STR(MFEM_ARKode(SetLinSysFn))
"()");
1697 if (
A != NULL) { SUNMatDestroy(
A);
A = NULL; }
1698 if (
LSA != NULL) { SUNLinSolFree(
LSA);
LSA = NULL; }
1702 MFEM_VERIFY(
LSA,
"error in SUNLinSol_SPGMR()");
1706 MFEM_VERIFY(
flag == ARK_SUCCESS,
1707 "error in " STR(MFEM_ARKode(SetLinearSolver))
"()");
1713 if (
M != NULL) { SUNMatDestroy(
M);
M = NULL; }
1714 if (
LSM != NULL) { SUNLinSolFree(
LSM);
LSM = NULL; }
1718 MFEM_VERIFY(
LSM,
"error in SUNLinSolNewEmpty()");
1720 LSM->content =
this;
1721 LSM->ops->gettype = LSGetType;
1723 LSM->ops->free = LSFree;
1726 MFEM_VERIFY(
M,
"error in SUNMatNewEmpty()");
1729 M->ops->getid = MatGetID;
1731 M->ops->destroy = MatDestroy;
1735 MFEM_VERIFY(
flag == ARK_SUCCESS,
1736 "error in " STR(MFEM_ARKode(SetMassLinearSolver))
"()");
1740 MFEM_VERIFY(
flag == ARK_SUCCESS,
1741 "error in " STR(MFEM_ARKode(SetMassFn))
"()");
1744 MFEM_VERIFY(!
f->
isExplicit(),
"ODE operator is expressed in EXPLICIT form")
1750 if (
M != NULL) { SUNMatDestroy(
A);
M = NULL; }
1751 if (
LSM != NULL) { SUNLinSolFree(
LSM);
LSM = NULL; }
1755 MFEM_VERIFY(
LSM,
"error in SUNLinSol_SPGMR()");
1759 MFEM_VERIFY(
flag == ARK_SUCCESS,
1760 "error in " STR(MFEM_ARKode(SetMassLinearSolver))
"()");
1765 MFEM_VERIFY(
flag == ARK_SUCCESS,
1766 "error in " STR(MFEM_ARKode(SetMassTimes))
"()");
1769 MFEM_VERIFY(!
f->
isExplicit(),
"ODE operator is expressed in EXPLICIT form")
1780 MFEM_VERIFY(
flag == ARK_SUCCESS,
1781 "error in " STR(MFEM_ARKode(SStolerances))
"()");
1787 MFEM_VERIFY(
flag == ARK_SUCCESS,
1788 "error in " STR(MFEM_ARKode(
SetMaxStep))
"()");
1794 MFEM_VERIFY(
flag == ARK_SUCCESS,
1795 "error in " STR(MFEM_ARKode(
SetOrder))
"()");
1801 MFEM_VERIFY(
flag == ARK_SUCCESS,
"error in ARKStepSetTableNum()");
1807 MFEM_VERIFY(
flag == ARK_SUCCESS,
"error in ARKStepSetTableNum()");
1814 MFEM_VERIFY(
flag == ARK_SUCCESS,
"error in ARKStepSetTableNum()");
1820 MFEM_VERIFY(
flag == ARK_SUCCESS,
1826 long int nsteps, expsteps, accsteps, step_attempts;
1827 long int nfe_evals, nfi_evals;
1828 long int nlinsetups, netfails;
1829 double hinused, hlast, hcur, tcur;
1830 long int nniters, nncfails;
1841 MFEM_VERIFY(
flag == ARK_SUCCESS,
"error in ARKStepGetTimestepperStats()");
1854 MFEM_VERIFY(
flag == ARK_SUCCESS,
1855 "error in " STR(MFEM_ARKode(GetNonlinSolvStats))
"()");
1859 "num steps: " << nsteps <<
"\n"
1860 "num exp rhs evals: " << nfe_evals <<
"\n"
1861 "num imp rhs evals: " << nfi_evals <<
"\n"
1862 "num lin setups: " << nlinsetups <<
"\n"
1863 "num nonlin sol iters: " << nniters <<
"\n"
1864 "num nonlin conv fail: " << nncfails <<
"\n"
1865 "num steps attempted: " << step_attempts <<
"\n"
1866 "num acc limited steps: " << accsteps <<
"\n"
1867 "num exp limited stepfails: " << expsteps <<
"\n"
1868 "num error test fails: " << netfails <<
"\n"
1869 "initial dt: " << hinused <<
"\n"
1870 "last dt: " << hlast <<
"\n"
1871 "current dt: " << hcur <<
"\n"
1872 "current t: " << tcur <<
"\n" << endl;
1882 SUNNonlinSolFree(
NLS);
1929 void *, N_Vector, N_Vector )
1997 : global_strategy(strategy), use_oper_grad(oper_grad), y_scale(NULL),
1998 f_scale(NULL), jacobian(NULL)
2005#if MFEM_SUNDIALS_VERSION < 70000
2006 abs_tol = pow(UNIT_ROUNDOFF, 1.0/3.0);
2008 abs_tol = pow(SUN_UNIT_ROUNDOFF, 1.0/3.0);
2015 : global_strategy(strategy), use_oper_grad(oper_grad), y_scale(NULL),
2016 f_scale(NULL), jacobian(NULL)
2023#if MFEM_SUNDIALS_VERSION < 70000
2024 abs_tol = pow(UNIT_ROUNDOFF, 1.0/3.0);
2026 abs_tol = pow(SUN_UNIT_ROUNDOFF, 1.0/3.0);
2040 long local_size =
height;
2048 MPI_Allreduce(&local_size, &global_size, 1, MPI_LONG, MPI_SUM,
2059 resize = (
Y->
Size() != local_size);
2064 int l_resize = (
Y->
Size() != local_size) ||
2066 MPI_Allreduce(&l_resize, &resize, 1, MPI_INT, MPI_LOR,
2088 Y->
SetSize(local_size, global_size);
2103 MFEM_ASSERT(
flag == KIN_SUCCESS,
"error in KINSetMAA()");
2106 MFEM_ASSERT(
flag == KIN_SUCCESS,
"error in KINSetDelayAA()");
2109 MFEM_ASSERT(
flag == KIN_SUCCESS,
"error in KINSetDampingAA()");
2111#if SUNDIALS_VERSION_MAJOR >= 6
2113 MFEM_ASSERT(
flag == KIN_SUCCESS,
"error in KINSetOrthAA()");
2119 MFEM_VERIFY(
flag == KIN_SUCCESS,
"error in KINInit()");
2123 MFEM_ASSERT(
flag == KIN_SUCCESS,
"error in KINSetUserData()");
2126 MFEM_ASSERT(
flag == KIN_SUCCESS,
"error in KINSetDamping()");
2136 if (
A != NULL) { SUNMatDestroy(
A);
A = NULL; }
2137 if (
LSA != NULL) { SUNLinSolFree(
LSA);
LSA = NULL; }
2140 MFEM_VERIFY(
LSA,
"error in SUNLinSol_SPGMR()");
2143 MFEM_ASSERT(
flag == KIN_SUCCESS,
"error in KINSetLinearSolver()");
2149 MFEM_ASSERT(
flag == KIN_SUCCESS,
"error in KINSetJacTimesVecFn()");
2167 if (
A != NULL) { SUNMatDestroy(
A);
A = NULL; }
2168 if (
LSA != NULL) { SUNLinSolFree(
LSA);
LSA = NULL; }
2172 MFEM_VERIFY(
LSA,
"error in SUNLinSolNewEmpty()");
2174 LSA->content =
this;
2175 LSA->ops->gettype = LSGetType;
2177 LSA->ops->free = LSFree;
2180 MFEM_VERIFY(
A,
"error in SUNMatNewEmpty()");
2183 A->ops->getid = MatGetID;
2184 A->ops->destroy = MatDestroy;
2188 MFEM_VERIFY(
flag == KIN_SUCCESS,
"error in KINSetLinearSolver()");
2192 MFEM_VERIFY(
flag == KIN_SUCCESS,
"error in KINSetJacFn()");
2204 if (
A != NULL) { SUNMatDestroy(
A);
A = NULL; }
2205 if (
LSA != NULL) { SUNLinSolFree(
LSA);
LSA = NULL; }
2210 MFEM_VERIFY(
LSA,
"error in SUNLinSol_SPFGMR()");
2216 MFEM_VERIFY(
flag == KIN_SUCCESS,
"error in KINSetLinearSolver()");
2223 MFEM_VERIFY(
flag == KIN_SUCCESS,
"error in KINSetPreconditioner()");
2230 MFEM_ASSERT(
flag == KIN_SUCCESS,
"error in KINSetScaledStepTol()");
2236 MFEM_ASSERT(
flag == KIN_SUCCESS,
"error in KINSetMaxSetupCalls()");
2245 MFEM_ABORT(
"Subsequent calls to EnableAndersonAcc() must set"
2246 " the subspace size to less or equal to the initially requested size."
2247 " If SetOperator() has already been called, the subspace size can't be"
2252 MFEM_ASSERT(
flag == KIN_SUCCESS,
"error in KINSetMAA()");
2255 MFEM_ASSERT(
flag == KIN_SUCCESS,
"error in KINSetDelayAA()");
2258 MFEM_ASSERT(
flag == KIN_SUCCESS,
"error in KINSetDampingAA()");
2260#if SUNDIALS_VERSION_MAJOR >= 6
2262 MFEM_ASSERT(
flag == KIN_SUCCESS,
"error in KINSetOrthAA()");
2264 if (orth != KIN_ORTH_MGS)
2266 MFEM_WARNING(
"SUNDIALS < v6 does not support setting the Anderson"
2267 " acceleration orthogonalization routine!");
2284 MFEM_ASSERT(
flag == KIN_SUCCESS,
"error in KINSetDamping()");
2290 MFEM_ABORT(
"this method is not supported! Use SetPrintLevel(int) instead.");
2315 double lnorm = norm;
2339 MFEM_ASSERT(
flag == KIN_SUCCESS,
"error in KINSetFuncNormTol()");
2350 MFEM_ASSERT(
flag == KIN_SUCCESS,
"KINSetNumMaxIters() failed!");
2364 MPI_Comm_rank(
Y->
GetComm(), &rank);
2370#if MFEM_SUNDIALS_VERSION < 70000
2372 MFEM_VERIFY(
flag == KIN_SUCCESS,
"KINSetPrintLevel() failed!");
2376#ifdef SUNDIALS_BUILD_WITH_MONITORING
2379 flag = SUNLinSolSetInfoFile_SPFGMR(
LSA, stdout);
2381 "error in SUNLinSolSetInfoFile_SPFGMR()");
2383 flag = SUNLinSolSetPrintLevel_SPFGMR(
LSA, 1);
2385 "error in SUNLinSolSetPrintLevel_SPFGMR()");
2402 MFEM_ASSERT(
flag == KIN_SUCCESS,
"error in KINGetNumNonlinSolvIters()");
2407 MFEM_ASSERT(
flag == KIN_SUCCESS,
"error in KINGetFuncNorm()");
Interface to ARKode's ARKStep module – additive Runge-Kutta methods.
static int RHS2(sunrealtype t, const N_Vector y, N_Vector ydot, void *user_data)
void SetMaxStep(double dt_max)
Set the maximum time step.
void PrintInfo() const
Print various ARKStep statistics.
Type rk_type
Runge-Kutta type.
ARKStepSolver(Type type=EXPLICIT)
Construct a serial wrapper to SUNDIALS' ARKode integrator.
void SetOrder(int order)
Chooses integration order for all explicit / implicit / IMEX methods.
void SetStepMode(int itask)
Select the ARKode step mode: ARK_NORMAL (default) or ARK_ONE_STEP.
Type
Types of ARKODE solvers.
@ IMPLICIT
Implicit RK method.
@ IMEX
Implicit-explicit ARK method.
@ EXPLICIT
Explicit RK method.
static int LinSysSolve(SUNLinearSolver LS, SUNMatrix A, N_Vector x, N_Vector b, sunrealtype tol)
Solve the linear system .
static int LinSysSetup(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix A, SUNMatrix M, sunbooleantype jok, sunbooleantype *jcur, sunrealtype gamma, void *user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3)
Setup the linear system .
void UseSundialsLinearSolver()
Attach a SUNDIALS GMRES linear solver to ARKode.
void Init(TimeDependentOperator &f_) override
Initialize ARKode: calls ARKStepCreate() to create the ARKStep memory and set some defaults.
static int MassMult2(N_Vector x, N_Vector v, sunrealtype t, void *mtimes_data)
Compute the matrix-vector product at time t.
void SetIRKTableNum(ARKODE_DIRKTableID table_id)
Choose a specific Butcher table for a diagonally implicit RK method.
void SetFixedStep(double dt)
Use a fixed time step size (disable temporal adaptivity).
void SetERKTableNum(ARKODE_ERKTableID table_id)
Choose a specific Butcher table for an explicit RK method.
int step_mode
ARKStep step mode (ARK_NORMAL or ARK_ONE_STEP).
static int RHS1(sunrealtype t, const N_Vector y, N_Vector ydot, void *user_data)
void UseMFEMMassLinearSolver(int tdep)
Attach mass matrix linear system setup, solve, and matrix-vector product methods from the TimeDepende...
bool use_implicit
True for implicit or imex integration.
void UseSundialsMassLinearSolver(int tdep)
Attach the SUNDIALS GMRES linear solver and the mass matrix matrix-vector product method from the Tim...
virtual ~ARKStepSolver()
Destroy the associated ARKode memory and SUNDIALS objects.
void SetIMEXTableNum(ARKODE_ERKTableID etable_id, ARKODE_DIRKTableID itable_id)
Choose a specific Butcher table for an IMEX RK method.
void UseMFEMLinearSolver()
Attach the linear system setup and solve methods from the TimeDependentOperator i....
static int MassMult1(SUNMatrix M, N_Vector x, N_Vector v)
Compute the matrix-vector product .
static int MassSysSolve(SUNLinearSolver LS, SUNMatrix M, N_Vector x, N_Vector b, sunrealtype tol)
Solve the linear system .
static int MassSysSetup(sunrealtype t, SUNMatrix M, void *user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3)
Setup the linear system .
void Step(Vector &x, real_t &t, real_t &dt) override
Integrate the ODE with ARKode using the specified step mode.
void SetSStolerances(double reltol, double abstol)
Set the scalar relative and scalar absolute tolerances.
static int RHSB(sunrealtype t, N_Vector y, N_Vector yB, N_Vector yBdot, void *user_dataB)
Wrapper to compute the ODE RHS backward function.
void EvalQuadIntegrationB(double t, Vector &dG_dp)
Evaluate Quadrature solution.
void EvalQuadIntegration(double t, Vector &q)
Evaluate Quadrature.
static int LinSysSetupB(sunrealtype t, N_Vector y, N_Vector yB, N_Vector fyB, SUNMatrix A, sunbooleantype jok, sunbooleantype *jcur, sunrealtype gamma, void *user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3)
Setup the linear system A x = b.
static int LinSysSolveB(SUNLinearSolver LS, SUNMatrix A, N_Vector x, N_Vector b, sunrealtype tol)
Solve the linear system A x = b.
static constexpr double default_abs_tolB
Default scalar backward absolute tolerance.
void SetMaxNStepsB(int mxstepsB)
Set the maximum number of backward steps.
static int RHSQ(sunrealtype t, const N_Vector y, N_Vector qdot, void *user_data)
Wrapper to compute the ODE RHS Quadrature function.
void Step(Vector &x, double &t, double &dt) override
void InitB(TimeDependentAdjointOperator &f_)
Initialize the adjoint problem.
static int RHSQB(sunrealtype t, N_Vector y, N_Vector yB, N_Vector qBdot, void *user_dataB)
Wrapper to compute the ODE RHS Backwards Quadrature function.
SundialsNVector * q
Quadrature vector.
int indexB
backward problem index
void GetForwardSolution(double tB, mfem::Vector &yy)
Get Interpolated Forward solution y at backward integration time tB.
SUNLinearSolver LSB
Linear solver for A.
void SetSVtolerancesB(double reltol, Vector abstol)
Tolerance specification functions for the adjoint problem.
void UseSundialsLinearSolverB()
Use built in SUNDIALS Newton solver.
void SetWFTolerances(EWTFunction func)
Set multiplicative error weights.
SundialsNVector * yy
State vector.
void Init(TimeDependentAdjointOperator &f_)
SUNMatrix AB
Linear system A = I - gamma J, M - gamma J, or J.
int ncheck
number of checkpoints used so far
SundialsNVector * qB
State vector.
static int ewt(N_Vector y, N_Vector w, void *user_data)
Error control function.
virtual void StepB(Vector &w, double &t, double &dt)
Solve one adjoint time step.
void InitQuadIntegrationB(mfem::Vector &qB0, double reltolQB=1e-3, double abstolQB=1e-8)
Initialize Quadrature Integration (Adjoint)
static constexpr double default_rel_tolB
Default scalar backward relative tolerance.
void InitAdjointSolve(int steps, int interpolation)
Initialize Adjoint.
SundialsNVector * yB
State vector.
void InitQuadIntegration(mfem::Vector &q0, double reltolQ=1e-3, double abstolQ=1e-8)
virtual ~CVODESSolver()
Destroy the associated CVODES memory and SUNDIALS objects.
void SetSStolerancesB(double reltol, double abstol)
Tolerance specification functions for the adjoint problem.
void UseMFEMLinearSolverB()
Set Linear Solver for the backward problem.
Interface to the CVODE library – linear multi-step methods.
void SetStepMode(int itask)
Select the CVODE step mode: CV_NORMAL (default) or CV_ONE_STEP.
void SetRootFinder(int components, RootFunction func)
Initialize Root Finder.
std::function< int(sunrealtype t, Vector y, Vector gout, CVODESolver *)> RootFunction
Typedef for root finding functions.
void SetSStolerances(double reltol, double abstol)
Set the scalar relative and scalar absolute tolerances.
void Init(TimeDependentOperator &f_) override
Initialize CVODE: calls CVodeCreate() to create the CVODE memory and set some defaults.
static int LinSysSolve(SUNLinearSolver LS, SUNMatrix A, N_Vector x, N_Vector b, sunrealtype tol)
Solve the linear system .
virtual ~CVODESolver()
Destroy the associated CVODE memory and SUNDIALS objects.
static int root(sunrealtype t, N_Vector y, sunrealtype *gout, void *user_data)
Prototype to define root finding for CVODE.
void SetMaxNSteps(int steps)
Set the maximum number of time steps.
CVODESolver(int lmm)
Construct a serial wrapper to SUNDIALS' CVODE integrator.
long GetNumSteps()
Get the number of internal steps taken so far.
void Step(Vector &x, double &t, double &dt) override
Integrate the ODE with CVODE using the specified step mode.
EWTFunction ewt_func
A class member to facilitate pointing to a user-specified error weight function.
static int RHS(sunrealtype t, const N_Vector y, N_Vector ydot, void *user_data)
Number of components in gout.
void SetMaxStep(double dt_max)
Set the maximum time step.
int lmm_type
Linear multistep method type.
void PrintInfo() const
Print various CVODE statistics.
void UseSundialsLinearSolver()
Attach SUNDIALS GMRES linear solver to CVODE.
void UseMFEMLinearSolver()
Attach the linear system setup and solve methods from the TimeDependentOperator i....
RootFunction root_func
A class member to facilitate pointing to a user-specified root function.
std::function< int(Vector y, Vector w, CVODESolver *)> EWTFunction
Typedef declaration for error weight functions.
int step_mode
CVODE step mode (CV_NORMAL or CV_ONE_STEP).
static int LinSysSetup(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix A, sunbooleantype jok, sunbooleantype *jcur, sunrealtype gamma, void *user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3)
Setup the linear system .
void SetSVtolerances(double reltol, Vector abstol)
Set the scalar relative and vector of absolute tolerances.
void SetMaxOrder(int max_order)
Set the maximum method order.
static MemoryType GetHostMemoryType()
Get the current Host MemoryType. This is the MemoryType used by most MFEM classes when allocating mem...
static bool IsAvailable()
Return true if an actual device (e.g. GPU) has been configured.
static MemoryType GetDeviceMemoryType()
Get the current Device MemoryType. This is the MemoryType used by most MFEM classes when allocating m...
Wrapper for hypre's parallel vector class.
real_t abs_tol
Absolute tolerance.
real_t rel_tol
Relative tolerance.
int print_level
(DEPRECATED) Legacy print level definition, which is left for compatibility with custom iterative sol...
int max_iter
Limit for the number of iterations the solver is allowed to do.
Interface to the KINSOL library – nonlinear solver methods.
SundialsNVector * f_scale
scaling vectors
KINSolver(int strategy, bool oper_grad=true)
Construct a serial wrapper to SUNDIALS' KINSOL nonlinear solver.
double aa_damping
Anderson Acceleration damping.
void SetJFNKSolver(Solver &solver)
virtual ~KINSolver()
Destroy the associated KINSOL memory.
static int Mult(const N_Vector u, N_Vector fu, void *user_data)
Wrapper to compute the nonlinear residual .
static int LinSysSolve(SUNLinearSolver LS, SUNMatrix J, N_Vector u, N_Vector b, sunrealtype tol)
Solve the linear system .
int aa_delay
Anderson Acceleration delay.
int global_strategy
KINSOL solution strategy.
static int PrecSolve(N_Vector uu, N_Vector uscale, N_Vector fval, N_Vector fscale, N_Vector vv, void *user_data)
Solve the preconditioner equation .
int maxlrs
Maximum linear solver restarts.
const Operator * jacobian
stores oper->GetGradient()
int maxli
Maximum linear iterations.
Vector wrk
Work vector needed for the JFNK PC.
void SetScaledStepTol(double sstol)
Set KINSOL's scaled step tolerance.
void SetSolver(Solver &solver) override
Set the linear solver for inverting the Jacobian.
SundialsNVector * y_scale
void SetOperator(const Operator &op) override
Set the nonlinear Operator of the system and initialize KINSOL.
void SetMaxSetupCalls(int max_calls)
Set maximum number of nonlinear iterations without a Jacobian update.
static int LinSysSetup(N_Vector u, N_Vector fu, SUNMatrix J, void *user_data, N_Vector tmp1, N_Vector tmp2)
Setup the linear system .
int aa_orth
Anderson Acceleration orthogonalization routine.
static int PrecSetup(N_Vector uu, N_Vector uscale, N_Vector fval, N_Vector fscale, void *user_data)
Setup the preconditioner.
void SetDamping(double damping)
double fp_damping
Fixed Point or Picard damping parameter.
void EnableAndersonAcc(int n, int orth=KIN_ORTH_MGS, int delay=0, double damping=1.0)
Enable Anderson Acceleration for KIN_FP or KIN_PICARD.
void SetPrintLevel(int print_lvl) override
Set the print level for the KINSetPrintLevel function.
bool use_oper_grad
use the Jv prod function
int aa_n
number of acceleration vectors
static int GradientMult(N_Vector v, N_Vector Jv, N_Vector u, sunbooleantype *new_u, void *user_data)
Wrapper to compute the Jacobian-vector product .
bool IsKnown(const void *h_ptr)
Return true if the pointer is known by the memory manager.
Class used by MFEM to store pointers to host and/or device memory.
void SetHostPtrOwner(bool own) const
Set/clear the ownership flag for the host pointer. Ownership indicates whether the pointer will be de...
void SetDevicePtrOwner(bool own) const
Set/clear the ownership flag for the device pointer. Ownership indicates whether the pointer will be ...
void Wrap(T *ptr, int size, bool own)
Wrap an externally allocated host pointer, ptr with the current host memory type returned by MemoryMa...
void Delete()
Delete the owned pointers and reset the Memory object.
void ClearOwnerFlags() const
Clear the ownership flags for the host and device pointers, as well as any internal data allocated by...
void SetOperator(const Operator &op) override
Also calls SetOperator for the preconditioner if there is one.
TimeDependentOperator * f
Pointer to the associated TimeDependentOperator.
virtual void Init(TimeDependentOperator &f_)
Associate a TimeDependentOperator with the ODE solver.
int Height() const
Get the height (size of output) of the Operator. Synonym with NumRows().
int height
Dimension of the output / number of rows in the matrix.
virtual void Mult(const Vector &x, Vector &y) const =0
Operator application: y=A(x).
virtual Operator & GetGradient(const Vector &x) const
Evaluate the gradient operator at the point x. The default behavior in class Operator is to generate ...
bool iterative_mode
If true, use the second argument of Mult() as an initial guess.
virtual void SetOperator(const Operator &op)=0
Set/update the solver for the given operator.
SundialsMemHelper & operator=(const SundialsMemHelper &)=delete
Disable copy assignment.
SundialsMemHelper()=default
Default constructor – object must be moved to.
static int SundialsMemHelper_Alloc(SUNMemoryHelper helper, SUNMemory *memptr, size_t memsize, SUNMemoryType mem_type #if(SUNDIALS_VERSION_MAJOR >=6), void *queue #endif)
static int SundialsMemHelper_Dealloc(SUNMemoryHelper helper, SUNMemory sunmem #if(SUNDIALS_VERSION_MAJOR >=6), void *queue #endif)
Vector interface for SUNDIALS N_Vectors.
long GlobalSize() const
Returns the MPI global length for the internal N_Vector x.
MPI_Comm GetComm() const
Returns the MPI communicator for the internal N_Vector x.
void MakeRef(Vector &base, int offset, int s)
Reset the Vector to be a reference to a sub-vector of base.
void SetSize(int s, long glob_size=0)
Resize the vector to size s.
static bool UseManagedMemory()
static N_Vector MakeNVector(bool use_device)
Create a N_Vector.
~SundialsNVector()
Calls SUNDIALS N_VDestroy function if the N_Vector is owned by 'this'.
void SetDataAndSize(double *d, int s, long glob_size=0)
Set the vector data and size.
void _SetNvecDataAndSize_(long glob_size=0)
Set data and length of internal N_Vector x from 'this'.
void _SetDataAndSize_()
Set data and length from the internal N_Vector x.
N_Vector x
The actual SUNDIALS object.
SundialsNVector()
Creates an empty SundialsNVector.
static constexpr double default_abs_tol
Default scalar absolute tolerance.
SUNMatrix M
Mass matrix M.
int flag
Last flag returned from a call to SUNDIALS.
long saved_global_size
Global vector length on last initialization.
static constexpr double default_rel_tol
Default scalar relative tolerance.
bool reinit
Flag to signal memory reinitialization is need.
SundialsNVector * Y
State vector.
void * sundials_mem
SUNDIALS mem structure.
SUNLinearSolver LSA
Linear solver for A.
SUNLinearSolver LSM
Linear solver for M.
SUNNonlinearSolver NLS
Nonlinear solver.
Singleton class for SUNContext and SundialsMemHelper objects.
static SUNContext & GetContext()
Provides access to the SUNContext object.
static SundialsMemHelper & GetMemHelper()
Provides access to the SundialsMemHelper object.
int GetAdjointHeight()
Returns the size of the adjoint problem state space.
Base abstract class for first order time dependent operators.
bool isExplicit() const
True if type is EXPLICIT.
virtual int SUNImplicitSolve(const Vector &r, Vector &dk, real_t tol)
Solve the ODE linear system A dk = r , where A and r are defined by the method SUNImplicitSetup().
virtual int SUNMassMult(const Vector &x, Vector &v)
Compute the mass matrix-vector product v = M x, where M is defined by the method SUNMassSetup().
virtual int SUNMassSetup()
Setup the mass matrix in the ODE system .
void Mult(const Vector &u, Vector &k) const override
Perform the action of the operator (u,t) -> k(u,t) where t is the current time set by SetTime() and k...
virtual int SUNMassSolve(const Vector &b, Vector &x, real_t tol)
Solve the mass matrix linear system M x = b, where M is defined by the method SUNMassSetup().
virtual void ExplicitMult(const Vector &u, Vector &v) const
Perform the action of the explicit part of the operator, G: v = G(u, t) where t is the current time.
virtual void SetEvalMode(const EvalMode new_eval_mode)
Set the evaluation mode of the time-dependent operator.
virtual void SetTime(const real_t t_)
Set the current time.
virtual int SUNImplicitSetup(const Vector &y, const Vector &v, int jok, int *jcur, real_t gamma)
Setup a linear system as needed by some SUNDIALS ODE solvers to perform a similar action to ImplicitS...
virtual real_t GetTime() const
Read the currently set time.
virtual const real_t * HostRead() const
Shortcut for mfem::Read(vec.GetMemory(), vec.Size(), false).
virtual real_t * ReadWrite(bool on_dev=true)
Shortcut for mfem::ReadWrite(vec.GetMemory(), vec.Size(), on_dev).
void SetDataAndSize(real_t *d, int s)
Set the Vector data and size.
real_t Normlinf() const
Returns the l_infinity norm of the vector.
Vector & Set(const real_t a, const Vector &x)
(*this) = a * x
virtual bool UseDevice() const
Return the device flag of the Memory object used by the Vector.
int Size() const
Returns the size of the vector.
void SetSize(int s)
Resize the vector to size s.
virtual real_t * HostReadWrite()
Shortcut for mfem::ReadWrite(vec.GetMemory(), vec.Size(), false).
T * HostReadWrite(Memory< T > &mem, int size)
Shortcut to ReadWrite(Memory<T> &mem, int size, false)
real_t u(const Vector &xvec)
OutStream out(std::cout)
Global stream used by the library for standard output. Initially it uses the same std::streambuf as s...
T * ReadWrite(Memory< T > &mem, int size, bool on_dev=true)
Get a pointer for read+write access to mem with the mfem::Device's DeviceMemoryClass,...
MemoryManager mm
The (single) global memory manager object.
Settings for the output behavior of the IterativeSolver.
Helper struct to convert a C++ type to an MPI type.
MFEM_DEPRECATED SUNLinearSolver SUNLinSolNewEmpty(SUNContext)
MFEM_DEPRECATED N_Vector N_VMake_MPIPlusX(MPI_Comm comm, N_Vector local_vector, SUNContext)
MFEM_DEPRECATED void * KINCreate(SUNContext)
MFEM_DEPRECATED SUNLinearSolver SUNLinSol_SPFGMR(N_Vector y, int pretype, int maxl, SUNContext)
MFEM_DEPRECATED void * CVodeCreate(int lmm, SUNContext)
MFEM_DEPRECATED N_Vector N_VNewEmpty_Parallel(MPI_Comm comm, sunindextype local_length, sunindextype global_length, SUNContext)
MFEM_DEPRECATED SUNMatrix SUNMatNewEmpty(SUNContext)
MFEM_DEPRECATED SUNMemoryHelper SUNMemoryHelper_NewEmpty(SUNContext)
MFEM_DEPRECATED N_Vector SUN_Hip_OR_Cuda N_VNewWithMemHelp(sunindextype length, sunbooleantype use_managed_mem, SUNMemoryHelper helper, SUNContext)
MFEM_DEPRECATED void * ARKStepCreate(ARKRhsFn fe, ARKRhsFn fi, sunrealtype t0, N_Vector y0, SUNContext)
MFEM_DEPRECATED N_Vector N_VNewEmpty_Serial(sunindextype vec_length, SUNContext)
MFEM_DEPRECATED SUNLinearSolver SUNLinSol_SPGMR(N_Vector y, int pretype, int maxl, SUNContext)
realtype sunrealtype
'sunrealtype' was first introduced in v6.0.0
booleantype sunbooleantype
'sunbooleantype' was first introduced in v6.0.0
constexpr ARKODE_ERKTableID ARKODE_ERK_NONE
constexpr ARKODE_DIRKTableID ARKODE_DIRK_NONE