Skip to content

Commit

Permalink
do not remove dead agents for now (need to recompute bins after doing…
Browse files Browse the repository at this point in the history
… this)
  • Loading branch information
atmyers committed Nov 21, 2023
1 parent 95978a3 commit 47a8984
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 19 deletions.
3 changes: 2 additions & 1 deletion src/AgentContainer.H
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ struct Status
never = 0, // never infected
infected, // infected
immune, // no longer infected, immune. lasts 6 months.
susceptible // no longer infected, no longer immnune
susceptible, // no longer infected, no longer immnune
dead
};
};

Expand Down
33 changes: 19 additions & 14 deletions src/AgentContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,8 @@ void AgentContainer::updateStatus (MultiFab& disease_stats)
amrex::Gpu::Atomic::AddNoRet(
&ds_arr(home_i_ptr[i], home_j_ptr[i], 0,
DiseaseStats::death), 1.0_rt);
pstruct_ptr[i].id() = -pstruct_ptr[i].id();
status_ptr[i] = Status::dead;
//pstruct_ptr[i].id() = -pstruct_ptr[i].id();
}
amrex::Gpu::Atomic::AddNoRet(
&ds_arr(home_i_ptr[i], home_j_ptr[i], 0,
Expand All @@ -784,7 +785,8 @@ void AgentContainer::updateStatus (MultiFab& disease_stats)
amrex::Gpu::Atomic::AddNoRet(
&ds_arr(home_i_ptr[i], home_j_ptr[i], 0,
DiseaseStats::death), 1.0_rt);
pstruct_ptr[i].id() = -pstruct_ptr[i].id();
status_ptr[i] = Status::dead;
//pstruct_ptr[i].id() = -pstruct_ptr[i].id();
}
amrex::Gpu::Atomic::AddNoRet(
&ds_arr(home_i_ptr[i], home_j_ptr[i], 0,
Expand All @@ -796,7 +798,8 @@ void AgentContainer::updateStatus (MultiFab& disease_stats)
amrex::Gpu::Atomic::AddNoRet(
&ds_arr(home_i_ptr[i], home_j_ptr[i], 0,
DiseaseStats::death), 1.0_rt);
pstruct_ptr[i].id() = -pstruct_ptr[i].id();
status_ptr[i] = Status::dead;
//pstruct_ptr[i].id() = -pstruct_ptr[i].id();
}
amrex::Gpu::Atomic::AddNoRet(
&ds_arr(home_i_ptr[i], home_j_ptr[i], 0,
Expand Down Expand Up @@ -966,9 +969,6 @@ void AgentContainer::interactAgentsHomeWork (MultiFab& mask_behavior, bool home)
auto work_i_ptr = soa.GetIntData(IntIdx::work_i).data();
auto work_j_ptr = soa.GetIntData(IntIdx::work_j).data();

auto i_ptr = home ? home_i_ptr : work_i_ptr;
auto j_ptr = home ? home_j_ptr : work_j_ptr;

auto mask_arr = mask_behavior[mfi].array();

//auto strain_ptr = soa.GetIntData(IntIdx::strain).data();
Expand All @@ -981,30 +981,33 @@ void AgentContainer::interactAgentsHomeWork (MultiFab& mask_behavior, bool home)
auto prob_ptr = soa.GetRealData(RealIdx::prob).data();
auto counter_ptr = soa.GetRealData(RealIdx::disease_counter).data();

AMREX_ALWAYS_ASSERT(np == bins_ptr->numItems());
auto* lparm = d_parm;
amrex::ParallelForRNG( bins_ptr->numItems(),
[=] AMREX_GPU_DEVICE (int ii, amrex::RandomEngine const& /*engine*/) noexcept
{
int i_cell = binner(pstruct_ptr[ii]);
auto i = inds[ii];
int i_cell = binner(pstruct_ptr[i]);
auto cell_start = offsets[i_cell];
auto cell_stop = offsets[i_cell+1];

auto i = inds[ii];
AMREX_ALWAYS_ASSERT(i < np);
if (status_ptr[i] == Status::immune) { return; }
if (status_ptr[i] == Status::infected && counter_ptr[i] < 3) { return; } // incubation stage
amrex::Real i_mask = mask_arr(i_ptr[i], j_ptr[i], 0);
//amrex::Real i_mask = mask_arr(home_i_ptr[i], home_j_ptr[i], 0);
for (unsigned int jj = cell_start; jj < cell_stop; ++jj) {
auto j = inds[jj];
amrex::Real j_mask = mask_arr(i_ptr[j], j_ptr[j], 0);
AMREX_ALWAYS_ASSERT(j < np);
//amrex::Real j_mask = mask_arr(home_i_ptr[j], home_j_ptr[j], 0);
if (status_ptr[j] == Status::immune) {continue;}
if (status_ptr[i] == Status::infected && counter_ptr[j] < 3) { continue; } // incubation stage

if (status_ptr[i] == Status::infected && status_ptr[j] != Status::infected) {
// i can infect j
amrex::Real infect = lparm->infect;
infect *= lparm->vac_eff;
infect *= i_mask;
infect *= j_mask;
//infect *= i_mask;
//infect *= j_mask;

amrex::Real social_scale = 1.0; // TODO this should vary based on cell
amrex::Real work_scale = 1.0; // TODO this should vary based on cell
Expand Down Expand Up @@ -1094,8 +1097,8 @@ void AgentContainer::interactAgentsHomeWork (MultiFab& mask_behavior, bool home)
// j can infect i
amrex::Real infect = lparm->infect;
infect *= lparm->vac_eff;
infect *= i_mask;
infect *= j_mask;
//infect *= i_mask;
//infect *= j_mask;

amrex::Real social_scale = 1.0; // TODO this should vary based on cell
amrex::Real work_scale = 1.0; // TODO this should vary based on cell
Expand Down Expand Up @@ -1236,6 +1239,8 @@ void AgentContainer::printTotals () {
-> amrex::GpuTuple<int,int,int,int>
{
int s[4] = {0, 0, 0, 0};
AMREX_ALWAYS_ASSERT(p.idata(IntIdx::status) >= 0);
AMREX_ALWAYS_ASSERT(p.idata(IntIdx::status) <= 3);
s[p.idata(IntIdx::status)] = 1;
return {s[0], s[1], s[2], s[3]};
}, reduce_ops);
Expand Down
2 changes: 1 addition & 1 deletion src/Initialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ namespace Initialization
auto cell_stop = offsets[i_cell+1];
int num_this_community = cell_stop - cell_start;
AMREX_ASSERT(num_this_community > 0);
AMREX_ASSERT(cell_stop < np);
//AMREX_ASSERT(cell_stop < np);

if (num_this_community == 0) { return;}

Expand Down
6 changes: 3 additions & 3 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ void runAgent ()

pc.infectAgents();

if ((params.random_travel_int > 0) && (i % params.random_travel_int == 0)) {
pc.moveRandomTravel();
}
// if ((params.random_travel_int > 0) && (i % params.random_travel_int == 0)) {
// pc.moveRandomTravel();
// }

pc.Redistribute();

Expand Down

0 comments on commit 47a8984

Please sign in to comment.