Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
drreynolds committed Sep 19, 2024
1 parent 8850586 commit bf8c1dd
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 84 deletions.
14 changes: 6 additions & 8 deletions benchmarks/diffusion_2D/main_arkode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,9 @@ struct UserOptions
// LSRKStep-specific dominant eigenvalue function prototype
// -----------------------------------------------------------------------------

static int dom_eig(sunrealtype t, N_Vector y, N_Vector fn,
sunrealtype* lambdaR, sunrealtype* lambdaI,
void* user_data,
N_Vector temp1, N_Vector temp2, N_Vector temp3);
static int dom_eig(sunrealtype t, N_Vector y, N_Vector fn, sunrealtype* lambdaR,
sunrealtype* lambdaI, void* user_data, N_Vector temp1,
N_Vector temp2, N_Vector temp3);

// -----------------------------------------------------------------------------
// Main Program
Expand Down Expand Up @@ -469,10 +468,9 @@ int main(int argc, char* argv[])
// Dominant eigenvalue estimation function
// -----------------------------------------------------------------------------

static int dom_eig(sunrealtype t, N_Vector y, N_Vector fn,
sunrealtype* lambdaR, sunrealtype* lambdaI,
void* user_data,
N_Vector temp1, N_Vector temp2, N_Vector temp3)
static int dom_eig(sunrealtype t, N_Vector y, N_Vector fn, sunrealtype* lambdaR,
sunrealtype* lambdaI, void* user_data, N_Vector temp1,
N_Vector temp2, N_Vector temp3)
{
// Access problem data
UserData* udata = (UserData*)user_data;
Expand Down
4 changes: 2 additions & 2 deletions examples/arkode/CXX_manyvector/ark_sod_lsrk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ void face_flux(sunrealtype (&w1d)[STSIZE][NSPECIES], sunrealtype* f_face,
int i, j;
sunrealtype rhosqrL, rhosqrR, rhosqrbar, u, v, w, H, qsq, csnd, cinv, gamm,
alpha, beta1, beta2, beta3, w1, w2, w3, f1, f2, f3;
sunrealtype RV[5][5], LV[5][5], p[STSIZE], flux[STSIZE][NSPECIES],
sunrealtype RV[5][5], LV[5][5], p[STSIZE], flux[STSIZE][NSPECIES],
fproj[5][NSPECIES], fs[5][NSPECIES], ff[NSPECIES];
const sunrealtype bc =
SUN_RCONST(1.083333333333333333333333333333333333333); // 13/12
Expand Down Expand Up @@ -416,7 +416,7 @@ void face_flux(sunrealtype (&w1d)[STSIZE][NSPECIES], sunrealtype* f_face,
flux[j][2] = u * w1d[j][2]; // f_my = rho*v*u = my*u
flux[j][3] = u * w1d[j][3]; // f_mz = rho*w*u = mz*u
flux[j][4] = u * (w1d[j][4] + p[j]); // f_et = u*(et + p)
csnd = sqrt(udata.gamma * p[j] / w1d[j][0]); // csnd = sqrt(gamma*p/rho)
csnd = sqrt(udata.gamma * p[j] / w1d[j][0]); // csnd = sqrt(gamma*p/rho)
alpha = max(alpha, abs(u) + csnd);
}

Expand Down
66 changes: 37 additions & 29 deletions examples/arkode/CXX_manyvector/ark_sod_lsrk.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,10 @@
#define FOURTH SUN_RCONST(0.25)

#define NSPECIES 5
#define STSIZE 6
#define STSIZE 6

#define WIDTH (10 + std::numeric_limits<sunrealtype>::digits10)


// -----------------------------------------------------------------------------
// Problem options
// -----------------------------------------------------------------------------
Expand All @@ -78,8 +77,8 @@ class ARKODEParameters
int maxsteps;

// Output-related information
int output; // 0 = none, 1 = stats, 2 = disk, 3 = disk with tstop
int nout; // number of output times
int output; // 0 = none, 1 = stats, 2 = disk, 3 = disk with tstop
int nout; // number of output times
std::ofstream uout; // output file stream

// constructor (with default values)
Expand Down Expand Up @@ -257,11 +256,11 @@ static void InputHelp()
{
std::cout << std::endl;
std::cout << "Command line options:" << std::endl;
std::cout
<< " --integrator <str> : method (ARKODE_LSRK_SSP_S_2, ARKODE_LSRK_SSP_S_3, "
"ARKODE_LSRK_SSP_10_4, or any valid ARKODE_ERKTableID)\n";
std::cout << " --integrator <str> : method (ARKODE_LSRK_SSP_S_2, "
"ARKODE_LSRK_SSP_S_3, "
"ARKODE_LSRK_SSP_10_4, or any valid ARKODE_ERKTableID)\n";
std::cout << " --stages <int> : number of stages (ignored for "
"ARKODE_LSRK_SSP_10_4 and ERK)\n";
"ARKODE_LSRK_SSP_10_4 and ERK)\n";
std::cout << " --tf <real> : final time\n";
std::cout << " --xl <real> : domain lower boundary\n";
std::cout << " --xr <real> : domain upper boundary\n";
Expand All @@ -276,7 +275,8 @@ static void InputHelp()
std::cout << " --help : print options and exit\n";
}

inline void find_arg(std::vector<std::string>& args, const std::string key, sunrealtype& dest)
inline void find_arg(std::vector<std::string>& args, const std::string key,
sunrealtype& dest)
{
auto it = find(args.begin(), args.end(), key);
if (it != args.end())
Expand All @@ -292,7 +292,8 @@ inline void find_arg(std::vector<std::string>& args, const std::string key, sunr
}
}

inline void find_arg(std::vector<std::string>& args, const std::string key, long int& dest)
inline void find_arg(std::vector<std::string>& args, const std::string key,
long int& dest)
{
auto it = find(args.begin(), args.end(), key);
if (it != args.end())
Expand All @@ -302,7 +303,8 @@ inline void find_arg(std::vector<std::string>& args, const std::string key, long
}
}

inline void find_arg(std::vector<std::string>& args, const std::string key, int& dest)
inline void find_arg(std::vector<std::string>& args, const std::string key,
int& dest)
{
auto it = find(args.begin(), args.end(), key);
if (it != args.end())
Expand All @@ -312,7 +314,8 @@ inline void find_arg(std::vector<std::string>& args, const std::string key, int&
}
}

inline void find_arg(std::vector<std::string>& args, const std::string key, std::string& dest)
inline void find_arg(std::vector<std::string>& args, const std::string key,
std::string& dest)
{
auto it = find(args.begin(), args.end(), key);
if (it != args.end())
Expand All @@ -322,8 +325,8 @@ inline void find_arg(std::vector<std::string>& args, const std::string key, std:
}
}

inline void find_arg(std::vector<std::string>& args, const std::string key, bool& dest,
bool store = true)
inline void find_arg(std::vector<std::string>& args, const std::string key,
bool& dest, bool store = true)
{
auto it = find(args.begin(), args.end(), key);
if (it != args.end())
Expand Down Expand Up @@ -387,7 +390,10 @@ static int PrintSetup(EulerData& udata, ARKODEParameters& uopts)
std::cout << " dx = " << udata.dx << std::endl;
std::cout << " --------------------------------- " << std::endl;
std::cout << " integrator = " << uopts.integrator << std::endl;
if (uopts.stages > 0) { std::cout << " stages = " << uopts.stages << std::endl; }
if (uopts.stages > 0)
{
std::cout << " stages = " << uopts.stages << std::endl;
}
std::cout << " rtol = " << uopts.rtol << std::endl;
std::cout << " atol = " << uopts.atol << std::endl;
std::cout << " fixed h = " << uopts.fixed_h << std::endl;
Expand All @@ -408,14 +414,15 @@ static int OpenOutput(EulerData& udata, ARKODEParameters& uopts)
std::cout << std::scientific;
std::cout << std::setprecision(std::numeric_limits<sunrealtype>::digits10);
std::cout << " t "
<< " ||rho|| "
<< " ||mx|| "
<< " ||my|| "
<< " ||mz|| "
<< " ||et||" << std::endl;
std::cout << " -----------------------------------------------------------------"
"---------"
<< std::endl;
<< " ||rho|| "
<< " ||mx|| "
<< " ||my|| "
<< " ||mz|| "
<< " ||et||" << std::endl;
std::cout
<< " -----------------------------------------------------------------"
"---------"
<< std::endl;
}

// Open output stream and output problem information
Expand Down Expand Up @@ -457,9 +464,9 @@ static int WriteOutput(sunrealtype t, N_Vector y, EulerData& udata,
sunrealtype myrms = sqrt(N_VDotProd(my, my) / udata.nx);
sunrealtype mzrms = sqrt(N_VDotProd(mz, mz) / udata.nx);
sunrealtype etrms = sqrt(N_VDotProd(et, et) / udata.nx);
std::cout << std::setprecision(2) << " " << t << std::setprecision(5) << " " << rhorms
<< " " << mxrms << " " << myrms << " " << mzrms << " " << etrms
<< std::endl;
std::cout << std::setprecision(2) << " " << t << std::setprecision(5)
<< " " << rhorms << " " << mxrms << " " << myrms << " "
<< mzrms << " " << etrms << std::endl;

// Write solution to disk
if (uopts.output >= 2)
Expand Down Expand Up @@ -497,9 +504,10 @@ static int CloseOutput(ARKODEParameters& uopts)
// Footer for status output
if (uopts.output)
{
std::cout << " -----------------------------------------------------------------"
"---------"
<< std::endl;
std::cout
<< " -----------------------------------------------------------------"
"---------"
<< std::endl;
std::cout << std::endl;
}

Expand Down
14 changes: 6 additions & 8 deletions examples/arkode/CXX_serial/ark_heat2D_lsrk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,9 @@ 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,
sunrealtype* lambdaR, sunrealtype* lambdaI,
void* user_data,
N_Vector temp1, N_Vector temp2, N_Vector temp3);
static int eig(sunrealtype t, N_Vector y, N_Vector fn, sunrealtype* lambdaR,
sunrealtype* lambdaI, void* user_data, N_Vector temp1,
N_Vector temp2, N_Vector temp3);

// -----------------------------------------------------------------------------
// UserData and input functions
Expand Down Expand Up @@ -499,10 +498,9 @@ 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,
sunrealtype* lambdaR, sunrealtype* lambdaI,
void* user_data,
N_Vector temp1, N_Vector temp2, N_Vector temp3)
static int eig(sunrealtype t, N_Vector y, N_Vector fn, sunrealtype* lambdaR,
sunrealtype* lambdaI, void* user_data, N_Vector temp1,
N_Vector temp2, N_Vector temp3)
{
// Access problem data
UserData* udata = (UserData*)user_data;
Expand Down
20 changes: 9 additions & 11 deletions examples/arkode/C_serial/lsrk_analytic.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,20 @@
#endif

#if defined(SUNDIALS_DOUBLE_PRECISION)
#define ATAN(x) (atan((x)))
#define ATAN(x) (atan((x)))
#elif defined(SUNDIALS_SINGLE_PRECISION)
#define ATAN(x) (atanf((x)))
#define ATAN(x) (atanf((x)))
#elif defined(SUNDIALS_EXTENDED_PRECISION)
#define ATAN(x) (atanl((x)))
#define ATAN(x) (atanl((x)))
#endif

/* User-supplied Functions Called by the Solver */
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,
sunrealtype* lambdaR, sunrealtype* lambdaI,
void* user_data,
N_Vector temp1, N_Vector temp2, N_Vector temp3);
static int dom_eig(sunrealtype t, N_Vector y, N_Vector fn, sunrealtype* lambdaR,
sunrealtype* lambdaI, void* user_data, N_Vector temp1,
N_Vector temp2, N_Vector temp3);

/* Private function to check function return values */
static int check_flag(void* flagvalue, const char* funcname, int opt);
Expand Down Expand Up @@ -222,10 +221,9 @@ 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,
sunrealtype* lambdaR, sunrealtype* lambdaI,
void* user_data,
N_Vector temp1, N_Vector temp2, N_Vector temp3)
static int dom_eig(sunrealtype t, N_Vector y, N_Vector fn, sunrealtype* lambdaR,
sunrealtype* lambdaI, void* user_data, N_Vector temp1,
N_Vector temp2, N_Vector temp3)
{
sunrealtype* rdata = (sunrealtype*)user_data; /* cast user_data to sunrealtype */
sunrealtype lambda = rdata[0]; /* set shortcut for stiffness parameter */
Expand Down
30 changes: 15 additions & 15 deletions examples/arkode/C_serial/lsrk_analytic_varjac.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,27 +48,26 @@
#endif

#if defined(SUNDIALS_DOUBLE_PRECISION)
#define ATAN(x) (atan((x)))
#define ACOS(x) (acos((x)))
#define COS(x) (cos((x)))
#define ATAN(x) (atan((x)))
#define ACOS(x) (acos((x)))
#define COS(x) (cos((x)))
#elif defined(SUNDIALS_SINGLE_PRECISION)
#define ATAN(x) (atanf((x)))
#define ACOS(x) (acosf((x)))
#define COS(x) (cosf((x)))
#define ATAN(x) (atanf((x)))
#define ACOS(x) (acosf((x)))
#define COS(x) (cosf((x)))
#elif defined(SUNDIALS_EXTENDED_PRECISION)
#define ATAN(x) (atanl((x)))
#define ACOS(x) (acosl((x)))
#define COS(x) (cosl((x)))
#define ATAN(x) (atanl((x)))
#define ACOS(x) (acosl((x)))
#define COS(x) (cosl((x)))
#endif

/* User-supplied Functions Called by the Solver */
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,
sunrealtype* lambdaR, sunrealtype* lambdaI,
void* user_data,
N_Vector temp1, N_Vector temp2, N_Vector temp3);
static int dom_eig(sunrealtype t, N_Vector y, N_Vector fn, sunrealtype* lambdaR,
sunrealtype* lambdaI, void* user_data, N_Vector temp1,
N_Vector temp2, N_Vector temp3);

