From 1d67cba10d34a65542294efaed6f02f6c3284ab0 Mon Sep 17 00:00:00 2001 From: Remi Lehe Date: Thu, 10 Aug 2023 21:43:57 -0700 Subject: Add Python wrapper to set the lens strength (#3748) * Add Python wrapper to set the lens strength * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Correct missing `c_real` * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Add assert message --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- Source/Python/WarpXWrappers.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'Source/Python/WarpXWrappers.cpp') diff --git a/Source/Python/WarpXWrappers.cpp b/Source/Python/WarpXWrappers.cpp index 8d3be68be..02cee52e0 100644 --- a/Source/Python/WarpXWrappers.cpp +++ b/Source/Python/WarpXWrappers.cpp @@ -773,6 +773,21 @@ namespace warpx.m_poisson_boundary_handler.setPotentialEB(potential); } + void warpx_setPlasmaLensStrength (const int i_lens, const amrex::Real strength_E, const amrex::Real strength_B ) { + auto & mypc = WarpX::GetInstance().GetPartContainer(); + WARPX_ALWAYS_ASSERT_WITH_MESSAGE( i_lens >= mypc.h_repeated_plasma_lens_strengths_E.size(), + "i_lens is larger than the number of plasma lenses."); + mypc.h_repeated_plasma_lens_strengths_E[i_lens] = strength_E; + mypc.h_repeated_plasma_lens_strengths_B[i_lens] = strength_B; + amrex::Gpu::copyAsync(amrex::Gpu::hostToDevice, + mypc.h_repeated_plasma_lens_strengths_E.begin(), mypc.h_repeated_plasma_lens_strengths_E.end(), + mypc.d_repeated_plasma_lens_strengths_E.begin()); + amrex::Gpu::copyAsync(amrex::Gpu::hostToDevice, + mypc.h_repeated_plasma_lens_strengths_B.begin(), mypc.h_repeated_plasma_lens_strengths_B.end(), + mypc.d_repeated_plasma_lens_strengths_B.begin()); + amrex::Gpu::synchronize(); + } + void mypc_Redistribute () { auto & mypc = WarpX::GetInstance().GetPartContainer(); mypc.Redistribute(); -- cgit v1.2.3