Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clean up the artifical viscosity routines #2934

Merged
merged 5 commits into from
Jul 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 65 additions & 57 deletions Source/hydro/advection_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,49 +302,52 @@ Castro::apply_av(const Box& bx,

Real diff_coeff = difmag;

amrex::ParallelFor(bx, NUM_STATE,
[=] AMREX_GPU_DEVICE (int i, int j, int k, int n) noexcept
amrex::ParallelFor(bx,
[=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
{

if (n == UTEMP) {
return;
}
Real div1;
if (idir == 0) {
div1 = 0.25_rt * (div(i,j,k) + div(i,j+dg1,k) +
div(i,j,k+dg2) + div(i,j+dg1,k+dg2));
} else if (idir == 1) {
div1 = 0.25_rt * (div(i,j,k) + div(i+1,j,k) +
div(i,j,k+dg2) + div(i+1,j,k+dg2));
} else {
div1 = 0.25_rt * (div(i,j,k) + div(i+1,j,k) +
div(i,j+dg1,k) + div(i+1,j+dg1,k));
}

div1 = diff_coeff * std::min(0.0_rt, div1);

for (int n = 0; n < NUM_STATE; ++n) {

if (n == UTEMP) {
continue;
}
#ifdef SHOCK_VAR
if (n == USHK) {
return;
}
if (n == USHK) {
continue;
}
#endif

#ifdef NSE_NET
if (n == UMUP || n == UMUN) {
return;
}
if (n == UMUP || n == UMUN) {
continue;
}
#endif
Real div1;
if (idir == 0) {

div1 = 0.25_rt * (div(i,j,k) + div(i,j+dg1,k) +
div(i,j,k+dg2) + div(i,j+dg1,k+dg2));
div1 = diff_coeff * amrex::min(0.0_rt, div1);
div1 = div1 * (uin(i,j,k,n) - uin(i-1,j,k,n));

} else if (idir == 1) {

div1 = 0.25_rt * (div(i,j,k) + div(i+1,j,k) +
div(i,j,k+dg2) + div(i+1,j,k+dg2));
div1 = diff_coeff * amrex::min(0.0_rt, div1);
div1 = div1 * (uin(i,j,k,n) - uin(i,j-dg1,k,n));

} else {
Real div_var{};

div1 = 0.25_rt * (div(i,j,k) + div(i+1,j,k) +
div(i,j+dg1,k) + div(i+1,j+dg1,k));
div1 = diff_coeff * amrex::min(0.0_rt, div1);
div1 = div1 * (uin(i,j,k,n) - uin(i,j,k-dg2,n));
if (idir == 0) {
div_var = div1 * (uin(i,j,k,n) - uin(i-1,j,k,n));
} else if (idir == 1) {
div_var = div1 * (uin(i,j,k,n) - uin(i,j-dg1,k,n));
} else {
div_var = div1 * (uin(i,j,k,n) - uin(i,j,k-dg2,n));
}

}

flux(i,j,k,n) += dx[idir] * div1;
flux(i,j,k,n) += dx[idir] * div_var;
}
});
}

Expand All @@ -359,37 +362,42 @@ Castro::apply_av_rad(const Box& bx,

const auto dx = geom.CellSizeArray();

Real diff_coeff = difmag;

amrex::ParallelFor(bx, Radiation::nGroups,
[=] AMREX_GPU_DEVICE (int i, int j, int k, int n) noexcept
{
amrex::Real diff_coeff = difmag;

Real div1;
if (idir == 0) {
int ngroups = Radiation::nGroups;

div1 = 0.25_rt * (div(i,j,k) + div(i,j+dg1,k) +
div(i,j,k+dg2) + div(i,j+dg1,k+dg2));
div1 = diff_coeff * amrex::min(0.0_rt, div1);
div1 = div1 * (Erin(i,j,k,n) - Erin(i-1,j,k,n));
amrex::ParallelFor(bx,
[=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
{

} else if (idir == 1) {
Real div1;
if (idir == 0) {
div1 = 0.25_rt * (div(i,j,k) + div(i,j+dg1,k) +
div(i,j,k+dg2) + div(i,j+dg1,k+dg2));
} else if (idir == 1) {
div1 = 0.25_rt * (div(i,j,k) + div(i+1,j,k) +
div(i,j,k+dg2) + div(i+1,j,k+dg2));
} else {
div1 = 0.25_rt * (div(i,j,k) + div(i+1,j,k) +
div(i,j+dg1,k) + div(i+1,j+dg1,k));
}

div1 = 0.25_rt * (div(i,j,k) + div(i+1,j,k) +
div(i,j,k+dg2) + div(i+1,j,k+dg2));
div1 = diff_coeff * amrex::min(0.0_rt, div1);
div1 = div1 * (Erin(i,j,k,n) - Erin(i,j-dg1,k,n));
div1 = diff_coeff * std::min(0.0_rt, div1);

} else {
for (int n = 0; n < ngroups; ++n) {

div1 = 0.25_rt * (div(i,j,k) + div(i+1,j,k) +
div(i,j+dg1,k) + div(i+1,j+dg1,k));
div1 = diff_coeff * amrex::min(0.0_rt, div1);
div1 = div1 * (Erin(i,j,k,n) - Erin(i,j,k-dg2,n));
Real div_var{};

}
if (idir == 0) {
div_var = div1 * (Erin(i,j,k,n) - Erin(i-1,j,k,n));
} else if (idir == 1) {
div_var = div1 * (Erin(i,j,k,n) - Erin(i,j-dg1,k,n));
} else {
div_var = div1 * (Erin(i,j,k,n) - Erin(i,j,k-dg2,n));
}

radflux(i,j,k,n) += dx[idir] * div1;
radflux(i,j,k,n) += dx[idir] * div_var;
}
});
}
#endif
Expand Down