Skip to content

Commit

Permalink
add more quantities to text output
Browse files Browse the repository at this point in the history
  • Loading branch information
atmyers committed Mar 26, 2024
1 parent 8671efa commit 791032a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/AgentContainer.H
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ public:

void generateCellData (amrex::MultiFab& mf) const;

std::array<amrex::Long, 5> printTotals ();
std::array<amrex::Long, 5> getTotals ();

const DiseaseParm * getDiseaseParameters_h () const {
return h_parm;
Expand Down
4 changes: 2 additions & 2 deletions src/AgentContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1387,8 +1387,8 @@ void AgentContainer::generateCellData (MultiFab& mf /*!< MultiFab with at least
Returns a vector with 5 components corresponding to each value of #Status; each element is
the total number of agents at a step with the corresponding #Status (in that order).
*/
std::array<Long, 5> AgentContainer::printTotals () {
BL_PROFILE("printTotals");
std::array<Long, 5> AgentContainer::getTotals () {
BL_PROFILE("getTotals");
amrex::ReduceOps<ReduceOpSum, ReduceOpSum, ReduceOpSum, ReduceOpSum, ReduceOpSum> reduce_ops;
auto r = amrex::ParticleReduce<ReduceData<int,int,int,int,int>> (
*this, [=] AMREX_GPU_DEVICE (const SuperParticleType& p) noexcept
Expand Down
26 changes: 22 additions & 4 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ void runAgent ()
amrex::FileOpenFailed(output_filename);
}

File << "Day Never Infected Immune Deaths\n";
File << "Day Never Infected Immune Deaths Hospitalized Ventilated ICU\n";

File.flush();

Expand Down Expand Up @@ -160,7 +160,7 @@ void runAgent ()
Long num_infected_peak = 0;
Long cumulative_deaths = 0;
{
auto counts = pc.printTotals();
auto counts = pc.getTotals();
if (counts[1] > num_infected_peak) {
num_infected_peak = counts[1];
step_of_peak = 0;
Expand Down Expand Up @@ -195,13 +195,31 @@ void runAgent ()
// }
// pc.Redistribute();

auto counts = pc.printTotals();
auto counts = pc.getTotals();
if (counts[1] > num_infected_peak) {
num_infected_peak = counts[1];
step_of_peak = i;
}
cumulative_deaths = counts[4];

auto const& ma = disease_stats.const_arrays();
GpuTuple<Real,Real,Real,Real> mm = ParReduce(
TypeList<ReduceOpSum,ReduceOpSum,ReduceOpSum,ReduceOpSum>{},
TypeList<Real,Real,Real,Real>{},
disease_stats, IntVect(0, 0),
[=] AMREX_GPU_DEVICE (int box_no, int i, int j, int k) noexcept
-> GpuTuple<Real,Real,Real,Real>
{
return { ma[box_no](i,j,k,0),
ma[box_no](i,j,k,1),
ma[box_no](i,j,k,2),
ma[box_no](i,j,k,3) };
});
std::array<Real, 4> mmc = {amrex::get<0>(mm), amrex::get<1>(mm), amrex::get<2>(mm), amrex::get<3>(mm)};

// total number of deaths computed on agents and on mesh should be the same...
AMREX_ALWAYS_ASSERT(mmc[3] == counts[4]);

if (ParallelDescriptor::IOProcessor())
{
std::ofstream File;
Expand All @@ -211,7 +229,7 @@ void runAgent ()
amrex::FileOpenFailed(output_filename);
}

File << i << " " << counts[0] << " " << counts[1] << " " << counts[2] << " " << counts[4] << "\n";
File << i << " " << counts[0] << " " << counts[1] << " " << counts[2] << " " << counts[4] << " " << mmc[0] << " " << mmc[1] << " " << mmc[2] << "\n";

File.flush();

Expand Down

0 comments on commit 791032a

Please sign in to comment.