Skip to content

Commit

Permalink
small fixes (#1682)
Browse files Browse the repository at this point in the history
  • Loading branch information
asalmgren authored Jul 11, 2024
1 parent 779828e commit 45a4e72
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
9 changes: 6 additions & 3 deletions Source/DataStructs/DataStruct.H
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,13 @@ struct SolverChoice {
pp.query("project_initial_velocity", project_initial_velocity);

int nvals_inc = pp.countval("incompressible");
AMREX_ALWAYS_ASSERT(nvals_inc == 1 || nvals_inc >= max_level+1);
AMREX_ALWAYS_ASSERT(nvals_inc == 0 || nvals_inc == 1 || nvals_inc >= max_level+1);
amrex::Vector<int> inc_in; inc_in.resize(nvals_inc);
pp.getarr("incompressible",inc_in);
if (nvals_inc == 1) {
pp.queryarr("incompressible",inc_in);
if (nvals_inc == 0) {
for (int i = 0; i <= max_level; ++i) incompressible.push_back(0);
amrex::Warning("NOTE: ERF was built with the Poisson solver but the incompressible flag was not set");
} else if (nvals_inc == 1) {
for (int i = 0; i <= max_level; ++i) incompressible.push_back(inc_in[0]);
} else {
for (int i = 0; i <= max_level; ++i) incompressible.push_back(inc_in[0]);
Expand Down
20 changes: 16 additions & 4 deletions Source/IO/ERF_Write1DProfiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,18 @@ ERF::derive_diag_profiles(Real time,
h_avg_u[k] /= area_z; h_avg_v[k] /= area_z; h_avg_w[k] /= area_z;
}

Gpu::DeviceVector<Real> d_avg_u(hu_size, Real(0.0));
Gpu::DeviceVector<Real> d_avg_v(hu_size, Real(0.0));
Gpu::DeviceVector<Real> d_avg_w(hu_size, Real(0.0));

auto* avg_u_ptr = d_avg_u.data();
auto* avg_v_ptr = d_avg_v.data();
auto* avg_w_ptr = d_avg_w.data();

Gpu::copy(Gpu::hostToDevice, h_avg_u.begin(), h_avg_u.end(), d_avg_u.begin());
Gpu::copy(Gpu::hostToDevice, h_avg_v.begin(), h_avg_v.end(), d_avg_v.begin());
Gpu::copy(Gpu::hostToDevice, h_avg_w.begin(), h_avg_w.end(), d_avg_w.begin());

int nvars = vars_new[lev][Vars::cons].nComp();
MultiFab mf_cons(vars_new[lev][Vars::cons], make_alias, 0, nvars);

Expand Down Expand Up @@ -273,15 +285,15 @@ ERF::derive_diag_profiles(Real time,
ksgs = cons_arr(i,j,k,RhoQKE_comp) / cons_arr(i,j,k,Rho_comp);
}
fab_arr(i, j, k, 2) = ksgs;
Real kturb = 0.0;
#if 1
Real kturb = 0.0;
if (l_use_Turb) kturb = eta_arr(i,j,k,EddyDiff::Mom_h);
fab_arr(i, j, k, 3) = kturb;
#else
// Here we hijack the "Kturb" variable name to print out the resolved kinetic energy
Real upert = u_cc_arr(i,j,k) - h_avg_u[k];
Real vpert = v_cc_arr(i,j,k) - h_avg_v[k];
Real wpert = w_cc_arr(i,j,k) - h_avg_w[k];
Real upert = u_cc_arr(i,j,k) - avg_u_ptr[k];
Real vpert = v_cc_arr(i,j,k) - avg_v_ptr[k];
Real wpert = w_cc_arr(i,j,k) - avg_w_ptr[k];
fab_arr(i, j, k, 3) = 0.5 * (upert*upert + vpert*vpert + wpert*wpert);
#endif
fab_arr(i, j, k, 4) = u_cc_arr(i,j,k) * u_cc_arr(i,j,k); // u*u
Expand Down

0 comments on commit 45a4e72

Please sign in to comment.