Skip to content

Commit

Permalink
Implement injection orthogal to plane
Browse files Browse the repository at this point in the history
  • Loading branch information
RemiLehe committed Jan 25, 2022
1 parent 4833bc8 commit 6162c11
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Source/Initialization/InjectorMomentum.H
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ struct InjectorMomentumGaussianFlux

// Note that in 2D, with m_flux_normal_axis == 1, uy is out of the plane and so Gaussian and uz is v*Gaussian
amrex::Real const ux = (m_flux_normal_axis == 0 ? m_ux_th*ur : amrex::RandomNormal(m_ux_m, m_ux_th, engine));
amrex::Real const uy = (m_flux_normal_axis == 1 && AMREX_SPACEDIM==3 ? m_uy_th*ur : amrex::RandomNormal(m_uy_m, m_uy_th, engine));
amrex::Real const uz = (m_flux_normal_axis == WARPX_ZINDEX ? m_uz_th*ur : amrex::RandomNormal(m_uz_m, m_uz_th, engine));
amrex::Real const uy = (m_flux_normal_axis == 1 ? m_uy_th*ur : amrex::RandomNormal(m_uy_m, m_uy_th, engine));
amrex::Real const uz = (m_flux_normal_axis == 2 ? m_uz_th*ur : amrex::RandomNormal(m_uz_m, m_uz_th, engine));
return amrex::XDim3{ux, uy, uz};
}

Expand Down
5 changes: 4 additions & 1 deletion Source/Initialization/PlasmaInjector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,9 @@ PlasmaInjector::PlasmaInjector (int ispecies, const std::string& name)
if (flux_normal_axis_string == "r" || flux_normal_axis_string == "R") {
flux_normal_axis = 0;
}
if (flux_normal_axis_string == "t" || flux_normal_axis_string == "T") {
flux_normal_axis = 1;
}
#else
# ifndef WARPX_DIM_1D_Z
if (flux_normal_axis_string == "x" || flux_normal_axis_string == "X") {
Expand All @@ -265,7 +268,7 @@ PlasmaInjector::PlasmaInjector (int ispecies, const std::string& name)
}
#endif
if (flux_normal_axis_string == "z" || flux_normal_axis_string == "Z") {
flux_normal_axis = WARPX_ZINDEX;
flux_normal_axis = 2;
}
#ifdef WARPX_DIM_3D
std::string flux_normal_axis_help = "'x', 'y', or 'z'.";
Expand Down
15 changes: 12 additions & 3 deletions Source/Particles/PhysicalParticleContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1181,9 +1181,13 @@ PhysicalParticleContainer::AddPlasmaFlux (amrex::Real dt)
const auto problo = geom.ProbLoArray();

Real scale_fac = 0._rt;
if (dx[plasma_injector->flux_normal_axis]*num_ppc_real != 0._rt) {
scale_fac = AMREX_D_TERM(dx[0], *dx[1], *dx[2])/dx[plasma_injector->flux_normal_axis]/num_ppc_real;
}
#if defined(WARPX_DIM_XZ) || defined(WARPX_DIM_RZ)
scale_fac = dx[0]*dx[1]/num_ppc_real;
if (plasma_injector->flux_normal_axis == 0) scale_fac /= dx[0];
if (plasma_injector->flux_normal_axis == 2) scale_fac /= dx[1];
#else
scale_fac = dx[0]*dx[1]*dx[2]/dx[plasma_injector->flux_normal_axis]/num_ppc_real;
#endif

amrex::LayoutData<amrex::Real>* cost = WarpX::getCosts(0);

Expand Down Expand Up @@ -1247,7 +1251,12 @@ PhysicalParticleContainer::AddPlasmaFlux (amrex::Real dt)
bool no_overlap = false;

for (int dir=0; dir<AMREX_SPACEDIM; dir++) {
// Needs to be checked
#if defined(WARPX_DIM_XZ) || defined(WARPX_DIM_RZ)
if (2*dir == plasma_injector->flux_normal_axis) {
#else
if (dir == plasma_injector->flux_normal_axis) {
#endif
if (plasma_injector->flux_direction > 0) {
if (plasma_injector->surface_flux_pos < tile_realbox.lo(dir) ||
plasma_injector->surface_flux_pos >= tile_realbox.hi(dir)) {
Expand Down

0 comments on commit 6162c11

Please sign in to comment.