diff --git a/src/AgentContainer.cpp b/src/AgentContainer.cpp index a1aeb3f..8bf0d51 100644 --- a/src/AgentContainer.cpp +++ b/src/AgentContainer.cpp @@ -1227,20 +1227,22 @@ void AgentContainer::interactAgentsHomeWork ( MultiFab& /*mask_behavior*/ /*!< M 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 + auto prob = prob_ptr[j]; + /* Determine what connections these individuals have */ if ((nborhood_ptr[i] == nborhood_ptr[j]) && (family_ptr[i] == family_ptr[j]) && (!DAYTIME)) { if (age_group_ptr[i] <= 1) { /* Transmitter i is a child */ if (school_ptr[i] < 0) { // not attending school, use _SC contacts - prob_ptr[j] *= 1.0 - infect * lparm->xmit_child_SC[age_group_ptr[j]]; + prob *= 1.0 - infect * lparm->xmit_child_SC[age_group_ptr[j]]; } else { - prob_ptr[j] *= 1.0 - infect * lparm->xmit_child[age_group_ptr[j]]; + prob *= 1.0 - infect * lparm->xmit_child[age_group_ptr[j]]; } } else { if (school_ptr[i] < 0) { // not attending school, use _SC contacts - prob_ptr[j] *= 1.0 - infect * lparm->xmit_adult_SC[age_group_ptr[j]]; + prob *= 1.0 - infect * lparm->xmit_adult_SC[age_group_ptr[j]]; } else { - prob_ptr[j] *= 1.0 - infect * lparm->xmit_adult[age_group_ptr[j]]; + prob *= 1.0 - infect * lparm->xmit_adult[age_group_ptr[j]]; } } } @@ -1248,15 +1250,15 @@ void AgentContainer::interactAgentsHomeWork ( MultiFab& /*mask_behavior*/ /*!< M else if ((nborhood_ptr[i] == nborhood_ptr[j]) && (!withdrawn_ptr[i]) && (!withdrawn_ptr[j]) && (!DAYTIME)) { if (age_group_ptr[i] <= 1) { /* Transmitter i is a child */ if (school_ptr[i] < 0) // not attending school, use _SC contacts - prob_ptr[j] *= 1.0 - infect * lparm->xmit_nc_child_SC[age_group_ptr[j]] * social_scale; + prob *= 1.0 - infect * lparm->xmit_nc_child_SC[age_group_ptr[j]] * social_scale; else - prob_ptr[j] *= 1.0 - infect * lparm->xmit_nc_child[age_group_ptr[j]] * social_scale; + prob *= 1.0 - infect * lparm->xmit_nc_child[age_group_ptr[j]] * social_scale; } else { if (school_ptr[i] < 0) // not attending school, use _SC contacts - prob_ptr[j] *= 1.0 - infect * lparm->xmit_nc_adult_SC[age_group_ptr[j]] * social_scale; + prob *= 1.0 - infect * lparm->xmit_nc_adult_SC[age_group_ptr[j]] * social_scale; else - prob_ptr[j] *= 1.0 - infect * lparm->xmit_nc_adult[age_group_ptr[j]] * social_scale; + prob *= 1.0 - infect * lparm->xmit_nc_adult[age_group_ptr[j]] * social_scale; } } @@ -1265,31 +1267,31 @@ void AgentContainer::interactAgentsHomeWork ( MultiFab& /*mask_behavior*/ /*!< M /* Should always be in the same community = same cell */ if (school_ptr[i] < 0) // not attending school, use _SC contacts - prob_ptr[j] *= 1.0 - infect * lparm->xmit_comm_SC[age_group_ptr[j]] * social_scale; + prob *= 1.0 - infect * lparm->xmit_comm_SC[age_group_ptr[j]] * social_scale; else - prob_ptr[j] *= 1.0 - infect * lparm->xmit_comm[age_group_ptr[j]] * social_scale; + prob *= 1.0 - infect * lparm->xmit_comm[age_group_ptr[j]] * social_scale; /* Workgroup transmission */ if (DAYTIME && workgroup_ptr[i] && (work_i_ptr[i] >= 0)) { // transmitter i at work if ((work_i_ptr[j] >= 0) && (workgroup_ptr[i] == workgroup_ptr[j])) { // coworker - prob_ptr[j] *= 1.0 - infect * lparm->xmit_work * work_scale; + prob *= 1.0 - infect * lparm->xmit_work * work_scale; } } // /* Neighborhood? */ if (nborhood_ptr[i] == nborhood_ptr[j]) { if (school_ptr[i] < 0) // not attending school, use _SC contacts - prob_ptr[j] *= 1.0 - infect * lparm->xmit_hood_SC[age_group_ptr[j]] * social_scale; + prob *= 1.0 - infect * lparm->xmit_hood_SC[age_group_ptr[j]] * social_scale; else - prob_ptr[j] *= 1.0 - infect * lparm->xmit_hood[age_group_ptr[j]] * social_scale; + prob *= 1.0 - infect * lparm->xmit_hood[age_group_ptr[j]] * social_scale; if ((school_ptr[i] == school_ptr[j]) && DAYTIME) { if (school_ptr[i] > 5) { /* Playgroup */ - prob_ptr[j] *= 1.0 - infect * lparm->xmit_school[6] * social_scale; + prob *= 1.0 - infect * lparm->xmit_school[6] * social_scale; } else if (school_ptr[i] == 5) { /* Day care */ - prob_ptr[j] *= 1.0 - infect * lparm->xmit_school[5] * social_scale; + prob *= 1.0 - infect * lparm->xmit_school[5] * social_scale; } } } /* same neighborhood */ @@ -1299,15 +1301,16 @@ void AgentContainer::interactAgentsHomeWork ( MultiFab& /*mask_behavior*/ /*!< M (school_ptr[i] > 0) && (school_ptr[i] < 5)) { if (age_group_ptr[i] <= 1) { /* Transmitter i is a child */ if (age_group_ptr[j] <= 1) { /* Receiver j is a child */ - prob_ptr[j] *= 1.0 - infect * lparm->xmit_school[school_ptr[i]] * social_scale; + prob *= 1.0 - infect * lparm->xmit_school[school_ptr[i]] * social_scale; } else { // Child student -> adult teacher/staff transmission - prob_ptr[j] *= 1.0 - infect * lparm->xmit_sch_c2a[school_ptr[i]] * social_scale; + prob *= 1.0 - infect * lparm->xmit_sch_c2a[school_ptr[i]] * social_scale; } } else if (age_group_ptr[j] <= 1) { // Adult teacher/staff -> child student - prob_ptr[j] *= 1.0 - infect * lparm->xmit_sch_a2c[school_ptr[i]] * social_scale; + prob *= 1.0 - infect * lparm->xmit_sch_a2c[school_ptr[i]] * social_scale; } } } /* within society */ + Gpu::Atomic::Multiply(&prob_ptr[j], prob); } else if (status_ptr[j] == Status::infected && status_ptr[i] != Status::infected) { if (counter_ptr[j] < lparm->incubation_length) { continue; } // j can infect i @@ -1319,19 +1322,21 @@ void AgentContainer::interactAgentsHomeWork ( MultiFab& /*mask_behavior*/ /*!< M 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 + auto prob = prob_ptr[i]; + /* Determine what connections these individuals have */ if ((nborhood_ptr[i] == nborhood_ptr[j]) && (family_ptr[i] == family_ptr[j]) && (! DAYTIME)) { if (age_group_ptr[j] <= 1) { /* Transmitter j is a child */ if (school_ptr[j] < 0) { // not attending school, use _SC contacts - prob_ptr[i] *= 1.0 - infect * lparm->xmit_child_SC[age_group_ptr[i]]; + prob *= 1.0 - infect * lparm->xmit_child_SC[age_group_ptr[i]]; } else { - prob_ptr[i] *= 1.0 - infect * lparm->xmit_child[age_group_ptr[i]]; + prob *= 1.0 - infect * lparm->xmit_child[age_group_ptr[i]]; } } else { if (school_ptr[j] < 0) { // not attending school, use _SC contacts - prob_ptr[i] *= 1.0 - infect * lparm->xmit_adult_SC[age_group_ptr[i]]; + prob *= 1.0 - infect * lparm->xmit_adult_SC[age_group_ptr[i]]; } else { - prob_ptr[i] *= 1.0 - infect * lparm->xmit_adult[age_group_ptr[i]]; + prob *= 1.0 - infect * lparm->xmit_adult[age_group_ptr[i]]; } } } @@ -1340,15 +1345,15 @@ void AgentContainer::interactAgentsHomeWork ( MultiFab& /*mask_behavior*/ /*!< M else if ((nborhood_ptr[i] == nborhood_ptr[j]) && (!withdrawn_ptr[i]) && (!withdrawn_ptr[j]) && (!DAYTIME)) { if (age_group_ptr[j] <= 1) { /* Transmitter i is a child */ if (school_ptr[j] < 0) { // not attending school, use _SC contacts - prob_ptr[i] *= 1.0 - infect * lparm->xmit_nc_child_SC[age_group_ptr[i]] * social_scale; + prob *= 1.0 - infect * lparm->xmit_nc_child_SC[age_group_ptr[i]] * social_scale; } else { - prob_ptr[i] *= 1.0 - infect * lparm->xmit_nc_child[age_group_ptr[i]] * social_scale; + prob *= 1.0 - infect * lparm->xmit_nc_child[age_group_ptr[i]] * social_scale; } } else { if (school_ptr[j] < 0) { // not attending school, use _SC contacts - prob_ptr[i] *= 1.0 - infect * lparm->xmit_nc_adult_SC[age_group_ptr[i]] * social_scale; + prob *= 1.0 - infect * lparm->xmit_nc_adult_SC[age_group_ptr[i]] * social_scale; } else { - prob_ptr[i] *= 1.0 - infect * lparm->xmit_nc_adult[age_group_ptr[i]] * social_scale; + prob *= 1.0 - infect * lparm->xmit_nc_adult[age_group_ptr[i]] * social_scale; } } } @@ -1359,33 +1364,33 @@ void AgentContainer::interactAgentsHomeWork ( MultiFab& /*mask_behavior*/ /*!< M // school < 0 means a child normally attends school, but not today /* Should always be in the same community = same cell */ if (school_ptr[j] < 0) { // not attending school, use _SC contacts - prob_ptr[i] *= 1.0 - infect * lparm->xmit_comm_SC[age_group_ptr[i]] * social_scale; + prob *= 1.0 - infect * lparm->xmit_comm_SC[age_group_ptr[i]] * social_scale; } else { - prob_ptr[i] *= 1.0 - infect * lparm->xmit_comm[age_group_ptr[i]] * social_scale; + prob *= 1.0 - infect * lparm->xmit_comm[age_group_ptr[i]] * social_scale; } /* Workgroup transmission */ if (DAYTIME && workgroup_ptr[j] && (work_i_ptr[j] >= 0)) { // transmitter j at work if ((work_i_ptr[i] >= 0) && (workgroup_ptr[i] == workgroup_ptr[j])) { // coworker - prob_ptr[i] *= 1.0 - infect * lparm->xmit_work * work_scale; + prob *= 1.0 - infect * lparm->xmit_work * work_scale; } } /* Neighborhood? */ if (nborhood_ptr[i] == nborhood_ptr[j]) { if (school_ptr[j] < 0) { // not attending school, use _SC contacts - prob_ptr[i] *= 1.0 - infect * lparm->xmit_hood_SC[age_group_ptr[i]] * social_scale; + prob *= 1.0 - infect * lparm->xmit_hood_SC[age_group_ptr[i]] * social_scale; } else { - prob_ptr[i] *= 1.0 - infect * lparm->xmit_hood[age_group_ptr[i]] * social_scale; + prob *= 1.0 - infect * lparm->xmit_hood[age_group_ptr[i]] * social_scale; } if ((school_ptr[i] == school_ptr[j]) && DAYTIME) { if (school_ptr[i] > 5) { /* Playgroup */ - prob_ptr[i] *= 1.0 - infect * lparm->xmit_school[6] * social_scale; + prob *= 1.0 - infect * lparm->xmit_school[6] * social_scale; } else if (school_ptr[i] == 5) { /* Day care */ - prob_ptr[i] *= 1.0 - infect * lparm->xmit_school[5] * social_scale; + prob *= 1.0 - infect * lparm->xmit_school[5] * social_scale; } } } /* same neighborhood */ @@ -1395,15 +1400,16 @@ void AgentContainer::interactAgentsHomeWork ( MultiFab& /*mask_behavior*/ /*!< M (school_ptr[i] > 0) && (school_ptr[i] < 5)) { if (age_group_ptr[i] <= 1) { /* Receiver i is a child */ if (age_group_ptr[j] <= 1) { /* Transmitter j is a child */ - prob_ptr[i] *= 1.0 - infect * lparm->xmit_school[school_ptr[i]] * social_scale; + prob *= 1.0 - infect * lparm->xmit_school[school_ptr[i]] * social_scale; } else { // Adult teacher/staff -> child student transmission - prob_ptr[i] *= 1.0 - infect * lparm->xmit_sch_a2c[school_ptr[i]] * social_scale; + prob *= 1.0 - infect * lparm->xmit_sch_a2c[school_ptr[i]] * social_scale; } } else if (age_group_ptr[j] <= 1) { // Child student -> adult teacher/staff - prob_ptr[i] *= 1.0 - infect * lparm->xmit_sch_c2a[school_ptr[i]] * social_scale; + prob *= 1.0 - infect * lparm->xmit_sch_c2a[school_ptr[i]] * social_scale; } } } /* within society */ + Gpu::Atomic::Multiply(&prob_ptr[i], prob); } } });