17
17
18
18
using namespace amrex ;
19
19
20
+ /* ! \brief One-on-one interaction between an infectious agent and a susceptible agent.
21
+ *
22
+ * This function defines the one-on-one interaction between an infectious agent and a
23
+ * susceptible agent in a neighborhood. */
24
+ AMREX_GPU_DEVICE AMREX_FORCE_INLINE
25
+ static void binaryInteractionNborhood ( const int a_i, /* !< Index of infectious agent */
26
+ const int a_j, /* !< Index of susceptible agent */
27
+ const DiseaseParm* const a_lparm, /* !< disease paramters */
28
+ const Real a_social_scale, /* !< Social scale */
29
+ const int * const a_age_group_ptr, /* !< age group */
30
+ const int * const a_family_ptr, /* !< family */
31
+ const int * const a_nborhood_ptr, /* !< neighborhood */
32
+ const int * const a_school_ptr, /* !< school */
33
+ ParticleReal* const a_prob_ptr /* !< infection probability */ )
34
+ {
35
+ Real infect = a_lparm->infect ;
36
+ infect *= a_lparm->vac_eff ;
37
+ // infect *= i_mask;
38
+ // infect *= j_mask;
39
+ auto prob = a_prob_ptr[a_j];
40
+
41
+ /* check for common neighborhood cluster: */
42
+ if ( (a_nborhood_ptr[a_i] == a_nborhood_ptr[a_j])
43
+ && ((a_family_ptr[a_i] / 4 ) == (a_family_ptr[a_j] / 4 )) ) {
44
+ if (a_age_group_ptr[a_i] <= 1 ) { /* Transmitter i is a child */
45
+ if (a_school_ptr[a_i] < 0 ) // not attending school, use _SC contacts
46
+ prob *= 1.0 - infect * a_lparm->xmit_nc_child_SC [a_age_group_ptr[a_j]] * a_social_scale;
47
+ else
48
+ prob *= 1.0 - infect * a_lparm->xmit_nc_child [a_age_group_ptr[a_j]] * a_social_scale;
49
+ }
50
+ else {
51
+ if (a_school_ptr[a_i] < 0 ) // not attending school, use _SC contacts
52
+ prob *= 1.0 - infect * a_lparm->xmit_nc_adult_SC [a_age_group_ptr[a_j]] * a_social_scale;
53
+ else
54
+ prob *= 1.0 - infect * a_lparm->xmit_nc_adult [a_age_group_ptr[a_j]] * a_social_scale;
55
+ }
56
+ }
57
+
58
+ // school < 0 means a child normally attends school, but not today
59
+ /* Should always be in the same community = same cell */
60
+ if (a_school_ptr[a_i] < 0 ) { // not attending school, use _SC contacts
61
+ prob *= 1.0 - infect * a_lparm->xmit_comm_SC [a_age_group_ptr[a_j]] * a_social_scale;
62
+ } else {
63
+ prob *= 1.0 - infect * a_lparm->xmit_comm [a_age_group_ptr[a_j]] * a_social_scale;
64
+ }
65
+ // /* Neighborhood? */
66
+ if (a_nborhood_ptr[a_i] == a_nborhood_ptr[a_j]) {
67
+ if (a_school_ptr[a_i] < 0 ) {
68
+ // not attending school, use _SC contacts
69
+ prob *= 1.0 - infect * a_lparm->xmit_hood_SC [a_age_group_ptr[a_j]] * a_social_scale;
70
+ } else {
71
+ prob *= 1.0 - infect * a_lparm->xmit_hood [a_age_group_ptr[a_j]] * a_social_scale;
72
+ }
73
+ }
74
+
75
+ Gpu::Atomic::Multiply (&a_prob_ptr[a_j], prob);
76
+ }
77
+
20
78
/* ! \brief Class describing agent interactions at neighborhood */
21
79
template <typename ACType /* !< agent container type */ , typename AType /* !< agent type */ >
22
80
class InteractionLocNborhood : public InteractionLocation <ACType,AType>
@@ -136,6 +194,9 @@ void InteractionLocNborhood<ACType,AType>::interactAgents(ACType& a_agents, /
136
194
|| notSusceptible ( i, status_ptr ) ) {
137
195
return ;
138
196
}
197
+ if (withdrawn_ptr[i]) {
198
+ return ;
199
+ }
139
200
140
201
// Real i_mask = mask_arr(home_i_ptr[i], home_j_ptr[i], 0);
141
202
for (unsigned int jj = cell_start; jj < cell_stop; ++jj) {
@@ -147,112 +208,34 @@ void InteractionLocNborhood<ACType,AType>::interactAgents(ACType& a_agents, /
147
208
|| notSusceptible ( j, status_ptr ) ) {
148
209
continue ;
149
210
}
211
+ if (withdrawn_ptr[j]) {
212
+ continue ;
213
+ }
150
214
151
215
if ( isInfectious ( i, status_ptr,counter_ptr,lparm->incubation_length )
152
216
&& isSusceptible ( j, status_ptr ) ) {
153
217
154
- // i can infect j
155
- Real infect = lparm->infect ;
156
- infect *= lparm->vac_eff ;
157
- // infect *= i_mask;
158
- // infect *= j_mask;
159
-
160
218
Real social_scale = 1.0 ; // TODO this should vary based on cell
161
- auto prob = prob_ptr[j];
162
-
163
- /* check for common neighborhood cluster: */
164
- if ( (nborhood_ptr[i] == nborhood_ptr[j])
165
- && (!withdrawn_ptr[i]) && (!withdrawn_ptr[j])
166
- && ((family_ptr[i] / 4 ) == (family_ptr[j] / 4 )) ) {
167
- if (age_group_ptr[i] <= 1 ) { /* Transmitter i is a child */
168
- if (school_ptr[i] < 0 ) // not attending school, use _SC contacts
169
- prob *= 1.0 - infect * lparm->xmit_nc_child_SC [age_group_ptr[j]] * social_scale;
170
- else
171
- prob *= 1.0 - infect * lparm->xmit_nc_child [age_group_ptr[j]] * social_scale;
172
- }
173
- else {
174
- if (school_ptr[i] < 0 ) // not attending school, use _SC contacts
175
- prob *= 1.0 - infect * lparm->xmit_nc_adult_SC [age_group_ptr[j]] * social_scale;
176
- else
177
- prob *= 1.0 - infect * lparm->xmit_nc_adult [age_group_ptr[j]] * social_scale;
178
- }
179
- }
180
-
181
- // /* Home isolation or household quarantine? */
182
- if ( (!withdrawn_ptr[i]) && (!withdrawn_ptr[j]) ) {
183
- // school < 0 means a child normally attends school, but not today
184
- /* Should always be in the same community = same cell */
185
- if (school_ptr[i] < 0 ) { // not attending school, use _SC contacts
186
- prob *= 1.0 - infect * lparm->xmit_comm_SC [age_group_ptr[j]] * social_scale;
187
- } else {
188
- prob *= 1.0 - infect * lparm->xmit_comm [age_group_ptr[j]] * social_scale;
189
- }
190
- // /* Neighborhood? */
191
- if (nborhood_ptr[i] == nborhood_ptr[j]) {
192
- if (school_ptr[i] < 0 ) {
193
- // not attending school, use _SC contacts
194
- prob *= 1.0 - infect * lparm->xmit_hood_SC [age_group_ptr[j]] * social_scale;
195
- } else {
196
- prob *= 1.0 - infect * lparm->xmit_hood [age_group_ptr[j]] * social_scale;
197
- }
198
- }
199
- }
200
-
201
- Gpu::Atomic::Multiply (&prob_ptr[j], prob);
219
+ binaryInteractionNborhood ( i, j,
220
+ lparm, social_scale,
221
+ age_group_ptr,
222
+ family_ptr,
223
+ nborhood_ptr,
224
+ school_ptr,
225
+ prob_ptr );
202
226
203
227
} else if ( isInfectious ( j, status_ptr,counter_ptr,lparm->incubation_length )
204
228
&& isSusceptible ( i, status_ptr ) ) {
205
229
206
- // j can infect i
207
- Real infect = lparm->infect ;
208
- infect *= lparm->vac_eff ;
209
- // infect *= i_mask;
210
- // infect *= j_mask;
211
-
212
230
Real social_scale = 1.0 ; // TODO this should vary based on cell
213
- auto prob = prob_ptr[i];
214
-
215
- /* check for common neighborhood cluster: */
216
- if ( (nborhood_ptr[i] == nborhood_ptr[j])
217
- && (!withdrawn_ptr[i])
218
- && (!withdrawn_ptr[j])
219
- && ((family_ptr[i] / 4 ) == (family_ptr[j] / 4 )) ) {
220
- if (age_group_ptr[j] <= 1 ) { /* Transmitter i is a child */
221
- if (school_ptr[j] < 0 ) { // not attending school, use _SC contacts
222
- prob *= 1.0 - infect * lparm->xmit_nc_child_SC [age_group_ptr[i]] * social_scale;
223
- } else {
224
- prob *= 1.0 - infect * lparm->xmit_nc_child [age_group_ptr[i]] * social_scale;
225
- }
226
- } else {
227
- if (school_ptr[j] < 0 ) { // not attending school, use _SC contacts
228
- prob *= 1.0 - infect * lparm->xmit_nc_adult_SC [age_group_ptr[i]] * social_scale;
229
- } else {
230
- prob *= 1.0 - infect * lparm->xmit_nc_adult [age_group_ptr[i]] * social_scale;
231
- }
232
- }
233
- }
234
-
235
- /* Home isolation or household quarantine? */
236
- // TODO - be careful about withdrawn versus at home...
237
- if ( (!withdrawn_ptr[i]) && (!withdrawn_ptr[j]) ) {
238
- // school < 0 means a child normally attends school, but not today
239
- /* Should always be in the same community = same cell */
240
- if (school_ptr[j] < 0 ) { // not attending school, use _SC contacts
241
- prob *= 1.0 - infect * lparm->xmit_comm_SC [age_group_ptr[i]] * social_scale;
242
- } else {
243
- prob *= 1.0 - infect * lparm->xmit_comm [age_group_ptr[i]] * social_scale;
244
- }
245
- /* Neighborhood? */
246
- if (nborhood_ptr[i] == nborhood_ptr[j]) {
247
- if (school_ptr[j] < 0 ) { // not attending school, use _SC contacts
248
- prob *= 1.0 - infect * lparm->xmit_hood_SC [age_group_ptr[i]] * social_scale;
249
- } else {
250
- prob *= 1.0 - infect * lparm->xmit_hood [age_group_ptr[i]] * social_scale;
251
- }
252
- }
253
- }
254
-
255
- Gpu::Atomic::Multiply (&prob_ptr[i], prob);
231
+ binaryInteractionNborhood ( j, i,
232
+ lparm, social_scale,
233
+ age_group_ptr,
234
+ family_ptr,
235
+ nborhood_ptr,
236
+ school_ptr,
237
+ prob_ptr );
238
+
256
239
}
257
240
}
258
241
});
0 commit comments