@@ -1351,16 +1351,11 @@ PhysicalParticleContainer::AddPlasmaFlux (PlasmaInjector const& plasma_injector,
1351
1351
#ifdef AMREX_USE_EB
1352
1352
bool const inject_from_eb = plasma_injector.m_inject_from_eb ; // whether to inject from EB or from a plane
1353
1353
// Extract data structures for embedded boundaries
1354
+ amrex::EBFArrayBoxFactory const * eb_factory = nullptr ;
1354
1355
amrex::FabArray<amrex::EBCellFlagFab> const * eb_flag = nullptr ;
1355
- amrex::MultiCutFab const * eb_bnd_area = nullptr ;
1356
- amrex::MultiCutFab const * eb_bnd_normal = nullptr ;
1357
- amrex::MultiCutFab const * eb_bnd_cent = nullptr ;
1358
1356
if (inject_from_eb) {
1359
- amrex::EBFArrayBoxFactory const & eb_box_factory = WarpX::GetInstance ().fieldEBFactory (0 );
1360
- eb_flag = &eb_box_factory.getMultiEBCellFlagFab ();
1361
- eb_bnd_area = &eb_box_factory.getBndryArea ();
1362
- eb_bnd_normal = &eb_box_factory.getBndryNormal ();
1363
- eb_bnd_cent = &eb_box_factory.getBndryCent ();
1357
+ eb_factory = &(WarpX::GetInstance ().fieldEBFactory (0 ));
1358
+ eb_flag = &(eb_factory->getMultiEBCellFlagFab ());
1364
1359
}
1365
1360
#endif
1366
1361
@@ -1456,17 +1451,8 @@ PhysicalParticleContainer::AddPlasmaFlux (PlasmaInjector const& plasma_injector,
1456
1451
}
1457
1452
1458
1453
#ifdef AMREX_USE_EB
1459
- // Extract data structures for embedded boundaries
1460
- amrex::Array4<const typename FabArray<EBCellFlagFab>::value_type> eb_flag_arr;
1461
- amrex::Array4<const amrex::Real> eb_bnd_area_arr;
1462
- amrex::Array4<const amrex::Real> eb_bnd_normal_arr;
1463
- amrex::Array4<const amrex::Real> eb_bnd_cent_arr;
1464
- if (inject_from_eb) {
1465
- eb_flag_arr = eb_flag->array (mfi);
1466
- eb_bnd_area_arr = eb_bnd_area->array (mfi);
1467
- eb_bnd_normal_arr = eb_bnd_normal->array (mfi);
1468
- eb_bnd_cent_arr = eb_bnd_cent->array (mfi);
1469
- }
1454
+ auto eb_flag_arr = eb_flag ? eb_flag->const_array (mfi) : Array4<EBCellFlag const >{};
1455
+ auto eb_data = eb_factory ? eb_factory->getEBData (mfi) : EBData{};
1470
1456
#endif
1471
1457
1472
1458
amrex::ParallelForRNG (overlap_box, [=] AMREX_GPU_DEVICE (int i, int j, int k, amrex::RandomEngine const & engine) noexcept
@@ -1482,7 +1468,7 @@ PhysicalParticleContainer::AddPlasmaFlux (PlasmaInjector const& plasma_injector,
1482
1468
// Skip cells that are not partially covered by the EB
1483
1469
if (eb_flag_arr (i,j,k).isRegular () || eb_flag_arr (i,j,k).isCovered ()) { return ; }
1484
1470
// Scale by the (normalized) area of the EB surface in this cell
1485
- num_ppc_real_in_this_cell *= eb_bnd_area_arr (i,j,k);
1471
+ num_ppc_real_in_this_cell *= eb_data. get <amrex::EBData_t::bndryarea> (i,j,k);
1486
1472
}
1487
1473
#else
1488
1474
amrex::Real const num_ppc_real_in_this_cell = num_ppc_real; // user input: number of macroparticles per cell
@@ -1574,7 +1560,10 @@ PhysicalParticleContainer::AddPlasmaFlux (PlasmaInjector const& plasma_injector,
1574
1560
Real scale_fac;
1575
1561
#ifdef AMREX_USE_EB
1576
1562
if (inject_from_eb) {
1577
- scale_fac = compute_scale_fac_area_eb (dx, num_ppc_real, eb_bnd_normal_arr, i, j, k );
1563
+ scale_fac = compute_scale_fac_area_eb (dx, num_ppc_real,
1564
+ AMREX_D_DECL (eb_data.get <amrex::EBData_t::bndrynorm>(i,j,k,0 ),
1565
+ eb_data.get <amrex::EBData_t::bndrynorm>(i,j,k,1 ),
1566
+ eb_data.get <amrex::EBData_t::bndrynorm>(i,j,k,2 )));
1578
1567
} else
1579
1568
#endif
1580
1569
{
@@ -1595,14 +1584,15 @@ PhysicalParticleContainer::AddPlasmaFlux (PlasmaInjector const& plasma_injector,
1595
1584
XDim3 r;
1596
1585
#ifdef AMREX_USE_EB
1597
1586
if (inject_from_eb) {
1587
+ auto const & pt = eb_data.randomPointOnEB (i,j,k,engine);
1598
1588
#if defined(WARPX_DIM_3D)
1599
- pos.x = overlap_corner[0 ] + (iv[0 ] + 0 .5_rt + eb_bnd_cent_arr (i,j,k, 0 ) )*dx[0 ];
1600
- pos.y = overlap_corner[1 ] + (iv[1 ] + 0 .5_rt + eb_bnd_cent_arr (i,j,k, 1 ) )*dx[1 ];
1601
- pos.z = overlap_corner[2 ] + (iv[2 ] + 0 .5_rt + eb_bnd_cent_arr (i,j,k, 2 ) )*dx[2 ];
1589
+ pos.x = overlap_corner[0 ] + (iv[0 ] + 0 .5_rt + pt[ 0 ] )*dx[0 ];
1590
+ pos.y = overlap_corner[1 ] + (iv[1 ] + 0 .5_rt + pt[ 1 ] )*dx[1 ];
1591
+ pos.z = overlap_corner[2 ] + (iv[2 ] + 0 .5_rt + pt[ 2 ] )*dx[2 ];
1602
1592
#elif defined(WARPX_DIM_XZ) || defined(WARPX_DIM_RZ)
1603
- pos.x = overlap_corner[0 ] + (iv[0 ] + 0 .5_rt + eb_bnd_cent_arr (i,j,k, 0 ) )*dx[0 ];
1593
+ pos.x = overlap_corner[0 ] + (iv[0 ] + 0 .5_rt + pt[ 0 ] )*dx[0 ];
1604
1594
pos.y = 0 .0_rt;
1605
- pos.z = overlap_corner[1 ] + (iv[1 ] + 0 .5_rt + eb_bnd_cent_arr (i,j,k, 1 ) )*dx[1 ];
1595
+ pos.z = overlap_corner[1 ] + (iv[1 ] + 0 .5_rt + pt[ 1 ] )*dx[1 ];
1606
1596
#endif
1607
1597
} else
1608
1598
#endif
@@ -1661,7 +1651,9 @@ PhysicalParticleContainer::AddPlasmaFlux (PlasmaInjector const& plasma_injector,
1661
1651
// Injection from EB: rotate momentum according to the normal of the EB surface
1662
1652
// (The above code initialized the momentum by assuming that z is the direction
1663
1653
// normal to the EB surface. Thus we need to rotate from z to the normal.)
1664
- rotate_momentum_eb (pu, eb_bnd_normal_arr, i, j , k);
1654
+ rotate_momentum_eb (pu, AMREX_D_DECL (eb_data.get <amrex::EBData_t::bndrynorm>(i,j,k,0 ),
1655
+ eb_data.get <amrex::EBData_t::bndrynorm>(i,j,k,1 ),
1656
+ eb_data.get <amrex::EBData_t::bndrynorm>(i,j,k,2 )));
1665
1657
}
1666
1658
#endif
1667
1659
0 commit comments