diff options
5 files changed, 26 insertions, 9 deletions
diff --git a/Examples/Modules/embedded_boundary_cube/analysis_fields_2d.py b/Examples/Modules/embedded_boundary_cube/analysis_fields_2d.py index 227048be9..67e893b19 100755 --- a/Examples/Modules/embedded_boundary_cube/analysis_fields_2d.py +++ b/Examples/Modules/embedded_boundary_cube/analysis_fields_2d.py @@ -48,7 +48,6 @@ for i in range(ncells[0]): (-Lx / 2 <= x < Lx / 2) * (-Lz / 2 <= z < Lz / 2) * np.cos(np.pi / Lx * c * t)) - rel_tol_err = 1e-3 # Compute relative l^2 error on By @@ -56,6 +55,10 @@ By_sim = data['By'].to_ndarray() rel_err_y = np.sqrt(np.sum(np.square(By_sim - By_th)) / np.sum(np.square(By_th))) assert (rel_err_y < rel_tol_err) +# Compute relative l^2 error on Ey +Ey_sim = data['Ey'].to_ndarray() +rel_err_y = np.sqrt(np.sum(np.square(Ey_sim/c - By_th)) / np.sum(np.square(By_th))) + test_name = os.path.split(os.getcwd())[1] checksumAPI.evaluate_checksum(test_name, filename) diff --git a/Examples/Modules/embedded_boundary_cube/inputs_2d b/Examples/Modules/embedded_boundary_cube/inputs_2d index 2b3348582..476992b36 100644 --- a/Examples/Modules/embedded_boundary_cube/inputs_2d +++ b/Examples/Modules/embedded_boundary_cube/inputs_2d @@ -20,6 +20,7 @@ my_constants.zmax = 0.5 warpx.eb_implicit_function = "max(max(x+xmin,-(x+xmax)), max(z+zmin,-(z+zmax)))" warpx.B_ext_grid_init_style = parse_B_ext_grid_function +warpx.E_ext_grid_init_style = parse_E_ext_grid_function my_constants.m = 0 my_constants.p = 1 @@ -30,6 +31,10 @@ warpx.Bz_external_grid_function(x,y,z) = 0 warpx.Bx_external_grid_function(x,y,z) = 0 warpx.By_external_grid_function(x,y,z) = cos(m * pi / Lx * (x - Lx / 2)) * cos(p * pi / Lz * (z - Lz / 2))*mu0 +warpx.Ez_external_grid_function(x,y,z) = 0 +warpx.Ex_external_grid_function(x,y,z) = 0 +warpx.Ey_external_grid_function(x,y,z) = cos(m * pi / Lx * (x - Lx / 2)) * cos(p * pi / Lz * (z - Lz / 2))*mu0*clight + diagnostics.diags_names = diag1 diag1.intervals = 1 diag1.diag_type = Full diff --git a/Regression/Checksum/benchmarks_json/embedded_boundary_cube_2d.json b/Regression/Checksum/benchmarks_json/embedded_boundary_cube_2d.json index e7c0d4828..37a82967a 100644 --- a/Regression/Checksum/benchmarks_json/embedded_boundary_cube_2d.json +++ b/Regression/Checksum/benchmarks_json/embedded_boundary_cube_2d.json @@ -1,11 +1,10 @@ { "lev=0": { - "Bx": 0.0, + "Bx": 9.263694545408502e-05, "By": 0.00031905198933489135, - "Bz": 0.0, - "Ex": 8553.906698053022, - "Ey": 0.0, + "Bz": 7.328424783762596e-05, + "Ex": 8553.90669805307, + "Ey": 60867.04830538045, "Ez": 0.0 } -} - +}
\ No newline at end of file diff --git a/Source/FieldSolver/FiniteDifferenceSolver/EvolveE.cpp b/Source/FieldSolver/FiniteDifferenceSolver/EvolveE.cpp index 02f1d8087..da91eb73d 100644 --- a/Source/FieldSolver/FiniteDifferenceSolver/EvolveE.cpp +++ b/Source/FieldSolver/FiniteDifferenceSolver/EvolveE.cpp @@ -166,9 +166,14 @@ void FiniteDifferenceSolver::EvolveECartesian ( [=] AMREX_GPU_DEVICE (int i, int j, int k){ #ifdef AMREX_USE_EB // Skip field push if this cell is fully covered by embedded boundaries +#ifdef WARPX_DIM_3D if (ly(i,j,k) <= 0) return; +#elif defined(WARPX_DIM_XZ) + //In XZ Ey is associated with a mesh node, so we need to check if the mesh node is covered + amrex::ignore_unused(ly); + if (lx(i, j, k)<=0 || lx(i-1, j, k)<=0 || lz(i, j-1, k)<=0 || lz(i, j, k)<=0) return; +#endif #endif - Ey(i, j, k) += c2 * dt * ( - T_Algo::DownwardDx(Bz, coefs_x, n_coefs_x, i, j, k) + T_Algo::DownwardDz(Bx, coefs_z, n_coefs_z, i, j, k) diff --git a/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveE.cpp b/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveE.cpp index 7f0f99556..d6bc9be9e 100644 --- a/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveE.cpp +++ b/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveE.cpp @@ -193,8 +193,13 @@ void FiniteDifferenceSolver::MacroscopicEvolveECartesian ( [=] AMREX_GPU_DEVICE (int i, int j, int k){ #ifdef AMREX_USE_EB - // Skip field push if this cell is fully covered by embedded boundaries +#ifdef WARPX_DIM_3D if (ly(i,j,k) <= 0) return; +#elif defined(WARPX_DIM_XZ) + //In XZ Ey is associated with a mesh node, so we need to check if the mesh node is covered + amrex::ignore_unused(ly); + if (lx(i, j, k)<=0 || lx(i-1, j, k)<=0 || lz(i, j, k)<=0 || lz(i, j-1, k)<=0) return; +#endif #endif // Interpolate conductivity, sigma, to Ey position on the grid amrex::Real const sigma_interp = CoarsenIO::Interp( sigma_arr, sigma_stag, |