diff --git a/Exec/science/flame_wave/Problem_Derive.H b/Exec/science/flame_wave/Problem_Derive.H new file mode 100644 index 0000000000..885d730a57 --- /dev/null +++ b/Exec/science/flame_wave/Problem_Derive.H @@ -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*/); + diff --git a/Exec/science/flame_wave/Problem_Derive.cpp b/Exec/science/flame_wave/Problem_Derive.cpp new file mode 100644 index 0000000000..d1736bcc36 --- /dev/null +++ b/Exec/science/flame_wave/Problem_Derive.cpp @@ -0,0 +1,53 @@ +#include + +#include + +#include +#include + +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 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; + }); +} + diff --git a/Exec/science/flame_wave/Problem_Derives.H b/Exec/science/flame_wave/Problem_Derives.H new file mode 100644 index 0000000000..d7eefefae9 --- /dev/null +++ b/Exec/science/flame_wave/Problem_Derives.H @@ -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);