-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add X(ash) as a derived variable for flame_wave (#2773)
It's fairly straightforward to calculate in C++, and this lets me include it in small plotfiles.
- Loading branch information
Showing
3 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
void ca_derxash | ||
(const amrex::Box& bx, amrex::FArrayBox& derfab, int /*dcomp*/, int /*ncomp*/, | ||
const amrex::FArrayBox& datfab, const amrex::Geometry& /*geomdata*/, | ||
amrex::Real /*time*/, const int* /*bcrec*/, int /*level*/); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#include <bitset> | ||
|
||
#include <AMReX_REAL.H> | ||
|
||
#include <Derive.H> | ||
#include <Castro.H> | ||
|
||
using namespace amrex; | ||
|
||
void ca_derxash(const Box& bx, FArrayBox& derfab, int /*dcomp*/, int /*ncomp*/, | ||
const FArrayBox& datfab, const Geometry& /*geomdata*/, | ||
Real /*time*/, const int* /*bcrec*/, int /*level*/) | ||
{ | ||
|
||
// determine which species should be considered ash | ||
|
||
std::bitset<NumSpec> is_ash{}; | ||
|
||
for (int i = 0; i < NumSpec; ++i) { | ||
// include all elements beyond oxygen | ||
if (zion[i] > 8.0) { | ||
is_ash.set(i); | ||
} | ||
} | ||
|
||
// exclude all of the "ash" species from the input file; they're actually | ||
// used for the star composition and hiding them helps make the flame more | ||
// visible | ||
for (const std::string& ash_name : {problem::ash1_name, | ||
problem::ash2_name, | ||
problem::ash3_name}) { | ||
int i = network_spec_index(ash_name); | ||
if (i != -1) { | ||
is_ash.reset(i); | ||
} | ||
} | ||
|
||
auto const dat = datfab.array(); | ||
auto const der = derfab.array(); | ||
|
||
amrex::ParallelFor(bx, | ||
[=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept | ||
{ | ||
Real sum = 0.0_rt; | ||
for (int n = 0; n < NumSpec; ++n) { | ||
if (is_ash[n]) { | ||
sum += dat(i,j,k,1+n)/dat(i,j,k,0); | ||
} | ||
} | ||
der(i,j,k,0) = sum; | ||
}); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// | ||
// X(ash) from rhoX - sum of all mass fractions for the elements beyond oxygen, | ||
// excluding the species that make up the star | ||
// | ||
derive_lst.add("X(ash)",IndexType::TheCellType(),1,ca_derxash,the_same_box); | ||
derive_lst.addComponent("X(ash)",desc_lst,State_Type,URHO,1); | ||
derive_lst.addComponent("X(ash)",desc_lst,State_Type,UFS,NumSpec); |