WarpX
Loading...
Searching...
No Matches
PML_current.H
Go to the documentation of this file.
1/* Copyright 2019 Aurore Blelly, Axel Huebl, Maxence Thevenet
2 * Remi Lehe
3 *
4 * This file is part of WarpX.
5 *
6 * License: BSD-3-Clause-LBNL
7 */
8#ifndef WARPX_PML_CURRENT_H_
9#define WARPX_PML_CURRENT_H_
10
12
13#include <AMReX.H>
14#include <AMReX_FArrayBox.H>
15
17void push_ex_pml_current (int j, int k, int l,
20 amrex::Real const * const sigjy,
21 amrex::Real const * const sigjz,
22 int ylo, int zlo,
23 amrex::Real mu_c2_dt)
24{
25#if defined(WARPX_DIM_3D)
26 amrex::Real alpha_xy, alpha_xz;
27 if (sigjy[k-ylo]+sigjz[l-zlo] == 0){
28 alpha_xy = 0.5;
29 alpha_xz = 0.5;
30 }
31 else {
32 alpha_xy = sigjy[k-ylo]/(sigjy[k-ylo]+sigjz[l-zlo]);
33 alpha_xz = sigjz[l-zlo]/(sigjy[k-ylo]+sigjz[l-zlo]);
34 }
35 Ex(j,k,l,PMLComp::xy) = Ex(j,k,l,PMLComp::xy) - mu_c2_dt * alpha_xy * jx(j,k,l);
36 Ex(j,k,l,PMLComp::xz) = Ex(j,k,l,PMLComp::xz) - mu_c2_dt * alpha_xz * jx(j,k,l);
37#else
38 Ex(j,k,l,PMLComp::xz) = Ex(j,k,l,PMLComp::xz) - mu_c2_dt * jx(j,k,l);
39 amrex::ignore_unused(sigjy, sigjz, ylo, zlo);
40#endif
41}
42
44void push_ey_pml_current (int j, int k, int l,
47 amrex::Real const * const sigjx,
48 amrex::Real const * const sigjz,
49 int xlo, int zlo,
50 amrex::Real mu_c2_dt)
51{
52#if defined(WARPX_DIM_3D)
53 amrex::Real alpha_yx, alpha_yz;
54 if (sigjx[j-xlo]+sigjz[l-zlo] == 0){
55 alpha_yx = 0.5;
56 alpha_yz = 0.5;
57 }
58 else {
59 alpha_yx = sigjx[j-xlo]/(sigjx[j-xlo]+sigjz[l-zlo]);
60 alpha_yz = sigjz[l-zlo]/(sigjx[j-xlo]+sigjz[l-zlo]);
61 }
62 Ey(j,k,l,PMLComp::yz) = Ey(j,k,l,PMLComp::yz) - mu_c2_dt * alpha_yz * jy(j,k,l);
63 Ey(j,k,l,PMLComp::yx) = Ey(j,k,l,PMLComp::yx) - mu_c2_dt * alpha_yx * jy(j,k,l);
64#else
65 Ey(j,k,l,PMLComp::yz) = Ey(j,k,l,PMLComp::yz) - amrex::Real(0.5) * mu_c2_dt * jy(j,k,l);
66 Ey(j,k,l,PMLComp::yx) = Ey(j,k,l,PMLComp::yx) - amrex::Real(0.5) * mu_c2_dt * jy(j,k,l);
67 amrex::ignore_unused(sigjx, sigjz, xlo, zlo);
68#endif
69}
70
72void push_ez_pml_current (int j, int k, int l,
75 amrex::Real const * const sigjx,
76 amrex::Real const * const sigjy,
77 int xlo, int ylo,
78 amrex::Real mu_c2_dt)
79{
80#if defined(WARPX_DIM_3D)
81 amrex::Real alpha_zx, alpha_zy;
82 if (sigjx[j-xlo]+sigjy[k-ylo]==0){
83 alpha_zx = 0.5;
84 alpha_zy = 0.5;
85 }
86 else {
87 alpha_zx = sigjx[j-xlo]/(sigjx[j-xlo]+sigjy[k-ylo]);
88 alpha_zy = sigjy[k-ylo]/(sigjx[j-xlo]+sigjy[k-ylo]);
89 }
90 Ez(j,k,l,PMLComp::zx) = Ez(j,k,l,PMLComp::zx) - mu_c2_dt * alpha_zx * jz(j,k,l);
91 Ez(j,k,l,PMLComp::zy) = Ez(j,k,l,PMLComp::zy) - mu_c2_dt * alpha_zy * jz(j,k,l);
92#else
93 Ez(j,k,l,PMLComp::zx) = Ez(j,k,l,PMLComp::zx) - mu_c2_dt * jz(j,k,l);
94 amrex::ignore_unused(sigjx, sigjy, xlo, ylo);
95#endif
96}
97
99void damp_jx_pml (int j, int k, int l,
101 amrex::Real const* const sigsjx,
102 amrex::Real const* const sigjy,
103 amrex::Real const* const sigjz,
104 int xlo, int ylo, int zlo)
105{
106#if defined(WARPX_DIM_3D)
107 jx(j,k,l) = jx(j,k,l) * sigsjx[j-xlo] * sigjy[k-ylo] * sigjz[l-zlo];
108#else
109 jx(j,k,l) = jx(j,k,l) * sigsjx[j-xlo] * sigjz[k-zlo];
110 amrex::ignore_unused(sigjy, ylo);
111#endif
112}
113
115void damp_jy_pml (int j, int k, int l,
117 amrex::Real const * const sigjx,
118 amrex::Real const * const sigsjy,
119 amrex::Real const * const sigjz,
120 int xlo, int ylo, int zlo)
121{
122#if defined(WARPX_DIM_3D)
123 jy(j,k,l) = jy(j,k,l) * sigjx[j-xlo] * sigsjy[k-ylo] * sigjz[l-zlo];
124#else
125 jy(j,k,l) = jy(j,k,l) * sigjx[j-xlo] * sigjz[k-zlo];
126 amrex::ignore_unused(sigsjy, ylo);
127#endif
128}
129
131void damp_jz_pml (int j, int k, int l,
133 amrex::Real const * const sigjx,
134 amrex::Real const * const sigjy,
135 amrex::Real const * const sigsjz,
136 int xlo, int ylo, int zlo)
137{
138#if defined(WARPX_DIM_3D)
139 jz(j,k,l) = jz(j,k,l) * sigjx[j-xlo] * sigjy[k-ylo] * sigsjz[l-zlo];
140#else
141 jz(j,k,l) = jz(j,k,l) * sigjx[j-xlo] * sigsjz[k-zlo];
142 amrex::ignore_unused(sigjy, ylo);
143#endif
144}
145
146#endif //WARPX_PML_CURRENT_H_
#define AMREX_INLINE
#define AMREX_GPU_HOST_DEVICE
AMREX_GPU_HOST_DEVICE AMREX_INLINE void push_ey_pml_current(int j, int k, int l, amrex::Array4< amrex::Real > const &Ey, amrex::Array4< amrex::Real const > const &jy, amrex::Real const *const sigjx, amrex::Real const *const sigjz, int xlo, int zlo, amrex::Real mu_c2_dt)
Definition PML_current.H:44
AMREX_GPU_HOST_DEVICE AMREX_INLINE void push_ez_pml_current(int j, int k, int l, amrex::Array4< amrex::Real > const &Ez, amrex::Array4< amrex::Real const > const &jz, amrex::Real const *const sigjx, amrex::Real const *const sigjy, int xlo, int ylo, amrex::Real mu_c2_dt)
Definition PML_current.H:72
AMREX_GPU_HOST_DEVICE AMREX_INLINE void damp_jz_pml(int j, int k, int l, amrex::Array4< amrex::Real > const &jz, amrex::Real const *const sigjx, amrex::Real const *const sigjy, amrex::Real const *const sigsjz, int xlo, int ylo, int zlo)
Definition PML_current.H:131
AMREX_GPU_HOST_DEVICE AMREX_INLINE void damp_jy_pml(int j, int k, int l, amrex::Array4< amrex::Real > const &jy, amrex::Real const *const sigjx, amrex::Real const *const sigsjy, amrex::Real const *const sigjz, int xlo, int ylo, int zlo)
Definition PML_current.H:115
AMREX_GPU_HOST_DEVICE AMREX_INLINE void damp_jx_pml(int j, int k, int l, amrex::Array4< amrex::Real > const &jx, amrex::Real const *const sigsjx, amrex::Real const *const sigjy, amrex::Real const *const sigjz, int xlo, int ylo, int zlo)
Definition PML_current.H:99
AMREX_GPU_HOST_DEVICE AMREX_INLINE void push_ex_pml_current(int j, int k, int l, amrex::Array4< amrex::Real > const &Ex, amrex::Array4< amrex::Real const > const &jx, amrex::Real const *const sigjy, amrex::Real const *const sigjz, int ylo, int zlo, amrex::Real mu_c2_dt)
Definition PML_current.H:17
__host__ __device__ void ignore_unused(const Ts &...)
@ xz
Definition PMLComponent.H:16
@ zx
Definition PMLComponent.H:18
@ zy
Definition PMLComponent.H:18
@ yz
Definition PMLComponent.H:17
@ yx
Definition PMLComponent.H:17
@ xy
Definition PMLComponent.H:16