From 3fb168fb9690e1c3d75f207c221e0decbb1a3284 Mon Sep 17 00:00:00 2001 From: shofmeyr Date: Wed, 6 Nov 2024 16:18:48 -1000 Subject: [PATCH] Made sure code is robust to having different precisions for ParticleReal and Real. --- UrbanPop-scripts/extract_urbanpop_feather.py | 2 +- src/AgentContainer.cpp | 54 ++++++++++++-------- src/CensusData.cpp | 8 +-- src/DiseaseParm.H | 20 +++++--- src/DiseaseStatus.H | 11 ++-- src/HospitalModel.H | 15 +++--- src/InteractionModHome.H | 10 ++-- src/InteractionModHomeNborhood.H | 8 +-- src/InteractionModSchool.H | 8 +-- src/InteractionModWork.H | 6 +-- src/InteractionModWorkNborhood.H | 6 +-- src/UrbanPopAgentStruct.H | 2 +- src/UrbanPopData.cpp | 15 ++++-- 13 files changed, 95 insertions(+), 70 deletions(-) diff --git a/UrbanPop-scripts/extract_urbanpop_feather.py b/UrbanPop-scripts/extract_urbanpop_feather.py index ab95644..cc472e5 100755 --- a/UrbanPop-scripts/extract_urbanpop_feather.py +++ b/UrbanPop-scripts/extract_urbanpop_feather.py @@ -153,7 +153,7 @@ def print_header(df): #include using std::string; -using float32_t = amrex::Real; +using float32_t = amrex::ParticleReal; namespace UrbanPop {{ diff --git a/src/AgentContainer.cpp b/src/AgentContainer.cpp index 27ed0cc..a1cb411 100644 --- a/src/AgentContainer.cpp +++ b/src/AgentContainer.cpp @@ -177,13 +177,13 @@ void AgentContainer::moveAgentsToWork () if (!inHospital(ip, ptd)) { ParticleType& p = pstruct[ip]; if (is_census) { // using census data - p.pos(0) = (work_i_ptr[ip] + 0.5_prt)*dx[0]; - p.pos(1) = (work_j_ptr[ip] + 0.5_prt)*dx[1]; + p.pos(0) = static_cast((work_i_ptr[ip] + 0.5_rt) * dx[0]); + p.pos(1) = static_cast((work_j_ptr[ip] + 0.5_rt) * dx[1]); } else { Real lng, lat; (*grid_to_lnglat_ptr)(work_i_ptr[ip], work_j_ptr[ip], lng, lat); - p.pos(0) = lng; - p.pos(1) = lat; + p.pos(0) = static_cast(lng); + p.pos(1) = static_cast(lat); } } }); @@ -234,13 +234,13 @@ void AgentContainer::moveAgentsToHome () if (!inHospital(ip, ptd)) { ParticleType& p = pstruct[ip]; if (is_census) { // using census data - p.pos(0) = (home_i_ptr[ip] + 0.5_prt) * dx[0]; - p.pos(1) = (home_j_ptr[ip] + 0.5_prt) * dx[1]; + p.pos(0) = static_cast((home_i_ptr[ip] + 0.5_rt) * dx[0]); + p.pos(1) = static_cast((home_j_ptr[ip] + 0.5_rt) * dx[1]); } else { Real lng, lat; (*grid_to_lnglat_ptr)(home_i_ptr[ip], home_j_ptr[ip], lng, lat); - p.pos(0) = lng; - p.pos(1) = lat; + p.pos(0) = static_cast(lng); + p.pos(1) = static_cast(lat); } } }); @@ -395,8 +395,8 @@ void AgentContainer::setAirTravel (const iMultiFab& unit_mf, AirTravelFlow& air, int unit = unit_arr(home_i_ptr[i], home_j_ptr[i], 0); int orgAirport= assigned_airport_ptr[unit]; int destAirport=-1; - float lowProb=0.0; - float random= amrex::Random(engine); + Real lowProb = 0.0_rt; + Real random = amrex::Random(engine); //choose a destination airport for the agent (number of airports is often small, so let's visit in sequential order) for(int idx= dest_airports_offset_ptr[orgAirport]; idx=0){ int destUnit=-1; - float random1= amrex::Random(engine); + Real random1= amrex::Random(engine); int low=arrivalUnits_offset_ptr[destAirport], high=arrivalUnits_offset_ptr[destAirport+1]; if(high-low<=16){ //this sequential algo. is very slow when we have to go through hundreds or thoudsands of units to select a destination @@ -480,13 +480,13 @@ void AgentContainer::returnRandomTravel () ParticleType& p = pstruct[i]; random_travel_ptr[i] = -1; if (is_census) { - p.pos(0) = (home_i_ptr[i] + 0.5_prt) * dx[0]; - p.pos(1) = (home_j_ptr[i] + 0.5_prt) * dx[1]; + p.pos(0) = static_cast((home_i_ptr[i] + 0.5_rt) * dx[0]); + p.pos(1) = static_cast((home_j_ptr[i] + 0.5_rt) * dx[1]); } else { Real lng, lat; (*grid_to_lnglat_ptr)(home_i_ptr[i], home_j_ptr[i], lng, lat); - p.pos(0) = lng; - p.pos(1) = lat; + p.pos(0) = static_cast(lng); + p.pos(1) = static_cast(lat); } } }); @@ -508,6 +508,9 @@ void AgentContainer::returnAirTravel () auto& plev = GetParticles(lev); const auto dx = Geom(lev).CellSizeArray(); + bool is_census = (ic_type == ExaEpi::ICType::Census); + auto grid_to_lnglat_ptr = &grid_to_lnglat; + #ifdef AMREX_USE_OMP #pragma omp parallel if (Gpu::notInLaunchRegion()) #endif @@ -527,8 +530,15 @@ void AgentContainer::returnAirTravel () if (air_travel_ptr[i] >= 0) { ParticleType& p = pstruct[i]; air_travel_ptr[i] = -1; - p.pos(0) = (home_i_ptr[i] + 0.5_prt) * dx[0]; - p.pos(1) = (home_j_ptr[i] + 0.5_prt) * dx[1]; + if (is_census) { // using census data + p.pos(0) = static_cast((home_i_ptr[i] + 0.5_rt) * dx[0]); + p.pos(1) = static_cast((home_j_ptr[i] + 0.5_rt) * dx[1]); + } else { + Real lng, lat; + (*grid_to_lnglat_ptr)(home_i_ptr[i], home_j_ptr[i], lng, lat); + p.pos(0) = static_cast(lng); + p.pos(1) = static_cast(lat); + } } }); } @@ -577,13 +587,13 @@ void AgentContainer::updateStatus ( MFPtrVec& a_disease_stats /*!< Community-wis if (inHospital(ip, ptd)) { ParticleType& p = pstruct[ip]; if (is_census) { - p.pos(0) = (hosp_i_ptr[ip] + 0.5_prt) * dx[0]; - p.pos(1) = (hosp_j_ptr[ip] + 0.5_prt) * dx[1]; + p.pos(0) = static_cast((hosp_i_ptr[ip] + 0.5_prt) * dx[0]); + p.pos(1) = static_cast((hosp_j_ptr[ip] + 0.5_prt) * dx[1]); } else { Real lng, lat; (*grid_to_lnglat_ptr)(hosp_i_ptr[ip], hosp_j_ptr[ip], lng, lat); - p.pos(0) = lng; - p.pos(1) = lat; + p.pos(0) = static_cast(lng); + p.pos(1) = static_cast(lat); } } }); @@ -700,7 +710,7 @@ void AgentContainer::infectAgents () amrex::ParallelForRNG( np, [=] AMREX_GPU_DEVICE (int i, amrex::RandomEngine const& engine) noexcept { - prob_ptr[i] = 1.0_rt - prob_ptr[i]; + prob_ptr[i] = 1.0_prt - prob_ptr[i]; if ( status_ptr[i] == Status::never || status_ptr[i] == Status::susceptible ) { if (amrex::Random(engine) < prob_ptr[i]) { diff --git a/src/CensusData.cpp b/src/CensusData.cpp index 193e125..c24f99c 100644 --- a/src/CensusData.cpp +++ b/src/CensusData.cpp @@ -425,15 +425,15 @@ void CensusData::initAgents (AgentContainer& pc, /*!< Agents */ } } - agent.pos(0) = (i + 0.5_rt)*dx[0]; - agent.pos(1) = (j + 0.5_rt)*dx[1]; + agent.pos(0) = static_cast((i + 0.5_rt) * dx[0]); + agent.pos(1) = static_cast((j + 0.5_rt) * dx[1]); agent.id() = pid+ip; agent.cpu() = my_proc; for (int d = 0; d < n_disease; d++) { status_ptrs[d][ip] = 0; - counter_ptrs[d][ip] = 0.0_rt; - timer_ptrs[d][ip] = 0.0_rt; + counter_ptrs[d][ip] = 0.0_prt; + timer_ptrs[d][ip] = 0.0_prt; } age_group_ptr[ip] = age_group; family_ptr[ip] = family_id_start + (ii / family_size); diff --git a/src/DiseaseParm.H b/src/DiseaseParm.H index ff34fb1..de0a46b 100644 --- a/src/DiseaseParm.H +++ b/src/DiseaseParm.H @@ -12,6 +12,7 @@ #include "AgentDefinitions.H" using amrex::Real; +using amrex::ParticleReal; using amrex::Vector; struct CaseTypes @@ -160,18 +161,21 @@ struct DiseaseParm /*! \brief Set this agent to infected status, and initialize disease periods. */ AMREX_GPU_DEVICE AMREX_FORCE_INLINE void setInfected ( int* status, - amrex::Real* counter, - amrex::Real* latent_period, - amrex::Real* infectious_period, - amrex::Real* incubation_period, + amrex::ParticleReal* counter, + amrex::ParticleReal* latent_period, + amrex::ParticleReal* infectious_period, + amrex::ParticleReal* incubation_period, amrex::RandomEngine const& engine, const DiseaseParm* lparm) { *status = Status::infected; - *counter = amrex::Real(0); - *latent_period = amrex::RandomNormal(lparm->latent_length_mean, lparm->latent_length_std, engine); - *infectious_period = amrex::RandomNormal(lparm->infectious_length_mean, lparm->infectious_length_std, engine); - *incubation_period = amrex::RandomNormal(lparm->incubation_length_mean, lparm->incubation_length_std, engine); + *counter = ParticleReal(0); + *latent_period = + static_cast(amrex::RandomNormal(lparm->latent_length_mean, lparm->latent_length_std, engine)); + *infectious_period = + static_cast(amrex::RandomNormal(lparm->infectious_length_mean, lparm->infectious_length_std, engine)); + *incubation_period = + static_cast(amrex::RandomNormal(lparm->incubation_length_mean, lparm->incubation_length_std, engine)); if (*latent_period < 0) { *latent_period = amrex::Real(0);} if (*infectious_period < 0) { *infectious_period = amrex::Real(0);} if (*incubation_period < 0) { *incubation_period = amrex::Real(0);} diff --git a/src/DiseaseStatus.H b/src/DiseaseStatus.H index c90870d..3ec87f8 100644 --- a/src/DiseaseStatus.H +++ b/src/DiseaseStatus.H @@ -146,10 +146,10 @@ void DiseaseStatus::updateAgents(AC& a_agents, /*!< Agent contain return; } else if (status_ptr[i] == Status::immune) { - counter_ptr[i] -= 1.0_rt; - if (counter_ptr[i] < 0.0_rt) { - counter_ptr[i] = 0.0_rt; - timer_ptr[i] = 0.0_rt; + counter_ptr[i] -= 1.0_prt; + if (counter_ptr[i] < 0.0_prt) { + counter_ptr[i] = 0.0_prt; + timer_ptr[i] = 0.0_prt; status_ptr[i] = Status::susceptible; return; } @@ -188,7 +188,8 @@ void DiseaseStatus::updateAgents(AC& a_agents, /*!< Agent contain else if (!inHospital(i,ptd)) { if (counter_ptr[i] >= (latent_period_ptr[i] + infectious_period_ptr[i])) { status_ptr[i] = Status::immune; - counter_ptr[i] = RandomNormal(immune_length_mean, immune_length_std, engine); + counter_ptr[i] = + static_cast(RandomNormal(immune_length_mean, immune_length_std, engine)); symptomatic_ptr[i] = SymptomStatus::presymptomatic; withdrawn_ptr[i] = 0; } diff --git a/src/HospitalModel.H b/src/HospitalModel.H index 6098073..1bdf049 100644 --- a/src/HospitalModel.H +++ b/src/HospitalModel.H @@ -149,7 +149,7 @@ void HospitalModel::treatAgents(PCType& a_agents, /*!< A AMREX_ALWAYS_ASSERT(status_ptrs[d][i] == Status::infected); // decrement days in hospital - timer_ptrs[d][i] -= 1.0_rt; + timer_ptrs[d][i] -= 1.0_prt; if (timer_ptrs[d][i] == 0) { // finished hospitalization period flag_status_ptr[i] = DiseaseStats::hospitalization + 1; @@ -169,10 +169,11 @@ void HospitalModel::treatAgents(PCType& a_agents, /*!< A } else { // If alive, hospitalized patient recovers status_ptrs[d][i] = Status::immune; - counter_ptrs[d][i] = RandomNormal(immune_length_mean, immune_length_std, engine); + counter_ptrs[d][i] = + static_cast(RandomNormal(immune_length_mean, immune_length_std, engine)); symptomatic_ptrs[d][i] = SymptomStatus::presymptomatic; withdrawn_ptr[i] = 0; - timer_ptrs[d][i] = 0.0_rt; + timer_ptrs[d][i] = 0.0_prt; } } }); @@ -207,13 +208,13 @@ void HospitalModel::treatAgents(PCType& a_agents, /*!< A withdrawn_ptr[i] = 0; PType& p = pstruct[i]; if (is_census) { - p.pos(0) = (home_i_ptr[i] + 0.5_prt) * dx[0]; - p.pos(1) = (home_j_ptr[i] + 0.5_prt) * dx[1]; + p.pos(0) = static_cast((home_i_ptr[i] + 0.5_rt) * dx[0]); + p.pos(1) = static_cast((home_j_ptr[i] + 0.5_rt) * dx[1]); } else { Real lng, lat; (*grid_to_lnglat_ptr)(home_i_ptr[i], home_j_ptr[i], lng, lat); - p.pos(0) = lng; - p.pos(1) = lat; + p.pos(0) = static_cast(lng); + p.pos(1) = static_cast(lat); } } } diff --git a/src/InteractionModHome.H b/src/InteractionModHome.H index 1800d87..f82a677 100644 --- a/src/InteractionModHome.H +++ b/src/InteractionModHome.H @@ -155,7 +155,7 @@ void InteractionModHome::fastInteractHome (PCType& agent auto prob_ptr = soa.GetRealData(RealIdx::nattribs + r0(d) + RealIdxDisease::prob).data(); auto lparm = agents.getDiseaseParameters_d(d); auto lparm_h = agents.getDiseaseParameters_h(d); - Real scale = 1.0_prt; // TODO this should vary based on cell + Real scale = 1.0_rt; // TODO this should vary based on cell Real infect = (1.0_rt - lparm_h->vac_eff); // loop to count infectious agents in each group ParallelFor(np, [=] AMREX_GPU_DEVICE (int i) noexcept { @@ -179,8 +179,8 @@ void InteractionModHome::fastInteractHome (PCType& agent // and in neighborhood cluster, adjust the infected counts to avoid double-counting the overlap. ParallelFor(np, [=] AMREX_GPU_DEVICE (int i) noexcept { if (isSusceptible(i, ptd, d) && isHomeCandidate(i, ptd)) { - ParticleReal xmit_family_prob = 0; - ParticleReal xmit_nc_prob = 0; + Real xmit_family_prob = 0; + Real xmit_nc_prob = 0; if (adults) { xmit_family_prob = lparm->xmit_hh_adult[ptd.m_idata[IntIdx::age_group][i]]; xmit_nc_prob = lparm->xmit_nc_adult[ptd.m_idata[IntIdx::age_group][i]]; @@ -192,7 +192,7 @@ void InteractionModHome::fastInteractHome (PCType& agent AMREX_ALWAYS_ASSERT(community <= max_communities); int family_i = community * max_family + family_ptr[i]; int num_infected_family = infected_family_d_ptr[family_i]; - ParticleReal family_prob = 1.0_prt - infect * xmit_family_prob * scale; + Real family_prob = 1.0_rt - infect * xmit_family_prob * scale; prob_ptr[i] *= static_cast(std::pow(family_prob, num_infected_family)); if (!ptd.m_idata[IntIdx::withdrawn][i]) { int num_infected_family_not_withdrawn = infected_family_not_withdrawn_d_ptr[family_i]; @@ -201,7 +201,7 @@ void InteractionModHome::fastInteractHome (PCType& agent int nc = (community * max_nborhood + nborhood_ptr[i]) * num_ncs + cluster; int num_infected_nc = infected_nc_d_ptr[nc] - num_infected_family_not_withdrawn; AMREX_ALWAYS_ASSERT(num_infected_nc >= 0); - ParticleReal nc_prob = 1.0_prt - infect * xmit_nc_prob * scale; + Real nc_prob = 1.0_rt - infect * xmit_nc_prob * scale; prob_ptr[i] *= static_cast(std::pow(nc_prob, num_infected_nc)); } } diff --git a/src/InteractionModHomeNborhood.H b/src/InteractionModHomeNborhood.H index c8994b4..1cdcc36 100644 --- a/src/InteractionModHomeNborhood.H +++ b/src/InteractionModHomeNborhood.H @@ -132,8 +132,8 @@ void InteractionModHomeNborhood::fastInteractHomeNborhoo auto prob_ptr = soa.GetRealData(RealIdx::nattribs + r0(d) + RealIdxDisease::prob).data(); auto lparm = agents.getDiseaseParameters_d(d); auto lparm_h = agents.getDiseaseParameters_h(d); - Real scale = 1.0_prt; // TODO this should vary based on cell - Real infect = (1.0_rt - lparm_h->vac_eff); + Real scale = 1.0_rt; // TODO this should vary based on cell + Real infect = 1.0_rt - lparm_h->vac_eff; ParallelFor(np, [=] AMREX_GPU_DEVICE (int i) noexcept { if (isInfectious(i, ptd, d) && isCandidate(i, ptd)) { @@ -152,9 +152,9 @@ void InteractionModHomeNborhood::fastInteractHomeNborhoo int num_infected_nborhood = infected_nborhood_d_ptr[community * max_nborhood + nborhood]; int num_infected_community = infected_community_d_ptr[community]; AMREX_ALWAYS_ASSERT(num_infected_community >= num_infected_nborhood); - ParticleReal comm_prob = 1.0_prt - infect * lparm->xmit_comm[ptd.m_idata[IntIdx::age_group][i]] * scale; + Real comm_prob = 1.0_prt - infect * lparm->xmit_comm[ptd.m_idata[IntIdx::age_group][i]] * scale; prob_ptr[i] *= static_cast(std::pow(comm_prob, num_infected_community - num_infected_nborhood)); - ParticleReal nborhood_prob = 1.0_prt - infect * lparm->xmit_hood[ptd.m_idata[IntIdx::age_group][i]] * scale; + Real nborhood_prob = 1.0_prt - infect * lparm->xmit_hood[ptd.m_idata[IntIdx::age_group][i]] * scale; prob_ptr[i] *= static_cast(std::pow(nborhood_prob, num_infected_nborhood)); } }); diff --git a/src/InteractionModSchool.H b/src/InteractionModSchool.H index ac20691..a148fa5 100644 --- a/src/InteractionModSchool.H +++ b/src/InteractionModSchool.H @@ -157,7 +157,7 @@ void InteractionModSchool::fastInteractSchool (PCType& a auto prob_ptr = soa.GetRealData(RealIdx::nattribs + r0(d) + RealIdxDisease::prob).data(); auto lparm = agents.getDiseaseParameters_d(d); auto lparm_h = agents.getDiseaseParameters_h(d); - Real scale = 1.0_prt; // TODO this should vary based on cell + Real scale = 1.0_rt; // TODO this should vary based on cell Real infect = (1.0_rt - lparm_h->vac_eff); ParallelFor(np, [=] AMREX_GPU_DEVICE (int i) noexcept { @@ -179,11 +179,11 @@ void InteractionModSchool::fastInteractSchool (PCType& a int pos = (community * max_school_id + school_id_ptr[i]) * max_school_grade + school_grade_ptr[i]; if (getSchoolType(school_grade_ptr[i]) == SchoolType::day_care) { int num_infected_daycare = infected_daycare_d_ptr[pos]; - ParticleReal daycare_prob = 1.0_prt - infect * lparm->xmit_school[SchoolType::day_care] * scale; + Real daycare_prob = 1.0_rt - infect * lparm->xmit_school[SchoolType::day_care] * scale; prob_ptr[i] *= static_cast(std::pow(daycare_prob, num_infected_daycare)); } else { int num_infected_school = infected_school_d_ptr[pos]; - ParticleReal xmit = 0; + Real xmit = 0.0_rt; if (adults) { // transmitters are adults if (age_group_ptr[i] <= AgeGroups::a5to17) { // Adult teacher/staff -> child student xmit = lparm->xmit_school_a2c[getSchoolType(school_grade_ptr[i])]; @@ -197,7 +197,7 @@ void InteractionModSchool::fastInteractSchool (PCType& a xmit = lparm->xmit_school_c2a[getSchoolType(school_grade_ptr[i])]; } } - ParticleReal school_prob = 1.0_prt - infect * xmit * scale; + Real school_prob = 1.0_rt - infect * xmit * scale; prob_ptr[i] *= static_cast(std::pow(school_prob, num_infected_school)); } } diff --git a/src/InteractionModWork.H b/src/InteractionModWork.H index 61762e2..39857ba 100644 --- a/src/InteractionModWork.H +++ b/src/InteractionModWork.H @@ -140,8 +140,8 @@ void InteractionModWork::fastInteractWork (PCType& agent auto prob_ptr = soa.GetRealData(RealIdx::nattribs + r0(d) + RealIdxDisease::prob).data(); auto lparm = agents.getDiseaseParameters_d(d); auto lparm_h = agents.getDiseaseParameters_h(d); - Real scale = 1.0_prt; // TODO this should vary based on cell - Real infect = (1.0_rt - lparm_h->vac_eff); + Real scale = 1.0_rt; // TODO this should vary based on cell + Real infect = 1.0_rt - lparm_h->vac_eff; ParallelFor(np, [=] AMREX_GPU_DEVICE (int i) noexcept { if (isInfectious(i, ptd, d) && isCandidate(i, ptd)) { @@ -157,7 +157,7 @@ void InteractionModWork::fastInteractWork (PCType& agent auto community = getCommunityIndex(ptd, i); int wgroup_i = (community * max_workgroup + workgroup_ptr[i]) * max_naics + naics_ptr[i]; int num_infected_workgroup = infected_workgroup_d_ptr[wgroup_i]; - ParticleReal workgroup_prob = 1.0_prt - infect * lparm->xmit_work * scale; + Real workgroup_prob = 1.0_prt - infect * lparm->xmit_work * scale; prob_ptr[i] *= static_cast(std::pow(workgroup_prob, num_infected_workgroup)); } }); diff --git a/src/InteractionModWorkNborhood.H b/src/InteractionModWorkNborhood.H index 35a7d55..a59bc99 100644 --- a/src/InteractionModWorkNborhood.H +++ b/src/InteractionModWorkNborhood.H @@ -135,7 +135,7 @@ void InteractionModWorkNborhood::fastInteractWorkNborhoo auto prob_ptr = soa.GetRealData(RealIdx::nattribs + r0(d) + RealIdxDisease::prob).data(); auto lparm = agents.getDiseaseParameters_d(d); auto lparm_h = agents.getDiseaseParameters_h(d); - Real scale = 1.0_prt; // TODO this should vary based on cell + Real scale = 1.0_rt; // TODO this should vary based on cell Real infect = (1.0_rt - lparm_h->vac_eff); ParallelFor(np, [=] AMREX_GPU_DEVICE (int i) noexcept { @@ -157,9 +157,9 @@ void InteractionModWorkNborhood::fastInteractWorkNborhoo int num_infected_nborhood = infected_nborhood_d_ptr[community * max_nborhood + nborhood]; int num_infected_community = infected_community_d_ptr[community]; AMREX_ALWAYS_ASSERT(num_infected_community >= num_infected_nborhood); - ParticleReal comm_prob = 1.0_prt - infect * lparm->xmit_comm[ptd.m_idata[IntIdx::age_group][i]] * scale; + Real comm_prob = 1.0_rt - infect * lparm->xmit_comm[ptd.m_idata[IntIdx::age_group][i]] * scale; prob_ptr[i] *= static_cast(std::pow(comm_prob, num_infected_community - num_infected_nborhood)); - ParticleReal nborhood_prob = 1.0_prt - infect * lparm->xmit_hood[ptd.m_idata[IntIdx::age_group][i]] * scale; + Real nborhood_prob = 1.0_rt - infect * lparm->xmit_hood[ptd.m_idata[IntIdx::age_group][i]] * scale; prob_ptr[i] *= static_cast(std::pow(nborhood_prob, num_infected_nborhood)); } }); diff --git a/src/UrbanPopAgentStruct.H b/src/UrbanPopAgentStruct.H index 95146c5..a96b9a5 100644 --- a/src/UrbanPopAgentStruct.H +++ b/src/UrbanPopAgentStruct.H @@ -12,7 +12,7 @@ #include using std::string; -using float32_t = amrex::Real; +using float32_t = amrex::ParticleReal; namespace UrbanPop { diff --git a/src/UrbanPopData.cpp b/src/UrbanPopData.cpp index 1fd613d..2488a2e 100644 --- a/src/UrbanPopData.cpp +++ b/src/UrbanPopData.cpp @@ -67,14 +67,20 @@ bool BlockGroup::read_agents(ifstream &f, Vector &agents, Vector< Abort("File is corrupted: wrong geoid, read " + to_string(agent.home_geoid) + " expected " + to_string(geoid) + "\n"); int home_x, home_y; lnglat_to_grid(agent.home_lng, agent.home_lat, home_x, home_y); - grid_to_lnglat(home_x, home_y, agent.home_lng, agent.home_lat); + Real home_lng, home_lat; + grid_to_lnglat(home_x, home_y, home_lng, home_lat); + agent.home_lng = static_cast(home_lng); + agent.home_lat = static_cast(home_lat); AMREX_ASSERT(home_x == x && home_y == y); AMREX_ASSERT(agent.home_lng == lng && agent.home_lat == lat); AMREX_ASSERT(agent.work_lat != -1 && agent.work_lng != -1); households.insert(agent.household_id); int work_x, work_y; lnglat_to_grid(agent.work_lng, agent.work_lat, work_x, work_y); - grid_to_lnglat(work_x, work_y, agent.work_lng, agent.work_lat); + Real work_lng, work_lat; + grid_to_lnglat(work_x, work_y, work_lng, work_lat); + agent.work_lng = static_cast(work_lng); + agent.work_lat = static_cast(work_lat); if (agent.role == ROLE::worker && agent.naics != NAICS::wfh) { num_employed++; auto it = xy_to_block_groups.find(IntVect(work_x, work_y)); @@ -452,7 +458,10 @@ void UrbanPopData::initAgents (AgentContainer &pc, const ExaEpi::TestParams &par else age_group_ptr[i] = AgeGroups::o65; family_ptr[i] = agent.household_id; lnglat_to_grid(agent.work_lng, agent.work_lat, work_i_ptr[i], work_j_ptr[i]); - grid_to_lnglat(work_i_ptr[i], work_j_ptr[i], agent.work_lng, agent.work_lat); + Real work_lng, work_lat; + grid_to_lnglat(work_i_ptr[i], work_j_ptr[i], work_lng, work_lat); + agent.work_lng = static_cast(work_lng); + agent.work_lat = static_cast(work_lat); int max_nborhood = group_home_populations_ptr[i] / nborhood_size + 1; nborhood_ptr[i] = Random_int(max_nborhood, engine) + 1; school_grade_ptr[i] = agent.grade;