Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
maggul committed Sep 28, 2024
1 parent 9eb4bff commit 3b56e31
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 61 deletions.
16 changes: 7 additions & 9 deletions examples/arkode/CXX_parallel/ark_heat2D_lsrk_p.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,8 @@ struct UserData
static int f(sunrealtype t, N_Vector u, N_Vector f, void* user_data);

// Spectral radius estimation routine
static int eig(sunrealtype t, N_Vector y, N_Vector fn,
suncomplextype* lambda, void* user_data, N_Vector temp1,
N_Vector temp2, N_Vector temp3);
static int eig(sunrealtype t, N_Vector y, N_Vector fn, suncomplextype* lambda,
void* user_data, N_Vector temp1, N_Vector temp2, N_Vector temp3);

// -----------------------------------------------------------------------------
// Helper functions
Expand Down Expand Up @@ -1121,17 +1120,16 @@ static int WaitRecv(UserData* udata)
}

// Spectral radius estimation routine
static int eig(sunrealtype t, N_Vector y, N_Vector fn,
suncomplextype* lambda, void* user_data, N_Vector temp1,
N_Vector temp2, N_Vector temp3)
static int eig(sunrealtype t, N_Vector y, N_Vector fn, suncomplextype* lambda,
void* user_data, N_Vector temp1, N_Vector temp2, N_Vector temp3)
{
// Access problem data
UserData* udata = (UserData*)user_data;

// Fill in spectral radius value
*lambda = - SUN_RCONST(8.0) * max(udata->kx / udata->dx / udata->dx,
udata->ky / udata->dy / udata->dy)
+ SUN_RCONST(0.0) * SUN_I;
*lambda = -SUN_RCONST(8.0) * max(udata->kx / udata->dx / udata->dx,
udata->ky / udata->dy / udata->dy) +
SUN_RCONST(0.0) * SUN_I;

// return with success
return 0;
Expand Down
16 changes: 7 additions & 9 deletions examples/arkode/CXX_serial/ark_heat2D_lsrk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,8 @@ struct UserData
static int f(sunrealtype t, N_Vector u, N_Vector f, void* user_data);

// Spectral radius estimation routine
static int eig(sunrealtype t, N_Vector y, N_Vector fn,
suncomplextype* lambda, void* user_data, N_Vector temp1,
N_Vector temp2, N_Vector temp3);
static int eig(sunrealtype t, N_Vector y, N_Vector fn, suncomplextype* lambda,
void* user_data, N_Vector temp1, N_Vector temp2, N_Vector temp3);

// -----------------------------------------------------------------------------
// UserData and input functions
Expand Down Expand Up @@ -498,17 +497,16 @@ static int f(sunrealtype t, N_Vector u, N_Vector f, void* user_data)
}

