aboutsummaryrefslogtreecommitdiff
path: root/Source/Initialization/WarpXInitData.cpp
diff options
context:
space:
mode:
authorGravatar Luca Fedeli <luca.fedeli@cea.fr> 2019-11-29 10:38:09 +0100
committerGravatar Luca Fedeli <luca.fedeli@cea.fr> 2019-11-29 10:38:09 +0100
commit9314ae556f7a1e586b619619414dddf282c85ecc (patch)
tree6d044f8cfa6377bb2118f3731e34a088cd8d0606 /Source/Initialization/WarpXInitData.cpp
parent5d7940bf90820207e763ad762003f8c101904234 (diff)
parent616a6aaedc186ef4b08a5a0bd2858b6bd747c968 (diff)
downloadWarpX-9314ae556f7a1e586b619619414dddf282c85ecc.tar.gz
WarpX-9314ae556f7a1e586b619619414dddf282c85ecc.tar.zst
WarpX-9314ae556f7a1e586b619619414dddf282c85ecc.zip
Merge remote-tracking branch 'upstream/dev' into qed_evolve_optical_depth
Diffstat (limited to 'Source/Initialization/WarpXInitData.cpp')
-rw-r--r--Source/Initialization/WarpXInitData.cpp83
1 files changed, 7 insertions, 76 deletions
diff --git a/Source/Initialization/WarpXInitData.cpp b/Source/Initialization/WarpXInitData.cpp
index 609399ece..29c9a8955 100644
--- a/Source/Initialization/WarpXInitData.cpp
+++ b/Source/Initialization/WarpXInitData.cpp
@@ -112,9 +112,13 @@ WarpX::InitFromScratch ()
mypc->AllocData();
mypc->InitData();
-#ifdef USE_OPENBC_POISSON
- InitOpenbc();
-#endif
+ // Loop through species and calculate their space-charge field
+ for (int ispecies=0; ispecies<mypc->nSpecies(); ispecies++){
+ WarpXParticleContainer& species = mypc->GetParticleContainer(ispecies);
+ if (species.initialize_self_fields) {
+ InitSpaceChargeField(species);
+ }
+ }
InitPML();
@@ -227,79 +231,6 @@ WarpX::PostRestart ()
mypc->PostRestart();
}
-#ifdef USE_OPENBC_POISSON
-void
-WarpX::InitOpenbc ()
-{
-#ifndef BL_USE_MPI
- static_assert(false, "must use MPI");
-#endif
-
- static_assert(AMREX_SPACEDIM == 3, "Openbc is 3D only");
- BL_ASSERT(finestLevel() == 0);
-
- const int lev = 0;
-
- const Geometry& gm = Geom(lev);
- const Box& gbox = gm.Domain();
- int lohi[6];
- warpx_openbc_decompose(gbox.loVect(), gbox.hiVect(), lohi, lohi+3);
-
- int nprocs = ParallelDescriptor::NProcs();
- int myproc = ParallelDescriptor::MyProc();
- Vector<int> alllohi(6*nprocs,100000);
-
- MPI_Allgather(lohi, 6, MPI_INT, alllohi.data(), 6, MPI_INT, ParallelDescriptor::Communicator());
-
- BoxList bl{IndexType::TheNodeType()};
- for (int i = 0; i < nprocs; ++i)
- {
- bl.push_back(Box(IntVect(alllohi[6*i ],alllohi[6*i+1],alllohi[6*i+2]),
- IntVect(alllohi[6*i+3],alllohi[6*i+4],alllohi[6*i+5]),
- IndexType::TheNodeType()));
- }
- BoxArray ba{bl};
-
- Vector<int> iprocmap(nprocs+1);
- std::iota(iprocmap.begin(), iprocmap.end(), 0);
- iprocmap.back() = myproc;
-
- DistributionMapping dm{iprocmap};
-
- MultiFab rho_openbc(ba, dm, 1, 0);
- MultiFab phi_openbc(ba, dm, 1, 0);
-
- bool local = true;
- const std::unique_ptr<MultiFab>& rho = mypc->GetChargeDensity(lev, local);
-
- rho_openbc.setVal(0.0);
- rho_openbc.copy(*rho, 0, 0, 1, rho->nGrow(), 0, gm.periodicity(), FabArrayBase::ADD);
-
- const Real* dx = gm.CellSize();
-
- warpx_openbc_potential(rho_openbc[myproc].dataPtr(), phi_openbc[myproc].dataPtr(), dx);
-
- BoxArray nba = boxArray(lev);
- nba.surroundingNodes();
- MultiFab phi(nba, DistributionMap(lev), 1, 0);
- phi.copy(phi_openbc, gm.periodicity());
-
-#ifdef _OPENMP
-#pragma omp parallel
-#endif
- for (MFIter mfi(phi); mfi.isValid(); ++mfi)
- {
- const Box& bx = mfi.validbox();
- warpx_compute_E(bx.loVect(), bx.hiVect(),
- BL_TO_FORTRAN_3D(phi[mfi]),
- BL_TO_FORTRAN_3D((*Efield[lev][0])[mfi]),
- BL_TO_FORTRAN_3D((*Efield[lev][1])[mfi]),
- BL_TO_FORTRAN_3D((*Efield[lev][2])[mfi]),
- dx);
- }
-}
-#endif
-
void
WarpX::InitLevelData (int lev, Real time)
{