/* Private function to check function return values */
static int check_flag(void* flagvalue, const char* funcname, int opt);
Expand Down Expand Up @@ -237,8 +236,9 @@ 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, sunrealtype* lambdaR, sunrealtype* lambdaI,
void* user_data, N_Vector temp1, N_Vector temp2, N_Vector temp3)
static int dom_eig(sunrealtype t, N_Vector y, N_Vector fn, sunrealtype* lambdaR,
sunrealtype* lambdaI, void* user_data, N_Vector temp1,
N_Vector temp2, N_Vector temp3)
{
sunrealtype* rdata = (sunrealtype*)user_data; /* cast user_data to sunrealtype */
sunrealtype lambda = rdata[0]; /* set shortcut for stiffness parameter 1 */
Expand Down
6 changes: 3 additions & 3 deletions examples/arkode/C_serial/lsrk_ssp_analytic.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@
#endif

#if defined(SUNDIALS_DOUBLE_PRECISION)
#define ATAN(x) (atan((x)))
#define ATAN(x) (atan((x)))
#elif defined(SUNDIALS_SINGLE_PRECISION)
#define ATAN(x) (atanf((x)))
#define ATAN(x) (atanf((x)))
#elif defined(SUNDIALS_EXTENDED_PRECISION)
#define ATAN(x) (atanl((x)))
#define ATAN(x) (atanl((x)))
#endif

/* User-supplied Functions Called by the Solver */
Expand Down
5 changes: 4 additions & 1 deletion include/arkode/arkode_lsrkstep.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@
extern "C" {
#endif

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

/* ------------------
* LSRKStep Constants
Expand Down
13 changes: 6 additions & 7 deletions src/arkode/arkode_lsrkstep.c
Original file line number Diff line number Diff line change
Expand Up @@ -566,8 +566,8 @@ int lsrkStep_TakeStepRKC(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr)
{
int retval;
sunrealtype* cvals;
sunrealtype hmax, w0, w1, temp1, temp2, arg, bjm1, bjm2, mus, thjm1, thjm2,
zjm1, zjm2, dzjm1, dzjm2, d2zjm1, d2zjm2, zj, dzj, d2zj, bj, ajm1, mu, nu,
sunrealtype hmax, w0, w1, temp1, temp2, arg, bjm1, bjm2, mus, thjm1, thjm2,
zjm1, zjm2, dzjm1, dzjm2, d2zjm1, d2zjm2, zj, dzj, d2zj, bj, ajm1, mu, nu,
thj;
const sunrealtype onep54 = SUN_RCONST(1.54), c13 = SUN_RCONST(13.0),
p8 = SUN_RCONST(0.8), p4 = SUN_RCONST(0.4);
Expand Down Expand Up @@ -612,8 +612,6 @@ int lsrkStep_TakeStepRKC(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr)
}
}



step_mem->stagemax = SUNMAX(step_mem->reqstages, step_mem->stagemax);

/* Call the full RHS if needed. If this is the first step then we may need to
Expand Down Expand Up @@ -1439,9 +1437,10 @@ int lsrkStep_ComputeNewDomEig(ARKodeMem ark_mem, ARKodeLSRKStepMem step_mem)

if ((step_mem->isextDomEig))
{
retval = step_mem->extDomEig(ark_mem->tn, ark_mem->ycur, ark_mem->fn, &step_mem->lambdaR,
&step_mem->lambdaI, ark_mem->user_data,
ark_mem->tempv1, ark_mem->tempv2, ark_mem->tempv3);
retval = step_mem->extDomEig(ark_mem->tn, ark_mem->ycur, ark_mem->fn,
&step_mem->lambdaR, &step_mem->lambdaI,
ark_mem->user_data, ark_mem->tempv1,
ark_mem->tempv2, ark_mem->tempv3);
if (retval != ARK_SUCCESS)
{
arkProcessError(ark_mem, ARK_DOMEIG_FAIL, __LINE__, __func__, __FILE__,
Expand Down

0 comments on commit bf8c1dd

Please sign in to comment.