diff options
-rw-r--r-- | Source/Parser/WarpXParserWrapper.H | 35 | ||||
-rw-r--r-- | Source/WarpX.H | 30 |
2 files changed, 36 insertions, 29 deletions
diff --git a/Source/Parser/WarpXParserWrapper.H b/Source/Parser/WarpXParserWrapper.H new file mode 100644 index 000000000..2dd7f72c7 --- /dev/null +++ b/Source/Parser/WarpXParserWrapper.H @@ -0,0 +1,35 @@ +#ifndef WARPX_PARSER_WRAPPER_H_ +#define WARPX_PARSER_WRAPPER_H_ + +#include <WarpXParser.H> +#include <AMReX_Gpu.H> +#include <GpuParser.H> +/** + * \brief + * The ParserWrapper struct is constructed to safely use the GpuParser class + * that can essentially be though of as a raw pointer. The GpuParser does + * not have an explicit destructor and the AddPlasma subroutines handle the GpuParser + * in a safe way. The ParserWrapper struct is used to avoid memory leak + * in the EB parser functions. + */ +struct ParserWrapper + : public amrex::Gpu::Managed +{ + ParserWrapper (WarpXParser const& a_parser) noexcept + : m_parser(a_parser) {} + + ~ParserWrapper() { + m_parser.clear(); + } + + AMREX_GPU_HOST_DEVICE + amrex::Real + getField (amrex::Real x, amrex::Real y, amrex::Real z) const noexcept + { + return m_parser(x,y,z); + } + + GpuParser m_parser; +}; + +#endif diff --git a/Source/WarpX.H b/Source/WarpX.H index 1721bd57f..49e424555 100644 --- a/Source/WarpX.H +++ b/Source/WarpX.H @@ -24,6 +24,7 @@ #include <AMReX_LayoutData.H> #include <AMReX_Interpolater.H> #include <AMReX_FillPatchUtil.H> +#include <WarpXParserWrapper.H> #ifdef _OPENMP # include <omp.h> @@ -49,35 +50,6 @@ enum struct PatchType : int coarse }; -/** - * \brief - * The ParserWrapper struct is constructed to safely use the GpuParser class - * that can essentially be though of as a raw pointer. The GpuParser does - * not have an explicit destructor and the AddPlasma subroutines handle the GpuParser - * in a safe way. The ParserWrapper struct is used to avoid memory leak - * in the EB parser functions. - */ -struct ParserWrapper - : public amrex::Gpu::Managed -{ - ParserWrapper (WarpXParser const& a_parser) noexcept - : m_parser(a_parser) {} - - ~ParserWrapper() { - m_parser.clear(); - } - - AMREX_GPU_HOST_DEVICE - amrex::Real - getField (amrex::Real x, amrex::Real y, amrex::Real z) const noexcept - { - return m_parser(x,y,z); - } - - GpuParser m_parser; -}; - - class WarpX : public amrex::AmrCore { |