Skip to content

Commit

Permalink
chemistry functions
Browse files Browse the repository at this point in the history
  • Loading branch information
ajnonaka committed Aug 22, 2024
1 parent c8befe2 commit 4e59a7a
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src_chemistry/chemistry_functions.H
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,12 @@ void InitializeChemistryNamespace();
// used in compressible code only
void compute_compressible_chemistry_source_CLE(amrex::Real dt, amrex::Real dV,
MultiFab& prim, MultiFab& source, MultiFab& ranchem);

void chemical_rates(const MultiFab& n_cc, MultiFab& chem_rate, amrex::Geometry geom, amrex::Real dt,
const MultiFab& n_interm, Vector<Real> lin_comb_coef_in);

AMREX_GPU_HOST_DEVICE void compute_reaction_rates(GpuArray<Real,MAX_SPECIES>& n_in,
GpuArray<Real,MAX_REACTION>& reaction_rates,
const amrex::Real& dv);

#endif
39 changes: 39 additions & 0 deletions src_chemistry/chemistry_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,3 +191,42 @@ void compute_compressible_chemistry_source_CLE(amrex::Real dt, amrex::Real dV,
});
}
}


void chemical_rates(const MultiFab& n_cc, MultiFab& chem_rate, amrex::Geometry geom, amrex::Real dt,
const MultiFab& n_interm, Vector<Real> lin_comb_coef_in)
{
int lin_comb_avg_react_rate = 1;
if (lin_comb_coef_in[0] == 1. && lin_comb_coef_in[1] == 0.) {
lin_comb_avg_react_rate = 0;
}

GpuArray<Real,2> lin_comb_coef;
lin_comb_coef[0] = lin_comb_coef_in[0];
lin_comb_coef[1] = lin_comb_coef_in[1];

const Real* dx = geom.CellSize();

Real dv = (AMREX_SPACEDIM == 3) ? dx[0]*dx[1]*dx[2] : dx[0]*dx[1]*cell_depth;



}

AMREX_GPU_HOST_DEVICE void compute_reaction_rates(GpuArray<Real,MAX_SPECIES>& n_in,
GpuArray<Real,MAX_REACTION>& reaction_rates,
const amrex::Real& dv)
{
GpuArray<Real,MAX_SPECIES> n_nonneg;

Real n_sum = 0.;

for (int i=0; i<nspecies; ++i) {
n_nonneg[i] = std::max(0.,n_in[i]);
n_sum += n_nonneg[i];
}
if (n_sum < 0.) n_sum = 1./dv;


}

0 comments on commit 4e59a7a

Please sign in to comment.