Skip to content

Commit b6afda7

Browse files
committed
standardize names for # of rhs calls, Jac evals, and steps
this will make it easier to merge a lot of integrator logic
1 parent ca9e532 commit b6afda7

10 files changed

+50
-50
lines changed

integration/RKC/actual_integrator.H

+4-4
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,9 @@ void actual_integrator (BurnT& state, amrex::Real dt, bool is_retry=false)
120120

121121
// Get the number of RHS and Jacobian evaluations.
122122

123-
state.n_rhs = rkc_state.nfe;
123+
state.n_rhs = rkc_state.n_rhs;
124124
state.n_jac = 0;
125-
state.n_step = rkc_state.nsteps;
125+
state.n_step = rkc_state.n_step;
126126

127127
if (istate != IERR_SUCCESS) {
128128
state.success = false;
@@ -152,8 +152,8 @@ void actual_integrator (BurnT& state, amrex::Real dt, bool is_retry=false)
152152
std::cout << "integration summary: " << std::endl;
153153
std::cout << "dens: " << state.rho << " temp: " << state.T << std::endl;
154154
std::cout << " energy released: " << state.e << std::endl;
155-
std::cout << "number of steps taken: " << rkc_state.nsteps << std::endl;
156-
std::cout << "number of f evaluations: " << rkc_state.nfe << std::endl;
155+
std::cout << "number of steps taken: " << rkc_state.n_step << std::endl;
156+
std::cout << "number of f evaluations: " << rkc_state.n_rhs << std::endl;
157157
}
158158
#endif
159159

integration/RKC/actual_integrator_sdc.H

+2-2
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,9 @@ void actual_integrator (BurnT& state, amrex::Real dt, bool is_retry=false)
105105

106106
// Get the number of RHS and Jacobian evaluations.
107107

108-
state.n_rhs = rkc_state.nfe;
108+
state.n_rhs = rkc_state.n_rhs;
109109
state.n_jac = 0;
110-
state.n_step = rkc_state.nsteps;
110+
state.n_step = rkc_state.n_step;
111111

112112
// Copy the integration data back to the burn state.
113113
// This will also update the aux state from X if we are using NSE

integration/RKC/rkc.H

+7-7
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ int rkclow (BurnT& state, RkcT& rstate)
138138
// we want to call with yn = y as the input and store the output in fn
139139
rhs(rstate.t, state, rstate, rstate.fn);
140140

141-
rstate.nfe++;
141+
rstate.n_rhs++;
142142
amrex::Real tdir = std::copysign(1.0_rt, rstate.tout - rstate.t);
143143
rstate.hmax = std::abs(rstate.tout - rstate.t);
144144

@@ -150,7 +150,7 @@ int rkclow (BurnT& state, RkcT& rstate)
150150
amrex::Real hold{};
151151