// Spectral radius estimation routine
static int eig(sunrealtype t, N_Vector y, N_Vector fn,
suncomplextype* lambda, void* user_data, N_Vector temp1,
N_Vector temp2, N_Vector temp3)
static int eig(sunrealtype t, N_Vector y, N_Vector fn, suncomplextype* lambda,
void* user_data, N_Vector temp1, N_Vector temp2, N_Vector temp3)
{
// Access problem data
UserData* udata = (UserData*)user_data;

// Fill in spectral radius value
*lambda = - SUN_RCONST(8.0) * max(udata->kx / udata->dx / udata->dx,
udata->ky / udata->dy / udata->dy)
+ SUN_RCONST(0.0) * SUN_I;
*lambda = -SUN_RCONST(8.0) * max(udata->kx / udata->dx / udata->dx,
udata->ky / udata->dy / udata->dy) +
SUN_RCONST(0.0) * SUN_I;

// return with success
return 0;
Expand Down
6 changes: 3 additions & 3 deletions examples/arkode/C_serial/ark_analytic_lsrk.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
static int f(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data);

/* User-supplied Dominated Eigenvalue Called by the Solver */
static int dom_eig(sunrealtype t, N_Vector y, N_Vector fn,
static int dom_eig(sunrealtype t, N_Vector y, N_Vector fn,
suncomplextype* lambda, void* user_data, N_Vector temp1,
N_Vector temp2, N_Vector temp3);

Expand All @@ -82,7 +82,7 @@ int main(void)
sunindextype NEQ = 1; /* number of dependent vars. */
sunrealtype reltol = SUN_RCONST(1.0e-8); /* tolerances */
sunrealtype abstol = SUN_RCONST(1.0e-8);
sunrealtype gamma = SUN_RCONST(-1000000.0); /* stiffness parameter */
sunrealtype gamma = SUN_RCONST(-1000000.0); /* stiffness parameter */

/* general problem variables */
int flag; /* reusable error-checking flag */
Expand Down Expand Up @@ -221,7 +221,7 @@ static int f(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data)
}

/* dom_eig routine to estimate the dominated eigenvalue */
static int dom_eig(sunrealtype t, N_Vector y, N_Vector fn,
static int dom_eig(sunrealtype t, N_Vector y, N_Vector fn,
suncomplextype* lambda, void* user_data, N_Vector temp1,
N_Vector temp2, N_Vector temp3)
{
Expand Down
16 changes: 8 additions & 8 deletions examples/arkode/C_serial/ark_analytic_lsrk_varjac.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
static int f(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data);

/* User-supplied Dominated Eigenvalue Called by the Solver */
static int dom_eig(sunrealtype t, N_Vector y, N_Vector fn,
static int dom_eig(sunrealtype t, N_Vector y, N_Vector fn,
suncomplextype* lambda, void* user_data, N_Vector temp1,
N_Vector temp2, N_Vector temp3);

Expand All @@ -97,7 +97,7 @@ int main(void)
sunindextype NEQ = 1; /* number of dependent vars. */
sunrealtype reltol = SUN_RCONST(1.0e-8); /* tolerances */
sunrealtype abstol = SUN_RCONST(1.0e-8);
sunrealtype gamma = SUN_RCONST(-1.0e+6); /* stiffness parameter 1*/
sunrealtype gamma = SUN_RCONST(-1.0e+6); /* stiffness parameter 1*/
sunrealtype theta = SUN_RCONST(1.0e+2); /* stiffness parameter 2*/
sunrealtype UserData[2];
UserData[0] = gamma;
Expand Down Expand Up @@ -232,7 +232,7 @@ static int f(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data)
{
sunrealtype* rdata = (sunrealtype*)user_data; /* cast user_data to sunrealtype */
sunrealtype gamma = rdata[0]; /* set shortcut for stiffness parameter 1 */
sunrealtype theta = rdata[1]; /* set shortcut for stiffness parameter 2 */
sunrealtype theta = rdata[1]; /* set shortcut for stiffness parameter 2 */
sunrealtype u = N_VGetArrayPointer(y)[0]; /* access current solution value */

/* fill in the RHS function: "N_VGetArrayPointer" accesses the 0th entry of ydot */
Expand All @@ -245,17 +245,17 @@ static int f(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data)
}

/* dom_eig routine to estimate the dominated eigenvalue */
static int dom_eig(sunrealtype t, N_Vector y, N_Vector fn,
static int dom_eig(sunrealtype t, N_Vector y, N_Vector fn,
suncomplextype* lambda, void* user_data, N_Vector temp1,
N_Vector temp2, N_Vector temp3)
{
sunrealtype* rdata = (sunrealtype*)user_data; /* cast user_data to sunrealtype */
sunrealtype gamma = rdata[0]; /* set shortcut for stiffness parameter 1 */
sunrealtype theta = rdata[1]; /* set shortcut for stiffness parameter 2 */
sunrealtype theta = rdata[1]; /* set shortcut for stiffness parameter 2 */

*lambda = (gamma - theta * COS((10 - t) / 10 * ACOS(-1))) +
SUN_RCONST(0.0) * SUN_I;

*lambda = (gamma - theta * COS((10 - t) / 10 * ACOS(-1)))
+ SUN_RCONST(0.0) * SUN_I;

return 0; /* return with success */
}

Expand Down
5 changes: 3 additions & 2 deletions include/arkode/arkode_lsrkstep.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ extern "C" {
#endif

typedef int (*ARKDomEigFn)(sunrealtype t, N_Vector y, N_Vector fn,
suncomplextype* lambda, void* user_data,
suncomplextype* lambda, void* user_data,
N_Vector temp1, N_Vector temp2, N_Vector temp3);

/* ------------------
Expand Down Expand Up @@ -80,7 +80,8 @@ SUNDIALS_EXPORT int LSRKStepSetSSPStageNum(void* arkode_mem, int num_of_stages);

/* Optional output functions */

SUNDIALS_EXPORT int LSRKStepGetNumRhsEvals(void* arkode_mem, int num_rhs_fn, long int* f_evals);
SUNDIALS_EXPORT int LSRKStepGetNumRhsEvals(void* arkode_mem, int num_rhs_fn,
long int* f_evals);

SUNDIALS_EXPORT int LSRKStepGetNumDomEigUpdates(void* arkode_mem,
long int* num_dom_eig_updates);
Expand Down
32 changes: 16 additions & 16 deletions include/sundials/sundials_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@
#ifndef _SUNDIALS_TYPES_H
#define _SUNDIALS_TYPES_H

#include <complex.h>
#include <float.h>
#include <stddef.h>
#include <stdint.h>
#include <complex.h>
#include <sundials/sundials_config.h>

#if SUNDIALS_MPI_ENABLED
Expand Down Expand Up @@ -120,27 +120,27 @@ typedef long double sunrealtype;

#if defined(SUNDIALS_SINGLE_PRECISION)

typedef float _Complex suncomplextype;
#define SUN_CCONST(x, y) x##F + y##F * I
#define SUN_I (1.0f * I)
#define SUN_REAL(z) crealf(z)
#define SUN_IMAG(z) cimagf(z)
typedef float _Complex suncomplextype;
#define SUN_CCONST(x, y) x##F + y##F* I
#define SUN_I (1.0f * I)
#define SUN_REAL(z) crealf(z)
#define SUN_IMAG(z) cimagf(z)

#elif defined(SUNDIALS_DOUBLE_PRECISION)

typedef double _Complex suncomplextype;
#define SUN_CCONST(x, y) x + y * I
#define SUN_I (1.0 * I)
#define SUN_REAL(z) creal(z)
#define SUN_IMAG(z) cimag(z)
typedef double _Complex suncomplextype;
#define SUN_CCONST(x, y) x + y* I
#define SUN_I (1.0 * I)
#define SUN_REAL(z) creal(z)
#define SUN_IMAG(z) cimag(z)

#elif defined(SUNDIALS_EXTENDED_PRECISION)

typedef long double _Complex suncomplextype;
#define SUN_CCONST(x, y) x##L + y##L * I
#define SUN_I (1.0L * I)
#define SUN_REAL(z) creall(z)
#define SUN_IMAG(z) cimagl(z)
typedef long double _Complex suncomplextype;
#define SUN_CCONST(x, y) x##L + y##L* I
#define SUN_I (1.0L * I)
#define SUN_REAL(z) creall(z)
#define SUN_IMAG(z) cimagl(z)

#endif

Expand Down
29 changes: 20 additions & 9 deletions src/arkode/arkode_interp.c
Original file line number Diff line number Diff line change
Expand Up @@ -958,7 +958,8 @@ void arkInterpPrintMem_Lagrange(ARKInterp interp, FILE* outfile)
if (interp != NULL)
{
fprintf(outfile, "arkode_interp (Lagrange): nmax = %i\n", LINT_NMAX(interp));
fprintf(outfile, "arkode_interp (Lagrange): nhist = %i\n", LINT_NHIST(interp));
fprintf(outfile, "arkode_interp (Lagrange): nhist = %i\n",
LINT_NHIST(interp));
if (LINT_THIST(interp) != NULL)
{
fprintf(outfile, "arkode_interp (Lagrange): thist =");
Expand Down Expand Up @@ -1055,7 +1056,8 @@ int arkInterpInit_Lagrange(ARKodeMem ark_mem, ARKInterp interp, sunrealtype tnew
/* allocate storage for time and solution histories */
if (LINT_THIST(interp) == NULL)
{
LINT_THIST(interp) = (sunrealtype*)malloc(LINT_NMAX(interp) * sizeof(sunrealtype));
LINT_THIST(interp) =
(sunrealtype*)malloc(LINT_NMAX(interp) * sizeof(sunrealtype));
if (LINT_THIST(interp) == NULL)
{
arkInterpFree(ark_mem, interp);
Expand Down Expand Up @@ -1084,11 +1086,18 @@ int arkInterpInit_Lagrange(ARKodeMem ark_mem, ARKInterp interp, sunrealtype tnew
}

/* update allocated size if necessary */
if (LINT_NMAX(interp) > LINT_NMAXALLOC(interp)) { LINT_NMAXALLOC(interp) = LINT_NMAX(interp); }
if (LINT_NMAX(interp) > LINT_NMAXALLOC(interp))
{
LINT_NMAXALLOC(interp) = LINT_NMAX(interp);
}

/* zero out history (to be safe) */
for (i = 0; i < LINT_NMAXALLOC(interp); i++) { LINT_TJ(interp, i) = SUN_RCONST(0.0); }
if (N_VConstVectorArray(LINT_NMAXALLOC(interp), SUN_RCONST(0.0), LINT_YHIST(interp)))
for (i = 0; i < LINT_NMAXALLOC(interp); i++)
{
LINT_TJ(interp, i) = SUN_RCONST(0.0);
}
if (N_VConstVectorArray(LINT_NMAXALLOC(interp), SUN_RCONST(0.0),
LINT_YHIST(interp)))
{
return (ARK_VECTOROP_ERR);
}
Expand Down Expand Up @@ -1130,7 +1139,7 @@ int arkInterpUpdate_Lagrange(ARKodeMem ark_mem, ARKInterp interp, sunrealtype tn

/* update t roundoff value */
LINT_TROUND(interp) = FUZZ_FACTOR * ark_mem->uround *
(SUNRabs(ark_mem->tcur) + SUNRabs(ark_mem->h));
(SUNRabs(ark_mem->tcur) + SUNRabs(ark_mem->h));

/* determine if tnew differs sufficiently from stored values */
tdiff = SUNRabs(tnew - thist[0]);
Expand Down Expand Up @@ -1182,8 +1191,9 @@ int arkInterpUpdate_Lagrange(ARKodeMem ark_mem, ARKInterp interp, sunrealtype tn
fixed step sizes, otherwise the stated lower bound is only
approximate).
---------------------------------------------------------------*/
int arkInterpEvaluate_Lagrange(ARKodeMem ark_mem, ARKInterp interp, sunrealtype tau,
int deriv, int degree, N_Vector yout)
int arkInterpEvaluate_Lagrange(ARKodeMem ark_mem, ARKInterp interp,
sunrealtype tau, int deriv, int degree,
N_Vector yout)
{
/* local variables */
int q, retval, i, j;
Expand Down Expand Up @@ -1375,7 +1385,8 @@ sunrealtype LBasisD3(ARKInterp interp, int j, sunrealtype t)
if (k == m) { continue; }
if (k == l) { continue; }
if (k == i) { continue; }
s *= (t - LINT_TJ(interp, k)) / (LINT_TJ(interp, j) - LINT_TJ(interp, k));
s *= (t - LINT_TJ(interp, k)) /
(LINT_TJ(interp, j) - LINT_TJ(interp, k));
}
r += s / (LINT_TJ(interp, j) - LINT_TJ(interp, i));
}
Expand Down
8 changes: 4 additions & 4 deletions src/arkode/arkode_lsrkstep.c
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,7 @@ int lsrkStep_TakeStepRKC(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr)
step_mem->req_stages = SUNMAX(ss, 2);
if (step_mem->req_stages == step_mem->stage_max_limit)
{
hmax = ark_mem->hadapt_mem->safety * SUNSQR(ss) / (onep54 * step_mem->sprad);
hmax = ark_mem->hadapt_mem->safety * SUNSQR(ss) / (onep54 * step_mem->sprad);
ark_mem->eta = hmax / ark_mem->h;
*nflagPtr = ARK_RETRY_STEP;
return (ARK_RETRY_STEP);
Expand Down Expand Up @@ -1611,9 +1611,9 @@ int lsrkStep_ComputeNewDomEig(ARKodeMem ark_mem, ARKodeLSRKStepMem step_mem)
if ((step_mem->is_ext_dom_eig))
{
retval = step_mem->extDomEig(ark_mem->tn, ark_mem->ycur, ark_mem->fn,
&step_mem->dom_eig_lambda,
ark_mem->user_data, ark_mem->tempv1,
ark_mem->tempv2, ark_mem->tempv3);
&step_mem->dom_eig_lambda, ark_mem->user_data,
ark_mem->tempv1, ark_mem->tempv2,
ark_mem->tempv3);
step_mem->num_dom_eig_updates++;
if (retval != ARK_SUCCESS)
{
Expand Down
2 changes: 1 addition & 1 deletion src/arkode/arkode_lsrkstep_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ typedef struct ARKodeLSRKStepMemRec
sunrealtype sprad; /* spectral radius*/
sunrealtype spr_max; /* max spectral radius*/
sunrealtype spr_min; /* min spectral radius*/
sunrealtype dom_eig_sfty; /* some safety factor for the user provided dom_eig*/
sunrealtype dom_eig_sfty; /* some safety factor for the user provided dom_eig*/
int dom_eig_freq; /* indicates dom_eig update after dom_eig_freq successful steps*/

/* Flags */
Expand Down

0 comments on commit 3b56e31

Please sign in to comment.