@@ -179,6 +179,14 @@ void ThetaImplicitEM::FinishFieldUpdate ( amrex::Real end_time )
179179
180180}
181181
182+ const amrex::MultiFab* ThetaImplicitEM::GetCurl2BCmask (const int lev, const int field_dir) const
183+ {
184+ using ablastr::fields::Direction;
185+ const amrex::MultiFab* mask = m_WarpX->m_fields .get (FieldType::curl2_BC_mask, Direction{field_dir}, lev);
186+ // return m_WarpX->m_fields.get(FieldType::curl2_BC_mask, Direction{field_dir}, lev);
187+ return mask;
188+ }
189+
182190void ThetaImplicitEM::InitializeCurlCurlBCMasks ()
183191{
184192
@@ -217,7 +225,6 @@ void ThetaImplicitEM::InitializeCurlCurlBCMasks ()
217225 */
218226
219227 using ablastr::fields::Direction;
220- m_curl2_BC_mask.resize (m_num_amr_levels);
221228 for (int lev = 0 ; lev < m_num_amr_levels; ++lev) {
222229 const amrex::IntVect ghosts = amrex::IntVect{0 };
223230 const auto & dm = m_WarpX->m_fields .get (FieldType::Efield_fp, Direction{1 }, lev)->DistributionMap ();
@@ -237,15 +244,13 @@ void ThetaImplicitEM::InitializeCurlCurlBCMasks ()
237244 const int ncomps_Ey = 6 ;
238245 const int ncomps_Ez = 6 ;
239246#endif
240- m_curl2_BC_mask[lev][0 ] = std::make_unique<amrex::MultiFab>(ba_Ex, dm, ncomps_Ex, ghosts);
241- m_curl2_BC_mask[lev][1 ] = std::make_unique<amrex::MultiFab>(ba_Ey, dm, ncomps_Ey, ghosts);
242- m_curl2_BC_mask[lev][2 ] = std::make_unique<amrex::MultiFab>(ba_Ez, dm, ncomps_Ez, ghosts);
243- m_curl2_BC_mask[lev][0 ]->setVal (1.0 );
244- m_curl2_BC_mask[lev][1 ]->setVal (1.0 );
245- m_curl2_BC_mask[lev][2 ]->setVal (1.0 );
247+ m_WarpX->m_fields .alloc_init (FieldType::curl2_BC_mask, Direction{0 }, lev, ba_Ex, dm, ncomps_Ex, ghosts, 1 .0_rt);
248+ m_WarpX->m_fields .alloc_init (FieldType::curl2_BC_mask, Direction{1 }, lev, ba_Ey, dm, ncomps_Ey, ghosts, 1 .0_rt);
249+ m_WarpX->m_fields .alloc_init (FieldType::curl2_BC_mask, Direction{2 }, lev, ba_Ez, dm, ncomps_Ez, ghosts, 1 .0_rt);
246250 }
247251
248- const amrex::Geometry& geom = GetGeometry (0 );
252+ const int lev = 0 ;
253+ const amrex::Geometry& geom = GetGeometry (lev);
249254 amrex::Box domain_box = geom.Domain ();
250255 domain_box.convert (amrex::IntVect::TheNodeVector ());
251256 const amrex::IntVect domain_lo = domain_box.smallEnd ();
@@ -254,10 +259,10 @@ void ThetaImplicitEM::InitializeCurlCurlBCMasks ()
254259 const amrex::Array<FieldBoundaryType,AMREX_SPACEDIM>& bc_type_lo = GetFieldBoundaryLo ();
255260 const amrex::Array<FieldBoundaryType,AMREX_SPACEDIM>& bc_type_hi = GetFieldBoundaryHi ();
256261
257- const int lev = 0 ;
262+ ablastr::fields::VectorField curl2_BC_mask = m_WarpX-> m_fields . get_alldirs (FieldType::curl2_BC_mask, lev) ;
258263#if AMREX_SPACEDIM < 3
259264 // Set the BC masks for the out-of-plane components of the curl curl E operator
260- for (amrex::MFIter mfi (*m_curl2_BC_mask[lev] [1 ], false ); mfi.isValid (); ++mfi) {
265+ for (amrex::MFIter mfi (*curl2_BC_mask [1 ], false ); mfi.isValid (); ++mfi) {
261266
262267 // Get nodal box that does not include ghost cells
263268 const amrex::Box node_box = amrex::convert (mfi.validbox (),amrex::IntVect::TheNodeVector ());
@@ -304,9 +309,9 @@ void ThetaImplicitEM::InitializeCurlCurlBCMasks ()
304309
305310 // Set mask values on the boundary cells (same for Ex and Ey for 1D_Z)
306311#if defined(WARPX_DIM_1D_Z)
307- amrex::Array4<amrex::Real> const & maskEx_arr = m_curl2_BC_mask[lev] [0 ]->array (mfi);
312+ amrex::Array4<amrex::Real> const & maskEx_arr = curl2_BC_mask [0 ]->array (mfi);
308313#endif
309- amrex::Array4<amrex::Real> const & maskEy_arr = m_curl2_BC_mask[lev] [1 ]->array (mfi);
314+ amrex::Array4<amrex::Real> const & maskEy_arr = curl2_BC_mask [1 ]->array (mfi);
310315 amrex::ParallelFor (bdry_box, [=] AMREX_GPU_DEVICE (int i, int j, int k) {
311316#if defined(WARPX_DIM_1D_Z)
312317 maskEx_arr (i,j,k,2 *bdry_dir ) = val0;
@@ -325,7 +330,7 @@ void ThetaImplicitEM::InitializeCurlCurlBCMasks ()
325330
326331#if AMREX_SPACEDIM > 1
327332 // Set the BC masks for the in-plane components of the curl curl E operator
328- for (amrex::MFIter mfi (*m_curl2_BC_mask[lev] [0 ], false ); mfi.isValid (); ++mfi) {
333+ for (amrex::MFIter mfi (*curl2_BC_mask [0 ], false ); mfi.isValid (); ++mfi) {
329334
330335 for (int bdry_dir = 0 ; bdry_dir < AMREX_SPACEDIM; ++bdry_dir) {
331336
@@ -343,7 +348,7 @@ void ThetaImplicitEM::InitializeCurlCurlBCMasks ()
343348 const int tdir1 = bdry_dir;
344349#endif
345350 // Get edge box for Ecomp (nodal in bdry-direction) that does not include ghost cells
346- const amrex::IntVect Edir_nodal = m_curl2_BC_mask[lev] [field_dir]->ixType ().toIntVect ();
351+ const amrex::IntVect Edir_nodal = curl2_BC_mask [field_dir]->ixType ().toIntVect ();
347352 const amrex::Box edge_box = amrex::convert (mfi.validbox (),Edir_nodal);
348353
349354 for (int bdry_side = 0 ; bdry_side < 2 ; ++bdry_side) {
@@ -384,7 +389,7 @@ void ThetaImplicitEM::InitializeCurlCurlBCMasks ()
384389
385390 // Set mask values on the boundary cells
386391 const int comp_shift = (tdir1 == bdry_dir) ? 0 :3 ;
387- amrex::Array4<amrex::Real> const & mask_arr = m_curl2_BC_mask[lev] [field_dir]->array (mfi);
392+ amrex::Array4<amrex::Real> const & mask_arr = curl2_BC_mask [field_dir]->array (mfi);
388393 amrex::ParallelFor (bdry_box, [=] AMREX_GPU_DEVICE (int i, int j, int k) {
389394 mask_arr (i,j,k,comp_shift+0 ) = val0;
390395 mask_arr (i,j,k,comp_shift+1 ) = val1;
0 commit comments