Skip to content

Commit

Permalink
Add X(ash) as a derived variable for flame_wave (#2773)
Browse files Browse the repository at this point in the history
It's fairly straightforward to calculate in C++, and this lets me
include it in small plotfiles.
  • Loading branch information
yut23 authored Mar 13, 2024
1 parent e94d826 commit e2ce5b5
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Exec/science/flame_wave/Problem_Derive.H
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*/);

53 changes: 53 additions & 0 deletions Exec/science/flame_wave/Problem_Derive.cpp
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;
});
}

7 changes: 7 additions & 0 deletions Exec/science/flame_wave/Problem_Derives.H
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);

0 comments on commit e2ce5b5

Please sign in to comment.