Skip to content

Commit 07a186e

Browse files
authored
remove reinterpret_cast in rhs.H (#1435)
1 parent a5faa5f commit 07a186e

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

networks/rhs.H

+12-14
Original file line numberDiff line numberDiff line change
@@ -273,19 +273,17 @@ constexpr int is_jacobian_term_used ()
273273
}
274274

275275
AMREX_GPU_HOST_DEVICE AMREX_INLINE
276-
void dgesl (RArray2D& a1, RArray1D& b1)
276+
void dgesl (const RArray2D& a, RArray1D& b)
277277
{
278-
auto const& a = reinterpret_cast<amrex::Array2D<amrex::Real, 0, INT_NEQS-1, 0, INT_NEQS-1>&>(a1);
279-
auto& b = reinterpret_cast<amrex::Array1D<amrex::Real, 0, INT_NEQS-1>&>(b1);
280278

281279
// solve a * x = b
282280
// first solve l * y = b
283-
constexpr_for<0, INT_NEQS-1>([&] (auto n1)
281+
constexpr_for<1, INT_NEQS>([&] (auto n1)
284282
{
285283
constexpr int k = n1;
286284

287285
amrex::Real t = b(k);
288-
constexpr_for<k+1, INT_NEQS>([&] (auto n2)
286+
constexpr_for<k+1, INT_NEQS+1>([&] (auto n2)
289287
{
290288
constexpr int j = n2;
291289

@@ -294,47 +292,47 @@ void dgesl (RArray2D& a1, RArray1D& b1)
294292
});
295293

296294
// now solve u * x = y
297-
constexpr_for<0, INT_NEQS>([&] (auto kb)
295+
constexpr_for<1, INT_NEQS+1>([&] (auto kb)
298296
{
299-
constexpr int k = INT_NEQS - kb - 1;
297+
constexpr int k = INT_NEQS + 1 - kb;
300298

301299
b(k) = b(k) / a(k,k);
302300
amrex::Real t = -b(k);
303301

304-
constexpr_for<0, k>([&] (auto j)
302+
constexpr_for<1, k>([&] (auto j)
305303
{
306304
b(j) += t * a(j,k);
307305
});
308306
});
309307
}
310308

311309
AMREX_GPU_HOST_DEVICE AMREX_INLINE
312-
void dgefa (RArray2D& a1)
310+
void dgefa (RArray2D& a)
313311
{
314-
auto& a = reinterpret_cast<amrex::Array2D<amrex::Real, 0, INT_NEQS-1, 0, INT_NEQS-1>&>(a1);
315312

316313
// LU factorization in-place without pivoting.
317314

318-
constexpr_for<0, INT_NEQS-1>([&] (auto n1)
315+
constexpr_for<1, INT_NEQS>([&] (auto n1)
319316
{
320317
[[maybe_unused]] constexpr int k = n1;
321318

322319
// compute multipliers
320+
323321
amrex::Real t = -1.0_rt / a(k,k);
324-
constexpr_for<k+1, INT_NEQS>([&] (auto n2)
322+
constexpr_for<k+1, INT_NEQS+1>([&] (auto n2)
325323
{
326324
[[maybe_unused]] constexpr int j = n2;
327325

328326
a(j,k) *= t;
329327
});
330328

331329
// row elimination with column indexing
332-
constexpr_for<k+1, INT_NEQS>([&] (auto n2)
330+
constexpr_for<k+1, INT_NEQS+1>([&] (auto n2)
333331
{
334332
[[maybe_unused]] constexpr int j = n2;
335333

336334
t = a(k,j);
337-
constexpr_for<k+1, INT_NEQS>([&] (auto n3)
335+
constexpr_for<k+1, INT_NEQS+1>([&] (auto n3)
338336
{
339337
[[maybe_unused]] constexpr int i = n3;
340338

0 commit comments

Comments
 (0)