@@ -238,43 +238,82 @@ WarpX::FillBoundaryF ()
238238void
239239WarpX::FillBoundaryE (int lev)
240240{
241- const auto & period = Geom (lev).periodicity ();
242-
243- if (do_pml && pml[lev]->ok ()) {
244- ExchangeWithPmlE (lev);
245- pml[lev]->FillBoundaryE ();
246- }
241+ FillBoundaryE (lev, PatchType::fine);
242+ if (lev > 0 ) FillBoundaryE (lev, PatchType::coarse);
243+ }
247244
248- (*Efield_fp[lev][0 ]).FillBoundary ( period );
249- (*Efield_fp[lev][1 ]).FillBoundary ( period );
250- (*Efield_fp[lev][2 ]).FillBoundary ( period );
245+ void
246+ WarpX::FillBoundaryE (int lev, PatchType patch_type)
247+ {
248+ if (patch_type == PatchType::fine)
249+ {
250+ if (do_pml && pml[lev]->ok ())
251+ {
252+ pml[lev]->ExchangeE (patch_type,
253+ { Efield_fp[lev][0 ].get (),
254+ Efield_fp[lev][1 ].get (),
255+ Efield_fp[lev][2 ].get () });
256+ pml[lev]->FillBoundaryE (patch_type);
257+ }
251258
252- if (lev > 0 )
259+ const auto & period = Geom (lev).periodicity ();
260+ (*Efield_fp[lev][0 ]).FillBoundary (period);
261+ (*Efield_fp[lev][1 ]).FillBoundary (period);
262+ (*Efield_fp[lev][2 ]).FillBoundary (period);
263+ }
264+ else if (patch_type == PatchType::coarse)
253265 {
266+ if (do_pml && pml[lev]->ok ())
267+ {
268+ pml[lev]->ExchangeE (patch_type,
269+ { Efield_cp[lev][0 ].get (),
270+ Efield_cp[lev][1 ].get (),
271+ Efield_cp[lev][2 ].get () });
272+ pml[lev]->FillBoundaryE (patch_type);
273+ }
274+
254275 const auto & cperiod = Geom (lev-1 ).periodicity ();
255276 (*Efield_cp[lev][0 ]).FillBoundary (cperiod);
256277 (*Efield_cp[lev][1 ]).FillBoundary (cperiod);
257278 (*Efield_cp[lev][2 ]).FillBoundary (cperiod);
258- }
279+ }
259280}
260281
261282void
262- WarpX::FillBoundaryB (int lev)
283+ WarpX::FillBoundaryB (int lev)
263284{
264- const auto & period = Geom (lev).periodicity ();
285+ FillBoundaryB (lev, PatchType::fine);
286+ if (lev > 0 ) FillBoundaryB (lev, PatchType::coarse);
287+ }
265288
266- if (do_pml && pml[lev]->ok ())
289+ void
290+ WarpX::FillBoundaryB (int lev, PatchType patch_type)
291+ {
292+ if (patch_type == PatchType::fine)
267293 {
268- ExchangeWithPmlB (lev);
269- pml[lev]->FillBoundaryB ();
294+ if (do_pml && pml[lev]->ok ())
295+ {
296+ pml[lev]->ExchangeB (patch_type,
297+ { Bfield_fp[lev][0 ].get (),
298+ Bfield_fp[lev][1 ].get (),
299+ Bfield_fp[lev][2 ].get () });
300+ pml[lev]->FillBoundaryB (patch_type);
301+ }
302+ const auto & period = Geom (lev).periodicity ();
303+ (*Bfield_fp[lev][0 ]).FillBoundary (period);
304+ (*Bfield_fp[lev][1 ]).FillBoundary (period);
305+ (*Bfield_fp[lev][2 ]).FillBoundary (period);
270306 }
271-
272- (*Bfield_fp[lev][0 ]).FillBoundary (period);
273- (*Bfield_fp[lev][1 ]).FillBoundary (period);
274- (*Bfield_fp[lev][2 ]).FillBoundary (period);
275-
276- if (lev > 0 )
307+ else if (patch_type == PatchType::coarse)
277308 {
309+ if (do_pml && pml[lev]->ok ())
310+ {
311+ pml[lev]->ExchangeB (patch_type,
312+ { Bfield_cp[lev][0 ].get (),
313+ Bfield_cp[lev][1 ].get (),
314+ Bfield_cp[lev][2 ].get () });
315+ pml[lev]->FillBoundaryB (patch_type);
316+ }
278317 const auto & cperiod = Geom (lev-1 ).periodicity ();
279318 (*Bfield_cp[lev][0 ]).FillBoundary (cperiod);
280319 (*Bfield_cp[lev][1 ]).FillBoundary (cperiod);
@@ -283,22 +322,36 @@ WarpX::FillBoundaryB(int lev)
283322}
284323
285324void
286- WarpX::FillBoundaryF (int lev)
325+ WarpX::FillBoundaryF (int lev)
287326{
288- const auto & period = Geom (lev).periodicity ();
327+ FillBoundaryF (lev, PatchType::fine);
328+ if (lev > 0 ) FillBoundaryF (lev, PatchType::coarse);
329+ }
289330
290- if (do_pml && pml[lev]->ok ())
331+ void
332+ WarpX::FillBoundaryF (int lev, PatchType patch_type)
333+ {
334+ if (patch_type == PatchType::fine && F_fp[lev])
291335 {
292- ExchangeWithPmlF ( lev);
293- pml[lev]-> FillBoundaryF ();
294- }
295-
296- if (F_fp[lev]) F_fp[lev]-> FillBoundary (period);
336+ if (do_pml && pml[ lev]-> ok ())
337+ {
338+ pml[lev]-> ExchangeF (patch_type, F_fp[lev]. get ());
339+ pml[lev]-> FillBoundaryF (patch_type);
340+ }
297341
298- if (lev > 0 )
342+ const auto & period = Geom (lev).periodicity ();
343+ F_fp[lev]->FillBoundary (period);
344+ }
345+ else if (patch_type == PatchType::coarse && F_cp[lev])
299346 {
347+ if (do_pml && pml[lev]->ok ())
348+ {
349+ pml[lev]->ExchangeF (patch_type, F_cp[lev].get ());
350+ pml[lev]->FillBoundaryF (patch_type);
351+ }
352+
300353 const auto & cperiod = Geom (lev-1 ).periodicity ();
301- if (F_cp[lev]) F_cp[lev]->FillBoundary (cperiod);
354+ F_cp[lev]->FillBoundary (cperiod);
302355 }
303356}
304357
0 commit comments