diff options
Diffstat (limited to 'Source')
-rw-r--r-- | Source/WarpX.H | 9 | ||||
-rw-r--r-- | Source/WarpXComm.cpp | 66 | ||||
-rw-r--r-- | Source/WarpXEvolve.cpp | 223 | ||||
-rw-r--r-- | Source/WarpXPML.H | 14 | ||||
-rw-r--r-- | Source/WarpXPML.cpp | 32 |
5 files changed, 178 insertions, 166 deletions
diff --git a/Source/WarpX.H b/Source/WarpX.H index 25a4a7bb6..03bb69735 100644 --- a/Source/WarpX.H +++ b/Source/WarpX.H @@ -236,6 +236,15 @@ private: /// Advance the simulation by numsteps steps, electromagnetic case. /// void EvolveEM(int numsteps); + + void FillBoundaryB (int lev, PatchType patch_type); + void FillBoundaryE (int lev, PatchType patch_type); + void FillBoundaryF (int lev, PatchType patch_type); + + void EvolveB (int lev, PatchType patch_type, amrex::Real dt); + void EvolveE (int lev, PatchType patch_type, amrex::Real dt); + void EvolveF (int lev, PatchType patch_type, amrex::Real dt, DtType dt_type); + void DampPML (int lev, PatchType patch_type); void OneStep_nosub (amrex::Real t); void OneStep_sub1 (amrex::Real t); diff --git a/Source/WarpXComm.cpp b/Source/WarpXComm.cpp index 2066b4975..3d7321913 100644 --- a/Source/WarpXComm.cpp +++ b/Source/WarpXComm.cpp @@ -249,11 +249,11 @@ WarpX::FillBoundaryE (int lev, PatchType patch_type) { if (do_pml && pml[lev]->ok()) { - pml[lev]->ExchangeE(patch_type, - { Efield_fp[lev][0].get(), - Efield_fp[lev][1].get(), - Efield_fp[lev][2].get() }); - pml[lev]->FillBoundaryE(patch_type); + pml[lev]->ExchangeE(patch_type, + { Efield_fp[lev][0].get(), + Efield_fp[lev][1].get(), + Efield_fp[lev][2].get() }); + pml[lev]->FillBoundaryE(patch_type); } const auto& period = Geom(lev).periodicity(); @@ -265,18 +265,18 @@ WarpX::FillBoundaryE (int lev, PatchType patch_type) { if (do_pml && pml[lev]->ok()) { - pml[lev]->ExchangeE(patch_type, - { Efield_cp[lev][0].get(), - Efield_cp[lev][1].get(), - Efield_cp[lev][2].get() }); - pml[lev]->FillBoundaryE(patch_type); + pml[lev]->ExchangeE(patch_type, + { Efield_cp[lev][0].get(), + Efield_cp[lev][1].get(), + Efield_cp[lev][2].get() }); + pml[lev]->FillBoundaryE(patch_type); } const auto& cperiod = Geom(lev-1).periodicity(); (*Efield_cp[lev][0]).FillBoundary(cperiod); (*Efield_cp[lev][1]).FillBoundary(cperiod); (*Efield_cp[lev][2]).FillBoundary(cperiod); - } + } } void @@ -293,13 +293,12 @@ WarpX::FillBoundaryB (int lev, PatchType patch_type) { if (do_pml && pml[lev]->ok()) { - pml[lev]->ExchangeB(patch_type, - { Bfield_fp[lev][0].get(), - Bfield_fp[lev][1].get(), - Bfield_fp[lev][2].get() }); - pml[lev]->FillBoundaryB(patch_type); + pml[lev]->ExchangeB(patch_type, + { Bfield_fp[lev][0].get(), + Bfield_fp[lev][1].get(), + Bfield_fp[lev][2].get() }); + pml[lev]->FillBoundaryB(patch_type); } - const auto& period = Geom(lev).periodicity(); (*Bfield_fp[lev][0]).FillBoundary(period); (*Bfield_fp[lev][1]).FillBoundary(period); @@ -309,13 +308,12 @@ WarpX::FillBoundaryB (int lev, PatchType patch_type) { if (do_pml && pml[lev]->ok()) { - pml[lev]->ExchangeB(patch_type, - { Bfield_cp[lev][0].get(), - Bfield_cp[lev][1].get(), - Bfield_cp[lev][2].get() }); - pml[lev]->FillBoundaryB(patch_type); + pml[lev]->ExchangeB(patch_type, + { Bfield_cp[lev][0].get(), + Bfield_cp[lev][1].get(), + Bfield_cp[lev][2].get() }); + pml[lev]->FillBoundaryB(patch_type); } - const auto& cperiod = Geom(lev-1).periodicity(); (*Bfield_cp[lev][0]).FillBoundary(cperiod); (*Bfield_cp[lev][1]).FillBoundary(cperiod); @@ -326,8 +324,8 @@ WarpX::FillBoundaryB (int lev, PatchType patch_type) void WarpX::FillBoundaryF (int lev) { - FillBoundaryF(lev, PatchType::fine); - if (lev > 0) FillBoundaryF(lev, PatchType::coarse); + FillBoundaryF(lev, PatchType::fine); + if (lev > 0) FillBoundaryF(lev, PatchType::coarse); } void @@ -348,8 +346,8 @@ WarpX::FillBoundaryF (int lev, PatchType patch_type) { if (do_pml && pml[lev]->ok()) { - pml[lev]->ExchangeF(patch_type, F_cp[lev].get()); - pml[lev]->FillBoundaryF(patch_type); + pml[lev]->ExchangeF(patch_type, F_cp[lev].get()); + pml[lev]->FillBoundaryF(patch_type); } const auto& cperiod = Geom(lev-1).periodicity(); @@ -555,7 +553,7 @@ WarpX::SyncRho (amrex::Vector<std::unique_ptr<amrex::MultiFab> >& rhof, Vector<std::unique_ptr<MultiFab> > rho_f_g(finest_level+1); Vector<std::unique_ptr<MultiFab> > rho_c_g(finest_level+1); Vector<std::unique_ptr<MultiFab> > rho_buf_g(finest_level+1); - + if (WarpX::use_filter) { for (int lev = 0; lev <= finest_level; ++lev) { const int ncomp = rhof[lev]->nComp(); @@ -580,7 +578,7 @@ WarpX::SyncRho (amrex::Vector<std::unique_ptr<amrex::MultiFab> >& rhof, for (int lev = 1; lev <= finest_level; ++lev) { if (charge_buf[lev]) { const int ncomp = charge_buf[lev]->nComp(); - IntVect ng = charge_buf[lev]->nGrowVect(); + IntVect ng = charge_buf[lev]->nGrowVect(); ng += 1; rho_buf_g[lev].reset(new MultiFab(charge_buf[lev]->boxArray(), charge_buf[lev]->DistributionMap(), @@ -612,7 +610,7 @@ WarpX::SyncRho (amrex::Vector<std::unique_ptr<amrex::MultiFab> >& rhof, crho = charge_buf[lev+1].get(); } - rhof[lev]->copy(*crho,0,0,ncomp,ngsrc,ngdst,period,FabArrayBase::ADD); + rhof[lev]->copy(*crho,0,0,ncomp,ngsrc,ngdst,period,FabArrayBase::ADD); } // Sum up coarse patch @@ -687,9 +685,9 @@ WarpX::RestrictCurrentFromFineToCoarsePatch (int lev) current_cp[lev][0]->setVal(0.0); current_cp[lev][1]->setVal(0.0); current_cp[lev][2]->setVal(0.0); - + const IntVect& ref_ratio = refRatio(lev-1); - + std::array<const MultiFab*,3> fine { current_fp[lev][0].get(), current_fp[lev][1].get(), current_fp[lev][2].get() }; @@ -723,7 +721,7 @@ void WarpX::AddCurrentFromFineLevelandSumBoundary (int lev) { ApplyFilterandSumBoundaryJ(lev, PatchType::fine); - + // When there are current buffers, unlike coarse patch, // we don't care about the final state of them. @@ -791,7 +789,7 @@ void WarpX::RestrictRhoFromFineToCoarsePatch (int lev) { if (rho_fp[lev]) { - rho_cp[lev]->setVal(0.0); + rho_cp[lev]->setVal(0.0); const IntVect& ref_ratio = refRatio(lev-1); SyncRho(*rho_fp[lev], *rho_cp[lev], ref_ratio[0]); } diff --git a/Source/WarpXEvolve.cpp b/Source/WarpXEvolve.cpp index a0fe641a3..e3af72cf4 100644 --- a/Source/WarpXEvolve.cpp +++ b/Source/WarpXEvolve.cpp @@ -98,7 +98,7 @@ WarpX::EvolveEM (int numsteps) FillBoundaryB(); UpdateAuxilaryData(); } - + if (do_subcycling == 0 || finest_level == 0) { OneStep_nosub(cur_time); } else if (do_subcycling == 1 && finest_level == 1) { @@ -242,7 +242,7 @@ WarpX::OneStep_nosub (Real cur_time) SyncCurrent(); SyncRho(rho_fp, rho_cp); - + // Push E and B from {n} to {n+1} // (And update guard cells immediately afterwards) #ifdef WARPX_USE_PSATD @@ -297,7 +297,7 @@ WarpX::OneStep_sub1 (Real curtime) if (do_pml) { DampPML(fine_lev, PatchType::fine); - FillBoundaryE(fine_lev, PatchType::fine); + FillBoundaryE(fine_lev, PatchType::fine); } FillBoundaryB(fine_lev, PatchType::fine); @@ -349,7 +349,7 @@ WarpX::OneStep_sub1 (Real curtime) if (do_pml) { DampPML(fine_lev, PatchType::fine); - FillBoundaryE(fine_lev, PatchType::fine); + FillBoundaryE(fine_lev, PatchType::fine); } FillBoundaryB(fine_lev, PatchType::fine); @@ -377,7 +377,7 @@ WarpX::OneStep_sub1 (Real curtime) EvolveE(coarse_lev, PatchType::fine, 0.5*dt[coarse_lev]); FillBoundaryE(coarse_lev, PatchType::fine); - + EvolveB(coarse_lev, PatchType::fine, 0.5*dt[coarse_lev]); EvolveF(coarse_lev, PatchType::fine, 0.5*dt[coarse_lev], DtType::SecondHalf); @@ -402,7 +402,8 @@ WarpX::EvolveB (int lev, Real dt) { BL_PROFILE("WarpX::EvolveB()"); EvolveB(lev, PatchType::fine, dt); - if (lev > 0) { + if (lev > 0) + { EvolveB(lev, PatchType::coarse, dt); } } @@ -413,7 +414,7 @@ WarpX::EvolveB (int lev, PatchType patch_type, amrex::Real dt) const int patch_level = (patch_type == PatchType::fine) ? lev : lev-1; const std::array<Real,3>& dx = WarpX::CellSize(patch_level); const std::array<Real,3> dtsdx {dt/dx[0], dt/dx[1], dt/dx[2]}; - + MultiFab *Ex, *Ey, *Ez, *Bx, *By, *Bz; if (patch_type == PatchType::fine) { @@ -444,25 +445,25 @@ WarpX::EvolveB (int lev, PatchType patch_type, amrex::Real dt) for ( MFIter mfi(*Bx,true); mfi.isValid(); ++mfi ) { Real wt = amrex::second(); - + const Box& tbx = mfi.tilebox(Bx_nodal_flag); const Box& tby = mfi.tilebox(By_nodal_flag); const Box& tbz = mfi.tilebox(Bz_nodal_flag); - + // Call picsar routine for each tile warpx_push_bvec( - tbx.loVect(), tbx.hiVect(), - tby.loVect(), tby.hiVect(), - tbz.loVect(), tbz.hiVect(), - BL_TO_FORTRAN_3D((*Ex)[mfi]), - BL_TO_FORTRAN_3D((*Ey)[mfi]), - BL_TO_FORTRAN_3D((*Ez)[mfi]), - BL_TO_FORTRAN_3D((*Bx)[mfi]), - BL_TO_FORTRAN_3D((*By)[mfi]), - BL_TO_FORTRAN_3D((*Bz)[mfi]), - &dtsdx[0], &dtsdx[1], &dtsdx[2], - &WarpX::maxwell_fdtd_solver_id); - + tbx.loVect(), tbx.hiVect(), + tby.loVect(), tby.hiVect(), + tbz.loVect(), tbz.hiVect(), + BL_TO_FORTRAN_3D((*Ex)[mfi]), + BL_TO_FORTRAN_3D((*Ey)[mfi]), + BL_TO_FORTRAN_3D((*Ez)[mfi]), + BL_TO_FORTRAN_3D((*Bx)[mfi]), + BL_TO_FORTRAN_3D((*By)[mfi]), + BL_TO_FORTRAN_3D((*Bz)[mfi]), + &dtsdx[0], &dtsdx[1], &dtsdx[2], + &WarpX::maxwell_fdtd_solver_id); + if (cost) { Box cbx = mfi.tilebox(IntVect{AMREX_D_DECL(0,0,0)}); if (patch_type == PatchType::coarse) cbx.refine(rr); @@ -484,19 +485,19 @@ WarpX::EvolveB (int lev, PatchType patch_type, amrex::Real dt) const Box& tbx = mfi.tilebox(Bx_nodal_flag); const Box& tby = mfi.tilebox(By_nodal_flag); const Box& tbz = mfi.tilebox(Bz_nodal_flag); - + WRPX_PUSH_PML_BVEC( - tbx.loVect(), tbx.hiVect(), - tby.loVect(), tby.hiVect(), - tbz.loVect(), tbz.hiVect(), - BL_TO_FORTRAN_3D((*pml_E[0])[mfi]), - BL_TO_FORTRAN_3D((*pml_E[1])[mfi]), - BL_TO_FORTRAN_3D((*pml_E[2])[mfi]), - BL_TO_FORTRAN_3D((*pml_B[0])[mfi]), - BL_TO_FORTRAN_3D((*pml_B[1])[mfi]), - BL_TO_FORTRAN_3D((*pml_B[2])[mfi]), - &dtsdx[0], &dtsdx[1], &dtsdx[2], - &WarpX::maxwell_fdtd_solver_id); + tbx.loVect(), tbx.hiVect(), + tby.loVect(), tby.hiVect(), + tbz.loVect(), tbz.hiVect(), + BL_TO_FORTRAN_3D((*pml_E[0])[mfi]), + BL_TO_FORTRAN_3D((*pml_E[1])[mfi]), + BL_TO_FORTRAN_3D((*pml_E[2])[mfi]), + BL_TO_FORTRAN_3D((*pml_B[0])[mfi]), + BL_TO_FORTRAN_3D((*pml_B[1])[mfi]), + BL_TO_FORTRAN_3D((*pml_B[2])[mfi]), + &dtsdx[0], &dtsdx[1], &dtsdx[2], + &WarpX::maxwell_fdtd_solver_id); } } } @@ -504,7 +505,8 @@ WarpX::EvolveB (int lev, PatchType patch_type, amrex::Real dt) void WarpX::EvolveE (Real dt) { - for (int lev = 0; lev <= finest_level; ++lev) { + for (int lev = 0; lev <= finest_level; ++lev) + { EvolveE(lev, dt); } } @@ -514,7 +516,8 @@ WarpX::EvolveE (int lev, Real dt) { BL_PROFILE("WarpX::EvolveE()"); EvolveE(lev, PatchType::fine, dt); - if (lev > 0) { + if (lev > 0) + { EvolveE(lev, PatchType::coarse, dt); } } @@ -569,41 +572,42 @@ WarpX::EvolveE (int lev, PatchType patch_type, amrex::Real dt) for ( MFIter mfi(*Ex,true); mfi.isValid(); ++mfi ) { Real wt = amrex::second(); - + const Box& tex = mfi.tilebox(Ex_nodal_flag); const Box& tey = mfi.tilebox(Ey_nodal_flag); const Box& tez = mfi.tilebox(Ez_nodal_flag); - + // Call picsar routine for each tile warpx_push_evec( - tex.loVect(), tex.hiVect(), - tey.loVect(), tey.hiVect(), - tez.loVect(), tez.hiVect(), - BL_TO_FORTRAN_3D((*Ex)[mfi]), - BL_TO_FORTRAN_3D((*Ey)[mfi]), - BL_TO_FORTRAN_3D((*Ez)[mfi]), - BL_TO_FORTRAN_3D((*Bx)[mfi]), - BL_TO_FORTRAN_3D((*By)[mfi]), - BL_TO_FORTRAN_3D((*Bz)[mfi]), - BL_TO_FORTRAN_3D((*jx)[mfi]), - BL_TO_FORTRAN_3D((*jy)[mfi]), - BL_TO_FORTRAN_3D((*jz)[mfi]), - &mu_c2_dt, - &dtsdx_c2[0], &dtsdx_c2[1], &dtsdx_c2[2]); - - if (F) { + tex.loVect(), tex.hiVect(), + tey.loVect(), tey.hiVect(), + tez.loVect(), tez.hiVect(), + BL_TO_FORTRAN_3D((*Ex)[mfi]), + BL_TO_FORTRAN_3D((*Ey)[mfi]), + BL_TO_FORTRAN_3D((*Ez)[mfi]), + BL_TO_FORTRAN_3D((*Bx)[mfi]), + BL_TO_FORTRAN_3D((*By)[mfi]), + BL_TO_FORTRAN_3D((*Bz)[mfi]), + BL_TO_FORTRAN_3D((*jx)[mfi]), + BL_TO_FORTRAN_3D((*jy)[mfi]), + BL_TO_FORTRAN_3D((*jz)[mfi]), + &mu_c2_dt, + &dtsdx_c2[0], &dtsdx_c2[1], &dtsdx_c2[2]); + + if (F) + { warpx_push_evec_f( - tex.loVect(), tex.hiVect(), - tey.loVect(), tey.hiVect(), - tez.loVect(), tez.hiVect(), - BL_TO_FORTRAN_3D((*Ex)[mfi]), - BL_TO_FORTRAN_3D((*Ey)[mfi]), - BL_TO_FORTRAN_3D((*Ez)[mfi]), - BL_TO_FORTRAN_3D((*F)[mfi]), - &dtsdx_c2[0], &dtsdx_c2[1], &dtsdx_c2[2], - &WarpX::maxwell_fdtd_solver_id); + tex.loVect(), tex.hiVect(), + tey.loVect(), tey.hiVect(), + tez.loVect(), tez.hiVect(), + BL_TO_FORTRAN_3D((*Ex)[mfi]), + BL_TO_FORTRAN_3D((*Ey)[mfi]), + BL_TO_FORTRAN_3D((*Ez)[mfi]), + BL_TO_FORTRAN_3D((*F)[mfi]), + &dtsdx_c2[0], &dtsdx_c2[1], &dtsdx_c2[2], + &WarpX::maxwell_fdtd_solver_id); } - + if (cost) { Box cbx = mfi.tilebox(IntVect{AMREX_D_DECL(0,0,0)}); if (patch_type == PatchType::coarse) cbx.refine(rr); @@ -627,31 +631,31 @@ WarpX::EvolveE (int lev, PatchType patch_type, amrex::Real dt) const Box& tex = mfi.tilebox(Ex_nodal_flag); const Box& tey = mfi.tilebox(Ey_nodal_flag); const Box& tez = mfi.tilebox(Ez_nodal_flag); - + WRPX_PUSH_PML_EVEC( - tex.loVect(), tex.hiVect(), - tey.loVect(), tey.hiVect(), - tez.loVect(), tez.hiVect(), - BL_TO_FORTRAN_3D((*pml_E[0])[mfi]), - BL_TO_FORTRAN_3D((*pml_E[1])[mfi]), - BL_TO_FORTRAN_3D((*pml_E[2])[mfi]), - BL_TO_FORTRAN_3D((*pml_B[0])[mfi]), - BL_TO_FORTRAN_3D((*pml_B[1])[mfi]), - BL_TO_FORTRAN_3D((*pml_B[2])[mfi]), - &dtsdx_c2[0], &dtsdx_c2[1], &dtsdx_c2[2]); - + tex.loVect(), tex.hiVect(), + tey.loVect(), tey.hiVect(), + tez.loVect(), tez.hiVect(), + BL_TO_FORTRAN_3D((*pml_E[0])[mfi]), + BL_TO_FORTRAN_3D((*pml_E[1])[mfi]), + BL_TO_FORTRAN_3D((*pml_E[2])[mfi]), + BL_TO_FORTRAN_3D((*pml_B[0])[mfi]), + BL_TO_FORTRAN_3D((*pml_B[1])[mfi]), + BL_TO_FORTRAN_3D((*pml_B[2])[mfi]), + &dtsdx_c2[0], &dtsdx_c2[1], &dtsdx_c2[2]); + if (pml_F) { WRPX_PUSH_PML_EVEC_F( - tex.loVect(), tex.hiVect(), - tey.loVect(), tey.hiVect(), - tez.loVect(), tez.hiVect(), - BL_TO_FORTRAN_3D((*pml_E[0])[mfi]), - BL_TO_FORTRAN_3D((*pml_E[1])[mfi]), - BL_TO_FORTRAN_3D((*pml_E[2])[mfi]), - BL_TO_FORTRAN_3D((*pml_F )[mfi]), - &dtsdx_c2[0], &dtsdx_c2[1], &dtsdx_c2[2], - &WarpX::maxwell_fdtd_solver_id); + tex.loVect(), tex.hiVect(), + tey.loVect(), tey.hiVect(), + tez.loVect(), tez.hiVect(), + BL_TO_FORTRAN_3D((*pml_E[0])[mfi]), + BL_TO_FORTRAN_3D((*pml_E[1])[mfi]), + BL_TO_FORTRAN_3D((*pml_E[2])[mfi]), + BL_TO_FORTRAN_3D((*pml_F )[mfi]), + &dtsdx_c2[0], &dtsdx_c2[1], &dtsdx_c2[2], + &WarpX::maxwell_fdtd_solver_id); } } } @@ -662,7 +666,8 @@ WarpX::EvolveF (Real dt, DtType dt_type) { if (!do_dive_cleaning) return; - for (int lev = 0; lev <= finest_level; ++lev) { + for (int lev = 0; lev <= finest_level; ++lev) + { EvolveF(lev, dt, dt_type); } } @@ -707,14 +712,14 @@ WarpX::EvolveF (int lev, PatchType patch_type, Real dt, DtType dt_type) rho = rho_cp[lev].get(); F = F_cp[lev].get(); } - + const int rhocomp = (dt_type == DtType::FirstHalf) ? 0 : 1; MultiFab src(rho->boxArray(), rho->DistributionMap(), 1, 0); ComputeDivE(src, 0, {Ex,Ey,Ez}, dx); MultiFab::Saxpy(src, -mu_c2, *rho, rhocomp, 0, 1, 0); MultiFab::Saxpy(*F, dt, src, 0, 0, 1, 0); - + if (do_pml && pml[lev]->ok()) { const auto& pml_F = (patch_type == PatchType::fine) ? pml[lev]->GetF_fp() : pml[lev]->GetF_cp(); @@ -727,11 +732,11 @@ WarpX::EvolveF (int lev, PatchType patch_type, Real dt, DtType dt_type) { const Box& bx = mfi.tilebox(); WRPX_PUSH_PML_F(bx.loVect(), bx.hiVect(), - BL_TO_FORTRAN_ANYD((*pml_F )[mfi]), - BL_TO_FORTRAN_ANYD((*pml_E[0])[mfi]), - BL_TO_FORTRAN_ANYD((*pml_E[1])[mfi]), - BL_TO_FORTRAN_ANYD((*pml_E[2])[mfi]), - &dtsdx[0], &dtsdx[1], &dtsdx[2]); + BL_TO_FORTRAN_ANYD((*pml_F )[mfi]), + BL_TO_FORTRAN_ANYD((*pml_E[0])[mfi]), + BL_TO_FORTRAN_ANYD((*pml_E[1])[mfi]), + BL_TO_FORTRAN_ANYD((*pml_E[2])[mfi]), + &dtsdx[0], &dtsdx[1], &dtsdx[2]); } } } @@ -764,7 +769,7 @@ WarpX::DampPML (int lev, PatchType patch_type) const auto& pml_B = (patch_type == PatchType::fine) ? pml[lev]->GetB_fp() : pml[lev]->GetB_cp(); const auto& pml_F = (patch_type == PatchType::fine) ? pml[lev]->GetF_fp() : pml[lev]->GetF_cp(); const auto& sigba = (patch_type == PatchType::fine) ? pml[lev]->GetMultiSigmaBox_fp() - : pml[lev]->GetMultiSigmaBox_cp(); + : pml[lev]->GetMultiSigmaBox_cp(); #ifdef _OPENMP #pragma omp parallel @@ -777,26 +782,26 @@ WarpX::DampPML (int lev, PatchType patch_type) const Box& tbx = mfi.tilebox(Bx_nodal_flag); const Box& tby = mfi.tilebox(By_nodal_flag); const Box& tbz = mfi.tilebox(Bz_nodal_flag); - + WRPX_DAMP_PML(tex.loVect(), tex.hiVect(), - tey.loVect(), tey.hiVect(), - tez.loVect(), tez.hiVect(), - tbx.loVect(), tbx.hiVect(), - tby.loVect(), tby.hiVect(), - tbz.loVect(), tbz.hiVect(), - BL_TO_FORTRAN_3D((*pml_E[0])[mfi]), - BL_TO_FORTRAN_3D((*pml_E[1])[mfi]), - BL_TO_FORTRAN_3D((*pml_E[2])[mfi]), - BL_TO_FORTRAN_3D((*pml_B[0])[mfi]), - BL_TO_FORTRAN_3D((*pml_B[1])[mfi]), - BL_TO_FORTRAN_3D((*pml_B[2])[mfi]), - WRPX_PML_TO_FORTRAN(sigba[mfi])); - + tey.loVect(), tey.hiVect(), + tez.loVect(), tez.hiVect(), + tbx.loVect(), tbx.hiVect(), + tby.loVect(), tby.hiVect(), + tbz.loVect(), tbz.hiVect(), + BL_TO_FORTRAN_3D((*pml_E[0])[mfi]), + BL_TO_FORTRAN_3D((*pml_E[1])[mfi]), + BL_TO_FORTRAN_3D((*pml_E[2])[mfi]), + BL_TO_FORTRAN_3D((*pml_B[0])[mfi]), + BL_TO_FORTRAN_3D((*pml_B[1])[mfi]), + BL_TO_FORTRAN_3D((*pml_B[2])[mfi]), + WRPX_PML_TO_FORTRAN(sigba[mfi])); + if (pml_F) { const Box& tnd = mfi.nodaltilebox(); WRPX_DAMP_PML_F(tnd.loVect(), tnd.hiVect(), - BL_TO_FORTRAN_3D((*pml_F)[mfi]), - WRPX_PML_TO_FORTRAN(sigba[mfi])); + BL_TO_FORTRAN_3D((*pml_F)[mfi]), + WRPX_PML_TO_FORTRAN(sigba[mfi])); } } } diff --git a/Source/WarpXPML.H b/Source/WarpXPML.H index 86edb18e1..0cf367284 100644 --- a/Source/WarpXPML.H +++ b/Source/WarpXPML.H @@ -54,7 +54,7 @@ namespace amrex { class FabFactory<SigmaBox> { public: - FabFactory<SigmaBox> (const BoxArray& grid_ba, const Real* dx, int ncell, int delta) + FabFactory<SigmaBox> (const BoxArray& grid_ba, const Real* dx, int ncell, int delta) : m_grids(grid_ba), m_dx(dx), m_ncell(ncell), m_delta(delta) {} virtual SigmaBox* create (const Box& box, int ncomps, const FabInfo& info, int box_index) const final @@ -62,7 +62,7 @@ namespace amrex { virtual void destroy (SigmaBox* fab) const final { delete fab; } - virtual FabFactory<SigmaBox>* clone () const { + virtual FabFactory<SigmaBox>* clone () const { return new FabFactory<SigmaBox>(*this); } private: @@ -91,7 +91,7 @@ enum struct PatchType : int; class PML { public: - PML (const amrex::BoxArray& ba, const amrex::DistributionMapping& dm, + PML (const amrex::BoxArray& ba, const amrex::DistributionMapping& dm, const amrex::Geometry* geom, const amrex::Geometry* cgeom, int ncell, int delta, int ref_ratio, int do_dive_cleaning, int do_moving_window); @@ -105,10 +105,10 @@ public: amrex::MultiFab* GetF_fp (); amrex::MultiFab* GetF_cp (); - const MultiSigmaBox& GetMultiSigmaBox_fp () const + const MultiSigmaBox& GetMultiSigmaBox_fp () const { return *sigba_fp; } - const MultiSigmaBox& GetMultiSigmaBox_cp () const + const MultiSigmaBox& GetMultiSigmaBox_cp () const { return *sigba_cp; } void ExchangeB (const std::array<amrex::MultiFab*,3>& B_fp, @@ -116,9 +116,9 @@ public: void ExchangeE (const std::array<amrex::MultiFab*,3>& E_fp, const std::array<amrex::MultiFab*,3>& E_cp); void ExchangeB (PatchType patch_type, - const std::array<amrex::MultiFab*,3>& Bp); + const std::array<amrex::MultiFab*,3>& Bp); void ExchangeE (PatchType patch_type, - const std::array<amrex::MultiFab*,3>& Ep); + const std::array<amrex::MultiFab*,3>& Ep); void ExchangeF (amrex::MultiFab* F_fp, amrex::MultiFab* F_cp); void ExchangeF (PatchType patch_type, amrex::MultiFab* Fp); diff --git a/Source/WarpXPML.cpp b/Source/WarpXPML.cpp index ea8c44080..1268cc592 100644 --- a/Source/WarpXPML.cpp +++ b/Source/WarpXPML.cpp @@ -221,7 +221,7 @@ SigmaBox::SigmaBox (const Box& box, const BoxArray& grids, const Real* dx, int n FillZero(idim, sigma[idim], sigma_star[idim], overlap); } else { amrex::Abort("SigmaBox::SigmaBox(): side_faces, how did this happen?\n"); - } + } } for (auto gid : direct_faces) @@ -327,7 +327,7 @@ MultiSigmaBox::ComputePMLFactorsE (const Real* dx, Real dt) } } -PML::PML (const BoxArray& grid_ba, const DistributionMapping& grid_dm, +PML::PML (const BoxArray& grid_ba, const DistributionMapping& grid_dm, const Geometry* geom, const Geometry* cgeom, int ncell, int delta, int ref_ratio, int do_dive_cleaning, int do_moving_window) : m_geom(geom), @@ -347,7 +347,7 @@ PML::PML (const BoxArray& grid_ba, const DistributionMapping& grid_dm, int ngb = 2; int ngf = (do_moving_window) ? 2 : 0; if (WarpX::maxwell_fdtd_solver_id == 1) ngf = std::max( ngf, 1 ); - + pml_E_fp[0].reset(new MultiFab(amrex::convert(ba,WarpX::Ex_nodal_flag), dm, 3, nge)); pml_E_fp[1].reset(new MultiFab(amrex::convert(ba,WarpX::Ey_nodal_flag), dm, 3, nge)); pml_E_fp[2].reset(new MultiFab(amrex::convert(ba,WarpX::Ez_nodal_flag), dm, 3, nge)); @@ -388,7 +388,7 @@ PML::PML (const BoxArray& grid_ba, const DistributionMapping& grid_dm, pml_B_cp[0].reset(new MultiFab(amrex::convert(cba,WarpX::Bx_nodal_flag), cdm, 2, ngb)); pml_B_cp[1].reset(new MultiFab(amrex::convert(cba,WarpX::By_nodal_flag), cdm, 2, ngb)); pml_B_cp[2].reset(new MultiFab(amrex::convert(cba,WarpX::Bz_nodal_flag), cdm, 2, ngb)); - + pml_E_cp[0]->setVal(0.0); pml_E_cp[1]->setVal(0.0); pml_E_cp[2]->setVal(0.0); @@ -416,7 +416,7 @@ PML::MakeBoxArray (const amrex::Geometry& geom, const amrex::BoxArray& grid_ba, domain.grow(idim, ncell); } } - + BoxList bl; for (int i = 0, N = grid_ba.size(); i < N; ++i) { @@ -428,7 +428,7 @@ PML::MakeBoxArray (const amrex::Geometry& geom, const amrex::BoxArray& grid_ba, Box bx = grid_bx; bx.grow(ncell); bx &= domain; - + Vector<Box> bndryboxes; #if (AMREX_SPACEDIM == 3) int kbegin = -1, kend = 1; @@ -445,7 +445,7 @@ PML::MakeBoxArray (const amrex::Geometry& geom, const amrex::BoxArray& grid_ba, if (b.ok()) { bndryboxes.push_back(b); } - } + } } } } @@ -460,7 +460,7 @@ PML::MakeBoxArray (const amrex::Geometry& geom, const amrex::BoxArray& grid_ba, } } } - + BoxArray ba(bl); ba.removeOverlap(false); @@ -520,8 +520,8 @@ void PML::ExchangeB (const std::array<amrex::MultiFab*,3>& B_fp, const std::array<amrex::MultiFab*,3>& B_cp) { - ExchangeB(PatchType::fine, B_fp); - ExchangeB(PatchType::coarse, B_cp); + ExchangeB(PatchType::fine, B_fp); + ExchangeB(PatchType::coarse, B_cp); } void @@ -547,7 +547,7 @@ PML::ExchangeE (const std::array<amrex::MultiFab*,3>& E_fp, const std::array<amrex::MultiFab*,3>& E_cp) { ExchangeB(PatchType::fine, E_fp); - ExchangeB(PatchType::coarse, E_cp); + ExchangeB(PatchType::coarse, E_cp); } void @@ -602,10 +602,10 @@ PML::Exchange (MultiFab& pml, MultiFab& reg, const Geometry& geom) if (ncp == 3) { MultiFab::Add(totpmlmf,pml,2,0,1,0); } - + MultiFab::Copy(tmpregmf, reg, 0, 0, 1, ngr); tmpregmf.ParallelCopy(totpmlmf, 0, 0, 1, IntVect(0), ngr, period); - + #ifdef _OPENMP #pragma omp parallel #endif @@ -652,7 +652,7 @@ PML::FillBoundaryE (PatchType patch_type) pml_E_fp[0]->FillBoundary(period); pml_E_fp[1]->FillBoundary(period); pml_E_fp[2]->FillBoundary(period); - } + } else if (patch_type == PatchType::coarse && pml_E_cp[0] && pml_E_cp[0]->nGrowVect().max() > 0) { const auto& period = m_cgeom->periodicity(); @@ -678,7 +678,7 @@ PML::FillBoundaryB (PatchType patch_type) pml_B_fp[0]->FillBoundary(period); pml_B_fp[1]->FillBoundary(period); pml_B_fp[2]->FillBoundary(period); - } + } else if (patch_type == PatchType::coarse && pml_B_cp[0]) { const auto& period = m_cgeom->periodicity(); @@ -702,7 +702,7 @@ PML::FillBoundaryF (PatchType patch_type) { const auto& period = m_geom->periodicity(); pml_F_fp->FillBoundary(period); - } + } else if (patch_type == PatchType::coarse && pml_F_cp && pml_F_cp->nGrowVect().max() > 0) { const auto& period = m_cgeom->periodicity(); |