Content-Length: 632445 | pFad | http://github.com/ensonun/PelePhysics/commit/90b8fe1cb79f50a3ea7ca6363d88494a41d074ec

E9 Cleanup Transport and SRK (#193) · ensonun/PelePhysics@90b8fe1 · GitHub
Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 90b8fe1

Browse files
authoredAug 26, 2021
Cleanup Transport and SRK (AMReX-Combustion#193)
Co-authored by Xiaozhu Meng<mxz297@gmail.com> at Rice University
1 parent 1a83c78 commit 90b8fe1

File tree

4 files changed

+148
-206
lines changed

4 files changed

+148
-206
lines changed
 

‎Eos/SRK.H

+23-28
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ struct SRK
2626
am = 0.0;
2727
bm = 0.0;
2828
AMREX_ASSERT(T > 0.0);
29-
amrex::Real sqrtT = std::sqrt(T);
29+
const amrex::Real sqrtT = std::sqrt(T);
3030
amrex::Real amloc[NUM_SPECIES];
3131

3232
// Combine as follows: add diagonal to am in first loop, loop upper triang
@@ -50,7 +50,7 @@ struct SRK
5050
{
5151
am = 0.0;
5252
AMREX_ASSERT(T > 0.0);
53-
amrex::Real sqrtT = std::sqrt(T);
53+
const amrex::Real sqrtT = std::sqrt(T);
5454
amrex::Real amloc[NUM_SPECIES];
5555

5656
// Combine as follows: add diagonal to am in first loop, loop upper triang
@@ -83,8 +83,8 @@ struct SRK
8383
{
8484
dAmdT = 0.0;
8585
AMREX_ASSERT(T > 0.0);
86-
amrex::Real oneOverT = 1.0 / T;
87-
amrex::Real sqrtT = std::sqrt(T);
86+
const amrex::Real oneOverT = 1.0 / T;
87+
const amrex::Real sqrtT = std::sqrt(T);
8888
amrex::Real amloc[NUM_SPECIES];
8989
amrex::Real amlocder[NUM_SPECIES];
9090

@@ -108,7 +108,7 @@ struct SRK
108108
void Calc_dAmdY(amrex::Real T, amrex::Real Y[], amrex::Real dAmdY[])
109109
{
110110
AMREX_ASSERT(T > 0.0);
111-
amrex::Real sqrtT = std::sqrt(T);
111+
const amrex::Real sqrtT = std::sqrt(T);
112112
amrex::Real amloc[NUM_SPECIES];
113113

114114
for (int ii = 0; ii < NUM_SPECIES; ii++) {
@@ -130,7 +130,7 @@ struct SRK
130130
amrex::Real T, amrex::Real* /*Y[]*/, amrex::Real d2AmdY2[][NUM_SPECIES])
131131
{
132132
AMREX_ASSERT(T > 0.0);
133-
amrex::Real sqrtT = std::sqrt(T);
133+
const amrex::Real sqrtT = std::sqrt(T);
134134
amrex::Real amloc[NUM_SPECIES];
135135

136136
for (int ii = 0; ii < NUM_SPECIES; ii++) {
@@ -150,8 +150,8 @@ struct SRK
150150
void Calc_d2AmdTY(amrex::Real T, amrex::Real Y[], amrex::Real d2AmdTY[])
151151
{
152152
AMREX_ASSERT(T > 0.0);
153-
amrex::Real oneOverT = 1.0 / T;
154-
amrex::Real sqrtT = std::sqrt(T);
153+
const amrex::Real oneOverT = 1.0 / T;
154+
const amrex::Real sqrtT = std::sqrt(T);
155155
amrex::Real amloc[NUM_SPECIES];
156156
amrex::Real amlocder[NUM_SPECIES];
157157

@@ -181,7 +181,6 @@ struct SRK
181181
amrex::Real T,
182182
amrex::Real Wbar)
183183
{
184-
amrex::Real theta, Z1, Z2, Z3, sqrtQ, third;
185184
amrex::Real RmT = Constants::RU / Wbar * T;
186185
amrex::Real B1 = bm * P / RmT;
187186
amrex::Real R1 = RmT;
@@ -193,18 +192,18 @@ struct SRK
193192
amrex::Real Q = (alpha * alpha - 3.0 * beta) / 9.0;
194193
amrex::Real R =
195194
(2.0 * alpha * alpha * alpha - 9.0 * alpha * beta + 27.0 * gamma) / 54.0;
196-
amrex::Real PIval = 3.1415926535897932;
197195

198196
// Multiple roots of cubic
199-
third = 1.0 / 3.0;
197+
const amrex::Real third = 1.0 / 3.0;
200198
if ((Q * Q * Q - R * R) > 0) {
201-
sqrtQ = std::sqrt(Q);
202-
theta = std::acos(R / (Q * sqrtQ));
203-
Z1 = -2.0 * sqrtQ * std::cos(theta * third) - alpha * third;
204-
Z2 =
205-
-2.0 * sqrtQ * std::cos((theta + 2.0 * PIval) * third) - alpha * third;
206-
Z3 =
207-
-2.0 * sqrtQ * std::cos((theta + 4.0 * PIval) * third) - alpha * third;
199+
const amrex::Real sqrtQ = std::sqrt(Q);
200+
const amrex::Real theta = std::acos(R / (Q * sqrtQ));
201+
const amrex::Real Z1 =
202+
-2.0 * sqrtQ * std::cos(theta * third) - alpha * third;
203+
const amrex::Real Z2 =
204+
-2.0 * sqrtQ * std::cos((theta + 2.0 * M_PI) * third) - alpha * third;
205+
const amrex::Real Z3 =
206+
-2.0 * sqrtQ * std::cos((theta + 4.0 * M_PI) * third) - alpha * third;
208207
Z = std::max(Z1, Z2);
209208
Z = std::max(Z, Z3);
210209
} else {
@@ -220,9 +219,9 @@ struct SRK
220219
void Calc_d2AmdT2(amrex::Real T, amrex::Real Y[], amrex::Real& d2AmdT2)
221220
{
222221
AMREX_ASSERT(T > 0.0);
223-
amrex::Real oneOverT = 1.0 / T;
224-
amrex::Real tmp1 = -0.5 * oneOverT;
225-
amrex::Real sqrtT = std::sqrt(T);
222+
const amrex::Real oneOverT = 1.0 / T;
223+
const amrex::Real tmp1 = -0.5 * oneOverT;
224+
const amrex::Real sqrtT = std::sqrt(T);
226225
amrex::Real amloc[NUM_SPECIES];
227226
amrex::Real amlocder[NUM_SPECIES];
228227

@@ -254,16 +253,12 @@ struct SRK
254253
amrex::Real& d2AmdT2)
255254
{
256255
AMREX_ASSERT(T > 0.0);
257-
amrex::Real oneOverT = 1.0 / T;
258-
amrex::Real tmp1 = -0.5 * oneOverT;
259-
amrex::Real sqrtT = std::sqrt(T);
256+
const amrex::Real oneOverT = 1.0 / T;
257+
const amrex::Real tmp1 = -0.5 * oneOverT;
258+
const amrex::Real sqrtT = std::sqrt(T);
260259
amrex::Real amloc[NUM_SPECIES];
261260
amrex::Real amlocder[NUM_SPECIES];
262261

263-
am = 0.0;
264-
dAmdT = 0.0;
265-
d2AmdT2 = 0.0;
266-
267262
// Compute species-dependent intermediates
268263
for (int ii = 0; ii < NUM_SPECIES; ii++) {
269264
amloc[ii] =

‎Transport/Constant.H

+16-29
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ struct ConstTransport
1515
AMREX_GPU_HOST_DEVICE
1616
AMREX_FORCE_INLINE
1717
void transport(
18-
bool wtr_get_xi,
19-
bool wtr_get_mu,
20-
bool wtr_get_lam,
21-
bool wtr_get_Ddiag,
22-
amrex::Real& /*Tloc*/,
23-
amrex::Real& /*rholoc*/,
18+
const bool wtr_get_xi,
19+
const bool wtr_get_mu,
20+
const bool wtr_get_lam,
21+
const bool wtr_get_Ddiag,
22+
const amrex::Real /*Tloc*/,
23+
const amrex::Real /*rholoc*/,
2424
amrex::Real* /*Yloc*/,
2525
amrex::Real* Ddiag,
2626
amrex::Real& mu,
@@ -52,9 +52,9 @@ struct ConstTransport
5252
AMREX_FORCE_INLINE
5353
void get_transport_coeffs(
5454
amrex::Box const& bx,
55-
amrex::Array4<const amrex::Real> const& Y_in,
56-
amrex::Array4<const amrex::Real> const& T_in,
57-
amrex::Array4<const amrex::Real> const& Rho_in,
55+
amrex::Array4<const amrex::Real> const& /*Y_in*/,
56+
amrex::Array4<const amrex::Real> const& /*T_in*/,
57+
amrex::Array4<const amrex::Real> const& /*Rho_in*/,
5858
amrex::Array4<amrex::Real> const& D_out,
5959
amrex::Array4<amrex::Real> const& mu_out,
6060
amrex::Array4<amrex::Real> const& xi_out,
@@ -64,32 +64,19 @@ struct ConstTransport
6464
const auto lo = amrex::lbound(bx);
6565
const auto hi = amrex::ubound(bx);
6666

67-
bool wtr_get_xi, wtr_get_mu, wtr_get_lam, wtr_get_Ddiag;
68-
69-
wtr_get_xi = true;
70-
wtr_get_mu = true;
71-
wtr_get_lam = true;
72-
wtr_get_Ddiag = true;
73-
74-
amrex::Real T;
75-
amrex::Real rho;
76-
amrex::Real massloc[NUM_SPECIES];
77-
78-
amrex::Real muloc, xiloc, lamloc;
79-
amrex::Real Ddiag[NUM_SPECIES];
67+
const bool wtr_get_xi = true;
68+
const bool wtr_get_mu = true;
69+
const bool wtr_get_lam = true;
70+
const bool wtr_get_Ddiag = true;
8071

8172
for (int k = lo.z; k <= hi.z; ++k) {
8273
for (int j = lo.y; j <= hi.y; ++j) {
8374
for (int i = lo.x; i <= hi.x; ++i) {
8475

85-
T = T_in(i, j, k);
86-
rho = Rho_in(i, j, k);
87-
for (int n = 0; n < NUM_SPECIES; ++n) {
88-
massloc[n] = Y_in(i, j, k, n);
89-
}
90-
76+
amrex::Real muloc, xiloc, lamloc;
77+
amrex::Real Ddiag[NUM_SPECIES] = {0.0};
9178
transport(
92-
wtr_get_xi, wtr_get_mu, wtr_get_lam, wtr_get_Ddiag, T, rho, massloc,
79+
wtr_get_xi, wtr_get_mu, wtr_get_lam, wtr_get_Ddiag, 0.0, 0.0, NULL,
9380
Ddiag, muloc, xiloc, lamloc, tparm);
9481

9582
// mu, xi and lambda are stored after D in the diffusion multifab
There was a problem loading the remainder of the diff.

0 commit comments

Comments
 (0)
Failed to load comments.








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/ensonun/PelePhysics/commit/90b8fe1cb79f50a3ea7ca6363d88494a41d074ec

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy