Skip to content

Commit

Permalink
Merge pull request #1 from baperry2/bpatch-nvidia-fix
Browse files Browse the repository at this point in the history
Bpatch nvidia fix
SreejithNREL authored May 6, 2024
2 parents 1caa176 + 937eab1 commit 1e2bb80
Showing 2 changed files with 14 additions and 10 deletions.
1 change: 1 addition & 0 deletions Source/PeleLMeX_BPatch.H
Original file line number Diff line number Diff line change
@@ -220,6 +220,7 @@ public:

// Accessors
BpatchDataContainer getHostData() { return m_bpdata_h; }
BpatchDataContainer* getHostDataPtr() { return &m_bpdata_h; }
BpatchDataContainer* getDeviceData() { return m_bpdata_d; }

std::string m_patchname;
23 changes: 13 additions & 10 deletions Source/PeleLMeX_Temporals.cpp
Original file line number Diff line number Diff line change
@@ -61,10 +61,9 @@ PeleLM::speciesBalancePatch()
{
tmppatchmfrFile << m_nstep << " " << m_cur_time; // Time info
for (int n = 0; n < m_bPatches.size(); n++) {
BPatch* patch = m_bPatches[n].get();
BPatch::BpatchDataContainer bphost = patch->getHostData();
for (int i = 0; i < bphost.num_species; i++) {
tmppatchmfrFile << " " << bphost.speciesFlux[i];
BPatch::BpatchDataContainer* bphost = m_bPatches[n].get()->getHostDataPtr();
for (int i = 0; i < bphost->num_species; i++) {
tmppatchmfrFile << " " << bphost->speciesFlux[i];
}
}
tmppatchmfrFile << "\n";
@@ -524,8 +523,6 @@ PeleLM::initBPatches(Geometry& a_geom)
ParmParse pp(pele_prefix);
int num_bPatches = 0;
num_bPatches = pp.countval("patchnames");
// amrex::Print()<<"\nThere are "<<num_bPatches<<" boundary patches in the
// input file.\n";

Vector<std::string> bpatch_name;
if (num_bPatches > 0) {
@@ -536,6 +533,9 @@ PeleLM::initBPatches(Geometry& a_geom)
for (int n = 0; n < num_bPatches; ++n) {
pp.get("patchnames", bpatch_name[n], n);
m_bPatches[n] = std::make_unique<BPatch>(bpatch_name[n], a_geom);
if (m_verbose > 0) {
Print() << " Initializing boundary patch: " << bpatch_name[n] << std::endl;
}
}
}

@@ -557,6 +557,9 @@ PeleLM::addRhoYFluxesPatch(
#if (AMREX_SPACEDIM == 1)
area[0] = 1.0;
#elif (AMREX_SPACEDIM == 2)
if (geom[0].IsRZ() && m_bPatches.size() > 0) {
Abort("Bpatches not supported in RZ coordinates");
}
area[0] = dx[1];
area[1] = dx[0];
#else
@@ -570,15 +573,15 @@ PeleLM::addRhoYFluxesPatch(

BPatch* patch = m_bPatches[n].get();
BPatch::BpatchDataContainer const* bpdevice = patch->getDeviceData();

int idim = bpdevice->m_boundary_dir;
BPatch::BpatchDataContainer const* bphost = patch->getHostDataPtr();
const int idim = bphost->m_boundary_dir;

auto faceDomain =
amrex::convert(a_geom.Domain(), IntVect::TheDimensionVector(idim));
auto const& fma = a_fluxes[idim]->const_arrays();

// Loop through species specified by user
for (int m = 0; m < bpdevice->num_species; m++) {
for (int m = 0; m < bphost->num_species; m++) {

Real sum_species_flux_global = 0.0;

@@ -617,7 +620,7 @@ PeleLM::addRhoYFluxesPatch(

ParallelAllReduce::Sum<Real>(
{sum_species_flux_global}, ParallelContext::CommunicatorSub());
bpdevice->speciesFlux[m] = a_factor * sum_species_flux_global;
bphost->speciesFlux[m] = a_factor * sum_species_flux_global;
// amrex::Print()<<"\nNew func = "<<a_factor * sum_species_flux_global;
}
}

0 comments on commit 1e2bb80

Please sign in to comment.