diff --git a/.clang-tidy b/.clang-tidy index 2d45d750ddc..c7fb58ae117 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -7,14 +7,17 @@ Checks: ' -bugprone-unchecked-optional-access, cert-*, -cert-err58-cpp, - cppcoreguidelines-avoid-goto, - cppcoreguidelines-interfaces-global-init, + cppcoreguidelines-*, + -cppcoreguidelines-avoid-c-arrays, + -cppcoreguidelines-avoid-magic-numbers, -cppcoreguidelines-avoid-non-const-global-variables, -cppcoreguidelines-init-variables, -cppcoreguidelines-macro-usage, - -cppcoreguidelines-narrowing-conversions, -cppcoreguidelines-no-malloc, + -cppcoreguidelines-narrowing-conversions, + -cppcoreguidelines-non-private-member-variables-in-classes, -cppcoreguidelines-owning-memory, + -cppcoreguidelines-pro-*, google-build-explicit-make-pair, google-build-namespaces, google-global-names-in-headers, diff --git a/.github/workflows/cuda.yml b/.github/workflows/cuda.yml index d3610179695..6b810e1cbb0 100644 --- a/.github/workflows/cuda.yml +++ b/.github/workflows/cuda.yml @@ -18,10 +18,6 @@ jobs: env: CXXFLAGS: "-Werror" CMAKE_GENERATOR: Ninja - # setuptools/mp4py work-around, see - # https://github.com/mpi4py/mpi4py/pull/159 - # https://github.com/mpi4py/mpi4py/issues/157#issuecomment-1001022274 - SETUPTOOLS_USE_DISTUTILS: stdlib steps: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 @@ -75,7 +71,8 @@ jobs: -DAMReX_CUDA_ERROR_CAPTURE_THIS=ON cmake --build build_sp -j 2 - python3 -m pip install --upgrade pip setuptools wheel + python3 -m pip install --upgrade pip + python3 -m pip install --upgrade build packaging setuptools wheel export WARPX_MPI=ON export PYWARPX_LIB_DIR=$PWD/build_sp/lib/site-packages/pywarpx/ python3 -m pip wheel . @@ -111,20 +108,16 @@ jobs: which nvcc || echo "nvcc not in PATH!" git clone https://github.com/AMReX-Codes/amrex.git ../amrex - cd ../amrex && git checkout --detach da79aff8053058371a78d4bf85488384242368ee && cd - + cd ../amrex && git checkout --detach d36463103daed09a40cdea235041a6ab79ff280c && cd - make COMP=gcc QED=FALSE USE_MPI=TRUE USE_GPU=TRUE USE_OMP=FALSE USE_PSATD=TRUE USE_CCACHE=TRUE -j 2 build_nvhpc21-11-nvcc: name: NVHPC@21.11 NVCC/NVC++ Release [tests] runs-on: ubuntu-20.04 if: github.event.pull_request.draft == false - env: - # For NVHPC, Ninja is slower than the default: - #CMAKE_GENERATOR: Ninja - # setuptools/mp4py work-around, see - # https://github.com/mpi4py/mpi4py/pull/159 - # https://github.com/mpi4py/mpi4py/issues/157#issuecomment-1001022274 - SETUPTOOLS_USE_DISTUTILS: stdlib + #env: + # # For NVHPC, Ninja is slower than the default: + # CMAKE_GENERATOR: Ninja steps: - uses: actions/checkout@v3 - name: Dependencies @@ -175,7 +168,8 @@ jobs: # https://github.com/mpi4py/mpi4py/issues/114 #export CFLAGS="-noswitcherror" - #python3 -m pip install --upgrade pip setuptools wheel + #python3 -m pip install --upgrade pip + #python3 -m pip install --upgrade build packaging setuptools wheel #export WARPX_MPI=ON #export PYWARPX_LIB_DIR=$PWD/build/lib/site-packages/pywarpx/ #python3 -m pip wheel . diff --git a/.github/workflows/intel.yml b/.github/workflows/intel.yml index aba8200f1b2..b4a8869d498 100644 --- a/.github/workflows/intel.yml +++ b/.github/workflows/intel.yml @@ -41,7 +41,8 @@ jobs: export CXX=$(which icpc) export CC=$(which icc) - python3 -m pip install --upgrade pip setuptools wheel + python3 -m pip install --upgrade pip + python3 -m pip install --upgrade build packaging setuptools wheel cmake -S . -B build_dp \ -DCMAKE_VERBOSE_MAKEFILE=ON \ @@ -104,7 +105,7 @@ jobs: export CC=$(which icx) python3 -m pip install --upgrade pip - python3 -m pip install --upgrade setuptools wheel + python3 -m pip install --upgrade build packaging setuptools wheel cmake -S . -B build_sp \ -DCMAKE_CXX_FLAGS_RELEASE="-O1 -DNDEBUG" \ @@ -178,6 +179,6 @@ jobs: # Skip this as it will copy the binary artifacts and we are tight on disk space # python3 -m pip install --upgrade pip - # python3 -m pip install --upgrade setuptools wheel + # python3 -m pip install --upgrade build packaging setuptools wheel # PYWARPX_LIB_DIR=$PWD/build_sp/lib/site-packages/pywarpx/ python3 -m pip wheel . # python3 -m pip install *.whl diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index c81ee598114..fda2cb77a51 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -16,10 +16,6 @@ jobs: HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: TRUE # For macOS, Ninja is slower than the default: #CMAKE_GENERATOR: Ninja - # setuptools/mp4py work-around, see - # https://github.com/mpi4py/mpi4py/pull/159 - # https://github.com/mpi4py/mpi4py/issues/157#issuecomment-1001022274 - SETUPTOOLS_USE_DISTUTILS: stdlib steps: - uses: actions/checkout@v3 - name: Brew Cache @@ -65,7 +61,7 @@ jobs: - name: build WarpX run: | python3 -m pip install --upgrade pip - python3 -m pip install --upgrade pip setuptools wheel + python3 -m pip install --upgrade build packaging setuptools wheel cmake -S . -B build_dp \ -DCMAKE_VERBOSE_MAKEFILE=ON \ diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 0b43760b621..8fa83c99bef 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -167,10 +167,6 @@ jobs: CXX: clang++ # On CI for this test, Ninja is slower than the default: #CMAKE_GENERATOR: Ninja - # setuptools/mp4py work-around, see - # https://github.com/mpi4py/mpi4py/pull/159 - # https://github.com/mpi4py/mpi4py/issues/157#issuecomment-1001022274 - SETUPTOOLS_USE_DISTUTILS: stdlib steps: - uses: actions/checkout@v3 - name: install dependencies @@ -190,7 +186,8 @@ jobs: ccache-openmp-pyfull- - name: build WarpX run: | - python3 -m pip install --upgrade pip setuptools wheel + python3 -m pip install --upgrade pip + python3 -m pip install --upgrade build packaging setuptools wheel export CXXFLAGS="-Werror -Wno-error=pass-failed" diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index e0629e3abca..8e2bb00f1db 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -41,7 +41,9 @@ jobs: cmake --build build --config Debug --parallel 2 if(!$?) { Exit $LASTEXITCODE } - python3 -m pip install --upgrade pip setuptools wheel + python3 -m pip install --upgrade pip + if(!$?) { Exit $LASTEXITCODE } + python3 -m pip install --upgrade build packaging setuptools wheel if(!$?) { Exit $LASTEXITCODE } cmake --build build --config Debug --target install if(!$?) { Exit $LASTEXITCODE } @@ -64,7 +66,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 with: - python-version: '3.x' + python-version: '3.8' - uses: seanmiddleditch/gha-setup-ninja@master - name: CCache Cache uses: actions/cache@v3 @@ -100,7 +102,9 @@ jobs: cmake --build build --config Release --target install if errorlevel 1 exit 1 - python3 -m pip install --upgrade pip setuptools wheel + python3 -m pip install --upgrade pip + if errorlevel 1 exit 1 + python3 -m pip install --upgrade build packaging setuptools wheel if errorlevel 1 exit 1 python3 -m pip install --upgrade -r requirements.txt if errorlevel 1 exit 1 diff --git a/CMakeLists.txt b/CMakeLists.txt index 4dc886be52d..b2744d9c768 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ # Preamble #################################################################### # cmake_minimum_required(VERSION 3.20.0) -project(WarpX VERSION 23.10) +project(WarpX VERSION 23.11) include(${WarpX_SOURCE_DIR}/cmake/WarpXFunctions.cmake) @@ -127,7 +127,7 @@ option(WarpX_PYTHON_IPO ) set(pyWarpX_VERSION_INFO "" CACHE STRING - "PEP-440 conformant version (set by distutils)") + "PEP-440 conformant version (set by setup.py)") # enforce consistency of dependent options if(WarpX_APP OR WarpX_PYTHON) diff --git a/Docs/source/acknowledge_us.rst b/Docs/source/acknowledge_us.rst index 2c0b1ce35f2..79bb9fa8884 100644 --- a/Docs/source/acknowledge_us.rst +++ b/Docs/source/acknowledge_us.rst @@ -55,9 +55,8 @@ If your project uses a specific algorithm or component, please consider citing t - Sandberg R T, Lehe R, Mitchell C E, Garten M, Qiang J, Vay J-L and Huebl A. **Hybrid Beamline Element ML-Training for Surrogates in the ImpactX Beam-Dynamics Code**. - 14th International Particle Accelerator Conference (IPAC'23), WEPA101, *in print*, 2023. - `preprint `__, - `DOI:10.18429/JACoW-IPAC-23-WEPA101 `__ + 14th International Particle Accelerator Conference (IPAC'23), WEPA101, 2023. + `DOI:10.18429/JACoW-IPAC2023-WEPA101 `__ - Huebl A, Lehe R, Zoni E, Shapoval O, Sandberg R T, Garten M, Formenti A, Jambunathan R, Kumar P, Gott K, Myers A, Zhang W, Almgren A, Mitchell C E, Qiang J, Sinn A, Diederichs S, Thevenet M, Grote D, Fedeli L, Clark T, Zaim N, Vincenti H, Vay JL. **From Compact Plasma Particle Sources to Advanced Accelerators with Modeling at Exascale**. @@ -75,6 +74,11 @@ If your project uses a specific algorithm or component, please consider citing t *New Journal of Physics* **24** 025009, 2022. `DOI:10.1088/1367-2630/ac4ef1 `__ +- Lehe R, Blelly A, Giacomel L, Jambunathan R, Vay JL. + **Absorption of charged particles in perfectly matched layers by optimal damping of the deposited current**. + *Physical Review E* **106** 045306, 2022. + `DOI:10.1103/PhysRevE.106.045306 `__ + - Zoni E, Lehe R, Shapoval O, Belkin D, Zaim N, Fedeli L, Vincenti H, Vay JL. **A hybrid nodal-staggered pseudo-spectral electromagnetic particle-in-cell method with finite-order centering**. *Computer Physics Communications* **279**, 2022. `DOI:10.1016/j.cpc.2022.108457 `__ diff --git a/Docs/source/conf.py b/Docs/source/conf.py index f9e06bcc8c3..f6fa22f40f8 100644 --- a/Docs/source/conf.py +++ b/Docs/source/conf.py @@ -79,9 +79,9 @@ # built documents. # # The short X.Y version. -version = u'23.10' +version = u'23.11' # The full version, including alpha/beta/rc tags. -release = u'23.10' +release = u'23.11' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/Docs/source/dataanalysis/formats.rst b/Docs/source/dataanalysis/formats.rst index 85518abebb7..a7836d41fef 100644 --- a/Docs/source/dataanalysis/formats.rst +++ b/Docs/source/dataanalysis/formats.rst @@ -19,7 +19,7 @@ When using the AMReX `plotfile` format, users can set the ``amrex.async_out=1`` option to perform the IO in a non-blocking fashion, meaning that the simulation will continue to run while an IO thread controls writing the data to disk. This can significantly reduce the overall time spent in IO. This is primarily intended for -large runs on supercomputers such as Summit and Cori; depending on the MPI +large runs on supercomputers (e.g. at OLCF or NERSC); depending on the MPI implementation you are using, you may not see a benefit on your workstation. When writing plotfiles, each rank will write to a separate file, up to some maximum number diff --git a/Docs/source/highlights.rst b/Docs/source/highlights.rst index 1e99629b9c2..0f9bee1808a 100644 --- a/Docs/source/highlights.rst +++ b/Docs/source/highlights.rst @@ -24,11 +24,10 @@ Scientific works in laser-plasma and beam-plasma acceleration. Phys. Rev. Research **5**, 033112, 2023 `DOI:10.1103/PhysRevResearch.5.033112 `__ -#. Sandberg R T, Lehe R, Mitchell C E, Garten M, Qiang J, Vay J-L, Huebl A. +#. Sandberg R T, Lehe R, Mitchell C E, Garten M, Qiang J, Vay J-L and Huebl A. **Hybrid Beamline Element ML-Training for Surrogates in the ImpactX Beam-Dynamics Code**. - 14th International Particle Accelerator Conference (IPAC'23), WEPA101, *in print*, 2023. - `preprint `__, - `DOI:10.18429/JACoW-IPAC-23-WEPA101 `__ + 14th International Particle Accelerator Conference (IPAC'23), WEPA101, 2023. + `DOI:10.18429/JACoW-IPAC2023-WEPA101 `__ #. Wang J, Zeng M, Li D, Wang X, Gao J. **High quality beam produced by tightly focused laser driven wakefield accelerators**. @@ -141,3 +140,11 @@ High-Performance Computing and Numerics Scientific works in High-Performance Computing, applied mathematics and numerics. Please see :ref:`this section `. + +Nuclear Fusion - Magnetically Confined Plasmas +********************************************** + +#. Nicks, B. S., Putvinski, S. and Tajima, T. + **Stabilization of the Alfvén-ion cyclotron instability through short plasmas: Fully kinetic simulations in a high-beta regime**. + Physics of Plasmas **30**, 102108, 2023. + `DOI:10.1063/5.0163889 `__ diff --git a/Docs/source/install/cmake.rst b/Docs/source/install/cmake.rst index 457a352b3c2..a76e8c212a2 100644 --- a/Docs/source/install/cmake.rst +++ b/Docs/source/install/cmake.rst @@ -211,7 +211,8 @@ PICMI Python Bindings .. code-block:: bash - python3 -m pip install -U pip setuptools wheel + python3 -m pip install -U pip + python3 -m pip install -U build packaging setuptools wheel python3 -m pip install -U cmake python3 -m pip install -r requirements.txt diff --git a/Docs/source/install/hpc.rst b/Docs/source/install/hpc.rst index d6e901276d7..9617f2a7fd6 100644 --- a/Docs/source/install/hpc.rst +++ b/Docs/source/install/hpc.rst @@ -33,7 +33,6 @@ This section documents quick-start guides for a selection of supercomputers that :maxdepth: 1 hpc/adastra - hpc/cori hpc/crusher hpc/frontier hpc/fugaku diff --git a/Docs/source/install/hpc/cori.rst b/Docs/source/install/hpc/cori.rst deleted file mode 100644 index 35421982142..00000000000 --- a/Docs/source/install/hpc/cori.rst +++ /dev/null @@ -1,412 +0,0 @@ -.. _building-cori: - -Cori (NERSC) -============ - -The `Cori cluster `_ is located at NERSC. - - -Introduction ------------- - -If you are new to this system, **please see the following resources**: - -* `GPU nodes `__ - -* `Cori user guide `__ -* Batch system: `Slurm `__ -* `Jupyter service `__ -* `Production directories `__: - - * ``$SCRATCH``: per-user production directory, purged every 30 days (20TB) - * ``/global/cscratch1/sd/m3239``: shared production directory for users in the project ``m3239``, purged every 30 days (50TB) - * ``/global/cfs/cdirs/m3239/``: community file system for users in the project ``m3239`` (100TB) - -Installation ------------- - -Use the following commands to download the WarpX source code and switch to the correct branch: - -.. code-block:: bash - - git clone https://github.com/ECP-WarpX/WarpX.git $HOME/src/warpx - -KNL -^^^ - -We use the following modules and environments on the system (``$HOME/knl_warpx.profile``). - -.. literalinclude:: ../../../../Tools/machines/cori-nersc/knl_warpx.profile.example - :language: bash - :caption: You can copy this file from ``Tools/machines/cori-nersc/knl_warpx.profile.example``. - -And install ADIOS2, BLAS++ and LAPACK++: - -.. code-block:: bash - - source $HOME/knl_warpx.profile - - # c-blosc (I/O compression) - git clone -b v1.21.1 https://github.com/Blosc/c-blosc.git src/c-blosc - rm -rf src/c-blosc-knl-build - cmake -S src/c-blosc -B src/c-blosc-knl-build -DBUILD_TESTS=OFF -DBUILD_BENCHMARKS=OFF -DDEACTIVATE_AVX2=OFF -DCMAKE_INSTALL_PREFIX=$HOME/sw/knl/c-blosc-1.12.1-install - cmake --build src/c-blosc-knl-build --target install --parallel 16 - - # ADIOS2 - git clone -b v2.7.1 https://github.com/ornladios/ADIOS2.git src/adios2 - rm -rf src/adios2-knl-build - cmake -S src/adios2 -B src/adios2-knl-build -DADIOS2_USE_Blosc=ON -DADIOS2_USE_Fortran=OFF -DADIOS2_USE_Python=OFF -DADIOS2_USE_ZeroMQ=OFF -DCMAKE_INSTALL_PREFIX=$HOME/sw/knl/adios2-2.7.1-install - cmake --build src/adios2-knl-build --target install --parallel 16 - - # BLAS++ (for PSATD+RZ) - git clone https://github.com/icl-utk-edu/blaspp.git src/blaspp - rm -rf src/blaspp-knl-build - cmake -S src/blaspp -B src/blaspp-knl-build -Duse_openmp=ON -Duse_cmake_find_blas=ON -DBLAS_LIBRARIES=${CRAY_LIBSCI_PREFIX_DIR}/lib/libsci_gnu.a -DCMAKE_CXX_STANDARD=17 -DCMAKE_INSTALL_PREFIX=$HOME/sw/knl/blaspp-master-install - cmake --build src/blaspp-knl-build --target install --parallel 16 - - # LAPACK++ (for PSATD+RZ) - git clone https://github.com/icl-utk-edu/lapackpp.git src/lapackpp - rm -rf src/lapackpp-knl-build - CXXFLAGS="-DLAPACK_FORTRAN_ADD_" cmake -S src/lapackpp -B src/lapackpp-knl-build -Duse_cmake_find_lapack=ON -DBLAS_LIBRARIES=${CRAY_LIBSCI_PREFIX_DIR}/lib/libsci_gnu.a -DLAPACK_LIBRARIES=${CRAY_LIBSCI_PREFIX_DIR}/lib/libsci_gnu.a -DCMAKE_CXX_STANDARD=17 -DCMAKE_INSTALL_PREFIX=$HOME/sw/knl/lapackpp-master-install - cmake --build src/lapackpp-knl-build --target install --parallel 16 - -For PICMI and Python workflows, also install a virtual environment: - -.. code-block:: bash - - # establish Python dependencies - python3 -m pip install --user --upgrade pip - python3 -m pip install --user virtualenv - - python3 -m venv $HOME/sw/knl/venvs/knl_warpx - source $HOME/sw/knl/venvs/knl_warpx/bin/activate - - python3 -m pip install --upgrade pip - python3 -m pip install --upgrade wheel - python3 -m pip install --upgrade cython - python3 -m pip install --upgrade numpy - python3 -m pip install --upgrade pandas - python3 -m pip install --upgrade scipy - MPICC="cc -shared" python3 -m pip install -U --no-cache-dir -v mpi4py - python3 -m pip install --upgrade openpmd-api - python3 -m pip install --upgrade matplotlib - python3 -m pip install --upgrade yt - # optional: for libEnsemble - #python3 -m pip install -r $HOME/src/warpx/Tools/LibEnsemble/requirements.txt - -Haswell -^^^^^^^ - -We use the following modules and environments on the system (``$HOME/haswell_warpx.profile``). - -.. literalinclude:: ../../../../Tools/machines/cori-nersc/haswell_warpx.profile.example - :language: bash - :caption: You can copy this file from ``Tools/machines/cori-nersc/haswell_warpx.profile.example``. - -And install ADIOS2, BLAS++ and LAPACK++: - -.. code-block:: bash - - source $HOME/haswell_warpx.profile - - # c-blosc (I/O compression) - git clone -b v1.21.1 https://github.com/Blosc/c-blosc.git src/c-blosc - rm -rf src/c-blosc-haswell-build - cmake -S src/c-blosc -B src/c-blosc-haswell-build -DBUILD_TESTS=OFF -DBUILD_BENCHMARKS=OFF -DDEACTIVATE_AVX2=OFF -DCMAKE_INSTALL_PREFIX=$HOME/sw/haswell/c-blosc-1.12.1-install - cmake --build src/c-blosc-haswell-build --target install --parallel 16 - - # ADIOS2 - git clone -b v2.7.1 https://github.com/ornladios/ADIOS2.git src/adios2 - rm -rf src/adios2-haswell-build - cmake -S src/adios2 -B src/adios2-haswell-build -DADIOS2_USE_Blosc=ON -DADIOS2_USE_Fortran=OFF -DADIOS2_USE_Python=OFF -DADIOS2_USE_ZeroMQ=OFF -DCMAKE_INSTALL_PREFIX=$HOME/sw/haswell/adios2-2.7.1-install - cmake --build src/adios2-haswell-build --target install --parallel 16 - - # BLAS++ (for PSATD+RZ) - git clone https://github.com/icl-utk-edu/blaspp.git src/blaspp - rm -rf src/blaspp-haswell-build - cmake -S src/blaspp -B src/blaspp-haswell-build -Duse_openmp=ON -Duse_cmake_find_blas=ON -DBLAS_LIBRARIES=${CRAY_LIBSCI_PREFIX_DIR}/lib/libsci_gnu.a -DCMAKE_CXX_STANDARD=17 -DCMAKE_INSTALL_PREFIX=$HOME/sw/blaspp-master-haswell-install - cmake --build src/blaspp-haswell-build --target install --parallel 16 - - # LAPACK++ (for PSATD+RZ) - git clone https://github.com/icl-utk-edu/lapackpp.git src/lapackpp - rm -rf src/lapackpp-haswell-build - CXXFLAGS="-DLAPACK_FORTRAN_ADD_" cmake -S src/lapackpp -B src/lapackpp-haswell-build -Duse_cmake_find_lapack=ON -DBLAS_LIBRARIES=${CRAY_LIBSCI_PREFIX_DIR}/lib/libsci_gnu.a -DLAPACK_LIBRARIES=${CRAY_LIBSCI_PREFIX_DIR}/lib/libsci_gnu.a -DCMAKE_CXX_STANDARD=17 -DCMAKE_INSTALL_PREFIX=$HOME/sw/haswell/lapackpp-master-install - cmake --build src/lapackpp-haswell-build --target install --parallel 16 - -For PICMI and Python workflows, also install a virtual environment: - -.. code-block:: bash - - # establish Python dependencies - python3 -m pip install --user --upgrade pip - python3 -m pip install --user virtualenv - - python3 -m venv $HOME/sw/haswell/venvs/haswell_warpx - source $HOME/sw/haswell/venvs/haswell_warpx/bin/activate - - python3 -m pip install --upgrade pip - python3 -m pip install --upgrade wheel - python3 -m pip install --upgrade cython - python3 -m pip install --upgrade numpy - python3 -m pip install --upgrade pandas - python3 -m pip install --upgrade scipy - MPICC="cc -shared" python3 -m pip install -U --no-cache-dir -v mpi4py - python3 -m pip install --upgrade openpmd-api - python3 -m pip install --upgrade matplotlib - python3 -m pip install --upgrade yt - # optional: for libEnsemble - #python3 -m pip install -r $HOME/src/warpx/Tools/LibEnsemble/requirements.txt - -GPU (V100) -^^^^^^^^^^ - -Cori provides a partition with `18 nodes that include V100 (16 GB) GPUs `__. -We use the following modules and environments on the system (``$HOME/gpu_warpx.profile``). -You can copy this file from ``Tools/machines/cori-nersc/gpu_warpx.profile.example``: - -.. literalinclude:: ../../../../Tools/machines/cori-nersc/gpu_warpx.profile.example - :language: bash - :caption: You can copy this file from ``Tools/machines/cori-nersc/gpu_warpx.profile.example``. - -And install ADIOS2: - -.. code-block:: bash - - source $HOME/gpu_warpx.profile - - # c-blosc (I/O compression) - git clone -b v1.21.1 https://github.com/Blosc/c-blosc.git src/c-blosc - rm -rf src/c-blosc-gpu-build - cmake -S src/c-blosc -B src/c-blosc-gpu-build -DBUILD_TESTS=OFF -DBUILD_BENCHMARKS=OFF -DDEACTIVATE_AVX2=OFF -DCMAKE_INSTALL_PREFIX=$HOME/sw/cori_gpu/c-blosc-1.12.1-install - cmake --build src/c-blosc-gpu-build --target install --parallel 16 - - git clone -b v2.7.1 https://github.com/ornladios/ADIOS2.git src/adios2 - rm -rf src/adios2-gpu-build - cmake -S src/adios2 -B src/adios2-gpu-build -DADIOS2_USE_Blosc=ON -DADIOS2_USE_Fortran=OFF -DADIOS2_USE_Python=OFF -DADIOS2_USE_ZeroMQ=OFF -DCMAKE_INSTALL_PREFIX=$HOME/sw/cori_gpu/adios2-2.7.1-install - cmake --build src/adios2-gpu-build --target install --parallel 16 - -For PICMI and Python workflows, also install a virtual environment: - -.. code-block:: bash - - # establish Python dependencies - python3 -m pip install --user --upgrade pip - python3 -m pip install --user virtualenv - - python3 -m venv $HOME/sw/cori_gpu/venvs/gpu_warpx - source $HOME/sw/cori_gpu/venvs/gpu_warpx/bin/activate - - python3 -m pip install --upgrade pip - python3 -m pip install --upgrade wheel - python3 -m pip install --upgrade cython - python3 -m pip install --upgrade numpy - python3 -m pip install --upgrade pandas - python3 -m pip install --upgrade scipy - python3 -m pip install -U --no-cache-dir -v mpi4py - python3 -m pip install --upgrade openpmd-api - python3 -m pip install --upgrade matplotlib - python3 -m pip install --upgrade yt - # optional: for libEnsemble - #python3 -m pip install -r $HOME/src/warpx/Tools/LibEnsemble/requirements.txt - -Building WarpX --------------- - -We recommend to store the above lines in individual ``warpx.profile`` files, as suggested above. -If you want to run on either of the three partitions of Cori, open a new terminal, log into Cori and *source* the environment you want to work with: - -.. code-block:: bash - - # KNL: - source $HOME/knl_warpx.profile - - # Haswell: - #source $HOME/haswell_warpx.profile - - # GPU: - #source $HOME/gpu_warpx.profile - -.. warning:: - - Consider that all three Cori partitions are *incompatible*. - - Do not *source* multiple ``...warpx.profile`` files in the same terminal session. - Open a new terminal and log into Cori again, if you want to switch the targeted Cori partition. - - If you re-submit an already compiled simulation that you ran on another day or in another session, *make sure to source* the corresponding ``...warpx.profile`` again after login! - -Then, ``cd`` into the directory ``$HOME/src/warpx`` and use the following commands to compile: - -.. code-block:: bash - - cd $HOME/src/warpx - rm -rf build - - # append if you target GPUs: -DWarpX_COMPUTE=CUDA - cmake -S . -B build -DWarpX_DIMS=3 - cmake --build build -j 16 - -The general :ref:`cmake compile-time options ` apply as usual. - -**That's it!** -A 3D WarpX executable is now in ``build/bin/`` and :ref:`can be run ` with a :ref:`3D example inputs file `. -Most people execute the binary directly or copy it out to a location in ``$SCRATCH``. - -The general :ref:`cmake compile-time options and instructions for Python (PICMI) bindings ` apply as usual: - -.. code-block:: bash - - # PICMI build - cd $HOME/src/warpx - - # install or update dependencies - python3 -m pip install -r requirements.txt - - # compile parallel PICMI interfaces with openPMD support and 3D, 2D, 1D and RZ - WARPX_MPI=ON BUILD_PARALLEL=16 python3 -m pip install --force-reinstall --no-deps -v . - - -.. _building-cori-tests: - -Testing -------- - -To run all tests (here on KNL), do: - -* change in ``Regressions/WarpX-tests.ini`` from ``mpiexec`` to ``srun``: ``MPIcommand = srun -n @nprocs@ @command@`` - -.. code-block:: bash - - # set test directory to a shared directory available on all nodes - # note: the tests will create the directory automatically - export WARPX_CI_TMP="$HOME/warpx-regression-tests" - - # compile with more cores - export WARPX_CI_NUM_MAKE_JOBS=16 - - # run all integration tests - # note: we set MPICC as a build-setting for mpi4py on KNL/Haswell - MPICC="cc -shared" ./run_test.sh - - -.. _running-cpp-cori: - -Running -------- - -Navigate (i.e. ``cd``) into one of the production directories (e.g. ``$SCRATCH``) before executing the instructions below. - -KNL -^^^ - -The batch script below can be used to run a WarpX simulation on 2 KNL nodes on -the supercomputer Cori at NERSC. Replace descriptions between chevrons ``<>`` -by relevant values, for instance ```` could be ``laserWakefield``. - -Do not forget to first ``source $HOME/knl_warpx.profile`` if you have not done so already for this terminal session. - -For PICMI Python runs, the ```` has to read ``python3`` and the ```` is the path to your PICMI input script. - -.. literalinclude:: ../../../../Tools/machines/cori-nersc/cori_knl.sbatch - :language: bash - :caption: You can copy this file from ``Tools/machines/cori-nersc/cori_knl.sbatch``. - -To run a simulation, copy the lines above to a file ``cori_knl.sbatch`` and run - -.. code-block:: bash - - sbatch cori_knl.sbatch - -to submit the job. - -For a 3D simulation with a few (1-4) particles per cell using FDTD Maxwell -solver on Cori KNL for a well load-balanced problem (in our case laser -wakefield acceleration simulation in a boosted frame in the quasi-linear -regime), the following set of parameters provided good performance: - -* ``amr.max_grid_size=64`` and ``amr.blocking_factor=64`` so that the size of - each grid is fixed to ``64**3`` (we are not using load-balancing here). - -* **8 MPI ranks per KNL node**, with ``OMP_NUM_THREADS=8`` (that is 64 threads - per KNL node, i.e. 1 thread per physical core, and 4 cores left to the - system). - -* **2 grids per MPI**, *i.e.*, 16 grids per KNL node. - -Haswell -^^^^^^^ - -The batch script below can be used to run a WarpX simulation on 1 `Haswell node `_ on the supercomputer Cori at NERSC. - -Do not forget to first ``source $HOME/haswell_warpx.profile`` if you have not done so already for this terminal session. - -.. literalinclude:: ../../../../Tools/machines/cori-nersc/cori_haswell.sbatch - :language: bash - :caption: You can copy this file from ``Tools/machines/cori-nersc/cori_haswell.sbatch``. - -To run a simulation, copy the lines above to a file ``cori_haswell.sbatch`` and -run - -.. code-block:: bash - - sbatch cori_haswell.sbatch - -to submit the job. - -For a 3D simulation with a few (1-4) particles per cell using FDTD Maxwell -solver on Cori Haswell for a well load-balanced problem (in our case laser -wakefield acceleration simulation in a boosted frame in the quasi-linear -regime), the following set of parameters provided good performance: - -* **4 MPI ranks per Haswell node** (2 MPI ranks per `Intel Xeon E5-2698 v3 `_), with ``OMP_NUM_THREADS=16`` (which uses `2x hyperthreading `_) - -GPU (V100) -^^^^^^^^^^ - -Do not forget to first ``source $HOME/gpu_warpx.profile`` if you have not done so already for this terminal session. - -Due to the limited amount of GPU development nodes, just request a single node with the above defined ``getNode`` function. -For single-node runs, try to run one grid per GPU. - -A multi-node batch script template can be found below: - -.. literalinclude:: ../../../../Tools/machines/cori-nersc/cori_gpu.sbatch - :language: bash - :caption: You can copy this file from ``Tools/machines/cori-nersc/cori_gpu.sbatch``. - - -.. _post-processing-cori: - -Post-Processing ---------------- - -For post-processing, most users use Python via NERSC's `Jupyter service `__ (`Docs `__). - -As a one-time preparatory setup, `create your own Conda environment as described in NERSC docs `__. -In this manual, we often use this ``conda create`` line over the officially documented one: - -.. code-block:: bash - - conda create -n myenv -c conda-forge python mamba ipykernel ipympl==0.8.6 matplotlib numpy pandas yt openpmd-viewer openpmd-api h5py fast-histogram dask dask-jobqueue pyarrow - -We then follow the `Customizing Kernels with a Helper Shell Script `__ section to finalize the setup of using this conda-environment as a custom Jupyter kernel. - -``kernel_helper.sh`` should read: - -.. code-block:: bash - - #!/bin/bash - module load python - source activate myenv - exec "$@" - -When opening a Jupyter notebook, just select the name you picked for your custom kernel on the top right of the notebook. - -Additional software can be installed later on, e.g., in a Jupyter cell using ``!mamba install -c conda-forge ...``. -Software that is not available via conda can be installed via ``!python -m pip install ...``. - -.. warning:: - - Jan 6th, 2022 (NERSC-INC0179165 and `ipympl #416 `__): - Above, we fixated the ``ipympl`` version to *not* take the latest release of `Matplotlib Jupyter Widgets `__. - This is an intentional work-around; the ``ipympl`` version needs to exactly fit the version pre-installed on the Jupyter base system. diff --git a/Docs/source/install/hpc/lawrencium.rst b/Docs/source/install/hpc/lawrencium.rst index 36039e5eda4..23be9b75431 100644 --- a/Docs/source/install/hpc/lawrencium.rst +++ b/Docs/source/install/hpc/lawrencium.rst @@ -80,6 +80,8 @@ Optionally, download and install Python packages for :ref:`PICMI ` python3 -m venv $HOME/sw/v100/venvs/warpx source $HOME/sw/v100/venvs/warpx/bin/activate python3 -m pip install --upgrade pip + python3 -m pip install --upgrade build + python3 -m pip install --upgrade packaging python3 -m pip install --upgrade wheel python3 -m pip install --upgrade setuptools python3 -m pip install --upgrade cython diff --git a/Docs/source/install/hpc/lxplus.rst b/Docs/source/install/hpc/lxplus.rst index 413337f711d..5bd8a3c9795 100644 --- a/Docs/source/install/hpc/lxplus.rst +++ b/Docs/source/install/hpc/lxplus.rst @@ -147,7 +147,8 @@ Now, ensure Python tooling is up-to-date: .. code-block:: bash - python3 -m pip install -U pip setuptools wheel + python3 -m pip install -U pip + python3 -m pip install -U build packaging setuptools wheel python3 -m pip install -U cmake Then we compile WarpX as in the previous section (with or without CUDA) adding ``-DWarpX_PYTHON=ON`` and then we install it into our Python: diff --git a/Docs/source/install/hpc/perlmutter.rst b/Docs/source/install/hpc/perlmutter.rst index c5d6a9e1898..e9ebcd4e1de 100644 --- a/Docs/source/install/hpc/perlmutter.rst +++ b/Docs/source/install/hpc/perlmutter.rst @@ -13,7 +13,7 @@ If you are new to this system, **please see the following resources**: * `NERSC user guide `__ * Batch system: `Slurm `__ -* `Jupyter service `__ +* `Jupyter service `__ (`documentation `__) * `Filesystems `__: * ``$HOME``: per-user directory, use only for inputs, source and scripts; backed up (40GB) @@ -271,11 +271,36 @@ Running Post-Processing --------------- -For post-processing, most users use Python via NERSC's `Jupyter service `__ (`Docs `__). +For post-processing, most users use Python via NERSC's `Jupyter service `__ (`documentation `__). -Please follow the same process as for :ref:`NERSC Cori post-processing `. -**Important:** The *environment + Jupyter kernel* must separate from the one you create for Cori. +As a one-time preparatory setup, log into Perlmutter via SSH and do *not* source the WarpX profile script above. +Create your own Conda environment and `Jupyter kernel `__ for post-processing: -The Perlmutter ``$PSCRATCH`` filesystem is only available on *Perlmutter* Jupyter nodes. -Likewise, Cori's ``$SCRATCH`` filesystem is only available on *Cori* Jupyter nodes. -You can use the Community FileSystem (CFS) from everywhere. +.. code-block:: bash + + module load python + + conda config --set auto_activate_base false + + # create conda environment + rm -rf $HOME/.conda/envs/warpx-pm-postproc + conda create --yes -n warpx-pm-postproc -c conda-forge mamba conda-libmamba-solver + conda activate warpx-pm-postproc + conda config --set solver libmamba + mamba install --yes -c conda-forge python ipykernel ipympl matplotlib numpy pandas yt openpmd-viewer openpmd-api h5py fast-histogram dask dask-jobqueue pyarrow + + # create Jupyter kernel + rm -rf $HOME/.local/share/jupyter/kernels/warpx-pm-postproc/ + python -m ipykernel install --user --name warpx-pm-postproc --display-name WarpX-PM-PostProcessing + echo -e '#!/bin/bash\nmodule load python\nsource activate warpx-pm-postproc\nexec "$@"' > $HOME/.local/share/jupyter/kernels/warpx-pm-postproc/kernel-helper.sh + chmod a+rx $HOME/.local/share/jupyter/kernels/warpx-pm-postproc/kernel-helper.sh + KERNEL_STR=$(jq '.argv |= ["{resource_dir}/kernel-helper.sh"] + .' $HOME/.local/share/jupyter/kernels/warpx-pm-postproc/kernel.json | jq '.argv[1] = "python"') + echo ${KERNEL_STR} | jq > $HOME/.local/share/jupyter/kernels/warpx-pm-postproc/kernel.json + + exit + + +When opening a Jupyter notebook on `https://jupyter.nersc.gov `__, just select ``WarpX-PM-PostProcessing`` from the list of available kernels on the top right of the notebook. + +Additional software can be installed later on, e.g., in a Jupyter cell using ``!mamba install -y -c conda-forge ...``. +Software that is not available via conda can be installed via ``!python -m pip install ...``. diff --git a/Docs/source/install/users.rst b/Docs/source/install/users.rst index 5174a3b5343..b7893e248c0 100644 --- a/Docs/source/install/users.rst +++ b/Docs/source/install/users.rst @@ -109,12 +109,11 @@ Given that you have the :ref:`WarpX dependencies ` install .. code-block:: bash - # optional: --user - python3 -m pip install -U pip setuptools wheel + python3 -m pip install -U pip + python3 -m pip install -U build packaging setuptools wheel python3 -m pip install -U cmake python3 -m pip wheel -v git+https://github.com/ECP-WarpX/WarpX.git - # optional: --user python3 -m pip install *whl In the future, will publish pre-compiled binary packages on `PyPI `__ for faster installs. diff --git a/Docs/source/maintenance/performance_tests.rst b/Docs/source/maintenance/performance_tests.rst index 13b1f6e3acb..8b902297ccb 100644 --- a/Docs/source/maintenance/performance_tests.rst +++ b/Docs/source/maintenance/performance_tests.rst @@ -75,6 +75,7 @@ Then, in ``$AUTOMATED_PERF_TESTS``, create a file ``run_automated_performance_te # lines below this comment once, before submission. # The commented lines take too long for the job script. #python3 -m pip install --upgrade pip + #python3 -m pip install --upgrade build packaging setuptools wheel #python3 -m pip install --upgrade cython #python3 -m pip install --upgrade numpy #python3 -m pip install --upgrade markupsafe diff --git a/Docs/source/maintenance/release.rst b/Docs/source/maintenance/release.rst index e4047563f76..f25b8c313e4 100644 --- a/Docs/source/maintenance/release.rst +++ b/Docs/source/maintenance/release.rst @@ -13,6 +13,7 @@ The following scripts automate this workflow, in case one needs a newer commit o .. code-block:: sh ./Tools/Release/updateAMReX.py + ./Tools/Release/updatepyAMReX.py ./Tools/Release/updatePICSAR.py @@ -32,6 +33,7 @@ In order to create a GitHub release, you need to: .. code-block:: sh ./Tools/Release/updateAMReX.py + ./Tools/Release/updatepyAMReX.py ./Tools/Release/updatePICSAR.py ./Tools/Release/newVersion.sh diff --git a/Docs/source/usage/workflows/debugging.rst b/Docs/source/usage/workflows/debugging.rst index 9a7d7efacd0..519649e4b46 100644 --- a/Docs/source/usage/workflows/debugging.rst +++ b/Docs/source/usage/workflows/debugging.rst @@ -23,6 +23,9 @@ Try the following steps to debug a simulation: Do you spot numerical artifacts or instabilities that could point to missing resolution or unexpected/incompatible numerical parameters? #. Did the job output files indicate a crash? Check the ``Backtrace.`` files for the location of the code that triggered the crash. Backtraces are read from bottom (high-level) to top (most specific line that crashed). + + #. Was this a segmentation fault in C++, but the run was controlled from Python (PICMI)? + To get the last called Python line for the backtrace, run again and add the Python ``faulthandler``, e.g., with ``python3 -X faulthandler PICMI_your_script_here.py``. #. Try to make the reproducible scenario as small as possible by modifying the inputs file. Reduce number of cells, particles and MPI processes to something as small and as quick to execute as possible. The next steps in debugging will increase runtime, so you will benefit from a fast reproducer. diff --git a/Examples/Tests/flux_injection/analysis_flux_injection_3d.py b/Examples/Tests/flux_injection/analysis_flux_injection_3d.py index 048ef70f9cc..0998de25a7b 100755 --- a/Examples/Tests/flux_injection/analysis_flux_injection_3d.py +++ b/Examples/Tests/flux_injection/analysis_flux_injection_3d.py @@ -57,11 +57,8 @@ def gaussian_dist(u, u_th): return 1./((2*np.pi)**.5*u_th) * np.exp(-u**2/(2*u_th**2) ) def gaussian_flux_dist(u, u_th, u_m): - au_m = np.abs(u_m) - normalization_factor = u_th**2 * np.exp(-au_m**2/(2*u_th**2)) + (np.pi/2)**.5*au_m*u_th * (1 + erf(au_m/(2**.5*u_th))) - result = 1./normalization_factor * np.where( u>0, u * np.exp(-(u-au_m)**2/(2*u_th**2)), 0 ) - if u_m < 0.: - result = result[::-1] + normalization_factor = u_th**2 * np.exp(-u_m**2/(2*u_th**2)) + (np.pi/2)**.5*u_m*u_th * (1 + erf(u_m/(2**.5*u_th))) + result = 1./normalization_factor * np.where( u>0, u * np.exp(-(u-u_m)**2/(2*u_th**2)), 0 ) return result def compare_gaussian(u, w, u_th, label=''): @@ -84,10 +81,10 @@ def compare_gaussian_flux(u, w, u_th, u_m, label=''): # Load data and perform check -plt.figure(figsize=(5,7)) +plt.figure(figsize=(8,7)) -plt.subplot(211) -plt.title('Electrons') +plt.subplot(221) +plt.title('Electrons u_m=0.07') ux = ad['electron','particle_momentum_x'].to_ndarray()/(m_e*c) uy = ad['electron','particle_momentum_y'].to_ndarray()/(m_e*c) @@ -97,21 +94,46 @@ def compare_gaussian_flux(u, w, u_th, u_m, label=''): compare_gaussian(ux, w, u_th=0.1, label='u_x') compare_gaussian_flux(uy, w, u_th=0.1, u_m=0.07, label='u_y') compare_gaussian(uz, w, u_th=0.1, label='u_z') -plt.legend(loc=0) -plt.subplot(212) -plt.title('Protons') +plt.subplot(223) +plt.title('Protons u_m=0.05') ux = ad['proton','particle_momentum_x'].to_ndarray()/(m_p*c) uy = ad['proton','particle_momentum_y'].to_ndarray()/(m_p*c) uz = ad['proton','particle_momentum_z'].to_ndarray()/(m_p*c) w = ad['proton', 'particle_weight'].to_ndarray() -compare_gaussian_flux(ux, w, u_th=0.1, u_m=-0.05, label='u_x') +compare_gaussian_flux(-ux, w, u_th=0.1, u_m=0.05, label='u_x') compare_gaussian(uy, w, u_th=0.1, label='u_y') compare_gaussian(uz, w, u_th=0.1, label='u_z') -plt.legend(loc=0) +plt.subplot(222) +plt.title('Electrons u_m=-0.07') + +ux = ad['electron_negative','particle_momentum_x'].to_ndarray()/(m_e*c) +uy = ad['electron_negative','particle_momentum_y'].to_ndarray()/(m_e*c) +uz = ad['electron_negative','particle_momentum_z'].to_ndarray()/(m_e*c) +w = ad['electron_negative', 'particle_weight'].to_ndarray() + +compare_gaussian(ux, w, u_th=0.1, label='u_x') +compare_gaussian(uy, w, u_th=0.1, label='u_y') +compare_gaussian_flux(uz, w, u_th=0.1, u_m=-0.07, label='u_z') +plt.legend(loc=(1.02, 0.5)) + +plt.subplot(224) +plt.title('Protons u_m=-0.05') + +ux = ad['proton_negative','particle_momentum_x'].to_ndarray()/(m_p*c) +uy = ad['proton_negative','particle_momentum_y'].to_ndarray()/(m_p*c) +uz = ad['proton_negative','particle_momentum_z'].to_ndarray()/(m_p*c) +w = ad['proton_negative', 'particle_weight'].to_ndarray() + +compare_gaussian(ux, w, u_th=0.1, label='u_x') +compare_gaussian(uy, w, u_th=0.1, label='u_y') +compare_gaussian_flux(-uz, w, u_th=0.1, u_m=-0.05, label='u_z') +#plt.legend(loc=0) + +plt.tight_layout() plt.savefig('Distribution.png') # Verify checksum diff --git a/Examples/Tests/flux_injection/inputs_3d b/Examples/Tests/flux_injection/inputs_3d index 7d277e7c292..80ee23feff9 100644 --- a/Examples/Tests/flux_injection/inputs_3d +++ b/Examples/Tests/flux_injection/inputs_3d @@ -28,7 +28,7 @@ boundary.field_lo = periodic periodic periodic boundary.field_hi = periodic periodic periodic # particles -particles.species_names = electron proton +particles.species_names = electron proton electron_negative proton_negative algo.particle_shape = 3 electron.charge = -q_e @@ -61,6 +61,37 @@ proton.ux_m = 0.05 proton.uy_th = 0.1 proton.uz_th = 0.1 +# "negative" is negative u_m +electron_negative.charge = -q_e +electron_negative.mass = m_e +electron_negative.injection_style = NFluxPerCell +electron_negative.num_particles_per_cell = 100 +electron_negative.surface_flux_pos = -4. +electron_negative.flux_normal_axis = z +electron_negative.flux_direction = +1 +electron_negative.flux_profile = parse_flux_function +electron_negative.flux_function(x,y,z,t) = "1." +electron_negative.momentum_distribution_type = gaussianflux +electron_negative.ux_th = 0.1 +electron_negative.uy_th = 0.1 +electron_negative.uz_th = 0.1 +electron_negative.uz_m = -0.07 + +proton_negative.charge = +q_e +proton_negative.mass = m_p +proton_negative.injection_style = NFluxPerCell +proton_negative.num_particles_per_cell = 100 +proton_negative.surface_flux_pos = 4. +proton_negative.flux_normal_axis = z +proton_negative.flux_direction = -1 +proton_negative.flux_profile = constant +proton_negative.flux = 1. +proton_negative.momentum_distribution_type = gaussianflux +proton_negative.ux_th = 0.1 +proton_negative.uy_th = 0.1 +proton_negative.uz_th = 0.1 +proton_negative.uz_m = -0.05 + # Diagnostics diagnostics.diags_names = diag1 diag1.intervals = 1000 diff --git a/Python/setup.py b/Python/setup.py index e5165b17c41..62294fcaae2 100644 --- a/Python/setup.py +++ b/Python/setup.py @@ -54,7 +54,7 @@ package_data = {} setup(name = 'pywarpx', - version = '23.10', + version = '23.11', packages = ['pywarpx'], package_dir = {'pywarpx': 'pywarpx'}, description = """Wrapper of WarpX""", diff --git a/Regression/Checksum/benchmarks_json/FluxInjection3D.json b/Regression/Checksum/benchmarks_json/FluxInjection3D.json index b2b3733737e..aa30f988f68 100644 --- a/Regression/Checksum/benchmarks_json/FluxInjection3D.json +++ b/Regression/Checksum/benchmarks_json/FluxInjection3D.json @@ -1,21 +1,39 @@ { - "electron": { - "particle_momentum_x": 1.1192116199394354e-18, - "particle_momentum_y": 2.238114590066897e-18, - "particle_momentum_z": 1.1156457989239732e-18, - "particle_position_x": 102495.14197173176, - "particle_position_y": 188132.22608016344, - "particle_position_z": 102423.13701045913, + "lev=0": {}, + "electron_negative": { + "particle_momentum_x": 1.1222699783863554e-18, + "particle_momentum_y": 1.1202176725070554e-18, + "particle_momentum_z": 1.3925955132362978e-18, + "particle_position_x": 102352.09026544492, + "particle_position_y": 102418.88243172191, + "particle_position_z": 194298.7949373403, "particle_weight": 8.959999999999998e-07 }, - "lev=0": {}, "proton": { - "particle_momentum_x": 3.835423016604918e-15, - "particle_momentum_y": 2.0468371931479925e-15, - "particle_momentum_z": 2.055186547721331e-15, - "particle_position_x": 189256.1546041931, - "particle_position_y": 102293.00576740496, - "particle_position_z": 102314.93877691089, + "particle_momentum_x": 3.8338884590187296e-15, + "particle_momentum_y": 2.0442156829943128e-15, + "particle_momentum_z": 2.045804260395492e-15, + "particle_position_x": 189238.69249885075, + "particle_position_y": 102242.91543133644, + "particle_position_z": 102297.92915049737, + "particle_weight": 8.959999999999998e-07 + }, + "electron": { + "particle_momentum_x": 1.1150196665556376e-18, + "particle_momentum_y": 2.2311586451156107e-18, + "particle_momentum_z": 1.1115069298757383e-18, + "particle_position_x": 102477.68142952351, + "particle_position_y": 188137.20906834095, + "particle_position_z": 102443.44417709563, + "particle_weight": 8.959999999999998e-07 + }, + "proton_negative": { + "particle_momentum_x": 2.051429985038282e-15, + "particle_momentum_y": 2.053711846305655e-15, + "particle_momentum_z": 2.7212135003240815e-15, + "particle_position_x": 102307.73649638034, + "particle_position_y": 102475.13878406698, + "particle_position_z": 193638.89296895845, "particle_weight": 8.959999999999998e-07 } } diff --git a/Regression/WarpX-GPU-tests.ini b/Regression/WarpX-GPU-tests.ini index 17d98e4b76d..c9ddc4e377d 100644 --- a/Regression/WarpX-GPU-tests.ini +++ b/Regression/WarpX-GPU-tests.ini @@ -60,7 +60,7 @@ emailBody = Check https://ccse.lbl.gov/pub/GpuRegressionTesting/WarpX/ for more [AMReX] dir = /home/regtester/git/amrex/ -branch = da79aff8053058371a78d4bf85488384242368ee +branch = d36463103daed09a40cdea235041a6ab79ff280c [source] dir = /home/regtester/git/WarpX diff --git a/Regression/WarpX-tests.ini b/Regression/WarpX-tests.ini index 6f08f34bc2c..1dd8ac3366d 100644 --- a/Regression/WarpX-tests.ini +++ b/Regression/WarpX-tests.ini @@ -59,7 +59,7 @@ emailBody = Check https://ccse.lbl.gov/pub/RegressionTesting/WarpX/ for more det [AMReX] dir = /home/regtester/AMReX_RegTesting/amrex/ -branch = da79aff8053058371a78d4bf85488384242368ee +branch = d36463103daed09a40cdea235041a6ab79ff280c [source] dir = /home/regtester/AMReX_RegTesting/warpx diff --git a/Source/AcceleratorLattice/LatticeElements/Drift.H b/Source/AcceleratorLattice/LatticeElements/Drift.H index a9067a09caa..7ad36df8dba 100644 --- a/Source/AcceleratorLattice/LatticeElements/Drift.H +++ b/Source/AcceleratorLattice/LatticeElements/Drift.H @@ -17,8 +17,6 @@ struct Drift Drift (); - ~Drift () = default; - /** * \brief Read in an element and add it to the lists * diff --git a/Source/AcceleratorLattice/LatticeElements/HardEdgedPlasmaLens.H b/Source/AcceleratorLattice/LatticeElements/HardEdgedPlasmaLens.H index 43009c0c4ed..c30a91867e6 100644 --- a/Source/AcceleratorLattice/LatticeElements/HardEdgedPlasmaLens.H +++ b/Source/AcceleratorLattice/LatticeElements/HardEdgedPlasmaLens.H @@ -27,8 +27,6 @@ struct HardEdgedPlasmaLens HardEdgedPlasmaLens (); - ~HardEdgedPlasmaLens () = default; - /** * \brief Read in an element and add it to the lists * diff --git a/Source/AcceleratorLattice/LatticeElements/HardEdgedQuadrupole.H b/Source/AcceleratorLattice/LatticeElements/HardEdgedQuadrupole.H index 82f1e860a40..0cdefea769e 100644 --- a/Source/AcceleratorLattice/LatticeElements/HardEdgedQuadrupole.H +++ b/Source/AcceleratorLattice/LatticeElements/HardEdgedQuadrupole.H @@ -27,8 +27,6 @@ struct HardEdgedQuadrupole HardEdgedQuadrupole (); - ~HardEdgedQuadrupole () = default; - /** * \brief Read in an element and add it to the lists * diff --git a/Source/AcceleratorLattice/LatticeElements/LatticeElementBase.H b/Source/AcceleratorLattice/LatticeElements/LatticeElementBase.H index ad72eeef910..15cb72435bd 100644 --- a/Source/AcceleratorLattice/LatticeElements/LatticeElementBase.H +++ b/Source/AcceleratorLattice/LatticeElements/LatticeElementBase.H @@ -25,8 +25,6 @@ struct LatticeElementBase */ LatticeElementBase (std::string const& element_name); - ~LatticeElementBase () = default; - /** * \brief Read in an element base data and add it to the lists * diff --git a/Source/AcceleratorLattice/LatticeElements/LatticeElementBase.cpp b/Source/AcceleratorLattice/LatticeElements/LatticeElementBase.cpp index 248db59aaf6..19afd8cd617 100644 --- a/Source/AcceleratorLattice/LatticeElements/LatticeElementBase.cpp +++ b/Source/AcceleratorLattice/LatticeElements/LatticeElementBase.cpp @@ -12,10 +12,8 @@ #include -LatticeElementBase::LatticeElementBase (std::string const& element_name) -{ - m_element_name = element_name; -} +LatticeElementBase::LatticeElementBase (std::string const& element_name): + m_element_name{element_name}{} void LatticeElementBase::AddElementBase (amrex::ParmParse & pp_element, amrex::ParticleReal & z_location) diff --git a/Source/BoundaryConditions/PML.H b/Source/BoundaryConditions/PML.H index 4be1be146cc..649d4a6b40b 100644 --- a/Source/BoundaryConditions/PML.H +++ b/Source/BoundaryConditions/PML.H @@ -81,7 +81,7 @@ public: const amrex::IntVect& ncell, const amrex::IntVect& delta, const amrex::Box& regular_domain, const amrex::Real v_sigma_sb) : m_grids(grid_ba), m_dx(dx), m_ncell(ncell), m_delta(delta), m_regdomain(regular_domain), m_v_sigma_sb(v_sigma_sb) {} - virtual ~SigmaBoxFactory () = default; + ~SigmaBoxFactory () override = default; SigmaBoxFactory (const SigmaBoxFactory&) = default; SigmaBoxFactory (SigmaBoxFactory&&) noexcept = default; @@ -90,13 +90,13 @@ public: SigmaBoxFactory& operator= (const SigmaBoxFactory&) = delete; SigmaBoxFactory& operator= (SigmaBoxFactory&&) = delete; - virtual SigmaBox* create (const amrex::Box& box, int /*ncomps*/, + SigmaBox* create (const amrex::Box& box, int /*ncomps*/, const amrex::FabInfo& /*info*/, int /*box_index*/) const final { return new SigmaBox(box, m_grids, m_dx, m_ncell, m_delta, m_regdomain, m_v_sigma_sb); } - virtual void destroy (SigmaBox* fab) const final { + void destroy (SigmaBox* fab) const final { delete fab; } - virtual SigmaBoxFactory* clone () const final { + SigmaBoxFactory* clone () const final { return new SigmaBoxFactory(*this); } private: @@ -200,8 +200,6 @@ public: static void Exchange (amrex::MultiFab& pml, amrex::MultiFab& reg, const amrex::Geometry& geom, int do_pml_in_domain); - ~PML () = default; - private: bool m_ok; diff --git a/Source/BoundaryConditions/PML_RZ.H b/Source/BoundaryConditions/PML_RZ.H index ac4b6ff2c4d..3a5a51770f8 100644 --- a/Source/BoundaryConditions/PML_RZ.H +++ b/Source/BoundaryConditions/PML_RZ.H @@ -52,8 +52,6 @@ public: void CheckPoint (const std::string& dir) const; void Restart (const std::string& dir); - ~PML_RZ () = default; - private: const int m_ncell; diff --git a/Source/Diagnostics/BTD_Plotfile_Header_Impl.H b/Source/Diagnostics/BTD_Plotfile_Header_Impl.H index d8038a48f3d..2becaba85b3 100644 --- a/Source/Diagnostics/BTD_Plotfile_Header_Impl.H +++ b/Source/Diagnostics/BTD_Plotfile_Header_Impl.H @@ -31,8 +31,6 @@ public: * \param[in] Headerfile_path string containing path of Headerfile */ BTDPlotfileHeaderImpl (std::string const& Headerfile_path); - /** Destructor */ - ~BTDPlotfileHeaderImpl () = default; /** Returns the Header file version for plotfile */ std::string fileVersion () const noexcept {return m_file_version; } @@ -166,7 +164,7 @@ class BTDMultiFabHeaderImpl * \param[in] Headerfile_path string containing path of Headerfile */ BTDMultiFabHeaderImpl (std::string const& Headerfile_path); - ~BTDMultiFabHeaderImpl () = default; + /** Reads the Multifab Header file and stores its data. */ void ReadMultiFabHeader (); /** Writes the meta-data of the Multifab in a header file, with path, m_Header_path. */ @@ -249,7 +247,7 @@ public: * \param[in] species_name string containing species name */ BTDSpeciesHeaderImpl (std::string const& Headerfile_path, std::string const& species_name); - ~BTDSpeciesHeaderImpl () = default; + /** Reads the Header file for BTD species*/ void ReadHeader (); /** Writes the meta-data of species Header file, with path, m_Header_path*/ @@ -314,8 +312,7 @@ public: * \param[in] Headerfile_path containing path of Headerfile */ BTDParticleDataHeaderImpl (std::string const& Headerfile_path); - /** Destructor */ - ~BTDParticleDataHeaderImpl () = default; + /** Reads the particle header file at m_Header_path and stores its data*/ void ReadHeader (); /** Writes the meta-data of particle box array in header file, with path, m_Header_path*/ diff --git a/Source/Diagnostics/BTDiagnostics.H b/Source/Diagnostics/BTDiagnostics.H index 9356fdbdaa2..4198846fa5b 100644 --- a/Source/Diagnostics/BTDiagnostics.H +++ b/Source/Diagnostics/BTDiagnostics.H @@ -47,7 +47,7 @@ private: * can be defined and implemented in Diagnostics.H, such that, * the function call to flush out buffer data for * FullDiagnostics and BTDiagnostics is the same */ - void Flush (int i_buffer) override; + void Flush (int i_buffer, bool force_flush) override; /** whether to write output files at this time step * The data is flushed when the buffer is full and/or * when the simulation ends or when forced. diff --git a/Source/Diagnostics/BTDiagnostics.cpp b/Source/Diagnostics/BTDiagnostics.cpp index 6f976d9ee11..868dc94ba41 100644 --- a/Source/Diagnostics/BTDiagnostics.cpp +++ b/Source/Diagnostics/BTDiagnostics.cpp @@ -1000,7 +1000,7 @@ BTDiagnostics::GetKIndexInSnapshotBoxFlag (const int i_buffer, const int lev) } void -BTDiagnostics::Flush (int i_buffer) +BTDiagnostics::Flush (int i_buffer, bool force_flush) { auto & warpx = WarpX::GetInstance(); std::string file_name = m_file_prefix; @@ -1009,7 +1009,7 @@ BTDiagnostics::Flush (int i_buffer) file_name = file_name+"/buffer"; } SetSnapshotFullStatus(i_buffer); - const bool isLastBTDFlush = ( m_snapshot_full[i_buffer] == 1 ); + const bool isLastBTDFlush = ( m_snapshot_full[i_buffer] == 1 ) || force_flush; bool const use_pinned_pc = true; bool const isBTD = true; double const labtime = m_t_lab[i_buffer]; diff --git a/Source/Diagnostics/BoundaryScrapingDiagnostics.H b/Source/Diagnostics/BoundaryScrapingDiagnostics.H index 71ee7bfbed8..e9efcfe5abb 100644 --- a/Source/Diagnostics/BoundaryScrapingDiagnostics.H +++ b/Source/Diagnostics/BoundaryScrapingDiagnostics.H @@ -34,7 +34,7 @@ private: utils::parser::IntervalsParser m_intervals; /** \brief Flush data to file. */ - void Flush (int i_buffer) override; + void Flush (int i_buffer, bool /* force_flush */) override; /** \brief Return whether to dump data to file at this time step. * (i.e. whether to call Flush) * diff --git a/Source/Diagnostics/BoundaryScrapingDiagnostics.cpp b/Source/Diagnostics/BoundaryScrapingDiagnostics.cpp index a3ea097352c..9797b77ac1d 100644 --- a/Source/Diagnostics/BoundaryScrapingDiagnostics.cpp +++ b/Source/Diagnostics/BoundaryScrapingDiagnostics.cpp @@ -130,7 +130,7 @@ BoundaryScrapingDiagnostics::DoDump (int step, int /*i_buffer*/, bool force_flus } void -BoundaryScrapingDiagnostics::Flush (int i_buffer) +BoundaryScrapingDiagnostics::Flush (int i_buffer, bool /* force_flush */) { auto & warpx = WarpX::GetInstance(); ParticleBoundaryBuffer& particle_buffer = warpx.GetParticleBoundaryBuffer(); diff --git a/Source/Diagnostics/ComputeDiagFunctors/CellCenterFunctor.H b/Source/Diagnostics/ComputeDiagFunctors/CellCenterFunctor.H index 84ea079c63c..58823d7bb17 100644 --- a/Source/Diagnostics/ComputeDiagFunctors/CellCenterFunctor.H +++ b/Source/Diagnostics/ComputeDiagFunctors/CellCenterFunctor.H @@ -34,7 +34,7 @@ public: * \param[in] dcomp first component of mf_dst in which cell-centered * data is stored */ - virtual void operator()(amrex::MultiFab& mf_dst, int dcomp, int /*i_buffer=0*/) const override; + void operator()(amrex::MultiFab& mf_dst, int dcomp, int /*i_buffer=0*/) const override; private: /** pointer to source multifab (can be multi-component) */ amrex::MultiFab const * const m_mf_src = nullptr; diff --git a/Source/Diagnostics/ComputeDiagFunctors/ComputeDiagFunctor.H b/Source/Diagnostics/ComputeDiagFunctors/ComputeDiagFunctor.H index b4c413b3aa1..9e21160242f 100644 --- a/Source/Diagnostics/ComputeDiagFunctors/ComputeDiagFunctor.H +++ b/Source/Diagnostics/ComputeDiagFunctors/ComputeDiagFunctor.H @@ -21,6 +21,13 @@ public: m_ncomp(ncomp), m_crse_ratio(crse_ratio) {} //** Virtual Destructor to handle clean destruction of derived classes */ virtual ~ComputeDiagFunctor() = default; + + // Default move and copy operations + ComputeDiagFunctor(const ComputeDiagFunctor&) = default; + ComputeDiagFunctor& operator=(const ComputeDiagFunctor&) = default; + ComputeDiagFunctor(ComputeDiagFunctor&&) = default; + ComputeDiagFunctor& operator=(ComputeDiagFunctor&&) = default; + /** Compute a field and store the result in mf_dst * * \param[out] mf_dst output MultiFab where the result is written diff --git a/Source/Diagnostics/ComputeDiagFunctors/ComputeParticleDiagFunctor.H b/Source/Diagnostics/ComputeDiagFunctors/ComputeParticleDiagFunctor.H index e14e777e066..4a5e8976943 100644 --- a/Source/Diagnostics/ComputeDiagFunctors/ComputeParticleDiagFunctor.H +++ b/Source/Diagnostics/ComputeDiagFunctors/ComputeParticleDiagFunctor.H @@ -24,6 +24,12 @@ public: /** Virtual Destructor to handle clean destruction of derived classes */ virtual ~ComputeParticleDiagFunctor() = default; + /** Default assignment and copy operations*/ + ComputeParticleDiagFunctor(const ComputeParticleDiagFunctor&) = default; + ComputeParticleDiagFunctor& operator=(const ComputeParticleDiagFunctor&) = default; + ComputeParticleDiagFunctor(ComputeParticleDiagFunctor&&) = default; + ComputeParticleDiagFunctor& operator=(ComputeParticleDiagFunctor&&) = default; + /** \brief Prepare data required to back-transform particle attribtutes for * lab-frame snapshot, with index i_buffer. * Note that this function has parameters that are specific to diff --git a/Source/Diagnostics/ComputeDiagFunctors/DivBFunctor.H b/Source/Diagnostics/ComputeDiagFunctors/DivBFunctor.H index f6a297741b9..ebf890f6545 100644 --- a/Source/Diagnostics/ComputeDiagFunctors/DivBFunctor.H +++ b/Source/Diagnostics/ComputeDiagFunctors/DivBFunctor.H @@ -32,7 +32,7 @@ public: * \param[in] dcomp first component of mf_dst in which cell-centered * data is stored */ - virtual void operator()(amrex::MultiFab& mf_dst, int dcomp, int /*i_buffer*/) const override; + void operator()(amrex::MultiFab& mf_dst, int dcomp, int /*i_buffer*/) const override; private: /** Vector of pointer to source multifab Bx, By, Bz */ std::array m_arr_mf_src; diff --git a/Source/Diagnostics/ComputeDiagFunctors/DivEFunctor.H b/Source/Diagnostics/ComputeDiagFunctors/DivEFunctor.H index c7d3badcf0d..76e5270b972 100644 --- a/Source/Diagnostics/ComputeDiagFunctors/DivEFunctor.H +++ b/Source/Diagnostics/ComputeDiagFunctors/DivEFunctor.H @@ -31,7 +31,7 @@ public: * \param[in] dcomp first component of mf_dst in which cell-centered * data is stored */ - virtual void operator()(amrex::MultiFab& mf_dst, int dcomp, int /*i_buffer=0*/) const override; + void operator()(amrex::MultiFab& mf_dst, int dcomp, int /*i_buffer=0*/) const override; private: /** Vector of pointer to source multifab Bx, By, Bz */ std::array m_arr_mf_src; diff --git a/Source/Diagnostics/ComputeDiagFunctors/JFunctor.H b/Source/Diagnostics/ComputeDiagFunctors/JFunctor.H index db0e0331148..c42f63f1369 100644 --- a/Source/Diagnostics/ComputeDiagFunctors/JFunctor.H +++ b/Source/Diagnostics/ComputeDiagFunctors/JFunctor.H @@ -35,7 +35,7 @@ public: * \param[in] dcomp first component of mf_dst in which cell-centered * data is stored */ - virtual void operator()(amrex::MultiFab& mf_dst, int dcomp, int /*i_buffer=0*/) const override; + void operator()(amrex::MultiFab& mf_dst, int dcomp, int /*i_buffer=0*/) const override; private: /** direction of the current density to save */ const int m_dir; diff --git a/Source/Diagnostics/ComputeDiagFunctors/PartPerCellFunctor.H b/Source/Diagnostics/ComputeDiagFunctors/PartPerCellFunctor.H index 7e435b3675e..af218d2667b 100644 --- a/Source/Diagnostics/ComputeDiagFunctors/PartPerCellFunctor.H +++ b/Source/Diagnostics/ComputeDiagFunctors/PartPerCellFunctor.H @@ -29,7 +29,7 @@ public: * \param[in] dcomp first component of mf_dst in which cell-centered * data is stored */ - virtual void operator()(amrex::MultiFab& mf_dst, int dcomp, int /*i_buffer=0*/) const override; + void operator()(amrex::MultiFab& mf_dst, int dcomp, int /*i_buffer=0*/) const override; private: int const m_lev; /**< level on which mf_src is defined */ }; diff --git a/Source/Diagnostics/ComputeDiagFunctors/PartPerGridFunctor.H b/Source/Diagnostics/ComputeDiagFunctors/PartPerGridFunctor.H index d5e0c45b956..b4d64117dd7 100644 --- a/Source/Diagnostics/ComputeDiagFunctors/PartPerGridFunctor.H +++ b/Source/Diagnostics/ComputeDiagFunctors/PartPerGridFunctor.H @@ -29,7 +29,7 @@ public: * \param[in] dcomp first component of mf_dst in which cell-centered * data is stored */ - virtual void operator()(amrex::MultiFab& mf_dst, int dcomp, int /*i_buffer=0*/) const override; + void operator()(amrex::MultiFab& mf_dst, int dcomp, int /*i_buffer=0*/) const override; private: int const m_lev; /**< level on which mf_src is defined */ }; diff --git a/Source/Diagnostics/ComputeDiagFunctors/ParticleReductionFunctor.H b/Source/Diagnostics/ComputeDiagFunctors/ParticleReductionFunctor.H index 09b54726211..12a17ff13af 100644 --- a/Source/Diagnostics/ComputeDiagFunctors/ParticleReductionFunctor.H +++ b/Source/Diagnostics/ComputeDiagFunctors/ParticleReductionFunctor.H @@ -42,7 +42,7 @@ public: * \param[in] dcomp first component of mf_dst in which cell-centered * data is stored */ - virtual void operator()(amrex::MultiFab& mf_dst, int dcomp, int /*i_buffer=0*/) const override; + void operator()(amrex::MultiFab& mf_dst, int dcomp, int /*i_buffer=0*/) const override; private: int const m_lev; /**< level on which mf_src is defined */ int const m_ispec; /**< index of species to average over */ diff --git a/Source/Diagnostics/ComputeDiagFunctors/RhoFunctor.H b/Source/Diagnostics/ComputeDiagFunctors/RhoFunctor.H index e359bb2f6a2..46f8a3be251 100644 --- a/Source/Diagnostics/ComputeDiagFunctors/RhoFunctor.H +++ b/Source/Diagnostics/ComputeDiagFunctors/RhoFunctor.H @@ -38,7 +38,7 @@ public: * \param[out] mf_dst output MultiFab where the result is written * \param[in] dcomp first component of mf_dst in which cell-centered data are stored */ - virtual void operator() ( amrex::MultiFab& mf_dst, int dcomp, int /*i_buffer=0*/ ) const override; + void operator() ( amrex::MultiFab& mf_dst, int dcomp, int /*i_buffer=0*/ ) const override; private: diff --git a/Source/Diagnostics/Diagnostics.H b/Source/Diagnostics/Diagnostics.H index 75441d6d9e8..dc9656433c6 100644 --- a/Source/Diagnostics/Diagnostics.H +++ b/Source/Diagnostics/Diagnostics.H @@ -40,6 +40,11 @@ public: /** Virtual Destructor to handle clean destruction of derived classes */ virtual ~Diagnostics (); + Diagnostics (Diagnostics const &) = delete; + Diagnostics& operator= (Diagnostics const & ) = delete; + Diagnostics(Diagnostics&& ) = default; + Diagnostics& operator=(Diagnostics&& ) = default; + /** Pack (stack) all fields in the cell-centered output MultiFab m_mf_output. * * Fields are computed (e.g., cell-centered or back-transformed) @@ -58,8 +63,10 @@ public: * multiple times yet. * When these are fixed, the implementation of Flush should be in Diagnostics.cpp * \param[in] i_buffer index of the buffer data to be flushed. + * \param[in] force_flush only used for BTD, whether to do a complete flush of the data + * (including metadata listing the total number of particles) even if the snapshot is incomplete */ - virtual void Flush (int i_buffer) = 0; + virtual void Flush (int i_buffer, bool force_flush) = 0; /** Initialize pointers to main fields and allocate output multifab m_mf_output. */ void InitData (); void InitDataBeforeRestart (); diff --git a/Source/Diagnostics/Diagnostics.cpp b/Source/Diagnostics/Diagnostics.cpp index 6e74fc2cfde..878504dda97 100644 --- a/Source/Diagnostics/Diagnostics.cpp +++ b/Source/Diagnostics/Diagnostics.cpp @@ -575,7 +575,7 @@ Diagnostics::FilterComputePackFlush (int step, bool force_flush) for (int i_buffer = 0; i_buffer < m_num_buffers; ++i_buffer) { if ( !DoDump (step, i_buffer, force_flush) ) continue; - Flush(i_buffer); + Flush(i_buffer, force_flush); } diff --git a/Source/Diagnostics/FlushFormats/FlushFormat.H b/Source/Diagnostics/FlushFormats/FlushFormat.H index d8820d35a12..f5a693a5fa4 100644 --- a/Source/Diagnostics/FlushFormats/FlushFormat.H +++ b/Source/Diagnostics/FlushFormats/FlushFormat.H @@ -12,7 +12,7 @@ class FlushFormat public: /** Flush fields and particles to file */ virtual void WriteToFile ( - amrex::Vector varnames, + const amrex::Vector& varnames, const amrex::Vector& mf, amrex::Vector& geom, amrex::Vector iteration, double time, @@ -27,7 +27,13 @@ public: bool isLastBTDFlush = false, const amrex::Vector& totalParticlesFlushedAlready = amrex::Vector() ) const = 0; - virtual ~FlushFormat() {} + FlushFormat () = default; + virtual ~FlushFormat() {} + + FlushFormat ( FlushFormat const &) = default; + FlushFormat& operator= ( FlushFormat const & ) = default; + FlushFormat ( FlushFormat&& ) = default; + FlushFormat& operator= ( FlushFormat&& ) = default; }; #endif // WARPX_FLUSHFORMAT_H_ diff --git a/Source/Diagnostics/FlushFormats/FlushFormatAscent.H b/Source/Diagnostics/FlushFormats/FlushFormatAscent.H index b15b7432dd5..228e4bc5cf6 100644 --- a/Source/Diagnostics/FlushFormats/FlushFormatAscent.H +++ b/Source/Diagnostics/FlushFormats/FlushFormatAscent.H @@ -28,8 +28,8 @@ class FlushFormatAscent : public FlushFormat { public: /** Do in-situ visualization for field and particle data */ - virtual void WriteToFile ( - amrex::Vector varnames, + void WriteToFile ( + const amrex::Vector& varnames, const amrex::Vector& mf, amrex::Vector& geom, amrex::Vector iteration, double time, @@ -53,7 +53,13 @@ public: void WriteParticles(const amrex::Vector& particle_diags, conduit::Node& a_bp_mesh) const; #endif - ~FlushFormatAscent() {} + FlushFormatAscent () = default; + ~FlushFormatAscent() override = default; + + FlushFormatAscent ( FlushFormatAscent const &) = default; + FlushFormatAscent& operator= ( FlushFormatAscent const & ) = default; + FlushFormatAscent ( FlushFormatAscent&& ) = default; + FlushFormatAscent& operator= ( FlushFormatAscent&& ) = default; }; #endif // WARPX_FLUSHFORMATASCENT_H_ diff --git a/Source/Diagnostics/FlushFormats/FlushFormatAscent.cpp b/Source/Diagnostics/FlushFormats/FlushFormatAscent.cpp index 8fe25bef32b..980047e3b46 100644 --- a/Source/Diagnostics/FlushFormats/FlushFormatAscent.cpp +++ b/Source/Diagnostics/FlushFormats/FlushFormatAscent.cpp @@ -11,7 +11,7 @@ using namespace amrex; void FlushFormatAscent::WriteToFile ( - const amrex::Vector varnames, + const amrex::Vector& varnames, const amrex::Vector& mf, amrex::Vector& geom, const amrex::Vector iteration, const double time, diff --git a/Source/Diagnostics/FlushFormats/FlushFormatCheckpoint.H b/Source/Diagnostics/FlushFormats/FlushFormatCheckpoint.H index 5131d6f4234..f6aad226d75 100644 --- a/Source/Diagnostics/FlushFormats/FlushFormatCheckpoint.H +++ b/Source/Diagnostics/FlushFormats/FlushFormatCheckpoint.H @@ -15,8 +15,8 @@ class FlushFormatCheckpoint final : public FlushFormatPlotfile { /** Flush fields and particles to plotfile */ - virtual void WriteToFile ( - amrex::Vector varnames, + void WriteToFile ( + const amrex::Vector& varnames, const amrex::Vector& mf, amrex::Vector& geom, amrex::Vector iteration, double time, @@ -29,7 +29,7 @@ class FlushFormatCheckpoint final : public FlushFormatPlotfile int bufferID = 1, int numBuffers = 1, const amrex::Geometry& full_BTD_snapshot = amrex::Geometry(), bool isLastBTDFlush = false, - const amrex::Vector& totalParticlesFlushedAlready = amrex::Vector() ) const override final; + const amrex::Vector& totalParticlesFlushedAlready = amrex::Vector() ) const final; void CheckpointParticles (const std::string& dir, const amrex::Vector& particle_diags) const; diff --git a/Source/Diagnostics/FlushFormats/FlushFormatCheckpoint.cpp b/Source/Diagnostics/FlushFormats/FlushFormatCheckpoint.cpp index 6608123bb33..2247a7eaadf 100644 --- a/Source/Diagnostics/FlushFormats/FlushFormatCheckpoint.cpp +++ b/Source/Diagnostics/FlushFormats/FlushFormatCheckpoint.cpp @@ -27,7 +27,7 @@ namespace void FlushFormatCheckpoint::WriteToFile ( - const amrex::Vector /*varnames*/, + const amrex::Vector& /*varnames*/, const amrex::Vector& /*mf*/, amrex::Vector& geom, const amrex::Vector iteration, const double /*time*/, diff --git a/Source/Diagnostics/FlushFormats/FlushFormatOpenPMD.H b/Source/Diagnostics/FlushFormats/FlushFormatOpenPMD.H index 4da45c00bbf..88380407f5e 100644 --- a/Source/Diagnostics/FlushFormats/FlushFormatOpenPMD.H +++ b/Source/Diagnostics/FlushFormats/FlushFormatOpenPMD.H @@ -28,7 +28,7 @@ public: /** Flush fields and particles to plotfile */ void WriteToFile ( - amrex::Vector varnames, + const amrex::Vector& varnames, const amrex::Vector& mf, amrex::Vector& geom, amrex::Vector iteration, double time, @@ -45,6 +45,11 @@ public: ~FlushFormatOpenPMD () override = default; + FlushFormatOpenPMD ( FlushFormatOpenPMD const &) = delete; + FlushFormatOpenPMD& operator= ( FlushFormatOpenPMD const & ) = delete; + FlushFormatOpenPMD ( FlushFormatOpenPMD&& ) = default; + FlushFormatOpenPMD& operator= ( FlushFormatOpenPMD&& ) = default; + private: /** This is responsible for dumping to file */ std::unique_ptr< WarpXOpenPMDPlot > m_OpenPMDPlotWriter; diff --git a/Source/Diagnostics/FlushFormats/FlushFormatOpenPMD.cpp b/Source/Diagnostics/FlushFormats/FlushFormatOpenPMD.cpp index 2185d4b4cca..3e43d18d7fa 100644 --- a/Source/Diagnostics/FlushFormats/FlushFormatOpenPMD.cpp +++ b/Source/Diagnostics/FlushFormats/FlushFormatOpenPMD.cpp @@ -112,7 +112,7 @@ FlushFormatOpenPMD::FlushFormatOpenPMD (const std::string& diag_name) void FlushFormatOpenPMD::WriteToFile ( - const amrex::Vector varnames, + const amrex::Vector& varnames, const amrex::Vector& mf, amrex::Vector& geom, const amrex::Vector iteration, const double time, diff --git a/Source/Diagnostics/FlushFormats/FlushFormatPlotfile.H b/Source/Diagnostics/FlushFormats/FlushFormatPlotfile.H index b8461e51f23..62c7311804e 100644 --- a/Source/Diagnostics/FlushFormats/FlushFormatPlotfile.H +++ b/Source/Diagnostics/FlushFormats/FlushFormatPlotfile.H @@ -22,8 +22,8 @@ class FlushFormatPlotfile : public FlushFormat { public: /** Flush fields and particles to plotfile */ - virtual void WriteToFile ( - amrex::Vector varnames, + void WriteToFile ( + const amrex::Vector& varnames, const amrex::Vector& mf, amrex::Vector& geom, amrex::Vector iteration, double time, @@ -56,7 +56,13 @@ public: amrex::Real time, bool isBTD = false) const; - ~FlushFormatPlotfile() {} + FlushFormatPlotfile () = default; + ~FlushFormatPlotfile() override {} + + FlushFormatPlotfile ( FlushFormatPlotfile const &) = default; + FlushFormatPlotfile& operator= ( FlushFormatPlotfile const & ) = default; + FlushFormatPlotfile ( FlushFormatPlotfile&& ) = default; + FlushFormatPlotfile& operator= ( FlushFormatPlotfile&& ) = default; }; #endif // WARPX_FLUSHFORMATPLOTFILE_H_ diff --git a/Source/Diagnostics/FlushFormats/FlushFormatPlotfile.cpp b/Source/Diagnostics/FlushFormats/FlushFormatPlotfile.cpp index a18bab25308..c2e372b1fb8 100644 --- a/Source/Diagnostics/FlushFormats/FlushFormatPlotfile.cpp +++ b/Source/Diagnostics/FlushFormats/FlushFormatPlotfile.cpp @@ -55,7 +55,7 @@ namespace void FlushFormatPlotfile::WriteToFile ( - const amrex::Vector varnames, + const amrex::Vector& varnames, const amrex::Vector& mf, amrex::Vector& geom, const amrex::Vector iteration, const double time, diff --git a/Source/Diagnostics/FlushFormats/FlushFormatSensei.H b/Source/Diagnostics/FlushFormats/FlushFormatSensei.H index 28785c1c905..54eb7099ba4 100644 --- a/Source/Diagnostics/FlushFormats/FlushFormatSensei.H +++ b/Source/Diagnostics/FlushFormats/FlushFormatSensei.H @@ -33,10 +33,12 @@ class FlushFormatSensei : public FlushFormat { public: FlushFormatSensei(); - ~FlushFormatSensei(); + ~FlushFormatSensei() override; - FlushFormatSensei(const FlushFormatSensei &) = delete; - void operator=(const FlushFormatSensei &) = delete; + FlushFormatSensei(const FlushFormatSensei &) = delete; + FlushFormatSensei& operator=(const FlushFormatSensei &) = delete; + FlushFormatSensei(FlushFormatSensei&&) = default; + FlushFormatSensei& operator=(FlushFormatSensei&& ) = default; /** Construct. * @@ -46,8 +48,8 @@ public: FlushFormatSensei (amrex::AmrMesh *amr_mesh, std::string diag_name); /** Do in-situ visualization for field and particle data */ - virtual void WriteToFile ( - amrex::Vector varnames, + void WriteToFile ( + const amrex::Vector& varnames, const amrex::Vector& mf, amrex::Vector& geom, amrex::Vector iteration, double time, diff --git a/Source/Diagnostics/FlushFormats/FlushFormatSensei.cpp b/Source/Diagnostics/FlushFormats/FlushFormatSensei.cpp index 060c0e4a5e9..7d047913988 100644 --- a/Source/Diagnostics/FlushFormats/FlushFormatSensei.cpp +++ b/Source/Diagnostics/FlushFormats/FlushFormatSensei.cpp @@ -50,7 +50,7 @@ FlushFormatSensei::~FlushFormatSensei () = default; void FlushFormatSensei::WriteToFile ( - const amrex::Vector varnames, + const amrex::Vector& varnames, const amrex::Vector& mf, amrex::Vector& geom, const amrex::Vector iteration, const double time, diff --git a/Source/Diagnostics/FullDiagnostics.H b/Source/Diagnostics/FullDiagnostics.H index 4bb3e27895a..4464d46ebac 100644 --- a/Source/Diagnostics/FullDiagnostics.H +++ b/Source/Diagnostics/FullDiagnostics.H @@ -27,7 +27,7 @@ private: */ bool m_solver_deposits_current = true; /** Flush m_mf_output and particles to file for the i^th buffer */ - void Flush (int i_buffer) override; + void Flush (int i_buffer, bool /* force_flush */) override; /** Flush raw data */ void FlushRaw (); /** whether to compute and pack cell-centered data in m_mf_output diff --git a/Source/Diagnostics/FullDiagnostics.cpp b/Source/Diagnostics/FullDiagnostics.cpp index 6848f9e1a18..4ca45eeb59d 100644 --- a/Source/Diagnostics/FullDiagnostics.cpp +++ b/Source/Diagnostics/FullDiagnostics.cpp @@ -41,16 +41,14 @@ using namespace amrex::literals; -FullDiagnostics::FullDiagnostics (int i, std::string name) - : Diagnostics(i, name) +FullDiagnostics::FullDiagnostics (int i, std::string name): + Diagnostics{i, name}, + m_solver_deposits_current{ + !(WarpX::electromagnetic_solver_id == ElectromagneticSolverAlgo::None && + WarpX::electrostatic_solver_id != ElectrostaticSolverAlgo::LabFrameElectroMagnetostatic)} { ReadParameters(); BackwardCompatibility(); - - m_solver_deposits_current = !( - WarpX::electromagnetic_solver_id == ElectromagneticSolverAlgo::None && - WarpX::electrostatic_solver_id != ElectrostaticSolverAlgo::LabFrameElectroMagnetostatic - ); } void @@ -128,7 +126,7 @@ FullDiagnostics::BackwardCompatibility () } void -FullDiagnostics::Flush ( int i_buffer ) +FullDiagnostics::Flush ( int i_buffer, bool /* force_flush */ ) { // This function should be moved to Diagnostics when plotfiles/openpmd format // is supported for BackTransformed Diagnostics, in BTDiagnostics class. diff --git a/Source/Diagnostics/ReducedDiags/BeamRelevant.H b/Source/Diagnostics/ReducedDiags/BeamRelevant.H index 4e0d0077dad..f5037e37bc0 100644 --- a/Source/Diagnostics/ReducedDiags/BeamRelevant.H +++ b/Source/Diagnostics/ReducedDiags/BeamRelevant.H @@ -33,7 +33,7 @@ public: * * @param[in] step current time step */ - virtual void ComputeDiags(int step) override final; + void ComputeDiags(int step) final; }; diff --git a/Source/Diagnostics/ReducedDiags/ChargeOnEB.H b/Source/Diagnostics/ReducedDiags/ChargeOnEB.H index c7aa58f06e2..ed69ce01767 100644 --- a/Source/Diagnostics/ReducedDiags/ChargeOnEB.H +++ b/Source/Diagnostics/ReducedDiags/ChargeOnEB.H @@ -42,7 +42,7 @@ public: * * @param[in] step current time step */ - virtual void ComputeDiags (int step) override final; + void ComputeDiags (int step) final; private: /// Optional parser to add weight inside the integral diff --git a/Source/Diagnostics/ReducedDiags/ColliderRelevant.H b/Source/Diagnostics/ReducedDiags/ColliderRelevant.H index 1998c56812d..fe00dd2e7e3 100644 --- a/Source/Diagnostics/ReducedDiags/ColliderRelevant.H +++ b/Source/Diagnostics/ReducedDiags/ColliderRelevant.H @@ -44,7 +44,7 @@ public: * [14]thetay_min, [15]thetay_ave, [16]thetay_max, [17]thetay_std * same for second species follows. */ - void ComputeDiags(int step) override final; + void ComputeDiags(int step) final; private: /// auxiliary structure to store headers and indices of the reduced diagnostics diff --git a/Source/Diagnostics/ReducedDiags/FieldEnergy.H b/Source/Diagnostics/ReducedDiags/FieldEnergy.H index 73ebad34ba0..4f5d1656841 100644 --- a/Source/Diagnostics/ReducedDiags/FieldEnergy.H +++ b/Source/Diagnostics/ReducedDiags/FieldEnergy.H @@ -37,7 +37,7 @@ public: * * @param[in] step current time step */ - virtual void ComputeDiags(int step) override final; + void ComputeDiags(int step) final; /** * \brief Calculate the integral of the field squared in RZ diff --git a/Source/Diagnostics/ReducedDiags/FieldMaximum.H b/Source/Diagnostics/ReducedDiags/FieldMaximum.H index ea40c0e128c..95ae6ff16da 100644 --- a/Source/Diagnostics/ReducedDiags/FieldMaximum.H +++ b/Source/Diagnostics/ReducedDiags/FieldMaximum.H @@ -31,7 +31,7 @@ public: * * @param[in] step current time step */ - virtual void ComputeDiags(int step) override final; + void ComputeDiags(int step) final; }; diff --git a/Source/Diagnostics/ReducedDiags/FieldMomentum.H b/Source/Diagnostics/ReducedDiags/FieldMomentum.H index 2dadb6a8e86..0f04b6413d1 100644 --- a/Source/Diagnostics/ReducedDiags/FieldMomentum.H +++ b/Source/Diagnostics/ReducedDiags/FieldMomentum.H @@ -32,7 +32,7 @@ public: * * \param[in] step current time step */ - virtual void ComputeDiags(int step) override final; + void ComputeDiags(int step) final; }; #endif diff --git a/Source/Diagnostics/ReducedDiags/FieldProbe.H b/Source/Diagnostics/ReducedDiags/FieldProbe.H index 2b232264329..9f318c4f8a0 100644 --- a/Source/Diagnostics/ReducedDiags/FieldProbe.H +++ b/Source/Diagnostics/ReducedDiags/FieldProbe.H @@ -46,18 +46,18 @@ public: /** * This function assins test/data particles to constructed environemnt */ - void InitData () override final; + void InitData () final; /** Redistribute parallel data structures during load balance */ - void LoadBalance () override final; + void LoadBalance () final; /** * This function computes the value of Ex, Ey, Ez, Bx, By, Bz and at a given point * * @param[in] step current time step */ - void ComputeDiags (int step) override final; + void ComputeDiags (int step) final; /* * Define constants used throughout FieldProbe @@ -113,7 +113,7 @@ private: /** * Built-in function in ReducedDiags to write out test data */ - virtual void WriteToFile (int step) const override; + void WriteToFile (int step) const override; /** Check if the probe is in the simulation domain boundary */ diff --git a/Source/Diagnostics/ReducedDiags/FieldProbeParticleContainer.H b/Source/Diagnostics/ReducedDiags/FieldProbeParticleContainer.H index b3277b875d9..c85bf8fd541 100644 --- a/Source/Diagnostics/ReducedDiags/FieldProbeParticleContainer.H +++ b/Source/Diagnostics/ReducedDiags/FieldProbeParticleContainer.H @@ -44,7 +44,12 @@ class FieldProbeParticleContainer { public: FieldProbeParticleContainer (amrex::AmrCore* amr_core); - virtual ~FieldProbeParticleContainer() {} + ~FieldProbeParticleContainer() override = default; + + FieldProbeParticleContainer ( FieldProbeParticleContainer const &) = delete; + FieldProbeParticleContainer& operator= ( FieldProbeParticleContainer const & ) = delete; + FieldProbeParticleContainer ( FieldProbeParticleContainer&& ) = default; + FieldProbeParticleContainer& operator= ( FieldProbeParticleContainer&& ) = default; //! amrex iterator for our number of attributes using iterator = amrex::ParIter<0, 0, FieldProbePIdx::nattribs, 0>; diff --git a/Source/Diagnostics/ReducedDiags/FieldProbeParticleContainer.cpp b/Source/Diagnostics/ReducedDiags/FieldProbeParticleContainer.cpp index 5d990b9eb07..9a943759542 100644 --- a/Source/Diagnostics/ReducedDiags/FieldProbeParticleContainer.cpp +++ b/Source/Diagnostics/ReducedDiags/FieldProbeParticleContainer.cpp @@ -50,7 +50,6 @@ #include #include #include -#include #include diff --git a/Source/Diagnostics/ReducedDiags/FieldReduction.H b/Source/Diagnostics/ReducedDiags/FieldReduction.H index c4c81c0161a..e99c87ad14f 100644 --- a/Source/Diagnostics/ReducedDiags/FieldReduction.H +++ b/Source/Diagnostics/ReducedDiags/FieldReduction.H @@ -58,7 +58,7 @@ public: * * @param[in] step the timestep */ - virtual void ComputeDiags(int step) override final; + void ComputeDiags(int step) final; /** * This function queries deprecated input parameters and aborts diff --git a/Source/Diagnostics/ReducedDiags/LoadBalanceCosts.H b/Source/Diagnostics/ReducedDiags/LoadBalanceCosts.H index f2bfc12d7e1..0ecb74d4bf5 100644 --- a/Source/Diagnostics/ReducedDiags/LoadBalanceCosts.H +++ b/Source/Diagnostics/ReducedDiags/LoadBalanceCosts.H @@ -62,7 +62,7 @@ public: * * @param[in] step current time step */ - virtual void ComputeDiags(int step) override final; + void ComputeDiags(int step) final; /** * write to file function for costs; this differs from the base class @@ -71,7 +71,7 @@ public: * * @param[in] step current time step */ - virtual void WriteToFile(int step) const override final; + void WriteToFile(int step) const final; }; diff --git a/Source/Diagnostics/ReducedDiags/LoadBalanceEfficiency.H b/Source/Diagnostics/ReducedDiags/LoadBalanceEfficiency.H index d0c823fb949..a43868ccc5f 100644 --- a/Source/Diagnostics/ReducedDiags/LoadBalanceEfficiency.H +++ b/Source/Diagnostics/ReducedDiags/LoadBalanceEfficiency.H @@ -31,7 +31,7 @@ public: * * @param[in] step current time step */ - virtual void ComputeDiags(int step) override final; + void ComputeDiags(int step) final; }; #endif diff --git a/Source/Diagnostics/ReducedDiags/ParticleEnergy.H b/Source/Diagnostics/ReducedDiags/ParticleEnergy.H index b143cc93f04..b0df66709f3 100644 --- a/Source/Diagnostics/ReducedDiags/ParticleEnergy.H +++ b/Source/Diagnostics/ReducedDiags/ParticleEnergy.H @@ -35,7 +35,7 @@ public: * * @param[in] step current time step */ - virtual void ComputeDiags(int step) override final; + void ComputeDiags(int step) final; }; diff --git a/Source/Diagnostics/ReducedDiags/ParticleExtrema.H b/Source/Diagnostics/ReducedDiags/ParticleExtrema.H index b6bfb7c5e22..51bc1a600f9 100644 --- a/Source/Diagnostics/ReducedDiags/ParticleExtrema.H +++ b/Source/Diagnostics/ReducedDiags/ParticleExtrema.H @@ -35,7 +35,7 @@ public: * * @param[in] step current time step */ - void ComputeDiags(int step) override final; + void ComputeDiags(int step) final; private: /// auxiliary structure to store headers and indices of the reduced diagnostics diff --git a/Source/Diagnostics/ReducedDiags/ParticleHistogram.H b/Source/Diagnostics/ReducedDiags/ParticleHistogram.H index 07a2b9599fb..758f4a399a9 100644 --- a/Source/Diagnostics/ReducedDiags/ParticleHistogram.H +++ b/Source/Diagnostics/ReducedDiags/ParticleHistogram.H @@ -62,7 +62,7 @@ public: * * @param[in] step current time step */ - virtual void ComputeDiags(int step) override final; + void ComputeDiags(int step) final; }; diff --git a/Source/Diagnostics/ReducedDiags/ParticleHistogram.cpp b/Source/Diagnostics/ReducedDiags/ParticleHistogram.cpp index 9da001ba7ed..ecefd08eab7 100644 --- a/Source/Diagnostics/ReducedDiags/ParticleHistogram.cpp +++ b/Source/Diagnostics/ReducedDiags/ParticleHistogram.cpp @@ -50,8 +50,8 @@ struct NormalizationType { }; // constructor -ParticleHistogram::ParticleHistogram (std::string rd_name) -: ReducedDiags{rd_name} +ParticleHistogram::ParticleHistogram (std::string rd_name): + ReducedDiags{rd_name} { const ParmParse pp_rd_name(rd_name); @@ -60,10 +60,15 @@ ParticleHistogram::ParticleHistogram (std::string rd_name) pp_rd_name.get("species",selected_species_name); // read bin parameters - utils::parser::getWithParser(pp_rd_name, "bin_number",m_bin_num); - utils::parser::getWithParser(pp_rd_name, "bin_max", m_bin_max); - utils::parser::getWithParser(pp_rd_name, "bin_min", m_bin_min); - m_bin_size = (m_bin_max - m_bin_min) / m_bin_num; + int bin_num = 0; + amrex::Real bin_max = 0.0_rt, bin_min = 0.0_rt; + utils::parser::getWithParser(pp_rd_name, "bin_number", bin_num); + utils::parser::getWithParser(pp_rd_name, "bin_max", bin_max); + utils::parser::getWithParser(pp_rd_name, "bin_min", bin_min); + m_bin_num = bin_num; + m_bin_max = bin_max; + m_bin_min = bin_min; + m_bin_size = (bin_max - bin_min) / bin_num; // read histogram function std::string function_string; diff --git a/Source/Diagnostics/ReducedDiags/ParticleHistogram2D.H b/Source/Diagnostics/ReducedDiags/ParticleHistogram2D.H index 6b82514567d..98697380a4a 100644 --- a/Source/Diagnostics/ReducedDiags/ParticleHistogram2D.H +++ b/Source/Diagnostics/ReducedDiags/ParticleHistogram2D.H @@ -84,14 +84,14 @@ public: * * @param[in] step current time step */ - void ComputeDiags(int step) override final; + void ComputeDiags(int step) final; /** * write to file function * * @param[in] step current time step */ - void WriteToFile (int step) const override final; + void WriteToFile (int step) const final; }; diff --git a/Source/Diagnostics/ReducedDiags/ParticleMomentum.H b/Source/Diagnostics/ReducedDiags/ParticleMomentum.H index ec16d8184c5..feb8957e516 100644 --- a/Source/Diagnostics/ReducedDiags/ParticleMomentum.H +++ b/Source/Diagnostics/ReducedDiags/ParticleMomentum.H @@ -34,7 +34,7 @@ public: * * \param [in] step current time step */ - virtual void ComputeDiags(int step) override final; + void ComputeDiags(int step) final; }; #endif diff --git a/Source/Diagnostics/ReducedDiags/ParticleNumber.H b/Source/Diagnostics/ReducedDiags/ParticleNumber.H index ad6c886e269..3143a387a74 100644 --- a/Source/Diagnostics/ReducedDiags/ParticleNumber.H +++ b/Source/Diagnostics/ReducedDiags/ParticleNumber.H @@ -32,7 +32,7 @@ public: * * @param[in] step current time step */ - virtual void ComputeDiags(int step) override final; + void ComputeDiags(int step) final; }; diff --git a/Source/Diagnostics/ReducedDiags/ReducedDiags.H b/Source/Diagnostics/ReducedDiags/ReducedDiags.H index c4fc82fbddf..01847a1ff12 100644 --- a/Source/Diagnostics/ReducedDiags/ReducedDiags.H +++ b/Source/Diagnostics/ReducedDiags/ReducedDiags.H @@ -59,6 +59,13 @@ public: */ virtual ~ReducedDiags () = default; + // Default move and copy operations + ReducedDiags(const ReducedDiags&) = default; + ReducedDiags& operator=(const ReducedDiags&) = default; + ReducedDiags(ReducedDiags&&) = default; + ReducedDiags& operator=(ReducedDiags&&) = default; + + /** * function to initialize data after amr * levels are initialized. diff --git a/Source/Diagnostics/ReducedDiags/RhoMaximum.H b/Source/Diagnostics/ReducedDiags/RhoMaximum.H index e7386f73383..6f306a5e7ad 100644 --- a/Source/Diagnostics/ReducedDiags/RhoMaximum.H +++ b/Source/Diagnostics/ReducedDiags/RhoMaximum.H @@ -36,7 +36,7 @@ public: * * @param[in] step current time step */ - virtual void ComputeDiags(int step) override final; + void ComputeDiags(int step) final; private: /** Vector of (pointers to) functors to compute rho, per level, per species. We reuse here the diff --git a/Source/Diagnostics/WarpXOpenPMD.H b/Source/Diagnostics/WarpXOpenPMD.H index 62a1fa3755f..1acfc19b5a9 100644 --- a/Source/Diagnostics/WarpXOpenPMD.H +++ b/Source/Diagnostics/WarpXOpenPMD.H @@ -99,6 +99,11 @@ public: ~WarpXOpenPMDPlot (); + WarpXOpenPMDPlot ( WarpXOpenPMDPlot const &) = delete; + WarpXOpenPMDPlot& operator= ( WarpXOpenPMDPlot const & ) = delete; + WarpXOpenPMDPlot ( WarpXOpenPMDPlot&& ) = default; + WarpXOpenPMDPlot& operator= ( WarpXOpenPMDPlot&& ) = default; + /** Set Iteration Step for the series * * @note If an iteration has been written, then it will give a warning diff --git a/Source/Diagnostics/WarpXOpenPMD.cpp b/Source/Diagnostics/WarpXOpenPMD.cpp index 458760d3664..110806cbbaa 100644 --- a/Source/Diagnostics/WarpXOpenPMD.cpp +++ b/Source/Diagnostics/WarpXOpenPMD.cpp @@ -378,6 +378,8 @@ WarpXOpenPMDPlot::WarpXOpenPMDPlot ( std::map< std::string, std::string > engine_parameters, std::vector fieldPMLdirections) :m_Series(nullptr), + m_MPIRank{amrex::ParallelDescriptor::MyProc()}, + m_MPISize{amrex::ParallelDescriptor::NProcs()}, m_Encoding(ie), m_OpenPMDFileType(std::move(openPMDFileType)), m_fieldPMLdirections(std::move(fieldPMLdirections)) @@ -490,15 +492,11 @@ WarpXOpenPMDPlot::Init (openPMD::Access access, bool isBTD) amrex::ParallelDescriptor::Communicator(), m_OpenPMDoptions ); - m_MPISize = amrex::ParallelDescriptor::NProcs(); - m_MPIRank = amrex::ParallelDescriptor::MyProc(); #else WARPX_ABORT_WITH_MESSAGE("openPMD-api not built with MPI support!"); #endif } else { m_Series = std::make_unique(filepath, access, m_OpenPMDoptions); - m_MPISize = 1; - m_MPIRank = 1; } m_Series->setIterationEncoding( m_Encoding ); @@ -1481,11 +1479,10 @@ WarpXOpenPMDPlot::WriteOpenPMDFieldsAll ( //const std::string& filename, // // // -WarpXParticleCounter::WarpXParticleCounter (ParticleContainer* pc) +WarpXParticleCounter::WarpXParticleCounter (ParticleContainer* pc): + m_MPIRank{amrex::ParallelDescriptor::MyProc()}, + m_MPISize{amrex::ParallelDescriptor::NProcs()} { - m_MPISize = amrex::ParallelDescriptor::NProcs(); - m_MPIRank = amrex::ParallelDescriptor::MyProc(); - m_ParticleCounterByLevel.resize(pc->finestLevel()+1); m_ParticleOffsetAtRank.resize(pc->finestLevel()+1); m_ParticleSizeAtRank.resize(pc->finestLevel()+1); diff --git a/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceSolver.cpp b/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceSolver.cpp index 1bb557d009d..8923ec1f6a5 100644 --- a/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceSolver.cpp +++ b/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceSolver.cpp @@ -30,12 +30,11 @@ FiniteDifferenceSolver::FiniteDifferenceSolver ( int const fdtd_algo, std::array cell_size, - short grid_type) { - + short grid_type): // Register the type of finite-difference algorithm - m_fdtd_algo = fdtd_algo; - m_grid_type = grid_type; - + m_fdtd_algo{fdtd_algo}, + m_grid_type{grid_type} +{ // return if not FDTD if (fdtd_algo == ElectromagneticSolverAlgo::None || fdtd_algo == ElectromagneticSolverAlgo::PSATD) return; diff --git a/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicProperties/MacroscopicProperties.H b/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicProperties/MacroscopicProperties.H index d67978f5f3e..d0806c332e3 100644 --- a/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicProperties/MacroscopicProperties.H +++ b/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicProperties/MacroscopicProperties.H @@ -49,7 +49,8 @@ public: */ void InitializeMacroMultiFabUsingParser (amrex::MultiFab *macro_mf, amrex::ParserExecutor<3> const& macro_parser, - int lev); + const amrex::GpuArray& dx_lev, + const amrex::RealBox& prob_domain_lev); /** Gpu Vector with index type of the conductivity multifab */ amrex::GpuArray sigma_IndexType; diff --git a/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicProperties/MacroscopicProperties.cpp b/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicProperties/MacroscopicProperties.cpp index 858972f2eb4..32c07e0b9fe 100644 --- a/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicProperties/MacroscopicProperties.cpp +++ b/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicProperties/MacroscopicProperties.cpp @@ -144,7 +144,8 @@ MacroscopicProperties::InitData () } else if (m_sigma_s == "parse_sigma_function") { - InitializeMacroMultiFabUsingParser(m_sigma_mf.get(), m_sigma_parser->compile<3>(), lev); + InitializeMacroMultiFabUsingParser(m_sigma_mf.get(), m_sigma_parser->compile<3>(), + warpx.Geom(lev).CellSizeArray(), warpx.Geom(lev).ProbDomain()); } // Initialize epsilon if (m_epsilon_s == "constant") { @@ -153,7 +154,8 @@ MacroscopicProperties::InitData () } else if (m_epsilon_s == "parse_epsilon_function") { - InitializeMacroMultiFabUsingParser(m_eps_mf.get(), m_epsilon_parser->compile<3>(), lev); + InitializeMacroMultiFabUsingParser(m_eps_mf.get(), m_epsilon_parser->compile<3>(), + warpx.Geom(lev).CellSizeArray(), warpx.Geom(lev).ProbDomain()); } // In the Maxwell solver, `epsilon` is used in the denominator. @@ -169,7 +171,8 @@ MacroscopicProperties::InitData () } else if (m_mu_s == "parse_mu_function") { - InitializeMacroMultiFabUsingParser(m_mu_mf.get(), m_mu_parser->compile<3>(), lev); + InitializeMacroMultiFabUsingParser(m_mu_mf.get(), m_mu_parser->compile<3>(), + warpx.Geom(lev).CellSizeArray(), warpx.Geom(lev).ProbDomain()); } @@ -204,11 +207,9 @@ void MacroscopicProperties::InitializeMacroMultiFabUsingParser ( amrex::MultiFab *macro_mf, amrex::ParserExecutor<3> const& macro_parser, - const int lev) + const amrex::GpuArray& dx_lev, + const amrex::RealBox& prob_domain_lev) { - WarpX& warpx = WarpX::GetInstance(); - const amrex::GpuArray dx_lev = warpx.Geom(lev).CellSizeArray(); - const amrex::RealBox& real_box = warpx.Geom(lev).ProbDomain(); const amrex::IntVect iv = macro_mf->ixType().toIntVect(); for ( amrex::MFIter mfi(*macro_mf, TilingIfNotGPU()); mfi.isValid(); ++mfi ) { // Initialize ghost cells in addition to valid cells @@ -223,20 +224,20 @@ MacroscopicProperties::InitializeMacroMultiFabUsingParser ( const amrex::Real x = 0._rt; const amrex::Real y = 0._rt; const amrex::Real fac_z = (1._rt - iv[0]) * dx_lev[0] * 0.5_rt; - const amrex::Real z = j * dx_lev[0] + real_box.lo(0) + fac_z; + const amrex::Real z = j * dx_lev[0] + prob_domain_lev.lo(0) + fac_z; #elif defined(WARPX_DIM_XZ) || defined(WARPX_DIM_RZ) const amrex::Real fac_x = (1._rt - iv[0]) * dx_lev[0] * 0.5_rt; - const amrex::Real x = i * dx_lev[0] + real_box.lo(0) + fac_x; + const amrex::Real x = i * dx_lev[0] + prob_domain_lev.lo(0) + fac_x; const amrex::Real y = 0._rt; const amrex::Real fac_z = (1._rt - iv[1]) * dx_lev[1] * 0.5_rt; - const amrex::Real z = j * dx_lev[1] + real_box.lo(1) + fac_z; + const amrex::Real z = j * dx_lev[1] + prob_domain_lev.lo(1) + fac_z; #else const amrex::Real fac_x = (1._rt - iv[0]) * dx_lev[0] * 0.5_rt; - const amrex::Real x = i * dx_lev[0] + real_box.lo(0) + fac_x; + const amrex::Real x = i * dx_lev[0] + prob_domain_lev.lo(0) + fac_x; const amrex::Real fac_y = (1._rt - iv[1]) * dx_lev[1] * 0.5_rt; - const amrex::Real y = j * dx_lev[1] + real_box.lo(1) + fac_y; + const amrex::Real y = j * dx_lev[1] + prob_domain_lev.lo(1) + fac_y; const amrex::Real fac_z = (1._rt - iv[2]) * dx_lev[2] * 0.5_rt; - const amrex::Real z = k * dx_lev[2] + real_box.lo(2) + fac_z; + const amrex::Real z = k * dx_lev[2] + prob_domain_lev.lo(2) + fac_z; #endif // initialize the macroparameter macro_fab(i,j,k) = macro_parser(x,y,z); diff --git a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmComoving.H b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmComoving.H index be9dbf26b59..87dfe6f2d9a 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmComoving.H +++ b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmComoving.H @@ -40,7 +40,7 @@ class PsatdAlgorithmComoving : public SpectralBaseAlgorithm /** * \brief Override the update equations in Fourier space */ - virtual void pushSpectralFields (SpectralFieldData& f) const override final; + void pushSpectralFields (SpectralFieldData& f) const final; /* \brief Initialize the coefficients needed in the update equations */ @@ -56,7 +56,7 @@ class PsatdAlgorithmComoving : public SpectralBaseAlgorithm * * \param[in,out] field_data All fields in Fourier space */ - virtual void CurrentCorrection (SpectralFieldData& field_data) override final; + void CurrentCorrection (SpectralFieldData& field_data) final; /** * \brief Virtual function for Vay current deposition in Fourier space. @@ -66,7 +66,7 @@ class PsatdAlgorithmComoving : public SpectralBaseAlgorithm * * \param[in,out] field_data All fields in Fourier space */ - virtual void VayDeposition (SpectralFieldData& field_data) override final; + void VayDeposition (SpectralFieldData& field_data) final; private: diff --git a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmFirstOrder.H b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmFirstOrder.H index dea72bec396..8fde50d8172 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmFirstOrder.H +++ b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmFirstOrder.H @@ -62,7 +62,7 @@ class PsatdAlgorithmFirstOrder : public SpectralBaseAlgorithm * * \param[in,out] f all the fields in spectral space */ - virtual void pushSpectralFields (SpectralFieldData& f) const override final; + void pushSpectralFields (SpectralFieldData& f) const final; /** * \brief Virtual function for current correction in Fourier space @@ -73,7 +73,7 @@ class PsatdAlgorithmFirstOrder : public SpectralBaseAlgorithm * * \param[in,out] field_data All fields in Fourier space */ - virtual void CurrentCorrection (SpectralFieldData& field_data) override final; + void CurrentCorrection (SpectralFieldData& field_data) final; /** * \brief Virtual function for Vay current deposition in Fourier space @@ -84,7 +84,7 @@ class PsatdAlgorithmFirstOrder : public SpectralBaseAlgorithm * * \param[in,out] field_data All fields in Fourier space */ - virtual void VayDeposition (SpectralFieldData& field_data) override final; + void VayDeposition (SpectralFieldData& field_data) final; private: diff --git a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmGalileanRZ.H b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmGalileanRZ.H index 37d76373990..ad0aca1ecf5 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmGalileanRZ.H +++ b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmGalileanRZ.H @@ -25,19 +25,19 @@ class PsatdAlgorithmGalileanRZ : public SpectralBaseAlgorithmRZ amrex::Real dt_step, bool update_with_rho); // Redefine functions from base class - virtual void pushSpectralFields (SpectralFieldDataRZ & f) override final; + void pushSpectralFields (SpectralFieldDataRZ & f) final; void InitializeSpectralCoefficients (SpectralFieldDataRZ const & f); /** * \brief Virtual function for current correction in Fourier space * This function overrides the virtual function \c CurrentCorrection in the - * base class \c SpectralBaseAlgorithmRZ (qualifier \c override) and cannot be + * base class \c SpectralBaseAlgorithmRZ and cannot be * overridden by further derived classes (qualifier \c final). * * \param[in,out] field_data all fields in Fourier space */ - virtual void CurrentCorrection (SpectralFieldDataRZ& field_data) override final; + void CurrentCorrection (SpectralFieldDataRZ& field_data) final; /** * \brief Virtual function for Vay current deposition in Fourier space @@ -47,11 +47,11 @@ class PsatdAlgorithmGalileanRZ : public SpectralBaseAlgorithmRZ * * \param[in,out] field_data All fields in Fourier space */ - virtual void VayDeposition (SpectralFieldDataRZ& field_data) override final; + void VayDeposition (SpectralFieldDataRZ& field_data) final; private: - bool coefficients_initialized; + bool coefficients_initialized = false; // Note that dt and v_galilean are saved to use in InitializeSpectralCoefficients amrex::Real m_dt; amrex::Vector m_v_galilean; diff --git a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmGalileanRZ.cpp b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmGalileanRZ.cpp index 3188712d61a..dad10716655 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmGalileanRZ.cpp +++ b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmGalileanRZ.cpp @@ -23,14 +23,13 @@ PsatdAlgorithmGalileanRZ::PsatdAlgorithmGalileanRZ (SpectralKSpaceRZ const & spe short const grid_type, const amrex::Vector& v_galilean, amrex::Real const dt, - bool const update_with_rho) + bool const update_with_rho): // Initialize members of base class - : SpectralBaseAlgorithmRZ(spectral_kspace, dm, spectral_index, norder_z, grid_type), - m_dt(dt), - m_v_galilean(v_galilean), - m_update_with_rho(update_with_rho) + SpectralBaseAlgorithmRZ{spectral_kspace, dm, spectral_index, norder_z, grid_type}, + m_dt{dt}, + m_v_galilean{v_galilean}, + m_update_with_rho{update_with_rho} { - // Allocate the arrays of coefficients amrex::BoxArray const & ba = spectral_kspace.spectralspace_ba; C_coef = SpectralRealCoefficients(ba, dm, n_rz_azimuthal_modes, 0); @@ -41,8 +40,6 @@ PsatdAlgorithmGalileanRZ::PsatdAlgorithmGalileanRZ (SpectralKSpaceRZ const & spe X4_coef = SpectralComplexCoefficients(ba, dm, n_rz_azimuthal_modes, 0); Theta2_coef = SpectralComplexCoefficients(ba, dm, n_rz_azimuthal_modes, 0); T_rho_coef = SpectralComplexCoefficients(ba, dm, n_rz_azimuthal_modes, 0); - - coefficients_initialized = false; } /* Advance the E and B field in spectral space (stored in `f`) diff --git a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmJConstantInTime.H b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmJConstantInTime.H index ed293fd1efa..94f00d6d4eb 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmJConstantInTime.H +++ b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmJConstantInTime.H @@ -65,7 +65,7 @@ class PsatdAlgorithmJConstantInTime : public SpectralBaseAlgorithm * * \param[in,out] f all the fields in spectral space */ - virtual void pushSpectralFields (SpectralFieldData& f) const override final; + void pushSpectralFields (SpectralFieldData& f) const final; /** * \brief Initializes the coefficients used in \c pushSpectralFields to update the E and B fields @@ -101,7 +101,7 @@ class PsatdAlgorithmJConstantInTime : public SpectralBaseAlgorithm * * \param[in,out] field_data All fields in Fourier space */ - virtual void CurrentCorrection (SpectralFieldData& field_data) override final; + void CurrentCorrection (SpectralFieldData& field_data) final; /** * \brief Virtual function for Vay current deposition in Fourier space @@ -112,7 +112,7 @@ class PsatdAlgorithmJConstantInTime : public SpectralBaseAlgorithm * * \param[in,out] field_data All fields in Fourier space */ - virtual void VayDeposition (SpectralFieldData& field_data) override final; + void VayDeposition (SpectralFieldData& field_data) final; private: diff --git a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmJConstantInTime.cpp b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmJConstantInTime.cpp index 11d9bbd94d3..5513a65a2ed 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmJConstantInTime.cpp +++ b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmJConstantInTime.cpp @@ -60,12 +60,12 @@ PsatdAlgorithmJConstantInTime::PsatdAlgorithmJConstantInTime( m_update_with_rho(update_with_rho), m_time_averaging(time_averaging), m_dive_cleaning(dive_cleaning), - m_divb_cleaning(divb_cleaning) + m_divb_cleaning(divb_cleaning), + m_is_galilean{ + (v_galilean[0] != 0.) || (v_galilean[1] != 0.) || (v_galilean[2] != 0.)} { const amrex::BoxArray& ba = spectral_kspace.spectralspace_ba; - m_is_galilean = (v_galilean[0] != 0.) || (v_galilean[1] != 0.) || (v_galilean[2] != 0.); - // Always allocate these coefficients C_coef = SpectralRealCoefficients(ba, dm, 1, 0); S_ck_coef = SpectralRealCoefficients(ba, dm, 1, 0); diff --git a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmJLinearInTime.H b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmJLinearInTime.H index 94eda8a2f72..aa3bcc08e77 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmJLinearInTime.H +++ b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmJLinearInTime.H @@ -64,7 +64,7 @@ class PsatdAlgorithmJLinearInTime : public SpectralBaseAlgorithm * * \param[in,out] f all the fields in spectral space */ - virtual void pushSpectralFields (SpectralFieldData& f) const override final; + void pushSpectralFields (SpectralFieldData& f) const final; /** * \brief Initializes the coefficients used in \c pushSpectralFields to update the E and B fields @@ -100,7 +100,7 @@ class PsatdAlgorithmJLinearInTime : public SpectralBaseAlgorithm * * \param[in,out] field_data All fields in Fourier space */ - virtual void CurrentCorrection (SpectralFieldData& field_data) override final; + void CurrentCorrection (SpectralFieldData& field_data) final; /** * \brief Virtual function for Vay current deposition in Fourier space @@ -111,7 +111,7 @@ class PsatdAlgorithmJLinearInTime : public SpectralBaseAlgorithm * * \param[in,out] field_data All fields in Fourier space */ - virtual void VayDeposition (SpectralFieldData& field_data) override final; + void VayDeposition (SpectralFieldData& field_data) final; private: diff --git a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmPml.H b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmPml.H index cef6331888e..1c25ca91903 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmPml.H +++ b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmPml.H @@ -74,7 +74,7 @@ class PsatdAlgorithmPml : public SpectralBaseAlgorithm * * \param[in,out] f All fields in spectral space */ - virtual void pushSpectralFields(SpectralFieldData& f) const override final; + void pushSpectralFields(SpectralFieldData& f) const final; /** * \brief Virtual function for current correction in Fourier space @@ -85,7 +85,7 @@ class PsatdAlgorithmPml : public SpectralBaseAlgorithm * * \param[in,out] field_data All fields in Fourier space */ - virtual void CurrentCorrection (SpectralFieldData& field_data) override final; + void CurrentCorrection (SpectralFieldData& field_data) final; /** * \brief Virtual function for Vay current deposition in Fourier space @@ -96,7 +96,7 @@ class PsatdAlgorithmPml : public SpectralBaseAlgorithm * * \param[in,out] field_data All fields in Fourier space */ - virtual void VayDeposition (SpectralFieldData& field_data) override final; + void VayDeposition (SpectralFieldData& field_data) final; private: diff --git a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmPml.cpp b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmPml.cpp index be91d920cba..92b8b3e900d 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmPml.cpp +++ b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmPml.cpp @@ -56,12 +56,11 @@ PsatdAlgorithmPml::PsatdAlgorithmPml( m_v_galilean(v_galilean), m_dt(dt), m_dive_cleaning(dive_cleaning), - m_divb_cleaning(divb_cleaning) + m_divb_cleaning(divb_cleaning), + m_is_galilean{(v_galilean[0] != 0.) || (v_galilean[1] != 0.) || (v_galilean[2] != 0.)} { const BoxArray& ba = spectral_kspace.spectralspace_ba; - m_is_galilean = (v_galilean[0] != 0.) || (v_galilean[1] != 0.) || (v_galilean[2] != 0.); - // Allocate arrays of coefficients C_coef = SpectralRealCoefficients(ba, dm, 1, 0); S_ck_coef = SpectralRealCoefficients(ba, dm, 1, 0); diff --git a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmPmlRZ.H b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmPmlRZ.H index 33dafd382ac..00264956900 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmPmlRZ.H +++ b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmPmlRZ.H @@ -23,7 +23,7 @@ class PsatdAlgorithmPmlRZ : public SpectralBaseAlgorithmRZ short grid_type, amrex::Real dt_step); // Redefine functions from base class - virtual void pushSpectralFields (SpectralFieldDataRZ & f) override final; + void pushSpectralFields (SpectralFieldDataRZ & f) final; void InitializeSpectralCoefficients (SpectralFieldDataRZ const & f); @@ -36,7 +36,7 @@ class PsatdAlgorithmPmlRZ : public SpectralBaseAlgorithmRZ * * \param[in,out] field_data All fields in Fourier space */ - virtual void CurrentCorrection (SpectralFieldDataRZ& field_data) override final; + void CurrentCorrection (SpectralFieldDataRZ& field_data) final; /** * \brief Virtual function for Vay current deposition in Fourier space @@ -47,11 +47,11 @@ class PsatdAlgorithmPmlRZ : public SpectralBaseAlgorithmRZ * * \param[in,out] field_data All fields in Fourier space */ - virtual void VayDeposition (SpectralFieldDataRZ& field_data) override final; + void VayDeposition (SpectralFieldDataRZ& field_data) final; private: - bool coefficients_initialized; + bool coefficients_initialized = false; // Note that dt is saved to use in InitializeSpectralCoefficients amrex::Real m_dt; SpectralRealCoefficients C_coef, S_ck_coef; diff --git a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmPmlRZ.cpp b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmPmlRZ.cpp index 45a21f2ffec..3bca43f4e8f 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmPmlRZ.cpp +++ b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmPmlRZ.cpp @@ -20,17 +20,16 @@ PsatdAlgorithmPmlRZ::PsatdAlgorithmPmlRZ (SpectralKSpaceRZ const & spectral_kspa amrex::DistributionMapping const & dm, const SpectralFieldIndex& spectral_index, int const n_rz_azimuthal_modes, int const norder_z, - short const grid_type, amrex::Real const dt) - // Initialize members of base class - : SpectralBaseAlgorithmRZ(spectral_kspace, dm, spectral_index, norder_z, grid_type), - m_dt(dt) + short const grid_type, amrex::Real const dt): + // Initialize members of base class and member variables + SpectralBaseAlgorithmRZ{spectral_kspace, dm, spectral_index, norder_z, grid_type}, + coefficients_initialized{false}, + m_dt{dt} { // Allocate the arrays of coefficients amrex::BoxArray const & ba = spectral_kspace.spectralspace_ba; C_coef = SpectralRealCoefficients(ba, dm, n_rz_azimuthal_modes, 0); S_ck_coef = SpectralRealCoefficients(ba, dm, n_rz_azimuthal_modes, 0); - - coefficients_initialized = false; } /* Advance the E and B field in spectral space (stored in `f`) diff --git a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmRZ.H b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmRZ.H index 5f02498f7d0..10feafec38b 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmRZ.H +++ b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmRZ.H @@ -28,7 +28,7 @@ class PsatdAlgorithmRZ : public SpectralBaseAlgorithmRZ bool dive_cleaning, bool divb_cleaning); // Redefine functions from base class - virtual void pushSpectralFields(SpectralFieldDataRZ & f) override final; + void pushSpectralFields(SpectralFieldDataRZ & f) final; void InitializeSpectralCoefficients(SpectralFieldDataRZ const & f); @@ -41,7 +41,7 @@ class PsatdAlgorithmRZ : public SpectralBaseAlgorithmRZ * * \param[in,out] field_data All fields in Fourier space */ - virtual void CurrentCorrection (SpectralFieldDataRZ& field_data) override final; + void CurrentCorrection (SpectralFieldDataRZ& field_data) final; /** * \brief Virtual function for Vay current deposition in Fourier space @@ -52,7 +52,7 @@ class PsatdAlgorithmRZ : public SpectralBaseAlgorithmRZ * * \param[in,out] field_data All fields in Fourier space */ - virtual void VayDeposition (SpectralFieldDataRZ& field_data) override final; + void VayDeposition (SpectralFieldDataRZ& field_data) final; private: diff --git a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmRZ.cpp b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmRZ.cpp index d5a95bc90bf..fcb89c39109 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmRZ.cpp +++ b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmRZ.cpp @@ -26,15 +26,15 @@ PsatdAlgorithmRZ::PsatdAlgorithmRZ (SpectralKSpaceRZ const & spectral_kspace, const int J_in_time, const int rho_in_time, const bool dive_cleaning, - const bool divb_cleaning) - // Initialize members of base class - : SpectralBaseAlgorithmRZ(spectral_kspace, dm, spectral_index, norder_z, grid_type), - m_dt(dt), - m_update_with_rho(update_with_rho), - m_time_averaging(time_averaging), - m_J_in_time(J_in_time), - m_dive_cleaning(dive_cleaning), - m_divb_cleaning(divb_cleaning) + const bool divb_cleaning): + // Initialize members of base class and member variables + SpectralBaseAlgorithmRZ{spectral_kspace, dm, spectral_index, norder_z, grid_type}, + m_dt{dt}, + m_update_with_rho{update_with_rho}, + m_time_averaging{time_averaging}, + m_J_in_time{J_in_time}, + m_dive_cleaning{dive_cleaning}, + m_divb_cleaning{divb_cleaning} { amrex::ignore_unused(rho_in_time); @@ -46,8 +46,6 @@ PsatdAlgorithmRZ::PsatdAlgorithmRZ (SpectralKSpaceRZ const & spectral_kspace, X2_coef = SpectralRealCoefficients(ba, dm, n_rz_azimuthal_modes, 0); X3_coef = SpectralRealCoefficients(ba, dm, n_rz_azimuthal_modes, 0); - coefficients_initialized = false; - if (time_averaging && J_in_time == JInTime::Linear) { X5_coef = SpectralRealCoefficients(ba, dm, n_rz_azimuthal_modes, 0); diff --git a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/SpectralBaseAlgorithm.H b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/SpectralBaseAlgorithm.H index 22fc506cc5a..4af24cfa559 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/SpectralBaseAlgorithm.H +++ b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/SpectralBaseAlgorithm.H @@ -41,7 +41,13 @@ class SpectralBaseAlgorithm // The destructor should also be a virtual function, so that // a pointer to subclass of `SpectraBaseAlgorithm` actually // calls the subclass's destructor. - virtual ~SpectralBaseAlgorithm() {} + virtual ~SpectralBaseAlgorithm() = default; + + // Default move and copy operations + SpectralBaseAlgorithm(const SpectralBaseAlgorithm&) = default; + SpectralBaseAlgorithm& operator=(const SpectralBaseAlgorithm&) = default; + SpectralBaseAlgorithm(SpectralBaseAlgorithm&&) = default; + SpectralBaseAlgorithm& operator=(SpectralBaseAlgorithm&&) = default; /** * \brief Virtual function for current correction in Fourier space diff --git a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/SpectralBaseAlgorithmRZ.H b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/SpectralBaseAlgorithmRZ.H index 5758f81e304..1a935de8cdf 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/SpectralBaseAlgorithmRZ.H +++ b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/SpectralBaseAlgorithmRZ.H @@ -28,6 +28,27 @@ class SpectralBaseAlgorithmRZ // calls the subclass's destructor. virtual ~SpectralBaseAlgorithmRZ() {} + /** + * \brief Default Copy constructor + */ + SpectralBaseAlgorithmRZ ( SpectralBaseAlgorithmRZ const &) = default; + + /** + * \brief Default Copy operator + */ + SpectralBaseAlgorithmRZ& operator= ( SpectralBaseAlgorithmRZ const & ) = default; + + + /** + * \brief Default Move constructor + */ + SpectralBaseAlgorithmRZ ( SpectralBaseAlgorithmRZ&& ) = default; + + /** + * \brief Default Move operator + */ + SpectralBaseAlgorithmRZ& operator= ( SpectralBaseAlgorithmRZ&& ) = default; + /** * \brief Virtual function for current correction in Fourier space * ( Vay et al, 2013). diff --git a/Source/FieldSolver/SpectralSolver/SpectralFieldData.H b/Source/FieldSolver/SpectralSolver/SpectralFieldData.H index 8fd23fac747..a4ef6a39189 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralFieldData.H +++ b/Source/FieldSolver/SpectralSolver/SpectralFieldData.H @@ -75,6 +75,26 @@ class SpectralFieldIndex */ ~SpectralFieldIndex () = default; + /** + * \brief Default Copy constructor + */ + SpectralFieldIndex ( SpectralFieldIndex const &) = default; + + /** + * \brief Default Copy operator + */ + SpectralFieldIndex& operator= ( SpectralFieldIndex const & ) = default; + + /** + * \brief Default Move constructor + */ + SpectralFieldIndex ( SpectralFieldIndex&& ) = default; + + /** + * \brief Default Move operator + */ + SpectralFieldIndex& operator= ( SpectralFieldIndex&& ) = default; + // Total number of fields that are actually allocated int n_fields; @@ -129,9 +149,14 @@ class SpectralFieldData int n_field_required, bool periodic_single_box); SpectralFieldData() = default; // Default constructor - SpectralFieldData& operator=(SpectralFieldData&& field_data) = default; ~SpectralFieldData(); + // default move and copy operations + SpectralFieldData(const SpectralFieldData&) = delete; + SpectralFieldData& operator=(const SpectralFieldData&) = delete; + SpectralFieldData(SpectralFieldData&&) = default; + SpectralFieldData& operator=(SpectralFieldData&& field_data) = default; + void ForwardTransform (int lev, const amrex::MultiFab& mf, int field_index, int i_comp); diff --git a/Source/FieldSolver/SpectralSolver/SpectralFieldData.cpp b/Source/FieldSolver/SpectralSolver/SpectralFieldData.cpp index 3547a5a55f5..c4d9a0dab35 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralFieldData.cpp +++ b/Source/FieldSolver/SpectralSolver/SpectralFieldData.cpp @@ -122,13 +122,12 @@ SpectralFieldData::SpectralFieldData( const int lev, const SpectralKSpace& k_space, const amrex::DistributionMapping& dm, const int n_field_required, - const bool periodic_single_box) + const bool periodic_single_box): + m_periodic_single_box{periodic_single_box} { amrex::LayoutData* cost = WarpX::getCosts(lev); const bool do_costs = WarpXUtilLoadBalance::doCosts(cost, realspace_ba, dm); - m_periodic_single_box = periodic_single_box; - const BoxArray& spectralspace_ba = k_space.spectralspace_ba; // Allocate the arrays that contain the fields in spectral space diff --git a/Source/FieldSolver/SpectralSolver/SpectralFieldDataRZ.H b/Source/FieldSolver/SpectralSolver/SpectralFieldDataRZ.H index b966c7c3c03..a8282fffbed 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralFieldDataRZ.H +++ b/Source/FieldSolver/SpectralSolver/SpectralFieldDataRZ.H @@ -40,9 +40,18 @@ class SpectralFieldDataRZ int n_field_required, int n_modes); SpectralFieldDataRZ () = default; // Default constructor - SpectralFieldDataRZ& operator=(SpectralFieldDataRZ&& field_data) = default; ~SpectralFieldDataRZ (); + /** Delete Copy constructor */ + SpectralFieldDataRZ ( SpectralFieldDataRZ const &) = delete; + /** Delete Copy operator */ + SpectralFieldDataRZ& operator= ( SpectralFieldDataRZ const & ) = delete; + /** Default Move constructor */ + SpectralFieldDataRZ ( SpectralFieldDataRZ&& ) = default; + /** Default Move operator */ + SpectralFieldDataRZ& operator=(SpectralFieldDataRZ&& field_data) = default; + + void ForwardTransform (int lev, const amrex::MultiFab& mf, int field_index, int i_comp=0); void ForwardTransform (int lev, const amrex::MultiFab& mf_r, int field_index_r, diff --git a/Source/Filter/NCIGodfreyFilter.H b/Source/Filter/NCIGodfreyFilter.H index 18b93189d76..86446495869 100644 --- a/Source/Filter/NCIGodfreyFilter.H +++ b/Source/Filter/NCIGodfreyFilter.H @@ -39,6 +39,8 @@ public: private: +//NCIGodfreyFilter not implemented in 1D +#if (AMREX_SPACEDIM >= 2) // Set of coefficients (different fields require to read // different coefficients from the table) godfrey_coeff_set m_coeff_set; @@ -46,6 +48,8 @@ private: amrex::Real m_cdtodz; // Whether the gather is from nodal fields or staggered fields bool m_nodal_gather; +#endif + }; #endif // #ifndef WARPX_GODFREY_FILTER_H_ diff --git a/Source/Filter/NCIGodfreyFilter.cpp b/Source/Filter/NCIGodfreyFilter.cpp index ff866332521..1cfd42aed03 100644 --- a/Source/Filter/NCIGodfreyFilter.cpp +++ b/Source/Filter/NCIGodfreyFilter.cpp @@ -23,39 +23,36 @@ using namespace amrex; -NCIGodfreyFilter::NCIGodfreyFilter(godfrey_coeff_set coeff_set, amrex::Real cdtodz, bool nodal_gather){ - // Store parameters into class data members - m_coeff_set = coeff_set; - m_cdtodz = cdtodz; - m_nodal_gather = nodal_gather; +//NCIGodfreyFilter not implemented in 1D +#if (AMREX_SPACEDIM >= 2) +NCIGodfreyFilter::NCIGodfreyFilter(godfrey_coeff_set coeff_set, amrex::Real cdtodz, bool nodal_gather): + m_coeff_set{coeff_set}, // Store parameters into class data members + m_cdtodz{cdtodz}, + m_nodal_gather{nodal_gather} +{ // NCI Godfrey filter has fixed size, and is applied along z only. -#if defined(WARPX_DIM_3D) +# if defined(WARPX_DIM_3D) stencil_length_each_dir = {1,1,5}; slen = {1,1,5}; -#elif defined(WARPX_DIM_XZ) || defined(WARPX_DIM_RZ) +# else stencil_length_each_dir = {1,5}; slen = {1,5,1}; -#else - amrex::ignore_unused(coeff_set, cdtodz, nodal_gather); - WARPX_ABORT_WITH_MESSAGE( - "NCIGodfreyFilter not implemented in 1D!"); -#endif +# endif } -void NCIGodfreyFilter::ComputeStencils(){ - -#if (AMREX_SPACEDIM >= 2) +void NCIGodfreyFilter::ComputeStencils() +{ using namespace warpx::nci_godfrey; // Sanity checks: filter length shoulz be 5 in z -#if defined(WARPX_DIM_3D) +# if defined(WARPX_DIM_3D) WARPX_ALWAYS_ASSERT_WITH_MESSAGE( slen.z==5,"ERROR: NCI filter requires 5 points in z"); -#else +# else WARPX_ALWAYS_ASSERT_WITH_MESSAGE( slen.y==5,"ERROR: NCI filter requires 5 points in z"); -#endif +# endif // Interpolate coefficients from the table, and store into prestencil. auto index = static_cast(tab_length*m_cdtodz); index = min(index, tab_length-2); @@ -111,33 +108,46 @@ void NCIGodfreyFilter::ComputeStencils(){ // so only 1 coeff, equal to 1) Vector h_stencil_x(1); h_stencil_x[0] = 1._rt; -#if defined(WARPX_DIM_3D) +# if defined(WARPX_DIM_3D) Vector h_stencil_y(1); h_stencil_y[0] = 1._rt; -#endif +# endif // Due to the way Filter::DoFilter() is written, // coefficient 0 has to be /2 h_stencil_x[0] /= 2._rt; -#if defined(WARPX_DIM_3D) +# if defined(WARPX_DIM_3D) h_stencil_y[0] /= 2._rt; -#endif +# endif h_stencil_z[0] /= 2._rt; stencil_x.resize(h_stencil_x.size()); -#if defined(WARPX_DIM_3D) +# if defined(WARPX_DIM_3D) stencil_y.resize(h_stencil_y.size()); -#endif +# endif stencil_z.resize(h_stencil_z.size()); Gpu::copyAsync(Gpu::hostToDevice,h_stencil_x.begin(),h_stencil_x.end(),stencil_x.begin()); -#if defined(WARPX_DIM_3D) +# if defined(WARPX_DIM_3D) Gpu::copyAsync(Gpu::hostToDevice,h_stencil_y.begin(),h_stencil_y.end(),stencil_y.begin()); -#endif +# endif Gpu::copyAsync(Gpu::hostToDevice,h_stencil_z.begin(),h_stencil_z.end(),stencil_z.begin()); Gpu::synchronize(); +} + #else - WARPX_ABORT_WITH_MESSAGE("NCIGodfreyFilter not implemented in 1D!"); -#endif + +NCIGodfreyFilter::NCIGodfreyFilter(godfrey_coeff_set, amrex::Real, bool) +{ + WARPX_ABORT_WITH_MESSAGE( + "NCIGodfreyFilter not implemented in 1D!"); } + +void NCIGodfreyFilter::ComputeStencils() +{ + WARPX_ABORT_WITH_MESSAGE( + "NCIGodfreyFilter not implemented in 1D!"); +} + +#endif diff --git a/Source/Fluids/MultiFluidContainer.H b/Source/Fluids/MultiFluidContainer.H index ef6cc6115cb..0576a211aa9 100644 --- a/Source/Fluids/MultiFluidContainer.H +++ b/Source/Fluids/MultiFluidContainer.H @@ -38,6 +38,11 @@ public: ~MultiFluidContainer() {} + MultiFluidContainer (MultiFluidContainer const &) = delete; + MultiFluidContainer& operator= (MultiFluidContainer const & ) = delete; + MultiFluidContainer(MultiFluidContainer&& ) = default; + MultiFluidContainer& operator=(MultiFluidContainer&& ) = default; + WarpXFluidContainer& GetFluidContainer (int ispecies) const {return *allcontainers[ispecies];} diff --git a/Source/Fluids/WarpXFluidContainer.H b/Source/Fluids/WarpXFluidContainer.H index 28f37ae393b..a4880f3c57a 100644 --- a/Source/Fluids/WarpXFluidContainer.H +++ b/Source/Fluids/WarpXFluidContainer.H @@ -33,6 +33,11 @@ public: WarpXFluidContainer (int nlevs_max, int ispecies, const std::string& name); ~WarpXFluidContainer() {} + WarpXFluidContainer (WarpXFluidContainer const &) = delete; + WarpXFluidContainer& operator= (WarpXFluidContainer const & ) = delete; + WarpXFluidContainer(WarpXFluidContainer&& ) = default; + WarpXFluidContainer& operator=(WarpXFluidContainer&& ) = default; + void AllocateLevelMFs (int lev, const amrex::BoxArray& ba, const amrex::DistributionMapping& dm); void InitData (int lev, amrex::Box init_box, amrex::Real cur_time); diff --git a/Source/Fluids/WarpXFluidContainer.cpp b/Source/Fluids/WarpXFluidContainer.cpp index 48631035397..13063c2cfc0 100644 --- a/Source/Fluids/WarpXFluidContainer.cpp +++ b/Source/Fluids/WarpXFluidContainer.cpp @@ -19,11 +19,10 @@ using namespace ablastr::utils::communication; using namespace amrex; -WarpXFluidContainer::WarpXFluidContainer(int nlevs_max, int ispecies, const std::string &name) +WarpXFluidContainer::WarpXFluidContainer(int nlevs_max, int ispecies, const std::string &name): + species_id{ispecies}, + species_name{name} { - species_id = ispecies; - species_name = name; - ReadParameters(); // Initialize injection objects diff --git a/Source/Initialization/GetTemperature.cpp b/Source/Initialization/GetTemperature.cpp index 4aa1f7fbd74..2e8670bbe6c 100644 --- a/Source/Initialization/GetTemperature.cpp +++ b/Source/Initialization/GetTemperature.cpp @@ -8,8 +8,9 @@ #include "GetTemperature.H" -GetTemperature::GetTemperature (TemperatureProperties const& temp) noexcept { - m_type = temp.m_type; +GetTemperature::GetTemperature (TemperatureProperties const& temp) noexcept : + m_type{temp.m_type} +{ if (m_type == TempConstantValue) { m_temperature = temp.m_temperature; } diff --git a/Source/Initialization/GetVelocity.cpp b/Source/Initialization/GetVelocity.cpp index 2d2a342a7ed..4dd77a74383 100644 --- a/Source/Initialization/GetVelocity.cpp +++ b/Source/Initialization/GetVelocity.cpp @@ -7,10 +7,9 @@ #include "GetVelocity.H" -GetVelocity::GetVelocity (VelocityProperties const& vel) noexcept { - m_type = vel.m_type; - m_dir = vel.m_dir; - m_sign_dir = vel.m_sign_dir; +GetVelocity::GetVelocity (VelocityProperties const& vel) noexcept: + m_type{vel.m_type}, m_dir{vel.m_dir}, m_sign_dir{vel.m_sign_dir} +{ if (m_type == VelConstantValue) { m_velocity = vel.m_velocity; } diff --git a/Source/Initialization/InjectorDensity.H b/Source/Initialization/InjectorDensity.H index df85e0625f7..681bb334015 100644 --- a/Source/Initialization/InjectorDensity.H +++ b/Source/Initialization/InjectorDensity.H @@ -150,6 +150,9 @@ struct InjectorDensity void operator= (InjectorDensity const&) = delete; void operator= (InjectorDensity &&) = delete; + // Default destructor + ~InjectorDensity () = default; + void clear (); // call getDensity from the object stored in the union diff --git a/Source/Initialization/InjectorFlux.H b/Source/Initialization/InjectorFlux.H index adfe75b3ed2..74ae840a502 100644 --- a/Source/Initialization/InjectorFlux.H +++ b/Source/Initialization/InjectorFlux.H @@ -79,6 +79,9 @@ struct InjectorFlux void operator= (InjectorFlux const&) = delete; void operator= (InjectorFlux &&) = delete; + // Default destructor + ~InjectorFlux () = default; + void clear () { switch (type) diff --git a/Source/Initialization/InjectorMomentum.H b/Source/Initialization/InjectorMomentum.H index b597e361dfa..d8409258fa0 100644 --- a/Source/Initialization/InjectorMomentum.H +++ b/Source/Initialization/InjectorMomentum.H @@ -104,37 +104,40 @@ namespace { // Momentum to be returned at the end of this function amrex::Real u = 0._rt; + const amrex::Real abs_u_m = std::abs(u_m); + if (u_th == 0._rt) { u = u_m; // Trivial case ; avoids division by 0 in the rest of the code below - } else if (u_m < 0.6*u_th) { - // Mean velocity is lower than thermal velocity - // Use the distribution u*exp(-u**2*(1-u_m/u_th)/(2*u_th**2)) as an approximation + } else if (abs_u_m < 0.6*u_th) { + // Mean velocity magnitude is less than thermal velocity + // Use the distribution u*exp(-u**2*(1-abs(u_m)/u_th)/(2*u_th**2)) as an approximation // and then use the rejection method to correct it - // ( stop rejecting with probability exp(-u_m/(2*u_th**3)*(u-u_th)**2) ) + // ( stop rejecting with probability exp(-abs(u_m)/(2*u_th**3)*(u-sign(u_m)*u_th)**2) ) // Note that this is the method that is used in the common case u_m=0 - const amrex::Real approx_u_th = u_th/std::sqrt( 1._rt - u_m/u_th ); - const amrex::Real reject_prefactor = (u_m/u_th)/(2._rt*u_th*u_th); // To save computation + const amrex::Real umsign = std::copysign(1._rt, u_m); + const amrex::Real approx_u_th = u_th/std::sqrt( 1._rt - abs_u_m/u_th ); + const amrex::Real reject_prefactor = (abs_u_m/u_th)/(2._rt*u_th*u_th); // To save computation bool reject = true; while (reject) { - // Generates u according to u*exp(-u**2/(2*approx_u_th**2), + // Generates u according to u*exp(-u**2/(2*approx_u_th**2)), // using the method of the inverse cumulative function amrex::Real xrand = 1._rt - amrex::Random(engine); // ensures urand > 0 u = approx_u_th * std::sqrt(2._rt*std::log(1._rt/xrand)); // Rejection method xrand = amrex::Random(engine); - if (xrand < std::exp(-reject_prefactor*(u-u_th)*(u-u_th))) reject = false; + if (xrand < std::exp(-reject_prefactor*(u - umsign*u_th)*(u - umsign*u_th))) reject = false; } } else { - // Mean velocity is greater than thermal velocity - // Use the distribution exp(-(u-u_m-u_th**2/u_m)**2/(2*u_th**2)) as an approximation + // Mean velocity magnitude is greater than thermal velocity + // Use the distribution exp(-(u-u_m-u_th**2/abs(u_m))**2/(2*u_th**2)) as an approximation // and then use the rejection method to correct it - // ( stop rejecting with probability (u/u_m)*exp(1-(u/u_m)) ; note + // ( stop rejecting with probability (u/abs(u_m))*exp(1-(u/abs(u_m))) ; note // that this number is always between 0 and 1 ) // Note that in the common case `u_m = 0`, this rejection method // is not used, and the above rejection method is used instead. bool reject = true; - const amrex::Real approx_u_m = u_m + u_th*u_th/u_m; - const amrex::Real inv_um = 1._rt/u_m; // To save computation + const amrex::Real approx_u_m = u_m + u_th*u_th/abs_u_m; + const amrex::Real inv_um = 1._rt/abs_u_m; // To save computation while (reject) { // Approximate distribution: normal distribution, where we only retain positive u u = -1._rt; @@ -166,13 +169,6 @@ struct InjectorMomentumGaussianFlux m_flux_normal_axis(a_flux_normal_axis), m_flux_direction(a_flux_direction) { - // For now, do not allow negative `u_m` along the flux axis - bool raise_error = false; - if ((m_flux_normal_axis == 0) && (m_ux_m < 0)) raise_error = true; - if ((m_flux_normal_axis == 1) && (m_uy_m < 0)) raise_error = true; - if ((m_flux_normal_axis == 2) && (m_uz_m < 0)) raise_error = true; - WARPX_ALWAYS_ASSERT_WITH_MESSAGE( raise_error==false, - "When using the `gaussianflux` distribution, the central momentum along the flux axis must be positive or zero." ); } AMREX_GPU_HOST_DEVICE @@ -229,17 +225,14 @@ struct InjectorMomentumUniform amrex::Real a_uz_min, amrex::Real a_ux_max, amrex::Real a_uy_max, amrex::Real a_uz_max) noexcept : m_ux_min(a_ux_min), m_uy_min(a_uy_min), m_uz_min(a_uz_min), - m_ux_max(a_ux_max), m_uy_max(a_uy_max), m_uz_max(a_uz_max) - { - using namespace amrex; - - m_Dux = m_ux_max - m_ux_min; - m_Duy = m_uy_max - m_uy_min; - m_Duz = m_uz_max - m_uz_min; - m_ux_h = 0.5_rt * (m_ux_max + m_ux_min); - m_uy_h = 0.5_rt * (m_uy_max + m_uy_min); - m_uz_h = 0.5_rt * (m_uz_max + m_uz_min); - } + m_ux_max(a_ux_max), m_uy_max(a_uy_max), m_uz_max(a_uz_max), + m_Dux(m_ux_max - m_ux_min), + m_Duy(m_uy_max - m_uy_min), + m_Duz(m_uz_max - m_uz_min), + m_ux_h(amrex::Real(0.5) * (m_ux_max + m_ux_min)), + m_uy_h(amrex::Real(0.5) * (m_uy_max + m_uy_min)), + m_uz_h(amrex::Real(0.5) * (m_uz_max + m_uz_min)) + {} AMREX_GPU_HOST_DEVICE amrex::XDim3 @@ -261,8 +254,8 @@ struct InjectorMomentumUniform private: amrex::Real m_ux_min, m_uy_min, m_uz_min; amrex::Real m_ux_max, m_uy_max, m_uz_max; - amrex::Real m_ux_h, m_uy_h, m_uz_h; amrex::Real m_Dux, m_Duy, m_Duz; + amrex::Real m_ux_h, m_uy_h, m_uz_h; }; // struct whose getMomentum returns momentum for 1 particle with relativistic @@ -587,6 +580,9 @@ struct InjectorMomentum void operator= (InjectorMomentum const&) = delete; void operator= (InjectorMomentum &&) = delete; + // Default destructor + ~InjectorMomentum() = default; + void clear (); // call getMomentum from the object stored in the union diff --git a/Source/Initialization/InjectorPosition.H b/Source/Initialization/InjectorPosition.H index 17ce8325543..2d099c56319 100644 --- a/Source/Initialization/InjectorPosition.H +++ b/Source/Initialization/InjectorPosition.H @@ -154,12 +154,14 @@ struct InjectorPosition zmin(a_zmin), zmax(a_zmax) { } + ~InjectorPosition () = default; + // Explicitly prevent the compiler from generating copy constructors // and copy assignment operators. InjectorPosition (InjectorPosition const&) = delete; - InjectorPosition (InjectorPosition&&) = delete; - void operator= (InjectorPosition const&) = delete; - void operator= (InjectorPosition &&) = delete; + InjectorPosition (InjectorPosition&&) = delete; + void operator= (InjectorPosition const&) = delete; + void operator= (InjectorPosition &&) = delete; // call getPositionUnitBox from the object stored in the union // (the union is called Object, and the instance is called object). diff --git a/Source/Initialization/PlasmaInjector.H b/Source/Initialization/PlasmaInjector.H index ac64980b952..0b2fac02f51 100644 --- a/Source/Initialization/PlasmaInjector.H +++ b/Source/Initialization/PlasmaInjector.H @@ -42,10 +42,17 @@ class PlasmaInjector public: + /** Default constructor*/ PlasmaInjector () = default; PlasmaInjector (int ispecies, const std::string& name, const amrex::Geometry& geom); + // Default move and copy operations + PlasmaInjector(const PlasmaInjector&) = delete; + PlasmaInjector& operator=(const PlasmaInjector&) = delete; + PlasmaInjector(PlasmaInjector&&) = default; + PlasmaInjector& operator=(PlasmaInjector&&) = default; + ~PlasmaInjector (); // bool: whether the point (x, y, z) is inside the plasma region diff --git a/Source/Initialization/VelocityProperties.cpp b/Source/Initialization/VelocityProperties.cpp index 802eabc40c9..30cb64cb70a 100644 --- a/Source/Initialization/VelocityProperties.cpp +++ b/Source/Initialization/VelocityProperties.cpp @@ -11,11 +11,12 @@ #include "Utils/Parser/ParserUtils.H" #include "Utils/TextMsg.H" -VelocityProperties::VelocityProperties (const amrex::ParmParse& pp) { +VelocityProperties::VelocityProperties (const amrex::ParmParse& pp): + m_velocity{0} +{ // Set defaults std::string vel_dist_s = "constant"; std::string vel_dir_s = "x"; - m_velocity = 0; pp.query("bulk_vel_dir", vel_dir_s); if(vel_dir_s[0] == '-'){ diff --git a/Source/Laser/LaserProfiles.H b/Source/Laser/LaserProfiles.H index 487e2d9e527..73776fa3525 100644 --- a/Source/Laser/LaserProfiles.H +++ b/Source/Laser/LaserProfiles.H @@ -97,7 +97,13 @@ public: amrex::Real t, amrex::Real* AMREX_RESTRICT amplitude) const = 0; + ILaserProfile () = default; virtual ~ILaserProfile(){} + + ILaserProfile ( ILaserProfile const &) = default; + ILaserProfile& operator= ( ILaserProfile const & ) = default; + ILaserProfile ( ILaserProfile&& ) = default; + ILaserProfile& operator= ( ILaserProfile&& ) = default; }; /** @@ -110,11 +116,11 @@ public: void init ( const amrex::ParmParse& ppl, - CommonLaserParameters params) override final; + CommonLaserParameters params) final; //No update needed void - update (amrex::Real /*t */) override final {} + update (amrex::Real /*t */) final {} void fill_amplitude ( @@ -122,7 +128,7 @@ public: amrex::Real const * AMREX_RESTRICT Xp, amrex::Real const * AMREX_RESTRICT Yp, amrex::Real t, - amrex::Real * AMREX_RESTRICT amplitude) const override final; + amrex::Real * AMREX_RESTRICT amplitude) const final; private: struct { @@ -152,11 +158,11 @@ public: void init ( const amrex::ParmParse& ppl, - CommonLaserParameters params) override final; + CommonLaserParameters params) final; //No update needed void - update (amrex::Real /*t */) override final {} + update (amrex::Real /*t */) final {} void fill_amplitude ( @@ -164,7 +170,7 @@ public: amrex::Real const * AMREX_RESTRICT Xp, amrex::Real const * AMREX_RESTRICT Yp, amrex::Real t, - amrex::Real * AMREX_RESTRICT amplitude) const override final; + amrex::Real * AMREX_RESTRICT amplitude) const final; private: struct{ @@ -187,14 +193,14 @@ public: void init ( const amrex::ParmParse& ppl, - CommonLaserParameters params) override final; + CommonLaserParameters params) final; /** \brief Reads new field data chunk from file if needed * * @param[in] t simulation time (seconds) */ void - update (amrex::Real t) override final; + update (amrex::Real t) final; /** \brief compute field amplitude at particles' position for a laser beam * loaded from an E(x,y,t) file. @@ -215,7 +221,7 @@ public: amrex::Real const * AMREX_RESTRICT Xp, amrex::Real const * AMREX_RESTRICT Yp, amrex::Real t, - amrex::Real * AMREX_RESTRICT amplitude) const override final; + amrex::Real * AMREX_RESTRICT amplitude) const final; /** \brief Function to fill the amplitude in case of a uniform grid and for the lasy format in 3D Cartesian. * This function cannot be private due to restrictions related to diff --git a/Source/Particles/Collision/BackgroundMCC/BackgroundMCCCollision.H b/Source/Particles/Collision/BackgroundMCC/BackgroundMCCCollision.H index d47234d4571..be92e42d5fc 100644 --- a/Source/Particles/Collision/BackgroundMCC/BackgroundMCCCollision.H +++ b/Source/Particles/Collision/BackgroundMCC/BackgroundMCCCollision.H @@ -25,7 +25,12 @@ class BackgroundMCCCollision final public: BackgroundMCCCollision (std::string collision_name); - virtual ~BackgroundMCCCollision () = default; + ~BackgroundMCCCollision () override = default; + + BackgroundMCCCollision ( BackgroundMCCCollision const &) = delete; + BackgroundMCCCollision& operator= ( BackgroundMCCCollision const & ) = delete; + BackgroundMCCCollision ( BackgroundMCCCollision&& ) = delete; + BackgroundMCCCollision& operator= ( BackgroundMCCCollision&& ) = delete; amrex::ParticleReal get_nu_max (amrex::Vector const& mcc_processes); diff --git a/Source/Particles/Collision/BackgroundMCC/MCCProcess.H b/Source/Particles/Collision/BackgroundMCC/MCCProcess.H index 31f790153bd..58fc86b2c29 100644 --- a/Source/Particles/Collision/BackgroundMCC/MCCProcess.H +++ b/Source/Particles/Collision/BackgroundMCC/MCCProcess.H @@ -38,11 +38,12 @@ public: amrex::ParticleReal energy ); - MCCProcess (MCCProcess const&) = delete; - MCCProcess& operator= (MCCProcess const&) = delete; + ~MCCProcess() = default; - MCCProcess (MCCProcess &&) = default; - MCCProcess& operator= (MCCProcess &&) = default; + MCCProcess (MCCProcess const&) = delete; + MCCProcess& operator= (MCCProcess const&) = delete; + MCCProcess (MCCProcess &&) = default; + MCCProcess& operator= (MCCProcess &&) = default; /** Read the given cross-section data file to memory. * diff --git a/Source/Particles/Collision/BackgroundStopping/BackgroundStopping.H b/Source/Particles/Collision/BackgroundStopping/BackgroundStopping.H index ee4b3b01653..55fa4b9e1e3 100644 --- a/Source/Particles/Collision/BackgroundStopping/BackgroundStopping.H +++ b/Source/Particles/Collision/BackgroundStopping/BackgroundStopping.H @@ -26,7 +26,12 @@ class BackgroundStopping final public: BackgroundStopping (std::string collision_name); - virtual ~BackgroundStopping () = default; + ~BackgroundStopping () override = default; + + BackgroundStopping ( BackgroundStopping const &) = delete; + BackgroundStopping& operator= ( BackgroundStopping const & ) = delete; + BackgroundStopping ( BackgroundStopping&& ) = delete; + BackgroundStopping& operator= ( BackgroundStopping&& ) = delete; /** Perform the stopping calculation * diff --git a/Source/Particles/Collision/BinaryCollision/BinaryCollision.H b/Source/Particles/Collision/BinaryCollision/BinaryCollision.H index 2f9ddbbcb3f..58fe2c9911a 100644 --- a/Source/Particles/Collision/BinaryCollision/BinaryCollision.H +++ b/Source/Particles/Collision/BinaryCollision/BinaryCollision.H @@ -104,7 +104,12 @@ public: m_copy_transform_functor = CopyTransformFunctorType(collision_name, mypc); } - virtual ~BinaryCollision () = default; + ~BinaryCollision () override = default; + + BinaryCollision ( BinaryCollision const &) = default; + BinaryCollision& operator= ( BinaryCollision const & ) = default; + BinaryCollision ( BinaryCollision&& ) = default; + BinaryCollision& operator= ( BinaryCollision&& ) = default; /** Perform the collisions * diff --git a/Source/Particles/Collision/BinaryCollision/Coulomb/PairWiseCoulombCollisionFunc.H b/Source/Particles/Collision/BinaryCollision/Coulomb/PairWiseCoulombCollisionFunc.H index d8fdaee8bd0..feb7acf81d3 100644 --- a/Source/Particles/Collision/BinaryCollision/Coulomb/PairWiseCoulombCollisionFunc.H +++ b/Source/Particles/Collision/BinaryCollision/Coulomb/PairWiseCoulombCollisionFunc.H @@ -45,15 +45,16 @@ public: */ PairWiseCoulombCollisionFunc (const std::string collision_name, [[maybe_unused]] MultiParticleContainer const * const mypc, - const bool isSameSpecies) + const bool isSameSpecies): + m_isSameSpecies{isSameSpecies} { using namespace amrex::literals; const amrex::ParmParse pp_collision_name(collision_name); // default Coulomb log, if < 0, will be computed automatically - m_CoulombLog = -1.0_prt; + amrex::ParticleReal CoulombLog = -1.0_prt; utils::parser::queryWithParser( - pp_collision_name, "CoulombLog", m_CoulombLog); - m_isSameSpecies = isSameSpecies; + pp_collision_name, "CoulombLog", CoulombLog); + m_CoulombLog = CoulombLog; } /** diff --git a/Source/Particles/Collision/BinaryCollision/NuclearFusion/NuclearFusionFunc.H b/Source/Particles/Collision/BinaryCollision/NuclearFusion/NuclearFusionFunc.H index 83952357ec5..397536b67bf 100644 --- a/Source/Particles/Collision/BinaryCollision/NuclearFusion/NuclearFusionFunc.H +++ b/Source/Particles/Collision/BinaryCollision/NuclearFusion/NuclearFusionFunc.H @@ -54,9 +54,12 @@ public: * @param[in] isSameSpecies whether the two colliding species are the same */ NuclearFusionFunc (const std::string collision_name, MultiParticleContainer const * const mypc, - const bool isSameSpecies) : m_isSameSpecies(isSameSpecies) + const bool isSameSpecies): + m_fusion_multiplier{amrex::ParticleReal{1.0}}, // default fusion multiplier + m_probability_threshold{amrex::ParticleReal{0.02}}, // default fusion probability threshold + m_probability_target_value{amrex::ParticleReal{0.002}}, // default fusion probability target_value + m_isSameSpecies{isSameSpecies} { - using namespace amrex::literals; #ifdef AMREX_SINGLE_PRECISION_PARTICLES WARPX_ABORT_WITH_MESSAGE("Nuclear fusion module does not currently work with single precision"); @@ -65,16 +68,10 @@ public: m_fusion_type = BinaryCollisionUtils::get_nuclear_fusion_type(collision_name, mypc); const amrex::ParmParse pp_collision_name(collision_name); - // default fusion multiplier - m_fusion_multiplier = 1.0_prt; utils::parser::queryWithParser( pp_collision_name, "fusion_multiplier", m_fusion_multiplier); - // default fusion probability threshold - m_probability_threshold = 0.02_prt; utils::parser::queryWithParser( pp_collision_name, "fusion_probability_threshold", m_probability_threshold); - // default fusion probability target_value - m_probability_target_value = 0.002_prt; utils::parser::queryWithParser( pp_collision_name, "fusion_probability_target_value", m_probability_target_value); diff --git a/Source/Particles/Collision/CollisionBase.H b/Source/Particles/Collision/CollisionBase.H index 517f5e414c0..272cc056b1a 100644 --- a/Source/Particles/Collision/CollisionBase.H +++ b/Source/Particles/Collision/CollisionBase.H @@ -25,6 +25,7 @@ public: CollisionBase(CollisionBase const &) = delete; CollisionBase(CollisionBase &&) = delete; CollisionBase & operator=(CollisionBase const &) = delete; + CollisionBase & operator=(CollisionBase const &&) = delete; virtual ~CollisionBase() = default; diff --git a/Source/Particles/Collision/CollisionBase.cpp b/Source/Particles/Collision/CollisionBase.cpp index 701d5ff6bc6..8f799c83013 100644 --- a/Source/Particles/Collision/CollisionBase.cpp +++ b/Source/Particles/Collision/CollisionBase.cpp @@ -18,8 +18,8 @@ CollisionBase::CollisionBase (std::string collision_name) pp_collision_name.getarr("species", m_species_names); // number of time steps between collisions - m_ndt = 1; + int ndt = 1; utils::parser::queryWithParser( - pp_collision_name, "ndt", m_ndt); - + pp_collision_name, "ndt", ndt); + m_ndt = ndt; } diff --git a/Source/Particles/ElementaryProcess/Ionization.H b/Source/Particles/ElementaryProcess/Ionization.H index 6cab9802ee8..2c96c1a15a2 100644 --- a/Source/Particles/ElementaryProcess/Ionization.H +++ b/Source/Particles/ElementaryProcess/Ionization.H @@ -115,6 +115,7 @@ struct IonizationFilterFunc m_ex_type, m_ey_type, m_ez_type, m_bx_type, m_by_type, m_bz_type, m_dx_arr, m_xyzmin_arr, m_lo, m_n_rz_azimuthal_modes, m_nox, m_galerkin_interpolation); + m_get_externalEB(i, ex, ey, ez, bx, by, bz); // Compute electric field amplitude in the particle's frame of // reference (particularly important when in boosted frame). diff --git a/Source/Particles/ElementaryProcess/Ionization.cpp b/Source/Particles/ElementaryProcess/Ionization.cpp index 335962ce93f..fb0b4d27080 100644 --- a/Source/Particles/ElementaryProcess/Ionization.cpp +++ b/Source/Particles/ElementaryProcess/Ionization.cpp @@ -32,18 +32,19 @@ IonizationFilterFunc::IonizationFilterFunc (const WarpXParIter& a_pti, int lev, const amrex::Real* const AMREX_RESTRICT a_adk_power, int a_comp, int a_atomic_number, - int a_offset) noexcept + int a_offset) noexcept: + m_ionization_energies{a_ionization_energies}, + m_adk_prefactor{a_adk_prefactor}, + m_adk_exp_prefactor{a_adk_exp_prefactor}, + m_adk_power{a_adk_power}, + comp{a_comp}, + m_atomic_number{a_atomic_number}, + m_galerkin_interpolation{WarpX::galerkin_interpolation}, + m_nox{WarpX::nox}, + m_n_rz_azimuthal_modes{WarpX::n_rz_azimuthal_modes} { - using namespace amrex::literals; - m_ionization_energies = a_ionization_energies; - m_adk_prefactor = a_adk_prefactor; - m_adk_exp_prefactor = a_adk_exp_prefactor; - m_adk_power = a_adk_power; - comp = a_comp; - m_atomic_number = a_atomic_number; - m_get_position = GetParticlePosition(a_pti, a_offset); m_get_externalEB = GetExternalEBField(a_pti, a_offset); m_Ex_external_particle = E_external_particle[0]; @@ -77,9 +78,5 @@ IonizationFilterFunc::IonizationFilterFunc (const WarpXParIter& a_pti, int lev, const std::array& xyzmin = WarpX::LowerCorner(box, lev, 0._rt); m_xyzmin_arr = {xyzmin[0], xyzmin[1], xyzmin[2]}; - m_galerkin_interpolation = WarpX::galerkin_interpolation; - m_nox = WarpX::nox; - m_n_rz_azimuthal_modes = WarpX::n_rz_azimuthal_modes; - m_lo = amrex::lbound(box); } diff --git a/Source/Particles/ElementaryProcess/QEDPairGeneration.cpp b/Source/Particles/ElementaryProcess/QEDPairGeneration.cpp index ab0e037852a..8f8c5e68796 100644 --- a/Source/Particles/ElementaryProcess/QEDPairGeneration.cpp +++ b/Source/Particles/ElementaryProcess/QEDPairGeneration.cpp @@ -28,8 +28,11 @@ PairGenerationTransformFunc (BreitWheelerGeneratePairs const generate_functor, amrex::FArrayBox const& bzfab, amrex::Vector& E_external_particle, amrex::Vector& B_external_particle, - int a_offset) -: m_generate_functor(generate_functor) + int a_offset): + m_generate_functor{generate_functor}, + m_galerkin_interpolation{WarpX::galerkin_interpolation}, + m_nox{WarpX::nox}, + m_n_rz_azimuthal_modes{WarpX::n_rz_azimuthal_modes} { using namespace amrex::literals; @@ -67,9 +70,5 @@ PairGenerationTransformFunc (BreitWheelerGeneratePairs const generate_functor, const std::array& xyzmin = WarpX::LowerCorner(box, lev, 0._rt); m_xyzmin_arr = {xyzmin[0], xyzmin[1], xyzmin[2]}; - m_galerkin_interpolation = WarpX::galerkin_interpolation; - m_nox = WarpX::nox; - m_n_rz_azimuthal_modes = WarpX::n_rz_azimuthal_modes; - m_lo = amrex::lbound(box); } diff --git a/Source/Particles/ElementaryProcess/QEDPhotonEmission.cpp b/Source/Particles/ElementaryProcess/QEDPhotonEmission.cpp index ba4abe66e85..a8bdd41b96c 100644 --- a/Source/Particles/ElementaryProcess/QEDPhotonEmission.cpp +++ b/Source/Particles/ElementaryProcess/QEDPhotonEmission.cpp @@ -29,10 +29,13 @@ PhotonEmissionTransformFunc (QuantumSynchrotronGetOpticalDepth opt_depth_functor amrex::FArrayBox const& bzfab, amrex::Vector& E_external_particle, amrex::Vector& B_external_particle, - int a_offset) -:m_opt_depth_functor{opt_depth_functor}, - m_opt_depth_runtime_comp{opt_depth_runtime_comp}, - m_emission_functor{emission_functor} + int a_offset): + m_opt_depth_functor{opt_depth_functor}, + m_opt_depth_runtime_comp{opt_depth_runtime_comp}, + m_emission_functor{emission_functor}, + m_galerkin_interpolation{WarpX::galerkin_interpolation}, + m_nox{WarpX::nox}, + m_n_rz_azimuthal_modes{WarpX::n_rz_azimuthal_modes} { using namespace amrex::literals; @@ -70,9 +73,7 @@ PhotonEmissionTransformFunc (QuantumSynchrotronGetOpticalDepth opt_depth_functor const std::array& xyzmin = WarpX::LowerCorner(box, lev, 0._rt); m_xyzmin_arr = {xyzmin[0], xyzmin[1], xyzmin[2]}; - m_galerkin_interpolation = WarpX::galerkin_interpolation; - m_nox = WarpX::nox; - m_n_rz_azimuthal_modes = WarpX::n_rz_azimuthal_modes; + m_lo = amrex::lbound(box); } diff --git a/Source/Particles/Gather/FieldGather.H b/Source/Particles/Gather/FieldGather.H index 0b2aae52ecc..1b5cede3c6f 100644 --- a/Source/Particles/Gather/FieldGather.H +++ b/Source/Particles/Gather/FieldGather.H @@ -252,7 +252,7 @@ void doGatherShapeN (const amrex::ParticleReal xp, by_arr(lo.x+l_by+iz, 0, 0, 0); } -#elif defined(WARPX_DIM_XZ) || defined(WARPX_DIM_RZ) +#elif defined(WARPX_DIM_XZ) // Gather field on particle Eyp from field on grid ey_arr for (int iz=0; iz<=depos_order; iz++){ for (int ix=0; ix<=depos_order; ix++){ @@ -288,7 +288,47 @@ void doGatherShapeN (const amrex::ParticleReal xp, } } -#ifdef WARPX_DIM_RZ +#elif defined(WARPX_DIM_RZ) + + amrex::ParticleReal Erp = 0.; + amrex::ParticleReal Ethetap = 0.; + amrex::ParticleReal Brp = 0.; + amrex::ParticleReal Bthetap = 0.; + + // Gather field on particle Ethetap from field on grid ey_arr + for (int iz=0; iz<=depos_order; iz++){ + for (int ix=0; ix<=depos_order; ix++){ + Ethetap += sx_ey[ix]*sz_ey[iz]* + ey_arr(lo.x+j_ey+ix, lo.y+l_ey+iz, 0, 0); + } + } + // Gather field on particle Erp from field on grid ex_arr + // Gather field on particle Bzp from field on grid bz_arr + for (int iz=0; iz<=depos_order; iz++){ + for (int ix=0; ix<=depos_order-galerkin_interpolation; ix++){ + Erp += sx_ex[ix]*sz_ex[iz]* + ex_arr(lo.x+j_ex+ix, lo.y+l_ex+iz, 0, 0); + Bzp += sx_bz[ix]*sz_bz[iz]* + bz_arr(lo.x+j_bz+ix, lo.y+l_bz+iz, 0, 0); + } + } + // Gather field on particle Ezp from field on grid ez_arr + // Gather field on particle Brp from field on grid bx_arr + for (int iz=0; iz<=depos_order-galerkin_interpolation; iz++){ + for (int ix=0; ix<=depos_order; ix++){ + Ezp += sx_ez[ix]*sz_ez[iz]* + ez_arr(lo.x+j_ez+ix, lo.y+l_ez+iz, 0, 0); + Brp += sx_bx[ix]*sz_bx[iz]* + bx_arr(lo.x+j_bx+ix, lo.y+l_bx+iz, 0, 0); + } + } + // Gather field on particle Bthetap from field on grid by_arr + for (int iz=0; iz<=depos_order-galerkin_interpolation; iz++){ + for (int ix=0; ix<=depos_order-galerkin_interpolation; ix++){ + Bthetap += sx_by[ix]*sz_by[iz]* + by_arr(lo.x+j_by+ix, lo.y+l_by+iz, 0, 0); + } + } amrex::Real costheta; amrex::Real sintheta; @@ -304,28 +344,28 @@ void doGatherShapeN (const amrex::ParticleReal xp, for (int imode=1 ; imode < n_rz_azimuthal_modes ; imode++) { - // Gather field on particle Eyp from field on grid ey_arr + // Gather field on particle Ethetap from field on grid ey_arr for (int iz=0; iz<=depos_order; iz++){ for (int ix=0; ix<=depos_order; ix++){ const amrex::Real dEy = (+ ey_arr(lo.x+j_ey+ix, lo.y+l_ey+iz, 0, 2*imode-1)*xy.real() - ey_arr(lo.x+j_ey+ix, lo.y+l_ey+iz, 0, 2*imode)*xy.imag()); - Eyp += sx_ey[ix]*sz_ey[iz]*dEy; + Ethetap += sx_ey[ix]*sz_ey[iz]*dEy; } } - // Gather field on particle Exp from field on grid ex_arr + // Gather field on particle Erp from field on grid ex_arr // Gather field on particle Bzp from field on grid bz_arr for (int iz=0; iz<=depos_order; iz++){ for (int ix=0; ix<=depos_order-galerkin_interpolation; ix++){ const amrex::Real dEx = (+ ex_arr(lo.x+j_ex+ix, lo.y+l_ex+iz, 0, 2*imode-1)*xy.real() - ex_arr(lo.x+j_ex+ix, lo.y+l_ex+iz, 0, 2*imode)*xy.imag()); - Exp += sx_ex[ix]*sz_ex[iz]*dEx; + Erp += sx_ex[ix]*sz_ex[iz]*dEx; const amrex::Real dBz = (+ bz_arr(lo.x+j_bz+ix, lo.y+l_bz+iz, 0, 2*imode-1)*xy.real() - bz_arr(lo.x+j_bz+ix, lo.y+l_bz+iz, 0, 2*imode)*xy.imag()); Bzp += sx_bz[ix]*sz_bz[iz]*dBz; } } // Gather field on particle Ezp from field on grid ez_arr - // Gather field on particle Bxp from field on grid bx_arr + // Gather field on particle Brp from field on grid bx_arr for (int iz=0; iz<=depos_order-galerkin_interpolation; iz++){ for (int ix=0; ix<=depos_order; ix++){ const amrex::Real dEz = (+ ez_arr(lo.x+j_ez+ix, lo.y+l_ez+iz, 0, 2*imode-1)*xy.real() @@ -333,28 +373,25 @@ void doGatherShapeN (const amrex::ParticleReal xp, Ezp += sx_ez[ix]*sz_ez[iz]*dEz; const amrex::Real dBx = (+ bx_arr(lo.x+j_bx+ix, lo.y+l_bx+iz, 0, 2*imode-1)*xy.real() - bx_arr(lo.x+j_bx+ix, lo.y+l_bx+iz, 0, 2*imode)*xy.imag()); - Bxp += sx_bx[ix]*sz_bx[iz]*dBx; + Brp += sx_bx[ix]*sz_bx[iz]*dBx; } } - // Gather field on particle Byp from field on grid by_arr + // Gather field on particle Bthetap from field on grid by_arr for (int iz=0; iz<=depos_order-galerkin_interpolation; iz++){ for (int ix=0; ix<=depos_order-galerkin_interpolation; ix++){ const amrex::Real dBy = (+ by_arr(lo.x+j_by+ix, lo.y+l_by+iz, 0, 2*imode-1)*xy.real() - by_arr(lo.x+j_by+ix, lo.y+l_by+iz, 0, 2*imode)*xy.imag()); - Byp += sx_by[ix]*sz_by[iz]*dBy; + Bthetap += sx_by[ix]*sz_by[iz]*dBy; } } xy = xy*xy0; } - // Convert Exp and Eyp (which are actually Er and Etheta) to Ex and Ey - const amrex::Real Exp_save = Exp; - Exp = costheta*Exp - sintheta*Eyp; - Eyp = costheta*Eyp + sintheta*Exp_save; - const amrex::Real Bxp_save = Bxp; - Bxp = costheta*Bxp - sintheta*Byp; - Byp = costheta*Byp + sintheta*Bxp_save; -#endif + // Convert Erp and Ethetap to Ex and Ey + Exp += costheta*Erp - sintheta*Ethetap; + Eyp += costheta*Ethetap + sintheta*Erp; + Bxp += costheta*Brp - sintheta*Bthetap; + Byp += costheta*Bthetap + sintheta*Brp; #else // defined(WARPX_DIM_3D) // Gather field on particle Exp from field on grid ex_arr diff --git a/Source/Particles/LaserParticleContainer.H b/Source/Particles/LaserParticleContainer.H index e125bab2ec5..464b411ac66 100644 --- a/Source/Particles/LaserParticleContainer.H +++ b/Source/Particles/LaserParticleContainer.H @@ -42,25 +42,31 @@ class LaserParticleContainer { public: LaserParticleContainer (amrex::AmrCore* amr_core, int ispecies, const std::string& name); - virtual ~LaserParticleContainer () {} + ~LaserParticleContainer () override = default; - virtual void InitData () final; + + LaserParticleContainer ( LaserParticleContainer const &) = delete; + LaserParticleContainer& operator= ( LaserParticleContainer const & ) = delete; + LaserParticleContainer ( LaserParticleContainer&& ) = default; + LaserParticleContainer& operator= ( LaserParticleContainer&& ) = default; + + void InitData () final; /** * \brief Method to initialize runtime attributes. Does nothing for LaserParticleContainer. */ - virtual void DefaultInitializeRuntimeAttributes ( + void DefaultInitializeRuntimeAttributes ( amrex::ParticleTile, NArrayReal, NArrayInt, amrex::PinnedArenaAllocator>& /*pinned_tile*/, const int /*n_external_attr_real*/, const int /*n_external_attr_int*/, - const amrex::RandomEngine& /*engine*/) override final {} + const amrex::RandomEngine& /*engine*/) final {} - virtual void ReadHeader (std::istream& is) final; + void ReadHeader (std::istream& is) final; - virtual void WriteHeader (std::ostream& os) const final; + void WriteHeader (std::ostream& os) const final; - virtual void Evolve (int lev, + void Evolve (int lev, const amrex::MultiFab&, const amrex::MultiFab&, const amrex::MultiFab&, const amrex::MultiFab&, const amrex::MultiFab&, const amrex::MultiFab&, amrex::MultiFab& jx, amrex::MultiFab& jy, amrex::MultiFab& jz, @@ -71,7 +77,7 @@ public: amrex::Real t, amrex::Real dt, DtType a_dt_type=DtType::Full, bool skip_deposition=false) final; - virtual void PushP (int lev, amrex::Real dt, + void PushP (int lev, amrex::Real dt, const amrex::MultiFab& , const amrex::MultiFab& , const amrex::MultiFab& , @@ -79,7 +85,7 @@ public: const amrex::MultiFab& , const amrex::MultiFab& ) final; - virtual void PostRestart () final; + void PostRestart () final; void calculate_laser_plane_coordinates (const WarpXParIter& pti, int np, amrex::Real * AMREX_RESTRICT pplane_Xp, diff --git a/Source/Particles/LaserParticleContainer.cpp b/Source/Particles/LaserParticleContainer.cpp index 782e630e805..7d918d5dfb5 100644 --- a/Source/Particles/LaserParticleContainer.cpp +++ b/Source/Particles/LaserParticleContainer.cpp @@ -46,7 +46,6 @@ #include #include #include -#include #include #include diff --git a/Source/Particles/MultiParticleContainer.H b/Source/Particles/MultiParticleContainer.H index cbefbcf77c0..64c8dbb085a 100644 --- a/Source/Particles/MultiParticleContainer.H +++ b/Source/Particles/MultiParticleContainer.H @@ -70,6 +70,11 @@ public: ~MultiParticleContainer() {} + MultiParticleContainer (MultiParticleContainer const &) = delete; + MultiParticleContainer& operator= (MultiParticleContainer const & ) = delete; + MultiParticleContainer(MultiParticleContainer&& ) = default; + MultiParticleContainer& operator=(MultiParticleContainer&& ) = default; + WarpXParticleContainer& GetParticleContainer (int index) const {return *allcontainers[index];} diff --git a/Source/Particles/NamedComponentParticleContainer.H b/Source/Particles/NamedComponentParticleContainer.H index e74dd8a6c7e..6ff9d157790 100644 --- a/Source/Particles/NamedComponentParticleContainer.H +++ b/Source/Particles/NamedComponentParticleContainer.H @@ -73,7 +73,7 @@ public: } /** Destructor for NamedComponentParticleContainer */ - virtual ~NamedComponentParticleContainer() = default; + ~NamedComponentParticleContainer() override = default; /** Construct a NamedComponentParticleContainer from a regular * amrex::ParticleContainer, and additional name-to-index maps diff --git a/Source/Particles/ParticleCreation/SmartCopy.H b/Source/Particles/ParticleCreation/SmartCopy.H index 4b29d90e065..94d10dfce6b 100644 --- a/Source/Particles/ParticleCreation/SmartCopy.H +++ b/Source/Particles/ParticleCreation/SmartCopy.H @@ -134,21 +134,17 @@ class SmartCopyFactory SmartCopyTag m_tag_int; PolicyVec m_policy_real; PolicyVec m_policy_int; - bool m_defined; + bool m_defined = false; public: template - SmartCopyFactory (const SrcPC& src, const DstPC& dst) noexcept - : m_defined(false) - { - m_tag_real = getSmartCopyTag(src.getParticleComps(), dst.getParticleComps()); - m_tag_int = getSmartCopyTag(src.getParticleiComps(), dst.getParticleiComps()); - - m_policy_real = getPolicies(dst.getParticleComps()); - m_policy_int = getPolicies(dst.getParticleiComps()); - - m_defined = true; - } + SmartCopyFactory (const SrcPC& src, const DstPC& dst) noexcept : + m_tag_real{getSmartCopyTag(src.getParticleComps(), dst.getParticleComps())}, + m_tag_int{getSmartCopyTag(src.getParticleiComps(), dst.getParticleiComps())}, + m_policy_real{getPolicies(dst.getParticleComps())}, + m_policy_int{getPolicies(dst.getParticleiComps())}, + m_defined{true} + {} SmartCopy getSmartCopy () const noexcept { diff --git a/Source/Particles/ParticleCreation/SmartCreate.H b/Source/Particles/ParticleCreation/SmartCreate.H index 875e69cab04..e91d39060b0 100644 --- a/Source/Particles/ParticleCreation/SmartCreate.H +++ b/Source/Particles/ParticleCreation/SmartCreate.H @@ -91,13 +91,11 @@ class SmartCreateFactory public: template - SmartCreateFactory (const PartTileData& part) noexcept - : m_defined(false) - { - m_policy_real = getPolicies(part.getParticleComps()); - m_policy_int = getPolicies(part.getParticleiComps()); - m_defined = true; - } + SmartCreateFactory (const PartTileData& part) noexcept: + m_policy_real{getPolicies(part.getParticleComps())}, + m_policy_int{getPolicies(part.getParticleiComps())}, + m_defined{true} + {} SmartCreate getSmartCreate () const noexcept { diff --git a/Source/Particles/PhotonParticleContainer.H b/Source/Particles/PhotonParticleContainer.H index 0f7b6e0e185..ada11857b34 100644 --- a/Source/Particles/PhotonParticleContainer.H +++ b/Source/Particles/PhotonParticleContainer.H @@ -36,11 +36,16 @@ public: PhotonParticleContainer (amrex::AmrCore* amr_core, int ispecies, const std::string& name); - virtual ~PhotonParticleContainer () {} + ~PhotonParticleContainer () override {} - virtual void InitData() override; + PhotonParticleContainer ( PhotonParticleContainer const &) = delete; + PhotonParticleContainer& operator= ( PhotonParticleContainer const & ) = delete; + PhotonParticleContainer ( PhotonParticleContainer&& ) = default; + PhotonParticleContainer& operator= ( PhotonParticleContainer&& ) = default; - virtual void Evolve (int lev, + void InitData() override; + + void Evolve (int lev, const amrex::MultiFab& Ex, const amrex::MultiFab& Ey, const amrex::MultiFab& Ez, @@ -66,7 +71,7 @@ public: DtType a_dt_type=DtType::Full, bool skip_deposition=false) override; - virtual void PushPX(WarpXParIter& pti, + void PushPX(WarpXParIter& pti, amrex::FArrayBox const * exfab, amrex::FArrayBox const * eyfab, amrex::FArrayBox const * ezfab, @@ -81,7 +86,7 @@ public: DtType a_dt_type) override; // Do nothing - virtual void PushP (int /*lev*/, + void PushP (int /*lev*/, amrex::Real /*dt*/, const amrex::MultiFab& /*Ex*/, const amrex::MultiFab& /*Ey*/, @@ -92,7 +97,7 @@ public: // DepositCharge should do nothing for photons - virtual void DepositCharge (WarpXParIter& /*pti*/, + void DepositCharge (WarpXParIter& /*pti*/, RealVector const & /*wp*/, const int * const /*ion_lev*/, amrex::MultiFab* /*rho*/, @@ -104,7 +109,7 @@ public: int /*depos_lev*/) override {} // DepositCurrent should do nothing for photons - virtual void DepositCurrent (WarpXParIter& /*pti*/, + void DepositCurrent (WarpXParIter& /*pti*/, RealVector const & /*wp*/, RealVector const & /*uxp*/, RealVector const & /*uyp*/, diff --git a/Source/Particles/PhysicalParticleContainer.H b/Source/Particles/PhysicalParticleContainer.H index 3e3ae069214..526e5e01b2d 100644 --- a/Source/Particles/PhysicalParticleContainer.H +++ b/Source/Particles/PhysicalParticleContainer.H @@ -56,20 +56,25 @@ public: * the run if one of them is specified. */ void BackwardCompatibility (); - virtual ~PhysicalParticleContainer () {} + ~PhysicalParticleContainer () override {} - virtual void InitData () override; + PhysicalParticleContainer (PhysicalParticleContainer const &) = delete; + PhysicalParticleContainer& operator= (PhysicalParticleContainer const & ) = delete; + PhysicalParticleContainer(PhysicalParticleContainer&& ) = default; + PhysicalParticleContainer& operator=(PhysicalParticleContainer&& ) = default; - virtual void ReadHeader (std::istream& is) override; + void InitData () override; - virtual void WriteHeader (std::ostream& os) const override; + void ReadHeader (std::istream& is) override; - virtual void InitIonizationModule () override; + void WriteHeader (std::ostream& os) const override; + + void InitIonizationModule () override; /* * \brief Returns a pointer to the plasma injector. */ - virtual PlasmaInjector* GetPlasmaInjector () override; + PlasmaInjector* GetPlasmaInjector () override; /** * \brief Evolve is the central function PhysicalParticleContainer that @@ -105,7 +110,7 @@ public: * field gather, particle push and current deposition for all particles * in the box. */ - virtual void Evolve (int lev, + void Evolve (int lev, const amrex::MultiFab& Ex, const amrex::MultiFab& Ey, const amrex::MultiFab& Ez, @@ -145,7 +150,7 @@ public: amrex::Real dt, ScaleFields scaleFields, DtType a_dt_type=DtType::Full); - virtual void PushP (int lev, amrex::Real dt, + void PushP (int lev, amrex::Real dt, const amrex::MultiFab& Ex, const amrex::MultiFab& Ey, const amrex::MultiFab& Ez, @@ -162,7 +167,7 @@ public: amrex::iMultiFab const* current_masks, amrex::iMultiFab const* gather_masks ); - virtual void PostRestart () final {} + void PostRestart () final {} void SplitParticles (int lev); @@ -240,13 +245,13 @@ public: * These are NOT initialized by this function. * @param[in] engine the random engine, used in initialization of QED optical depths */ - virtual void DefaultInitializeRuntimeAttributes ( + void DefaultInitializeRuntimeAttributes ( amrex::ParticleTile, NArrayReal, NArrayInt, amrex::PinnedArenaAllocator>& pinned_tile, int n_external_attr_real, int n_external_attr_int, - const amrex::RandomEngine& engine) override final; + const amrex::RandomEngine& engine) final; /** * \brief Apply NCI Godfrey filter to all components of E and B before gather @@ -307,7 +312,7 @@ public: * * @param[in] timestep the current timestep. */ - void resample (int timestep, bool verbose=true) override final; + void resample (int timestep, bool verbose) final; #ifdef WARPX_QED //Functions decleared in WarpXParticleContainer.H diff --git a/Source/Particles/PhysicalParticleContainer.cpp b/Source/Particles/PhysicalParticleContainer.cpp index 3d6d57d46e8..70614702ca5 100644 --- a/Source/Particles/PhysicalParticleContainer.cpp +++ b/Source/Particles/PhysicalParticleContainer.cpp @@ -83,7 +83,6 @@ #include #include #include -#include #include #include #include @@ -144,12 +143,21 @@ namespace ParticleReal x, y, z; AMREX_GPU_HOST_DEVICE - PDim3(const PDim3&) = default; + PDim3(const amrex::XDim3& a): + x{a.x}, y{a.y}, z{a.z} + {} + AMREX_GPU_HOST_DEVICE - PDim3(const amrex::XDim3& a) : x(a.x), y(a.y), z(a.z) {} + ~PDim3() = default; AMREX_GPU_HOST_DEVICE - PDim3& operator=(const PDim3&) = default; + PDim3(PDim3 const &) = default; + AMREX_GPU_HOST_DEVICE + PDim3& operator=(PDim3 const &) = default; + AMREX_GPU_HOST_DEVICE + PDim3(PDim3&&) = default; + AMREX_GPU_HOST_DEVICE + PDim3& operator=(PDim3&&) = default; }; AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE diff --git a/Source/Particles/Resampling/LevelingThinning.H b/Source/Particles/Resampling/LevelingThinning.H index d7db1e7021c..fa05525e270 100644 --- a/Source/Particles/Resampling/LevelingThinning.H +++ b/Source/Particles/Resampling/LevelingThinning.H @@ -45,7 +45,7 @@ public: * @param[in] lev the index of the refinement level. * @param[in] pc a pointer to the particle container. */ - void operator() (WarpXParIter& pti, int lev, WarpXParticleContainer* pc) const override final; + void operator() (WarpXParIter& pti, int lev, WarpXParticleContainer* pc) const final; private: amrex::Real m_target_ratio = amrex::Real(1.5); diff --git a/Source/Particles/Resampling/Resampling.H b/Source/Particles/Resampling/Resampling.H index 820b14f5dc5..35439e905df 100644 --- a/Source/Particles/Resampling/Resampling.H +++ b/Source/Particles/Resampling/Resampling.H @@ -30,6 +30,15 @@ struct ResamplingAlgorithm * \brief Virtual destructor of the abstract ResamplingAlgorithm class */ virtual ~ResamplingAlgorithm () = default; + + /** Default constructor */ + ResamplingAlgorithm () = default; + + + ResamplingAlgorithm ( ResamplingAlgorithm const &) = default; + ResamplingAlgorithm& operator= ( ResamplingAlgorithm const & ) = default; + ResamplingAlgorithm ( ResamplingAlgorithm&& ) = default; + ResamplingAlgorithm& operator= ( ResamplingAlgorithm&& ) = default; }; /** diff --git a/Source/Particles/RigidInjectedParticleContainer.H b/Source/Particles/RigidInjectedParticleContainer.H index 0f6f20f5f71..29bf294f939 100644 --- a/Source/Particles/RigidInjectedParticleContainer.H +++ b/Source/Particles/RigidInjectedParticleContainer.H @@ -48,13 +48,20 @@ public: RigidInjectedParticleContainer (amrex::AmrCore* amr_core, int ispecies, const std::string& name); - virtual ~RigidInjectedParticleContainer () {} + ~RigidInjectedParticleContainer () override = default; - virtual void InitData() override; + + RigidInjectedParticleContainer ( RigidInjectedParticleContainer const &) = delete; + RigidInjectedParticleContainer& operator= ( RigidInjectedParticleContainer const & ) = delete; + RigidInjectedParticleContainer ( RigidInjectedParticleContainer&& ) = default; + RigidInjectedParticleContainer& operator= ( RigidInjectedParticleContainer&& ) = default; + + + void InitData() override; virtual void RemapParticles(); - virtual void Evolve (int lev, + void Evolve (int lev, const amrex::MultiFab& Ex, const amrex::MultiFab& Ey, const amrex::MultiFab& Ez, @@ -80,7 +87,7 @@ public: DtType a_dt_type=DtType::Full, bool skip_deposition=false ) override; - virtual void PushPX (WarpXParIter& pti, + void PushPX (WarpXParIter& pti, amrex::FArrayBox const * exfab, amrex::FArrayBox const * eyfab, amrex::FArrayBox const * ezfab, @@ -94,7 +101,7 @@ public: amrex::Real dt, ScaleFields scaleFields, DtType a_dt_type=DtType::Full) override; - virtual void PushP (int lev, amrex::Real dt, + void PushP (int lev, amrex::Real dt, const amrex::MultiFab& Ex, const amrex::MultiFab& Ey, const amrex::MultiFab& Ez, @@ -102,9 +109,9 @@ public: const amrex::MultiFab& By, const amrex::MultiFab& Bz) override; - virtual void ReadHeader (std::istream& is) override; + void ReadHeader (std::istream& is) override; - virtual void WriteHeader (std::ostream& os) const override; + void WriteHeader (std::ostream& os) const override; private: diff --git a/Source/Particles/Sorting/SortingUtils.H b/Source/Particles/Sorting/SortingUtils.H index dd53ad6f610..ac2c63e88f8 100644 --- a/Source/Particles/Sorting/SortingUtils.H +++ b/Source/Particles/Sorting/SortingUtils.H @@ -84,13 +84,13 @@ class fillBufferFlag public: fillBufferFlag( WarpXParIter const& pti, amrex::iMultiFab const* bmasks, amrex::Gpu::DeviceVector& inexflag, - amrex::Geometry const& geom ) { - + amrex::Geometry const& geom ): // Extract simple structure that can be used directly on the GPU - m_particles = pti.GetArrayOfStructs().data(); - m_buffer_mask = (*bmasks)[pti].array(); - m_inexflag_ptr = inexflag.dataPtr(); - m_domain = geom.Domain(); + m_domain{geom.Domain()}, + m_inexflag_ptr{inexflag.dataPtr()}, + m_particles{pti.GetArrayOfStructs().data()}, + m_buffer_mask{(*bmasks)[pti].array()} + { for (int idim=0; idim m_prob_lo; - amrex::GpuArray m_inv_cell_size; amrex::Box m_domain; int* m_inexflag_ptr; WarpXParticleContainer::ParticleType const* m_particles; amrex::Array4 m_buffer_mask; + amrex::GpuArray m_prob_lo; + amrex::GpuArray m_inv_cell_size; }; /** \brief Functor that fills the elements of the particle array `inexflag` @@ -143,14 +143,14 @@ class fillBufferFlagRemainingParticles amrex::Geometry const& geom, amrex::Gpu::DeviceVector const& particle_indices, long const start_index ) : - m_start_index(start_index) { - + m_domain{geom.Domain()}, // Extract simple structure that can be used directly on the GPU - m_particles = pti.GetArrayOfStructs().data(); - m_buffer_mask = (*bmasks)[pti].array(); - m_inexflag_ptr = inexflag.dataPtr(); - m_indices_ptr = particle_indices.dataPtr(); - m_domain = geom.Domain(); + m_inexflag_ptr{inexflag.dataPtr()}, + m_particles{pti.GetArrayOfStructs().data()}, + m_buffer_mask{(*bmasks)[pti].array()}, + m_start_index{start_index}, + m_indices_ptr{particle_indices.dataPtr()} + { for (int idim=0; idim const& src, amrex::Gpu::DeviceVector& dst, - amrex::Gpu::DeviceVector const& indices ) { - // Extract simple structure that can be used directly on the GPU - m_src_ptr = src.dataPtr(); - m_dst_ptr = dst.dataPtr(); - m_indices_ptr = indices.dataPtr(); - } + amrex::Gpu::DeviceVector const& indices ): + // Extract simple structure that can be used directly on the GPU + m_src_ptr{src.dataPtr()}, + m_dst_ptr{dst.dataPtr()}, + m_indices_ptr{indices.dataPtr()} + {} AMREX_GPU_DEVICE AMREX_FORCE_INLINE void operator()( const long ip ) const { diff --git a/Source/Particles/WarpXParticleContainer.H b/Source/Particles/WarpXParticleContainer.H index 98269104ae8..157ec2008dc 100644 --- a/Source/Particles/WarpXParticleContainer.H +++ b/Source/Particles/WarpXParticleContainer.H @@ -115,7 +115,13 @@ public: using DiagnosticParticles = amrex::Vector, DiagnosticParticleData> >; WarpXParticleContainer (amrex::AmrCore* amr_core, int ispecies); - virtual ~WarpXParticleContainer() {} + ~WarpXParticleContainer() override {} + + // Move and copy operations + WarpXParticleContainer(const WarpXParticleContainer&) = delete; + WarpXParticleContainer& operator=(const WarpXParticleContainer&) = delete; + WarpXParticleContainer(WarpXParticleContainer&&) = default; + WarpXParticleContainer& operator=(WarpXParticleContainer&&) = default; virtual void InitData () = 0; @@ -466,8 +472,7 @@ protected: TmpParticles tmp_particle_data; private: - virtual void particlePostLocate(ParticleType& p, const amrex::ParticleLocData& pld, - int lev) override; + void particlePostLocate(ParticleType& p, const amrex::ParticleLocData& pld, int lev) override; }; diff --git a/Source/Particles/WarpXParticleContainer.cpp b/Source/Particles/WarpXParticleContainer.cpp index 6e02e71fd23..98868d1cf14 100644 --- a/Source/Particles/WarpXParticleContainer.cpp +++ b/Source/Particles/WarpXParticleContainer.cpp @@ -59,7 +59,6 @@ #include #include #include -#include #include diff --git a/Source/Utils/Parser/IntervalsParser.cpp b/Source/Utils/Parser/IntervalsParser.cpp index 16595f6f49c..6af4ce6a8c3 100644 --- a/Source/Utils/Parser/IntervalsParser.cpp +++ b/Source/Utils/Parser/IntervalsParser.cpp @@ -16,9 +16,9 @@ #include -utils::parser::SliceParser::SliceParser (const std::string& instr, const bool isBTD) +utils::parser::SliceParser::SliceParser (const std::string& instr, const bool isBTD): + m_isBTD{isBTD} { - m_isBTD = isBTD; // split string and trim whitespaces auto insplit = ablastr::utils::text::split_string>( instr, m_separator, true); diff --git a/Source/WarpX.H b/Source/WarpX.H index e56d2e647c1..cd05d90555a 100644 --- a/Source/WarpX.H +++ b/Source/WarpX.H @@ -97,8 +97,7 @@ public: */ static void Finalize(); - /** Destructor */ - ~WarpX (); + ~WarpX () override; /** Copy constructor */ WarpX ( WarpX const &) = delete; @@ -1037,7 +1036,7 @@ public: // This needs to be public for CUDA. //! Tagging cells for refinement - virtual void ErrorEst (int lev, amrex::TagBoxArray& tags, amrex::Real time, int /*ngrow*/) final; + void ErrorEst (int lev, amrex::TagBoxArray& tags, amrex::Real time, int /*ngrow*/) final; // Return the accelerator lattice instance defined at the given refinement level const AcceleratorLattice& get_accelerator_lattice (int lev) {return *(m_accelerator_lattice[lev]);} @@ -1176,28 +1175,28 @@ protected: //! Use this function to override the Level 0 grids made by AMReX. //! This function is called in amrex::AmrCore::InitFromScratch. - virtual void PostProcessBaseGrids (amrex::BoxArray& ba0) const final; + void PostProcessBaseGrids (amrex::BoxArray& ba0) const final; //! Make a new level from scratch using provided BoxArray and //! DistributionMapping. Only used during initialization. Called //! by AmrCoreInitFromScratch. - virtual void MakeNewLevelFromScratch (int lev, amrex::Real time, const amrex::BoxArray& ba, + void MakeNewLevelFromScratch (int lev, amrex::Real time, const amrex::BoxArray& ba, const amrex::DistributionMapping& dm) final; //! Make a new level using provided BoxArray and //! DistributionMapping and fill with interpolated coarse level //! data. Called by AmrCore::regrid. - virtual void MakeNewLevelFromCoarse (int /*lev*/, amrex::Real /*time*/, const amrex::BoxArray& /*ba*/, + void MakeNewLevelFromCoarse (int /*lev*/, amrex::Real /*time*/, const amrex::BoxArray& /*ba*/, const amrex::DistributionMapping& /*dm*/) final; //! Remake an existing level using provided BoxArray and //! DistributionMapping and fill with existing fine and coarse //! data. Called by AmrCore::regrid. - virtual void RemakeLevel (int lev, amrex::Real time, const amrex::BoxArray& ba, + void RemakeLevel (int lev, amrex::Real time, const amrex::BoxArray& ba, const amrex::DistributionMapping& dm) final; //! Delete level data. Called by AmrCore::regrid. - virtual void ClearLevel (int lev) final; + void ClearLevel (int lev) final; private: diff --git a/Source/ablastr/parallelization/KernelTimer.H b/Source/ablastr/parallelization/KernelTimer.H index 0d11220daba..0329948da75 100644 --- a/Source/ablastr/parallelization/KernelTimer.H +++ b/Source/ablastr/parallelization/KernelTimer.H @@ -71,6 +71,11 @@ public: #endif //AMREX_USE_GPU } + KernelTimer ( KernelTimer const &) = default; + KernelTimer& operator= ( KernelTimer const & ) = default; + KernelTimer ( KernelTimer&& ) = default; + KernelTimer& operator= ( KernelTimer&& ) = default; + #if (defined AMREX_USE_GPU) private: //! Stores whether kernel timer is active. diff --git a/Source/ablastr/profiler/ProfilerWrapper.H b/Source/ablastr/profiler/ProfilerWrapper.H index 1dbe80c59b1..f23f13773c1 100644 --- a/Source/ablastr/profiler/ProfilerWrapper.H +++ b/Source/ablastr/profiler/ProfilerWrapper.H @@ -38,6 +38,12 @@ namespace ablastr::profiler device_synchronize(m_do_device_synchronize); } + // default move and copy operations + SynchronizeOnDestruct(const SynchronizeOnDestruct&) = default; + SynchronizeOnDestruct& operator=(const SynchronizeOnDestruct&) = default; + SynchronizeOnDestruct(SynchronizeOnDestruct&&) = default; + SynchronizeOnDestruct& operator=(SynchronizeOnDestruct&& field_data) = default; + bool m_do_device_synchronize = false; }; diff --git a/Source/ablastr/warn_manager/WarnManager.H b/Source/ablastr/warn_manager/WarnManager.H index 75fd642a884..34a8102620e 100644 --- a/Source/ablastr/warn_manager/WarnManager.H +++ b/Source/ablastr/warn_manager/WarnManager.H @@ -52,12 +52,27 @@ namespace ablastr::warn_manager /** * A singleton class should not be cloneable. */ - WarnManager(WarnManager &other) = delete; + WarnManager( const WarnManager& ) = delete; + + /** + * A singleton class should not be cloneable. + */ + WarnManager( WarnManager&& ) = delete; /** * A singleton class should not be assignable. */ - void operator=(const WarnManager &) = delete; + WarnManager& operator=( const WarnManager & ) = delete; + + /** + * A singleton class should not be assignable. + */ + WarnManager& operator=( const WarnManager&& ) = delete; + + /** + * Default destructor + */ + ~WarnManager() = default; static WarnManager& GetInstance(); diff --git a/Tools/Release/updatepyAMReX.py b/Tools/Release/updatepyAMReX.py new file mode 100755 index 00000000000..8ba10c895e0 --- /dev/null +++ b/Tools/Release/updatepyAMReX.py @@ -0,0 +1,124 @@ +#!/usr/bin/env python3 +# +# Copyright 2021 Axel Huebl +# +# This file is part of WarpX. +# + +# This file is a maintainer tool to bump the pyAMReX version that we pull in +# when building WarpX. +# +import datetime +from pathlib import Path +import re +import sys + +import requests + +# Maintainer Inputs ########################################################### + +print("""Hi there, this is a WarpX maintainer tool to update the source +code of WarpX to a new commit/release of pyAMReX. +For it to work, you need write access on the source directory and +you should be working in a clean git branch without ongoing +rebase/merge/conflict resolves and without unstaged changes.""") + +# check source dir +REPO_DIR = Path(__file__).parent.parent.parent.absolute() +print(f"\nYour current source directory is: {REPO_DIR}") + +REPLY = input("Are you sure you want to continue? [y/N] ") +print() +if not REPLY in ["Y", "y"]: + print("You did not confirm with 'y', aborting.") + sys.exit(1) + + +# Current Versions ############################################################ + +# pyAMReX development HEAD +pyamrex_gh = requests.get('https://api.github.com/repos/AMReX-Codes/pyamrex/commits/development') +pyamrex_HEAD = pyamrex_gh.json()["sha"] + +# WarpX references to pyAMReX: cmake/dependencies/pyAMReX.cmake +pyamrex_cmake_path = str(REPO_DIR.joinpath("cmake/dependencies/pyAMReX.cmake")) +# branch/commit/tag (git fetcher) version +# set(WarpX_pyamrex_branch "development" ... +pyamrex_branch = f"unknown (format issue in {pyamrex_cmake_path})" +with open(pyamrex_cmake_path, encoding='utf-8') as f: + r_minimal = re.findall(r'.*set\(WarpX_pyamrex_branch\s+"(.+)"\s+.*', + f.read(), re.MULTILINE) + if len(r_minimal) >= 1: + pyamrex_branch = r_minimal[0] + +# minimal (external) version +# find_package(AMReX YY.MM CONFIG ... +pyamrex_minimal = f"unknown (format issue in {pyamrex_cmake_path})" +with open(pyamrex_cmake_path, encoding='utf-8') as f: + r_minimal = re.findall(r'.*find_package\(pyAMReX\s+(.+)\s+CONFIG\s+.*', + f.read(), re.MULTILINE) + if len(r_minimal) >= 1: + pyamrex_minimal = r_minimal[0] + + +# Ask for new ################################################################# + +print("""We will now run a few sed commands on your source directory. +Please answer the following questions about the version number +you want to require from pyAMReX:\n""") + +print(f"Currently, WarpX builds against this pyAMReX commit/branch/sha: {pyamrex_branch}") +print(f"pyAMReX HEAD commit (development branch): {pyamrex_HEAD}") +pyamrex_new_branch = input(f"Update pyAMReX commit/branch/sha: ").strip() +if not pyamrex_new_branch: + pyamrex_new_branch = pyamrex_branch + print(f"--> Nothing entered, will keep: {pyamrex_branch}") +print() + +print(f"Currently, a pre-installed pyAMReX is required at least at version: {pyamrex_minimal}") +today = datetime.date.today().strftime("%y.%m") +pyamrex_new_minimal = input(f"New minimal pyAMReX version (e.g. {today})? ").strip() +if not pyamrex_new_minimal: + pyamrex_new_minimal = pyamrex_minimal + print(f"--> Nothing entered, will keep: {pyamrex_minimal}") + +print() +print(f"New pyAMReX commit/branch/sha: {pyamrex_new_branch}") +print(f"New minimal pyAMReX version: {pyamrex_new_minimal}\n") + +REPLY = input("Is this information correct? Will now start updating! [y/N] ") +print() +if not REPLY in ["Y", "y"]: + print("You did not confirm with 'y', aborting.") + sys.exit(1) + + +# Updates ##################################################################### + +# WarpX references to pyAMReX: cmake/dependencies/pyAMReX.cmake +with open(pyamrex_cmake_path, encoding='utf-8') as f: + pyAMReX_cmake_content = f.read() + + # branch/commit/tag (git fetcher) version + # set(WarpX_pyamrex_branch "development" ... + pyAMReX_cmake_content = re.sub( + r'(.*set\(WarpX_pyamrex_branch\s+")(.+)("\s+.*)', + r'\g<1>{}\g<3>'.format(pyamrex_new_branch), + pyAMReX_cmake_content, flags = re.MULTILINE) + + # minimal (external) version + # find_package(AMReX YY.MM CONFIG ... + pyAMReX_cmake_content = re.sub( + r'(.*find_package\(pyAMReX\s+)(.+)(\s+CONFIG\s+.*)', + r'\g<1>{}\g<3>'.format(pyamrex_new_minimal), + pyAMReX_cmake_content, flags = re.MULTILINE) + +with open(pyamrex_cmake_path, "w", encoding='utf-8') as f: + f.write(pyAMReX_cmake_content) + + +# Epilogue #################################################################### + +print("""Done. Please check your source, e.g. via + git diff +now and commit the changes if no errors occurred.""") diff --git a/Tools/machines/adastra-cines/install_dependencies.sh b/Tools/machines/adastra-cines/install_dependencies.sh index b94d5224833..8a4cef4a2ec 100755 --- a/Tools/machines/adastra-cines/install_dependencies.sh +++ b/Tools/machines/adastra-cines/install_dependencies.sh @@ -101,6 +101,8 @@ rm -rf ${SW_DIR}/venvs/warpx-adastra python3 -m venv ${SW_DIR}/venvs/warpx-adastra source ${SW_DIR}/venvs/warpx-adastra/bin/activate python3 -m pip install --upgrade pip +python3 -m pip install --upgrade build +python3 -m pip install --upgrade packaging python3 -m pip install --upgrade wheel python3 -m pip install --upgrade setuptools python3 -m pip install --upgrade cython diff --git a/Tools/machines/crusher-olcf/install_dependencies.sh b/Tools/machines/crusher-olcf/install_dependencies.sh index 2defd795786..ab5deb6b0a6 100755 --- a/Tools/machines/crusher-olcf/install_dependencies.sh +++ b/Tools/machines/crusher-olcf/install_dependencies.sh @@ -86,6 +86,8 @@ rm -rf ${SW_DIR}/venvs/warpx-crusher python3 -m venv ${SW_DIR}/venvs/warpx-crusher source ${SW_DIR}/venvs/warpx-crusher/bin/activate python3 -m pip install --upgrade pip +python3 -m pip install --upgrade build +python3 -m pip install --upgrade packaging python3 -m pip install --upgrade wheel python3 -m pip install --upgrade setuptools python3 -m pip install --upgrade cython diff --git a/Tools/machines/frontier-olcf/install_dependencies.sh b/Tools/machines/frontier-olcf/install_dependencies.sh index 690941b2078..896cd9edbbc 100755 --- a/Tools/machines/frontier-olcf/install_dependencies.sh +++ b/Tools/machines/frontier-olcf/install_dependencies.sh @@ -86,6 +86,8 @@ rm -rf ${SW_DIR}/venvs/warpx-frontier python3 -m venv ${SW_DIR}/venvs/warpx-frontier source ${SW_DIR}/venvs/warpx-frontier/bin/activate python3 -m pip install --upgrade pip +python3 -m pip install --upgrade build +python3 -m pip install --upgrade packaging python3 -m pip install --upgrade wheel python3 -m pip install --upgrade setuptools python3 -m pip install --upgrade cython diff --git a/Tools/machines/hpc3-uci/install_gpu_dependencies.sh b/Tools/machines/hpc3-uci/install_gpu_dependencies.sh index e7a5f9f086f..9334d0a2287 100755 --- a/Tools/machines/hpc3-uci/install_gpu_dependencies.sh +++ b/Tools/machines/hpc3-uci/install_gpu_dependencies.sh @@ -116,6 +116,8 @@ rm -rf ${SW_DIR}/venvs/warpx-gpu python3 -m venv ${SW_DIR}/venvs/warpx-gpu source ${SW_DIR}/venvs/warpx-gpu/bin/activate python3 -m pip install --upgrade pip +python3 -m pip install --upgrade build +python3 -m pip install --upgrade packaging python3 -m pip install --upgrade wheel python3 -m pip install --upgrade setuptools python3 -m pip install --upgrade cython diff --git a/Tools/machines/karolina-it4i/install_cpu_dependencies.sh b/Tools/machines/karolina-it4i/install_cpu_dependencies.sh index f5067e03447..2695435738f 100755 --- a/Tools/machines/karolina-it4i/install_cpu_dependencies.sh +++ b/Tools/machines/karolina-it4i/install_cpu_dependencies.sh @@ -120,6 +120,8 @@ rm -rf ${SW_DIR}/venvs/warpx-cpu python3 -m venv ${SW_DIR}/venvs/warpx-cpu source ${SW_DIR}/venvs/warpx-cpu/bin/activate python3 -m pip install --upgrade pip +python3 -m pip install --upgrade build +python3 -m pip install --upgrade packaging python3 -m pip install --upgrade wheel python3 -m pip install --upgrade setuptools python3 -m pip install --upgrade cython diff --git a/Tools/machines/karolina-it4i/install_gpu_dependencies.sh b/Tools/machines/karolina-it4i/install_gpu_dependencies.sh index 4cd1ce5851a..a03bb008816 100755 --- a/Tools/machines/karolina-it4i/install_gpu_dependencies.sh +++ b/Tools/machines/karolina-it4i/install_gpu_dependencies.sh @@ -120,6 +120,8 @@ rm -rf ${SW_DIR}/venvs/warpx-gpu python3 -m venv ${SW_DIR}/venvs/warpx-gpu source ${SW_DIR}/venvs/warpx-gpu/bin/activate python3 -m pip install --upgrade pip +python3 -m pip install --upgrade build +python3 -m pip install --upgrade packaging python3 -m pip install --upgrade wheel python3 -m pip install --upgrade setuptools python3 -m pip install --upgrade cython diff --git a/Tools/machines/lassen-llnl/install_v100_dependencies.sh b/Tools/machines/lassen-llnl/install_v100_dependencies.sh index dfbf139f27d..fe8285b7501 100755 --- a/Tools/machines/lassen-llnl/install_v100_dependencies.sh +++ b/Tools/machines/lassen-llnl/install_v100_dependencies.sh @@ -117,6 +117,8 @@ python3 -m venv ${SW_DIR}/venvs/warpx-lassen source ${SW_DIR}/venvs/warpx-lassen/bin/activate python3 -m pip install --upgrade pip python3 -m pip cache purge +python3 -m pip install --upgrade build +python3 -m pip install --upgrade packaging python3 -m pip install --upgrade wheel python3 -m pip install --upgrade setuptools # Older version for h4py diff --git a/Tools/machines/lassen-llnl/install_v100_dependencies_toss3.sh b/Tools/machines/lassen-llnl/install_v100_dependencies_toss3.sh index b8273a69c87..916986ee119 100644 --- a/Tools/machines/lassen-llnl/install_v100_dependencies_toss3.sh +++ b/Tools/machines/lassen-llnl/install_v100_dependencies_toss3.sh @@ -117,6 +117,8 @@ python3 -m venv ${SW_DIR}/venvs/warpx-lassen-toss3 source ${SW_DIR}/venvs/warpx-lassen-toss3/bin/activate python3 -m pip install --upgrade pip python3 -m pip cache purge +python3 -m pip install --upgrade build +python3 -m pip install --upgrade packaging python3 -m pip install --upgrade wheel python3 -m pip install --upgrade setuptools # Older version for h4py diff --git a/Tools/machines/lassen-llnl/install_v100_ml.sh b/Tools/machines/lassen-llnl/install_v100_ml.sh index 6e00be035d6..72a4d04f2f1 100755 --- a/Tools/machines/lassen-llnl/install_v100_ml.sh +++ b/Tools/machines/lassen-llnl/install_v100_ml.sh @@ -64,6 +64,7 @@ rm -rf build cd - # optional: optimas dependencies (based on libEnsemble & ax->botorch->gpytorch->pytorch) +# TODO: scikit-learn needs a BLAS hint # commented because scikit-learn et al. compile > 2 hrs # please run manually on a login node if needed #python3 -m pip install -r ${SRC_DIR}/warpx/Tools/optimas/requirements.txt diff --git a/Tools/machines/leonardo-cineca/install_gpu_dependencies.sh b/Tools/machines/leonardo-cineca/install_gpu_dependencies.sh index 3a332f97420..bbaf0ab8464 100644 --- a/Tools/machines/leonardo-cineca/install_gpu_dependencies.sh +++ b/Tools/machines/leonardo-cineca/install_gpu_dependencies.sh @@ -85,6 +85,8 @@ source ${SW_DIR}/venvs/warpx/bin/activate python3 -m ensurepip --upgrade python3 -m pip cache purge python3 -m pip install --upgrade pip +python3 -m pip install --upgrade build +python3 -m pip install --upgrade packaging python3 -m pip install --upgrade wheel python3 -m pip install --upgrade setuptools python3 -m pip install --upgrade cython diff --git a/Tools/machines/lumi-csc/install_dependencies.sh b/Tools/machines/lumi-csc/install_dependencies.sh index 281ca10c449..0e466f1f57f 100755 --- a/Tools/machines/lumi-csc/install_dependencies.sh +++ b/Tools/machines/lumi-csc/install_dependencies.sh @@ -101,6 +101,8 @@ rm -rf ${SW_DIR}/venvs/warpx-lumi python3 -m venv ${SW_DIR}/venvs/warpx-lumi source ${SW_DIR}/venvs/warpx-lumi/bin/activate python3 -m pip install --upgrade pip +python3 -m pip install --upgrade build +python3 -m pip install --upgrade packaging python3 -m pip install --upgrade wheel python3 -m pip install --upgrade setuptools python3 -m pip install --upgrade cython diff --git a/Tools/machines/perlmutter-nersc/install_cpu_dependencies.sh b/Tools/machines/perlmutter-nersc/install_cpu_dependencies.sh index fa4e77cb309..dbe59438a16 100755 --- a/Tools/machines/perlmutter-nersc/install_cpu_dependencies.sh +++ b/Tools/machines/perlmutter-nersc/install_cpu_dependencies.sh @@ -116,6 +116,8 @@ rm -rf ${SW_DIR}/venvs/warpx python3 -m venv ${SW_DIR}/venvs/warpx source ${SW_DIR}/venvs/warpx/bin/activate python3 -m pip install --upgrade pip +python3 -m pip install --upgrade build +python3 -m pip install --upgrade packaging python3 -m pip install --upgrade wheel python3 -m pip install --upgrade setuptools python3 -m pip install --upgrade cython diff --git a/Tools/machines/perlmutter-nersc/install_gpu_dependencies.sh b/Tools/machines/perlmutter-nersc/install_gpu_dependencies.sh index 98e14f09ede..8dd64c56c58 100755 --- a/Tools/machines/perlmutter-nersc/install_gpu_dependencies.sh +++ b/Tools/machines/perlmutter-nersc/install_gpu_dependencies.sh @@ -116,6 +116,8 @@ rm -rf ${SW_DIR}/venvs/warpx python3 -m venv ${SW_DIR}/venvs/warpx source ${SW_DIR}/venvs/warpx/bin/activate python3 -m pip install --upgrade pip +python3 -m pip install --upgrade build +python3 -m pip install --upgrade packaging python3 -m pip install --upgrade wheel python3 -m pip install --upgrade setuptools python3 -m pip install --upgrade cython diff --git a/Tools/machines/quartz-llnl/install_dependencies.sh b/Tools/machines/quartz-llnl/install_dependencies.sh index 114bef3d3c3..2920b00663b 100755 --- a/Tools/machines/quartz-llnl/install_dependencies.sh +++ b/Tools/machines/quartz-llnl/install_dependencies.sh @@ -99,6 +99,8 @@ python3 -m venv ${SW_DIR}/venvs/warpx-quartz source ${SW_DIR}/venvs/warpx-quartz/bin/activate python3 -m pip install --upgrade pip python3 -m pip cache purge +python3 -m pip install --upgrade build +python3 -m pip install --upgrade packaging python3 -m pip install --upgrade wheel python3 -m pip install --upgrade setuptools python3 -m pip install --upgrade cython diff --git a/Tools/machines/summit-olcf/install_gpu_dependencies.sh b/Tools/machines/summit-olcf/install_gpu_dependencies.sh index 7679b999ea3..433b7ab0580 100755 --- a/Tools/machines/summit-olcf/install_gpu_dependencies.sh +++ b/Tools/machines/summit-olcf/install_gpu_dependencies.sh @@ -99,6 +99,8 @@ rm -rf ${SW_DIR}/venvs/warpx-summit python3 -m venv ${SW_DIR}/venvs/warpx-summit source ${SW_DIR}/venvs/warpx-summit/bin/activate python3 -m pip install --upgrade pip +python3 -m pip install --upgrade build +python3 -m pip install --upgrade packaging python3 -m pip install --upgrade wheel python3 -m pip install --upgrade setuptools python3 -m pip install --upgrade cython diff --git a/cmake/dependencies/AMReX.cmake b/cmake/dependencies/AMReX.cmake index fbdd39e4f43..488310b7cc2 100644 --- a/cmake/dependencies/AMReX.cmake +++ b/cmake/dependencies/AMReX.cmake @@ -1,4 +1,10 @@ macro(find_amrex) + # if pyAMReX is external, AMReX must be as well + if(DEFINED WarpX_pyamrex_internal AND NOT WarpX_pyamrex_internal) + set(WarpX_amrex_internal OFF CACHE BOOL + "Download & build AMReX" FORCE) + endif() + if(WarpX_amrex_src) message(STATUS "Compiling local AMReX ...") message(STATUS "AMReX source path: ${WarpX_amrex_src}") @@ -10,6 +16,7 @@ macro(find_amrex) message(STATUS "AMReX repository: ${WarpX_amrex_repo} (${WarpX_amrex_branch})") include(FetchContent) endif() + if(WarpX_amrex_internal OR WarpX_amrex_src) set(CMAKE_POLICY_DEFAULT_CMP0077 NEW) @@ -243,7 +250,12 @@ macro(find_amrex) endif() set(COMPONENT_PRECISION ${WarpX_PRECISION} P${WarpX_PARTICLE_PRECISION}) - find_package(AMReX 23.10 CONFIG REQUIRED COMPONENTS ${COMPONENT_ASCENT} ${COMPONENT_DIMS} ${COMPONENT_EB} PARTICLES ${COMPONENT_PIC} ${COMPONENT_PRECISION} ${COMPONENT_SENSEI} TINYP LSOLVERS) + find_package(AMReX 23.11 CONFIG REQUIRED COMPONENTS ${COMPONENT_ASCENT} ${COMPONENT_DIMS} ${COMPONENT_EB} PARTICLES ${COMPONENT_PIC} ${COMPONENT_PRECISION} ${COMPONENT_SENSEI} LSOLVERS) + # note: TINYP skipped because user-configured and optional + + # AMReX CMake helper scripts + list(APPEND CMAKE_MODULE_PATH "${AMReX_DIR}/AMReXCMakeModules") + message(STATUS "AMReX: Found version '${AMReX_VERSION}'") endif() endmacro() @@ -257,7 +269,7 @@ set(WarpX_amrex_src "" set(WarpX_amrex_repo "https://github.com/AMReX-Codes/amrex.git" CACHE STRING "Repository URI to pull and build AMReX from if(WarpX_amrex_internal)") -set(WarpX_amrex_branch "da79aff8053058371a78d4bf85488384242368ee" +set(WarpX_amrex_branch "d36463103daed09a40cdea235041a6ab79ff280c" CACHE STRING "Repository branch for WarpX_amrex_repo if(WarpX_amrex_internal)") diff --git a/cmake/dependencies/PICSAR.cmake b/cmake/dependencies/PICSAR.cmake index 8400dc06a4b..a1e93a9e33c 100644 --- a/cmake/dependencies/PICSAR.cmake +++ b/cmake/dependencies/PICSAR.cmake @@ -85,7 +85,7 @@ function(find_picsar) #message(STATUS "PICSAR: Using version '${PICSAR_VERSION}'") else() # not supported by PICSAR (yet) - #find_package(PICSAR 23.09 CONFIG REQUIRED QED) + #find_package(PICSAR 23.11 CONFIG REQUIRED QED) #message(STATUS "PICSAR: Found version '${PICSAR_VERSION}'") message(FATAL_ERROR "PICSAR: Cannot be used as externally installed " "library yet. " @@ -106,7 +106,7 @@ if(WarpX_QED) set(WarpX_picsar_repo "https://github.com/ECP-WarpX/picsar.git" CACHE STRING "Repository URI to pull and build PICSAR from if(WarpX_picsar_internal)") - set(WarpX_picsar_branch "23.09" + set(WarpX_picsar_branch "aa54e985398c1d575abc7e6737cdbc660a13765f" CACHE STRING "Repository branch for WarpX_picsar_repo if(WarpX_picsar_internal)") diff --git a/cmake/dependencies/pyAMReX.cmake b/cmake/dependencies/pyAMReX.cmake index 2ff354785da..20232969f75 100644 --- a/cmake/dependencies/pyAMReX.cmake +++ b/cmake/dependencies/pyAMReX.cmake @@ -64,8 +64,8 @@ function(find_pyamrex) endif() elseif(NOT WarpX_pyamrex_internal) # TODO: MPI control - find_package(pyAMReX 23.10 CONFIG REQUIRED) - message(STATUS "pyAMReX: Found version '${pyamrex_VERSION}'") + find_package(pyAMReX 23.11 CONFIG REQUIRED) + message(STATUS "pyAMReX: Found version '${pyAMReX_VERSION}'") endif() endfunction() @@ -79,7 +79,7 @@ option(WarpX_pyamrex_internal "Download & build pyAMReX" ON) set(WarpX_pyamrex_repo "https://github.com/AMReX-Codes/pyamrex.git" CACHE STRING "Repository URI to pull and build pyamrex from if(WarpX_pyamrex_internal)") -set(WarpX_pyamrex_branch "23.10" +set(WarpX_pyamrex_branch "d90e390971de4144fb380ae62d5c74cdc27dd3fc" CACHE STRING "Repository branch for WarpX_pyamrex_repo if(WarpX_pyamrex_internal)") diff --git a/pyproject.toml b/pyproject.toml index d7096f82d01..f53522b5622 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,6 +2,7 @@ requires = [ "setuptools>=42", "wheel", - "cmake>=3.20.0,<4.0.0" + "cmake>=3.20.0,<4.0.0", + "packaging>=23", ] build-backend = "setuptools.build_meta" diff --git a/run_test.sh b/run_test.sh index 2e86618f2f2..e6ab5b166ca 100755 --- a/run_test.sh +++ b/run_test.sh @@ -61,17 +61,14 @@ echo "cd $PWD" rm -rf py-venv python3 -m venv py-venv source py-venv/bin/activate -python3 -m pip install --upgrade pip setuptools wheel +python3 -m pip install --upgrade pip +python3 -m pip install --upgrade build packaging setuptools wheel python3 -m pip install --upgrade cmake -# setuptools/mp4py work-around, see -# https://github.com/mpi4py/mpi4py/pull/159 -# https://github.com/mpi4py/mpi4py/issues/157#issuecomment-1001022274 -export SETUPTOOLS_USE_DISTUTILS="stdlib" python3 -m pip install --upgrade -r warpx/Regression/requirements.txt # Clone AMReX and warpx-data git clone https://github.com/AMReX-Codes/amrex.git -cd amrex && git checkout --detach da79aff8053058371a78d4bf85488384242368ee && cd - +cd amrex && git checkout --detach d36463103daed09a40cdea235041a6ab79ff280c && cd - # warpx-data contains various required data sets git clone --depth 1 https://github.com/ECP-WarpX/warpx-data.git # openPMD-example-datasets contains various required data sets diff --git a/setup.py b/setup.py index 4636d6995f6..bb92d69b417 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,3 @@ -from distutils.command.build import build -from distutils.command.clean import clean -from distutils.version import LooseVersion import os import platform import re @@ -9,6 +6,7 @@ import sys from setuptools import Extension, setup +from setuptools.command.build import build from setuptools.command.build_ext import build_ext @@ -26,10 +24,8 @@ def run(self): # by default, this stays around. we want to make sure generated # files like libwarpx.(1d|2d|rz|3d).(so|pyd) are always only the # ones we want to package and not ones from an earlier wheel's stage - c = clean(self.distribution) - c.all = True - c.finalize_options() - c.run() + if os.path.exists(self.build_base): + shutil.rmtree(self.build_base) # call superclass build.run(self) @@ -59,6 +55,8 @@ def __init__(self, name, sourcedir=''): class CMakeBuild(build_ext): def run(self): + from packaging.version import parse + try: out = subprocess.check_output(['cmake', '--version']) except OSError: @@ -67,11 +65,8 @@ def run(self): "extensions: " + ", ".join(e.name for e in self.extensions)) - cmake_version = LooseVersion(re.search( - r'version\s*([\d.]+)', - out.decode() - ).group(1)) - if cmake_version < '3.20.0': + cmake_version = parse(re.search(r"version\s*([\d.]+)", out.decode()).group(1)) + if cmake_version < parse("3.20.0"): raise RuntimeError("CMake >= 3.20.0 is required") for ext in self.extensions: @@ -283,7 +278,7 @@ def build_extension(self, ext): setup( name='pywarpx', # note PEP-440 syntax: x.y.zaN but x.y.z.devN - version = '23.10', + version = '23.11', packages = ['pywarpx'], package_dir = {'pywarpx': 'Python/pywarpx'}, author='Jean-Luc Vay, David P. Grote, Maxence Thévenet, Rémi Lehe, Andrew Myers, Weiqun Zhang, Axel Huebl, et al.',