152152
// Start of loop for taking one step.
153-
while (rstate.nsteps < integrator_rp::ode_max_steps) {
153+
while (rstate.n_step < integrator_rp::ode_max_steps) {
154154

155155
// Estimate the spectral radius of the Jacobian
156156
// when newspc = .true..
@@ -170,7 +170,7 @@ int rkclow (BurnT& state, RkcT& rstate)
170170

171171
// Compute an initial step size.
172172

173-
if (rstate.nsteps == 0) {
173+
if (rstate.n_step == 0) {
174174
absh = rkc_init_dt(state, rstate, rstate.hmax, sprad);
175175
}
176176

@@ -200,8 +200,8 @@ int rkclow (BurnT& state, RkcT& rstate)
200200
std::abs(rstate.t + h));
201201
step(state, rstate, h, m);
202202
rhs(rstate.t+h, state, rstate, rstate.yjm1);
203-
rstate.nfe += m;
204-
rstate.nsteps++;
203+
rstate.n_rhs += m;
204+
rstate.n_step++;
205205

206206
// Estimate the local error and compute its weighted RMS norm.
207207

@@ -309,8 +309,8 @@ int rkc (BurnT& state, RkcT& rstate)
309309

310310
// Initialize counters and pointers.
311311

312-
rstate.nfe = 0;
313-
rstate.nsteps = 0;
312+
rstate.n_rhs = 0;
313+
rstate.n_step = 0;
314314
rstate.naccpt = 0;
315315
rstate.nrejct = 0;
316316
rstate.nfesig = 0;

integration/RKC/rkc_type.H

+2-2
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,10 @@ struct rkc_t {
7575
// block
7676

7777
// number of function evaluations
78-
int nfe;
78+
int n_rhs;
7979

8080
// number of integration stesp
81-
int nsteps;
81+
int n_step;
8282

8383
// number of accepted steps
8484
int naccpt;

integration/VODE/actual_integrator_sdc.H

+3-3
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,9 @@ void actual_integrator (BurnT& state, amrex::Real dt, bool is_retry=false)
117117

118118
// Get the number of RHS and Jacobian evaluations.
119119

120-
state.n_rhs = vode_state.NFE;
121-
state.n_jac = vode_state.NJE;
122-
state.n_step = vode_state.NST;
120+
state.n_rhs = vode_state.n_rhs;
121+
state.n_jac = vode_state.n_jac;
122+
state.n_step = vode_state.n_step;
123123

124124
// Copy the integration data back to the burn state.
125125
// This will also update the aux state from X if we are using NSE

integration/VODE/vode_dvjac.H

+6-6
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ void dvjac (int& IERPJ, BurnT& state, DvodeT& vstate)
4545
// steps, we consider the cached Jacobian too old and will want to re-evaluate
4646
// it, so we look at whether the step of the last Jacobian evaluation (NSLJ)
4747
// is more than max_steps_between_jacobian_evals steps in the past.
48-
if (vstate.NST == 0 || vstate.NST > vstate.NSLJ + max_steps_between_jacobian_evals) {
48+
if (vstate.n_step == 0 || vstate.n_step > vstate.NSLJ + max_steps_between_jacobian_evals) {
4949
evaluate_jacobian = 1;
5050
}
5151

@@ -71,10 +71,10 @@ void dvjac (int& IERPJ, BurnT& state, DvodeT& vstate)
7171
// For the analytic Jacobian, call the user-supplied function.
7272

7373
// Increment the Jacobian evaluation counter.
74-
vstate.NJE += 1;
74+
vstate.n_jac += 1;
7575

7676
// Refresh the timestep marker for the last Jacobian evaluation.
77-
vstate.NSLJ = vstate.NST;
77+
vstate.NSLJ = vstate.n_step;
7878

7979
// Indicate that the Jacobian is current for this solve.
8080
vstate.JCUR = 1;
@@ -97,10 +97,10 @@ void dvjac (int& IERPJ, BurnT& state, DvodeT& vstate)
9797
// For the numerical Jacobian, make N calls to the RHS to approximate it.
9898

9999
// Increment the Jacobian evaluation counter.
100-
vstate.NJE += 1;
100+
vstate.n_jac += 1;
101101

102102
// Refresh the timestep marker for the last Jacobian evaluation.
103-
vstate.NSLJ = vstate.NST;
103+
vstate.NSLJ = vstate.n_step;
104104

105105
// Indicate that the Jacobian is current for this solve.
106106
vstate.JCUR = 1;
@@ -133,7 +133,7 @@ void dvjac (int& IERPJ, BurnT& state, DvodeT& vstate)
133133
}
134134

135135
// Increment the RHS evaluation counter by N.
136-
vstate.NFE += int_neqs;
136+
vstate.n_rhs += int_neqs;
137137

138138
#ifdef ALLOW_JACOBIAN_CACHING
139139
// Store the Jacobian if we're caching.

integration/VODE/vode_dvnlsd.H

+4-4
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Real dvnlsd (int& NFLAG, BurnT& state, DvodeT& vstate)
4646
// In any case, DVJAC is called at least every MSBP steps.
4747

4848
vstate.DRC = std::abs(vstate.RC - 1.0_rt);
49-
if (vstate.DRC > CCMAX || vstate.NST >= vstate.NSLP + MSBP) {
49+
if (vstate.DRC > CCMAX || vstate.n_step >= vstate.NSLP + MSBP) {
5050
vstate.IPUP = 1;
5151
}
5252

@@ -67,7 +67,7 @@ Real dvnlsd (int& NFLAG, BurnT& state, DvodeT& vstate)
6767
}
6868

6969
rhs(vstate.tn, state, vstate, vstate.savf);
70-
vstate.NFE += 1;
70+
vstate.n_rhs += 1;
7171

7272
if (vstate.IPUP == 1) {
7373

@@ -82,7 +82,7 @@ Real dvnlsd (int& NFLAG, BurnT& state, DvodeT& vstate)
8282
vstate.RC = 1.0_rt;
8383
vstate.DRC = 0.0_rt;
8484
vstate.CRATE = 1.0_rt;
85-
vstate.NSLP = vstate.NST;
85+
vstate.NSLP = vstate.n_step;
8686

8787
// If matrix is singular, take error return to force cut in step size.
8888
if (IERPJ != 0) {
@@ -172,7 +172,7 @@ Real dvnlsd (int& NFLAG, BurnT& state, DvodeT& vstate)
172172

173173
DELP = DEL;
174174
rhs(vstate.tn, state, vstate, vstate.savf);
175-
vstate.NFE += 1;
175+
vstate.n_rhs += 1;
176176

177177
}
178178

integration/VODE/vode_dvode.H

+7-7
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ int dvode (BurnT& state, DvodeT& vstate)
4545

4646
vstate.tn = vstate.t;
4747

48-
vstate.NST = 0;
49-
vstate.NJE = 0;
48+
vstate.n_step = 0;
49+
vstate.n_jac = 0;
5050
vstate.NSLJ = 0;
5151

5252
// Initial call to the RHS.
@@ -59,7 +59,7 @@ int dvode (BurnT& state, DvodeT& vstate)
5959
vstate.yh(i,2) = f_init(i);
6060
}
6161

62-
vstate.NFE = 1;
62+
vstate.n_rhs = 1;
6363

6464
// Load the initial value array in yh.
6565

@@ -81,7 +81,7 @@ int dvode (BurnT& state, DvodeT& vstate)
8181
// Call DVHIN to set initial step size H0 to be attempted.
8282
H0 = 0.0_rt;
8383
dvhin(state, vstate, H0, NITER, IER);
84-
vstate.NFE += NITER;
84+
vstate.n_rhs += NITER;
8585

8686
if (IER != 0) {
8787
#ifndef AMREX_USE_GPU
@@ -129,7 +129,7 @@ int dvode (BurnT& state, DvodeT& vstate)
129129
// start of problem), check for too much accuracy being requested, and
130130
// check for H below the roundoff level in T.
131131

132-
if (vstate.NST >= ode_max_steps) {
132+
if (vstate.n_step >= ode_max_steps) {
133133
// The maximum number of steps was taken before reaching TOUT.
134134
#ifndef AMREX_USE_GPU
135135
std::cout << amrex::Font::Bold << amrex::FGColor::Red << "DVODE: maximum number of steps taken before reaching TOUT" << amrex::ResetDisplay << std::endl;
@@ -164,7 +164,7 @@ int dvode (BurnT& state, DvodeT& vstate)
164164

165165
if (TOLSF > 1.0_rt) {
166166

167-
if (vstate.NST == 0) {
167+
if (vstate.n_step == 0) {
168168
#ifndef AMREX_USE_GPU
169169
std::cout << amrex::Font::Bold << amrex::FGColor::Red << "DVODE: too much accuracy requested at start of integration" << amrex::ResetDisplay << std::endl;
170170
#endif
@@ -229,7 +229,7 @@ int dvode (BurnT& state, DvodeT& vstate)
229229
// wild exploration. Also ensure we are not working > tmax,
230230
// so we don't need to worry about extrapolating back in time.
231231

232-
if (vstate.NST > MIN_NSE_BAILOUT_STEPS && vstate.tn <= vstate.tout) {
232+
if (vstate.n_step > MIN_NSE_BAILOUT_STEPS && vstate.tn <= vstate.tout) {
233233
// first we need to make the burn_t in sync
234234

235235
#ifdef STRANG

integration/VODE/vode_dvstep.H

+5-5
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ int dvstep (BurnT& state, DvodeT& vstate)
319319
// If ETAMAX = 1 (a failure occurred this step), keep NQWAIT >= 2.
320320

321321
kflag = 0;
322-
vstate.NST += 1;
322+
vstate.n_step += 1;
323323
for (int iback = 1; iback <= vstate.NQ; ++iback) {
324324
const int i = vstate.L - iback;
325325
vstate.tau(i+1) = vstate.tau(i);
@@ -352,7 +352,7 @@ int dvstep (BurnT& state, DvodeT& vstate)
352352
vstate.NEWH = 0;
353353
vstate.ETA = 1.0_rt;
354354
vstate.ETAMAX = ETAMX3;
355-
if (vstate.NST <= 10) {
355+
if (vstate.n_step <= 10) {
356356
vstate.ETAMAX = ETAMX2;
357357
}
358358

@@ -455,7 +455,7 @@ int dvstep (BurnT& state, DvodeT& vstate)
455455
vstate.HSCAL = vstate.H;
456456
vstate.tau(1) = vstate.H;
457457
rhs(vstate.tn, state, vstate, vstate.savf);
458-
vstate.NFE += 1;
458+
vstate.n_rhs += 1;
459459
for (int i = 1; i <= int_neqs; ++i) {
460460
vstate.yh(i,2) = vstate.H * vstate.savf(i);
461461
}
@@ -543,7 +543,7 @@ int dvstep (BurnT& state, DvodeT& vstate)
543543
vstate.ETA = vstate.ETA / amrex::max(1.0_rt, std::abs(vstate.H) * vstate.HMXI * vstate.ETA);
544544
vstate.NEWH = 1;
545545
vstate.ETAMAX = ETAMX3;
546-
if (vstate.NST <= 10) {
546+
if (vstate.n_step <= 10) {
547547
vstate.ETAMAX = ETAMX2;
548548
}
549549
R = 1.0_rt / vstate.tq(2);
@@ -557,7 +557,7 @@ int dvstep (BurnT& state, DvodeT& vstate)
557557
vstate.NEWH = 0;
558558
vstate.ETA = 1.0_rt;
559559
vstate.ETAMAX = ETAMX3;
560-
if (vstate.NST <= 10) {
560+
if (vstate.n_step <= 10) {
561561
vstate.ETAMAX = ETAMX2;
562562
}
563563
R = 1.0_rt / vstate.tq(2);

integration/VODE/vode_type.H

+10-10
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,14 @@ struct dvode_t
7575
// TN = The independent variable, updated on each step taken
7676
amrex::Real tn;
7777

78-
// NFE = The number of f evaluations for the problem so far
79-
int NFE;
78+
// n_rhs = The number of f evaluations for the problem so far
79+
int n_rhs;
8080

81-
// NJE = The number of Jacobian evaluations so far
82-
int NJE;
81+
// n_jac = The number of Jacobian evaluations so far
82+
int n_jac;
8383

84-
// NST = The number of steps taken for the problem so far
85-
int NST;
84+
// n_step = The number of steps taken for the problem so far
85+
int n_step;
8686

8787
// ICF = Integer flag for convergence failure in DVNLSD:
8888
// 0 means no failures
@@ -119,7 +119,7 @@ struct dvode_t
119119
// NSLJ = The number of steps taken as of the last Jacobian update
120120
int NSLJ;
121121

122-
// NSLP = Saved value of NST as of last Newton matrix update
122+
// NSLP = Saved value of n_step as of last Newton matrix update
123123
int NSLP;
124124

125125
// jacobian_type = the type of Jacobian to use (1 = analytic, 2 = numerical)
@@ -202,9 +202,9 @@ void print_state(dvode_t<int_neqs>& dvode_state)
202202
std::cout << "tq(4) = " << dvode_state.tq(4) << std::endl;
203203
std::cout << "tq(5) = " << dvode_state.tq(5) << std::endl;
204204
std::cout << "tn = " << dvode_state.tn << std::endl;
205-
std::cout << "NFE = " << dvode_state.NFE << std::endl;
206-
std::cout << "NJE = " << dvode_state.NJE << std::endl;
207-
std::cout << "NST = " << dvode_state.NST << std::endl;
205+
std::cout << "n_rhs = " << dvode_state.n_rhs << std::endl;
206+
std::cout << "n_jac = " << dvode_state.n_jac << std::endl;
207+
std::cout << "n_step = " << dvode_state.n_step << std::endl;
208208
std::cout << "ICF = " << dvode_state.ICF << std::endl;
209209
std::cout << "IPUP = " << dvode_state.IPUP << std::endl;
210210
std::cout << "JCUR = " << dvode_state.JCUR << std::endl;

0 commit comments

Comments
 (0)