1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
|
#if (AMREX_SPACEDIM == 3)
#define WRPX_PXR_GETEB_ENERGY_CONSERVING geteb3d_energy_conserving_generic
#define WRPX_PXR_CURRENT_DEPOSITION depose_jxjyjz_generic
#define WRPX_PXR_PUSH_BVEC pxrpush_em3d_bvec
#define WRPX_PXR_PUSH_BVEC_CKC pxrpush_em3d_bvec_ckc
#define WRPX_PXR_PUSH_EVEC_F pxrpush_em3d_evec_f
#define WRPX_PXR_PUSH_EVEC_F_CKC pxrpush_em3d_evec_f_ckc
#define WRPX_PXR_PUSH_EVEC pxrpush_em3d_evec
#elif (AMREX_SPACEDIM == 2)
#define WRPX_PXR_GETEB_ENERGY_CONSERVING geteb2dxz_energy_conserving_generic
#define WRPX_PXR_CURRENT_DEPOSITION depose_jxjyjz_generic_2d
#define WRPX_PXR_PUSH_BVEC pxrpush_em2d_bvec
#define WRPX_PXR_PUSH_BVEC_CKC pxrpush_em2d_bvec_ckc
#define WRPX_PXR_PUSH_EVEC_F pxrpush_em2d_evec_f
#define WRPX_PXR_PUSH_EVEC_F_CKC pxrpush_em2d_evec_f_ckc
#define WRPX_PXR_PUSH_EVEC pxrpush_em2d_evec
#endif
#define LVECT_CURRDEPO 8_c_long
#define LVECT_FIELDGATHE 64_c_long
! _________________________________________________________________
!
!> @brief
!> Module that contains subroutines to be called with AMReX
!> and that uses subroutines of Picsar
!>
!> @details
!> This avoids the use of interface with bind in the core of Picsar
!> This enables the use of integer in AMReX and Logical in Picsar
!> wihtout compatibility issue
!>
!> @author
!> Weiqun Zhang
!> Ann Almgren
!> Remi Lehe
!> Mathieu Lobet
!>
module warpx_to_pxr_module
! _________________________________________________________________
use iso_c_binding
use amrex_fort_module, only : amrex_real
implicit none
integer, parameter :: pxr_logical = 8
contains
! _________________________________________________________________
!>
!> @brief
!> Main subroutine for the field gathering process
!>
!> @param[in] np number of particles
!> @param[in] xp,yp,zp particle position arrays
!> @param[in] ex,ey,ez particle electric fields in each direction
!> @param[in] bx,by,bz particle magnetic fields in each direction
!> @param[in] ixyzmin tile grid minimum index
!> @param[in] xmin,ymin,zmin tile grid minimum position
!> @param[in] dx,dy,dz space discretization steps
!> @param[in] xyzmin grid minimum position
!> @param[in] dxyz space discretization steps
!> @param[in] nox,noy,noz interpolation order
!> @param[in] exg,eyg,ezg electric field grid arrays
!> @param[in] bxg,byg,bzg electric field grid arrays
!> @param[in] lvect vector length
!>
subroutine warpx_geteb_energy_conserving(np,xp,yp,zp, &
ex,ey,ez,bx,by,bz,ixyzmin,xmin,ymin,zmin,dx,dy,dz,nox,noy,noz, &
exg,exg_lo,exg_hi,eyg,eyg_lo,eyg_hi,ezg,ezg_lo,ezg_hi, &
bxg,bxg_lo,bxg_hi,byg,byg_lo,byg_hi,bzg,bzg_lo,bzg_hi, &
ll4symtry,l_lower_order_in_v, &
lvect,field_gathe_algo) &
bind(C, name="warpx_geteb_energy_conserving")
integer, intent(in) :: exg_lo(AMREX_SPACEDIM), eyg_lo(AMREX_SPACEDIM), ezg_lo(AMREX_SPACEDIM), &
bxg_lo(AMREX_SPACEDIM), byg_lo(AMREX_SPACEDIM), bzg_lo(AMREX_SPACEDIM)
integer, intent(in) :: exg_hi(AMREX_SPACEDIM), eyg_hi(AMREX_SPACEDIM), ezg_hi(AMREX_SPACEDIM), &
bxg_hi(AMREX_SPACEDIM), byg_hi(AMREX_SPACEDIM), bzg_hi(AMREX_SPACEDIM)
integer, intent(in) :: ixyzmin(AMREX_SPACEDIM)
real(amrex_real), intent(in) :: xmin,ymin,zmin,dx,dy,dz
integer(c_long), intent(in) :: field_gathe_algo
integer(c_long), intent(in) :: np,nox,noy,noz
integer(c_int), intent(in) :: ll4symtry,l_lower_order_in_v
integer(c_long),intent(in) :: lvect
real(amrex_real), intent(in), dimension(np) :: xp,yp,zp
real(amrex_real), intent(out), dimension(np) :: ex,ey,ez,bx,by,bz
real(amrex_real),intent(in):: exg(*), eyg(*), ezg(*), bxg(*), byg(*), bzg(*)
logical(pxr_logical) :: pxr_ll4symtry, pxr_l_lower_order_in_v
! Compute the number of valid cells and guard cells
integer(c_long) :: exg_nvalid(AMREX_SPACEDIM), eyg_nvalid(AMREX_SPACEDIM), ezg_nvalid(AMREX_SPACEDIM), &
bxg_nvalid(AMREX_SPACEDIM), byg_nvalid(AMREX_SPACEDIM), bzg_nvalid(AMREX_SPACEDIM), &
exg_nguards(AMREX_SPACEDIM), eyg_nguards(AMREX_SPACEDIM), ezg_nguards(AMREX_SPACEDIM), &
bxg_nguards(AMREX_SPACEDIM), byg_nguards(AMREX_SPACEDIM), bzg_nguards(AMREX_SPACEDIM)
pxr_ll4symtry = ll4symtry .eq. 1
pxr_l_lower_order_in_v = l_lower_order_in_v .eq. 1
exg_nguards = ixyzmin - exg_lo
eyg_nguards = ixyzmin - eyg_lo
ezg_nguards = ixyzmin - ezg_lo
bxg_nguards = ixyzmin - bxg_lo
byg_nguards = ixyzmin - byg_lo
bzg_nguards = ixyzmin - bzg_lo
exg_nvalid = exg_lo + exg_hi - 2_c_long*ixyzmin + 1_c_long
eyg_nvalid = eyg_lo + eyg_hi - 2_c_long*ixyzmin + 1_c_long
ezg_nvalid = ezg_lo + ezg_hi - 2_c_long*ixyzmin + 1_c_long
bxg_nvalid = bxg_lo + bxg_hi - 2_c_long*ixyzmin + 1_c_long
byg_nvalid = byg_lo + byg_hi - 2_c_long*ixyzmin + 1_c_long
bzg_nvalid = bzg_lo + bzg_hi - 2_c_long*ixyzmin + 1_c_long
CALL WRPX_PXR_GETEB_ENERGY_CONSERVING(np,xp,yp,zp, &
ex,ey,ez,bx,by,bz,xmin,ymin,zmin,dx,dy,dz,nox,noy,noz, &
exg,exg_nguards,exg_nvalid,&
eyg,eyg_nguards,eyg_nvalid,&
ezg,ezg_nguards,ezg_nvalid,&
bxg,bxg_nguards,bxg_nvalid,&
byg,byg_nguards,byg_nvalid,&
bzg,bzg_nguards,bzg_nvalid,&
pxr_ll4symtry, pxr_l_lower_order_in_v, &
lvect, field_gathe_algo )
end subroutine warpx_geteb_energy_conserving
! _________________________________________________________________
!>
!> @brief
!> Main subroutine for the charge deposition
!>
!> @details
!> This subroutines enable to controle the interpolation order
!> via the parameters nox,noy,noz and the type of algorithm via
!> the parameter charge_depo_algo
!
!> @param[inout] rho charge array
!> @param[in] np number of particles
!> @param[in] xp,yp,zp particle position arrays
!> @param[in] w particle weight arrays
!> @param[in] q particle species charge
!> @param[in] xmin,ymin,zmin tile grid minimum position
!> @param[in] dx,dy,dz space discretization steps
!> @param[in] nx,ny,nz number of cells
!> @param[in] nxguard,nyguard,nzguard number of guard cells
!> @param[in] nox,noy,noz interpolation order
!> @param[in] lvect vector length
!> @param[in] charge_depo_algo algorithm choice for the charge deposition
!>
subroutine warpx_charge_deposition(rho,np,xp,yp,zp,w,q,xmin,ymin,zmin,dx,dy,dz,nx,ny,nz,&
nxguard,nyguard,nzguard,nox,noy,noz,lvect,charge_depo_algo) &
bind(C, name="warpx_charge_deposition")
integer(c_long), intent(IN) :: np
integer(c_long), intent(IN) :: nx,ny,nz
integer(c_long), intent(IN) :: nxguard,nyguard,nzguard
integer(c_long), intent(IN) :: nox,noy,noz
real(amrex_real), intent(IN OUT) :: rho(*)
real(amrex_real), intent(IN) :: q
real(amrex_real), intent(IN) :: dx,dy,dz
real(amrex_real), intent(IN) :: xmin,ymin,zmin
real(amrex_real), intent(IN), dimension(np) :: xp,yp,zp,w
integer(c_long), intent(IN) :: lvect
integer(c_long), intent(IN) :: charge_depo_algo
! Dimension 3
#if (AMREX_SPACEDIM==3)
SELECT CASE(charge_depo_algo)
! Scalar classical charge deposition subroutines
CASE(1)
IF ((nox.eq.1).and.(noy.eq.1).and.(noz.eq.1)) THEN
CALL depose_rho_scalar_1_1_1(rho,np,xp,yp,zp,w,q,xmin,ymin,zmin,dx,dy,dz,nx,ny,nz,&
nxguard,nyguard,nzguard,lvect)
ELSE IF ((nox.eq.2).and.(noy.eq.2).and.(noz.eq.2)) THEN
CALL depose_rho_scalar_2_2_2(rho,np,xp,yp,zp,w,q,xmin,ymin,zmin,dx,dy,dz,nx,ny,nz,&
nxguard,nyguard,nzguard,lvect)
ELSE IF ((nox.eq.3).and.(noy.eq.3).and.(noz.eq.3)) THEN
CALL depose_rho_scalar_3_3_3(rho,np,xp,yp,zp,w,q,xmin,ymin,zmin,dx,dy,dz,nx,ny,nz,&
nxguard,nyguard,nzguard,lvect)
ELSE
CALL pxr_depose_rho_n(rho,np,xp,yp,zp,w,q,xmin,ymin,zmin,dx,dy,dz,nx,ny,nz,&
nxguard,nyguard,nzguard,nox,noy,noz, &
.TRUE._c_long,.FALSE._c_long)
ENDIF
! Optimized subroutines
CASE DEFAULT
IF ((nox.eq.1).and.(noy.eq.1).and.(noz.eq.1)) THEN
CALL depose_rho_vecHVv2_1_1_1(rho,np,xp,yp,zp,w,q,xmin,ymin,zmin,dx,dy,dz,nx,ny,nz,&
nxguard,nyguard,nzguard,lvect)
ELSE
CALL pxr_depose_rho_n(rho,np,xp,yp,zp,w,q,xmin,ymin,zmin,dx,dy,dz,nx,ny,nz,&
nxguard,nyguard,nzguard,nox,noy,noz, &
.TRUE._c_long,.FALSE._c_long)
ENDIF
END SELECT
! Dimension 2
#elif (AMREX_SPACEDIM==2)
CALL pxr_depose_rho_n_2dxz(rho,np,xp,yp,zp,w,q,xmin,zmin,dx,dz,nx,nz,&
nxguard,nzguard,nox,noz, &
.TRUE._c_long, .FALSE._c_long, .FALSE._c_long, 0_c_long)
#endif
end subroutine warpx_charge_deposition
! _________________________________________________________________
!>
!> @brief
!> Main subroutine for the current deposition
!>
!> @details
!> This subroutines enable to controle the interpolation order
!> via the parameters nox,noy,noz and the type of algorithm via
!> the parameter current_depo_algo
!
!> @param[inout] jx,jy,jz current arrays
!> @param[in] np number of particles
!> @param[in] xp,yp,zp particle position arrays
!> @param[in] uxp,uyp,uzp particle momentum arrays
!> @param[in] gaminv inverve of the particle Lorentz factor (array)
!> @param[in] w particle weight arrays
!> @param[in] q particle species charge
!> @param[in] xmin,ymin,zmin tile grid minimum position
!> @param[in] dx,dy,dz space discretization steps
!> @param[in] nx,ny,nz number of cells
!> @param[in] nxguard,nyguard,nzguard number of guard cells
!> @param[in] nox,noy,noz interpolation order
!> @param[in] lvect vector length
!> @param[in] charge_depo_algo algorithm choice for the charge deposition
!>
subroutine warpx_current_deposition( &
jx,jx_ng,jx_ntot,jy,jy_ng,jy_ntot,jz,jz_ng,jz_ntot, &
np,xp,yp,zp,uxp,uyp,uzp,gaminv,w,q,xmin,ymin,zmin,dt,dx,dy,dz,nox,noy,noz,&
lvect,current_depo_algo) &
bind(C, name="warpx_current_deposition")
integer, intent(in) :: jx_ntot(AMREX_SPACEDIM), jy_ntot(AMREX_SPACEDIM), jz_ntot(AMREX_SPACEDIM)
integer(c_long), intent(in) :: jx_ng, jy_ng, jz_ng
integer(c_long), intent(IN) :: np
integer(c_long), intent(IN) :: nox,noy,noz
real(amrex_real), intent(IN OUT):: jx(*), jy(*), jz(*)
real(amrex_real), intent(IN) :: q
real(amrex_real), intent(IN) :: dx,dy,dz
real(amrex_real), intent(IN) :: dt
real(amrex_real), intent(IN) :: xmin,ymin,zmin
real(amrex_real), intent(IN), dimension(np) :: xp,yp,zp,w
real(amrex_real), intent(IN), dimension(np) :: uxp,uyp,uzp
real(amrex_real), intent(IN), dimension(np) :: gaminv
integer(c_long), intent(IN) :: lvect
integer(c_long), intent(IN) :: current_depo_algo
! Compute the number of valid cells and guard cells
integer(c_long) :: jx_nvalid(AMREX_SPACEDIM), jy_nvalid(AMREX_SPACEDIM), jz_nvalid(AMREX_SPACEDIM), &
jx_nguards(AMREX_SPACEDIM), jy_nguards(AMREX_SPACEDIM), jz_nguards(AMREX_SPACEDIM)
jx_nvalid = jx_ntot - 2*jx_ng
jy_nvalid = jy_ntot - 2*jy_ng
jz_nvalid = jz_ntot - 2*jz_ng
jx_nguards = jx_ng
jy_nguards = jy_ng
jz_nguards = jz_ng
! Dimension 3
#if (AMREX_SPACEDIM==3)
CALL WRPX_PXR_CURRENT_DEPOSITION( &
jx,jx_nguards,jx_nvalid, &
jy,jy_nguards,jy_nvalid, &
jz,jz_nguards,jz_nvalid, &
np,xp,yp,zp,uxp,uyp,uzp,gaminv,w,q, &
xmin,ymin,zmin,dt,dx,dy,dz, &
nox,noy,noz,current_depo_algo)
! Dimension 2
#elif (AMREX_SPACEDIM==2)
CALL WRPX_PXR_CURRENT_DEPOSITION( &
jx,jx_nguards,jx_nvalid, &
jy,jy_nguards,jy_nvalid, &
jz,jz_nguards,jz_nvalid, &
np,xp,yp,zp,uxp,uyp,uzp,gaminv,w,q, &
xmin,zmin,dt,dx,dz,nox,noz,lvect)
#endif
end subroutine warpx_current_deposition
! _________________________________________________________________
!>
!> @brief
!> Main subroutine for the particle pusher (velocity and position)
!>
!> @param[in] np number of super-particles
!> @param[in] xp,yp,zp particle position arrays
!> @param[in] uxp,uyp,uzp normalized momentum in each direction
!> @param[in] gaminv particle Lorentz factors
!> @param[in] ex,ey,ez particle electric fields in each direction
!> @param[in] bx,by,bz particle magnetic fields in each direction
!> @param[in] q charge
!> @param[in] m masse
!> @param[in] dt time step
!> @param[in] particle_pusher_algo Particle pusher algorithm
subroutine warpx_particle_pusher(np,xp,yp,zp,uxp,uyp,uzp, &
gaminv,&
ex,ey,ez,bx,by,bz,q,m,dt, &
particle_pusher_algo) &
bind(C, name="warpx_particle_pusher")
INTEGER(c_long), INTENT(IN) :: np
REAL(amrex_real),INTENT(INOUT) :: gaminv(np)
REAL(amrex_real),INTENT(INOUT) :: xp(np),yp(np),zp(np)
REAL(amrex_real),INTENT(INOUT) :: uxp(np),uyp(np),uzp(np)
REAL(amrex_real),INTENT(IN) :: ex(np),ey(np),ez(np)
REAL(amrex_real),INTENT(IN) :: bx(np),by(np),bz(np)
REAL(amrex_real),INTENT(IN) :: q,m,dt
INTEGER(c_long), INTENT(IN) :: particle_pusher_algo
SELECT CASE (particle_pusher_algo)
!! Vay pusher -- Full push
CASE (1_c_long)
CALL pxr_set_gamma(np,uxp,uyp,uzp,gaminv)
CALL pxr_ebcancelpush3d(np,uxp,uyp,uzp,gaminv, &
ex,ey,ez, &
bx,by,bz,q,m,dt,0_c_long)
CASE DEFAULT
! Momentum pusher in a single loop
CALL pxr_boris_push_u_3d(np,uxp,uyp,uzp,&
gaminv, &
ex,ey,ez, &
bx,by,bz, &
q,m,dt)
END SELECT
!!!! --- push particle species positions a time step
#if (AMREX_SPACEDIM == 3)
CALL pxr_pushxyz(np,xp,yp,zp,uxp,uyp,uzp,gaminv,dt)
#elif (AMREX_SPACEDIM == 2)
CALL pxr_pushxz(np,xp,zp,uxp,uzp,gaminv,dt)
#endif
end subroutine warpx_particle_pusher
! _________________________________________________________________
!>
!> @brief
!> Main subroutine for the particle pusher (velocity)
!>
!> @param[in] np number of super-particles
!> @param[in] xp,yp,zp particle position arrays
!> @param[in] uxp,uyp,uzp normalized momentum in each direction
!> @param[in] gaminv particle Lorentz factors
!> @param[in] ex,ey,ez particle electric fields in each direction
!> @param[in] bx,by,bz particle magnetic fields in each direction
!> @param[in] q charge
!> @param[in] m masse
!> @param[in] dt time step
!> @param[in] particle_pusher_algo Particle pusher algorithm
subroutine warpx_particle_pusher_momenta(np,xp,yp,zp,uxp,uyp,uzp, &
gaminv,&
ex,ey,ez,bx,by,bz,q,m,dt, &
particle_pusher_algo) &
bind(C, name="warpx_particle_pusher_momenta")
INTEGER(c_long), INTENT(IN) :: np
REAL(amrex_real),INTENT(INOUT) :: gaminv(np)
REAL(amrex_real),INTENT(IN) :: xp(np),yp(np),zp(np)
REAL(amrex_real),INTENT(INOUT) :: uxp(np),uyp(np),uzp(np)
REAL(amrex_real),INTENT(IN) :: ex(np),ey(np),ez(np)
REAL(amrex_real),INTENT(IN) :: bx(np),by(np),bz(np)
REAL(amrex_real),INTENT(IN) :: q,m,dt
INTEGER(c_long), INTENT(IN) :: particle_pusher_algo
SELECT CASE (particle_pusher_algo)
!! Vay pusher -- Full push
CASE (1_c_long)
CALL pxr_set_gamma(np,uxp,uyp,uzp,gaminv)
CALL pxr_ebcancelpush3d(np,uxp,uyp,uzp,gaminv, &
ex,ey,ez, &
bx,by,bz,q,m,dt,0_c_long)
CASE DEFAULT
! Momentum pusher in a single loop
CALL pxr_boris_push_u_3d(np,uxp,uyp,uzp,&
gaminv, &
ex,ey,ez, &
bx,by,bz, &
q,m,dt)
END SELECT
end subroutine warpx_particle_pusher_momenta
! _________________________________________________________________
!>
!> @brief
!> Main subroutine for the particle pusher of positions
!>
!> @param[in] np number of super-particles
!> @param[in] xp,yp,zp particle position arrays
!> @param[in] uxp,uyp,uzp normalized momentum in each direction
!> @param[in] gaminv particle Lorentz factors
!> @param[in] dt time step
!> @param[in] particle_pusher_algo Particle pusher algorithm
subroutine warpx_particle_pusher_positions(np,xp,yp,zp,uxp,uyp,uzp, &
gaminv,dt) &
bind(C, name="warpx_particle_pusher_positions")
INTEGER(c_long), INTENT(IN) :: np
REAL(amrex_real),INTENT(INOUT) :: gaminv(np)
REAL(amrex_real),INTENT(INOUT) :: xp(np),yp(np),zp(np)
REAL(amrex_real),INTENT(INOUT) :: uxp(np),uyp(np),uzp(np)
REAL(amrex_real),INTENT(IN) :: dt
CALL pxr_set_gamma(np,uxp,uyp,uzp,gaminv)
!!!! --- push particle species positions a time step
#if (AMREX_SPACEDIM == 3)
CALL pxr_pushxyz(np,xp,yp,zp,uxp,uyp,uzp,gaminv,dt)
#elif (AMREX_SPACEDIM == 2)
CALL pxr_pushxz(np,xp,zp,uxp,uzp,gaminv,dt)
#endif
end subroutine warpx_particle_pusher_positions
! _________________________________________________________________
!>
!> @brief
!> Main subroutine for the Maxwell solver (E field)
!>
!> @param[in] xlo, xhi, ylo, yhi, zlo, zhi lower and higher bounds
!> where to apply the solver (PICSAR's valid cells)
!> @param[inout] ex, ey, ez arrays for electric field to update
!> @param[in] bx, by, bz, jx, jy, jz arrays for magnetic field and current
!> @param[in] exlo, exhi, eylo, eyhi, ezlo, ezhi lower and higher bound for
!> the electric field arrays
!> @param[in] bxlo, bxhi, bylo, byhi, bzlo, bzhi lower and higher bound for
!> the magnetic field arrays
!> @param[in] jxlo, jxhi, jylo, jyhi, jzlo, jzhi lower and higher bound for
!> the current arrays
!> @param[in] mudt normalized time step mu_0 * c**2 * dt
!> @param[in] dtsdx, dtsdy, dtsdz factors c**2 * dt/(dx, dy, dz)
subroutine warpx_push_evec( &
xlo, xhi, ylo, yhi, zlo, zhi, &
ex, exlo, exhi, &
ey, eylo, eyhi, &
ez, ezlo, ezhi, &
bx, bxlo, bxhi, &
by, bylo, byhi, &
bz, bzlo, bzhi, &
jx, jxlo, jxhi, &
jy, jylo, jyhi, &
jz, jzlo, jzhi, &
mudt, dtsdx, dtsdy, dtsdz) bind(C, name="warpx_push_evec")
integer(c_int), intent(in) :: xlo(BL_SPACEDIM), xhi(BL_SPACEDIM), &
ylo(BL_SPACEDIM), yhi(BL_SPACEDIM), zlo(BL_SPACEDIM), zhi(BL_SPACEDIM), &
exlo(BL_SPACEDIM), exhi(BL_SPACEDIM), eylo(BL_SPACEDIM), eyhi(BL_SPACEDIM), &
ezlo(BL_SPACEDIM), ezhi(BL_SPACEDIM), bxlo(BL_SPACEDIM), bxhi(BL_SPACEDIM), &
bylo(BL_SPACEDIM), byhi(BL_SPACEDIM), bzlo(BL_SPACEDIM), bzhi(BL_SPACEDIM), &
jxlo(BL_SPACEDIM), jxhi(BL_SPACEDIM), jylo(BL_SPACEDIM), jyhi(BL_SPACEDIM), &
jzlo(BL_SPACEDIM), jzhi(BL_SPACEDIM)
real(amrex_real), intent(IN OUT):: ex(*), ey(*), ez(*)
real(amrex_real), intent(IN):: bx(*), by(*), bz(*), jx(*), jy(*), jz(*)
real(amrex_real), intent(IN) :: mudt, dtsdx, dtsdy, dtsdz
CALL WRPX_PXR_PUSH_EVEC(&
xlo, xhi, ylo, yhi, zlo, zhi, &
ex, exlo, exhi,&
ey, eylo, eyhi,&
ez, ezlo, ezhi,&
bx, bxlo, bxhi,&
by, bylo, byhi,&
bz, bzlo, bzhi,&
jx, jxlo, jxhi,&
jy, jylo, jyhi,&
jz, jzlo, jzhi,&
mudt, dtsdx, dtsdy, dtsdz);
end subroutine warpx_push_evec
! _________________________________________________________________
!>
!> @brief
!> Main subroutine for the Maxwell solver (B field)
!>
!> @param[in] xlo, xhi, ylo, yhi, zlo, zhi lower and higher bounds
!> where to apply the solver (PICSAR's valid cells)
!> @param[in] ex, ey, ez arrays for electric field
!> @param[inout] bx, by, bz arrays for magnetic field to update
!> @param[in] exlo, exhi, eylo, eyhi, ezlo, ezhi lower and higher bound for
!> the electric field arrays
!> @param[in] bxlo, bxhi, bylo, byhi, bzlo, bzhi lower and higher bound for
!> the magnetic field arrays
!> @param[in] dtsdx, dtsdy, dtsdz factors 0.5 * dt/(dx, dy, dz)
subroutine warpx_push_bvec( &
xlo, xhi, ylo, yhi, zlo, zhi, &
ex, exlo, exhi, &
ey, eylo, eyhi, &
ez, ezlo, ezhi, &
bx, bxlo, bxhi, &
by, bylo, byhi, &
bz, bzlo, bzhi, &
dtsdx, dtsdy, dtsdz, &
maxwell_fdtd_solver_id) bind(C, name="warpx_push_bvec")
integer(c_int), intent(in) :: xlo(BL_SPACEDIM), xhi(BL_SPACEDIM), &
ylo(BL_SPACEDIM), yhi(BL_SPACEDIM), zlo(BL_SPACEDIM), zhi(BL_SPACEDIM), &
exlo(BL_SPACEDIM), exhi(BL_SPACEDIM), eylo(BL_SPACEDIM), eyhi(BL_SPACEDIM), &
ezlo(BL_SPACEDIM), ezhi(BL_SPACEDIM), bxlo(BL_SPACEDIM), bxhi(BL_SPACEDIM), &
bylo(BL_SPACEDIM), byhi(BL_SPACEDIM), bzlo(BL_SPACEDIM), bzhi(BL_SPACEDIM), &
maxwell_fdtd_solver_id
real(amrex_real), intent(IN OUT):: ex(*), ey(*), ez(*)
real(amrex_real), intent(IN):: bx(*), by(*), bz(*)
real(amrex_real), intent(IN) :: dtsdx, dtsdy, dtsdz
IF (maxwell_fdtd_solver_id .eq. 0) THEN
! Yee FDTD solver
CALL WRPX_PXR_PUSH_BVEC( &
xlo, xhi, ylo, yhi, zlo, zhi, &
ex, exlo, exhi, &
ey, eylo, eyhi, &
ez, ezlo, ezhi, &
bx, bxlo, bxhi, &
by, bylo, byhi, &
bz, bzlo, bzhi, &
dtsdx,dtsdy,dtsdz)
ELSE IF (maxwell_fdtd_solver_id .eq. 1) THEN
! Cole-Karkkainen FDTD solver
CALL WRPX_PXR_PUSH_BVEC_CKC( &
xlo, xhi, ylo, yhi, zlo, zhi, &
ex, exlo, exhi, &
ey, eylo, eyhi, &
ez, ezlo, ezhi, &
bx, bxlo, bxhi, &
by, bylo, byhi, &
bz, bzlo, bzhi, &
dtsdx,dtsdy,dtsdz)
ENDIF
end subroutine warpx_push_bvec
! _________________________________________________________________
!>
!> @brief
!> Subroutine for pushing E with the grad F terms
!>
!> @param[in] xlo, xhi, ylo, yhi, zlo, zhi lower and higher bounds
!> where to apply the solver (PICSAR's valid cells)
!> @param[inout] ex, ey, ez arrays for electric field to update
!> @param[in] f array for the charge-correction term
!> @param[in] exlo, exhi, eylo, eyhi, ezlo, ezhi lower and higher bound for
!> the electric field arrays
!> @param[in] flo, fhi, lower and higher bound for the charge-correction term
!> @param[in] dtsdx_c2, dtsdy_c2, dtsdz_c2 factors dt/(dx, dy, dz)*c2
subroutine warpx_push_evec_f( &
xlo, xhi, ylo, yhi, zlo, zhi, &
ex, exlo, exhi, &
ey, eylo, eyhi, &
ez, ezlo, ezhi, &
f, flo, fhi, &
dtsdx_c2, dtsdy_c2, dtsdz_c2, &
maxwell_fdtd_solver_id) bind(C, name="warpx_push_evec_f")
integer(c_int), intent(in) :: xlo(BL_SPACEDIM), xhi(BL_SPACEDIM), &
ylo(BL_SPACEDIM), yhi(BL_SPACEDIM), zlo(BL_SPACEDIM), zhi(BL_SPACEDIM), &
exlo(BL_SPACEDIM), exhi(BL_SPACEDIM), eylo(BL_SPACEDIM), eyhi(BL_SPACEDIM), &
ezlo(BL_SPACEDIM), ezhi(BL_SPACEDIM), flo(BL_SPACEDIM), fhi(BL_SPACEDIM), &
maxwell_fdtd_solver_id
real(amrex_real), intent(IN OUT):: ex(*), ey(*), ez(*)
real(amrex_real), intent(IN):: f
real(amrex_real), intent(IN) :: dtsdx_c2, dtsdy_c2, dtsdz_c2
IF (maxwell_fdtd_solver_id .eq. 0) THEN
! Yee FDTD solver
CALL WRPX_PXR_PUSH_EVEC_F( &
xlo, xhi, ylo, yhi, zlo, zhi, &
ex, exlo, exhi, &
ey, eylo, eyhi, &
ez, ezlo, ezhi, &
f, flo, fhi, &
dtsdx_c2, dtsdy_c2, dtsdz_c2)
ELSE IF (maxwell_fdtd_solver_id .eq. 1) THEN
! Cole-Karkkainen FDTD solver
CALL WRPX_PXR_PUSH_EVEC_F_CKC( &
xlo, xhi, ylo, yhi, zlo, zhi, &
ex, exlo, exhi, &
ey, eylo, eyhi, &
ez, ezlo, ezhi, &
f, flo, fhi, &
dtsdx_c2, dtsdy_c2, dtsdz_c2)
ENDIF
end subroutine warpx_push_evec_f
end module warpx_to_pxr_module
|