-
Notifications
You must be signed in to change notification settings - Fork 75
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
Reaction mask implementation gpu #805
base: development
Are you sure you want to change the base?
Changes from all commits
3ac47b6
6e2e9db
6c6ddb4
8481cc2
798b366
0cc4444
153694a
4c662f3
1a0f6e2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -108,6 +108,12 @@ amrex::Vector<std::string> PeleC::m_diagVars; | |
|
||
amrex::Vector<int> PeleC::src_list; | ||
|
||
bool PeleC::use_chem_mask = false; // Flag to check if mask is activated. | ||
amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> | ||
PeleC::lo_chem_mask_coordinate; // Box coordinate low | ||
amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> | ||
PeleC::hi_chem_mask_coordinate; // Box coordinate high | ||
|
||
// this will be reset upon restart | ||
amrex::Real PeleC::previousCPUTimeUsed = 0.0; | ||
amrex::Real PeleC::startCPUTime = 0.0; | ||
|
@@ -250,6 +256,16 @@ PeleC::read_params() | |
pp.query("use_typ_vals_chem", use_typical_vals_chem); | ||
pp.query("use_typ_vals_chem_usr", use_typical_vals_chem_usr); | ||
|
||
pp.query("chem_mask", use_chem_mask); | ||
|
||
// Reading chemistry mask box coordinates | ||
if (use_chem_mask) { | ||
for (int n = 0; n < AMREX_SPACEDIM; ++n) { | ||
pp.get("lo_chemmask", lo_chem_mask_coordinate[n], n); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's be more explicit with this user facing string |
||
pp.get("hi_chemmask", hi_chem_mask_coordinate[n], n); | ||
} | ||
} | ||
|
||
if (use_typical_vals_chem_usr) { | ||
use_typical_vals_chem = true; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,9 @@ PeleC::react_state( | |
|
||
const amrex::Real strt_time = amrex::ParallelDescriptor::second(); | ||
|
||
const auto plo = geom.ProbLoArray(); | ||
const auto dx = geom.CellSizeArray(); | ||
|
||
AMREX_ASSERT(do_react == 1); | ||
|
||
if ((verbose != 0) && amrex::ParallelDescriptor::IOProcessor()) { | ||
|
@@ -126,6 +129,15 @@ PeleC::react_state( | |
#pragma omp parallel if (amrex::Gpu::notInLaunchRegion()) | ||
#endif | ||
{ | ||
|
||
amrex::RealBox Chem_Masked_Region( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. name this |
||
AMREX_D_DECL( | ||
lo_chem_mask_coordinate[0], lo_chem_mask_coordinate[1], | ||
lo_chem_mask_coordinate[2]), | ||
AMREX_D_DECL( | ||
hi_chem_mask_coordinate[0], hi_chem_mask_coordinate[1], | ||
hi_chem_mask_coordinate[2])); | ||
|
||
for (amrex::MFIter mfi(S_new, amrex::TilingIfNotGPU()); mfi.isValid(); | ||
++mfi) { | ||
|
||
|
@@ -170,6 +182,20 @@ PeleC::react_state( | |
auto const& mask = dummyMask.array(mfi); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. while we are at it. Let's rename this "dummyMask` to something that means something. |
||
auto const& fc = fctCount.array(mfi); | ||
|
||
if (use_chem_mask) { | ||
amrex::ParallelFor( | ||
bx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept { | ||
amrex::XDim3 point; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can simplify: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should probably just happen once? No need to do it every step? if so, can we move to the init somewhere? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think @marchdf means |
||
point.x = plo[0] + (i + 0.5) * dx[0]; | ||
point.y = plo[1] + (j + 0.5) * dx[1]; | ||
point.z = plo[2] + (k + 0.5) * dx[2]; | ||
|
||
if (Chem_Masked_Region.contains(point)) { | ||
mask(i, j, k) = -1; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can then make this a ternary expression: |
||
} | ||
}); | ||
} | ||
|
||
amrex::ParallelFor( | ||
bx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept { | ||
// work on old state | ||
|
@@ -209,7 +235,7 @@ PeleC::react_state( | |
); | ||
|
||
amrex::Gpu::Device::streamSynchronize(); | ||
|
||
bool use_chem_mask_d = use_chem_mask; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. const this. |
||
// unpack data | ||
amrex::ParallelFor( | ||
bx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept { | ||
|
@@ -236,6 +262,13 @@ PeleC::react_state( | |
- rho_old * e_old) // old internal energy | ||
/ dt; | ||
|
||
if (use_chem_mask_d && mask(i, j, k) == -1) { | ||
for (int nsp = 0; nsp < NUM_SPECIES; nsp++) { | ||
rhoY(i, j, k, nsp) += nonrs_arr(i, j, k, UFS + nsp) * dt; | ||
} | ||
rhoY(i, j, k, NUM_SPECIES) += rhoedot_ext * dt; | ||
} | ||
|
||
amrex::Real umnew = | ||
sold_arr(i, j, k, UMX) + dt * nonrs_arr(i, j, k, UMX); | ||
amrex::Real vmnew = | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The best way to do this is actually a bit different. You would add the option(s) here and run the
Source/Params/mk_params.sh
script to make this all automatic. I will do the definition/declaration/parmparse for you.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also add some documentation about what these new input parameters mean for the user?