From 807f0daf577a03d4b82cae3f5e110e28f49ddbe7 Mon Sep 17 00:00:00 2001 From: Grant Johnson <69021085+johnson452@users.noreply.github.com> Date: Thu, 12 Oct 2023 14:20:26 -0700 Subject: [PATCH 01/25] Added extended writeup to the docs for PR3991, fluids (#4365) --- Docs/source/theory/cold_fluid_model.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Docs/source/theory/cold_fluid_model.rst b/Docs/source/theory/cold_fluid_model.rst index 0a98ede772f..971ebdba062 100644 --- a/Docs/source/theory/cold_fluid_model.rst +++ b/Docs/source/theory/cold_fluid_model.rst @@ -97,7 +97,8 @@ Step 5: **Current and Charge Deposition** The implemented MUSCL scheme has a simplifed slope averaging, see the extended writeup for details. - More details on the precise implementation will be made available online soon. + More details on the precise implementation are available here, `WarpX_Cold_Rel_Fluids.pdf`_. +.. _WarpX_Cold_Rel_Fluids.pdf: https://github.com/ECP-WarpX/WarpX/files/12886437/WarpX_Cold_Rel_Fluids.pdf .. warning:: If using the fluid model with the Kinetic-Fluid Hybrid model or the electrostatic solver, there is a known From d07e8bbd2fdba0b40c67d10768e5789a0d9c1f6d Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Fri, 13 Oct 2023 07:49:40 -0700 Subject: [PATCH 02/25] Electrostatic Diagnostics for `j`: Default to Direct Deposition (#4362) * Change Default: Direct Current Deposition for ES Used as a diagnostics for `j`. * Reset j in Benchmarks Esirkepov -> Direct Deposition --- Docs/source/usage/parameters.rst | 4 +++- .../Checksum/benchmarks_json/Python_prev_positions.json | 6 +++--- .../Checksum/benchmarks_json/hard_edged_quadrupoles.json | 6 +++--- .../benchmarks_json/hard_edged_quadrupoles_moving.json | 6 +++--- Source/Utils/WarpXAlgorithmSelection.cpp | 3 ++- Source/WarpX.cpp | 3 ++- 6 files changed, 16 insertions(+), 12 deletions(-) diff --git a/Docs/source/usage/parameters.rst b/Docs/source/usage/parameters.rst index 17504a8065f..06b3edd0f2d 100644 --- a/Docs/source/usage/parameters.rst +++ b/Docs/source/usage/parameters.rst @@ -1824,7 +1824,9 @@ Particle push, charge and current deposition, field gathering Available options are: ``direct``, ``esirkepov``, and ``vay``. The default choice is ``esirkepov`` for FDTD maxwell solvers but ``direct`` for standard or Galilean PSATD solver (i.e. with ``algo.maxwell_solver = psatd``) and - for the hybrid-PIC solver (i.e. with ``algo.maxwell_solver = hybrid``). + for the hybrid-PIC solver (i.e. with ``algo.maxwell_solver = hybrid``) and for + diagnostics output with the electrostatic solvers (i.e., with + ``warpx.do_electrostatic = ...``). Note that ``vay`` is only available for ``algo.maxwell_solver = psatd``. 1. ``direct`` diff --git a/Regression/Checksum/benchmarks_json/Python_prev_positions.json b/Regression/Checksum/benchmarks_json/Python_prev_positions.json index e6e39d2272b..55c886775d5 100644 --- a/Regression/Checksum/benchmarks_json/Python_prev_positions.json +++ b/Regression/Checksum/benchmarks_json/Python_prev_positions.json @@ -6,9 +6,9 @@ "Ex": 3710588.849989976, "Ey": 0.0, "Ez": 646727.8074440088, - "jx": 4745.078379617619, - "jy": 368.4331779923921, - "jz": 632.1508106460103 + "jx": 15259.034603501308, + "jy": 650.139263398662, + "jz": 943.0244062246846 }, "electrons": { "particle_momentum_x": 8.78764082600202e-23, diff --git a/Regression/Checksum/benchmarks_json/hard_edged_quadrupoles.json b/Regression/Checksum/benchmarks_json/hard_edged_quadrupoles.json index 80a2dc87964..f8186748f2c 100644 --- a/Regression/Checksum/benchmarks_json/hard_edged_quadrupoles.json +++ b/Regression/Checksum/benchmarks_json/hard_edged_quadrupoles.json @@ -6,9 +6,9 @@ "Ex": 9.882421146615367e-06, "Ey": 1.0440261046714249e-05, "Ez": 1.003739697324731e-05, - "jx": 2.9148662809570633e-10, - "jy": 8.46582291468749e-19, - "jz": 3.823492756863969e-08 + "jx": 2.914866280957325e-10, + "jy": 8.46605718473121e-19, + "jz": 3.82349275686397e-08 }, "electron": { "particle_momentum_x": 2.0819392991319055e-25, diff --git a/Regression/Checksum/benchmarks_json/hard_edged_quadrupoles_moving.json b/Regression/Checksum/benchmarks_json/hard_edged_quadrupoles_moving.json index 813eead7374..05b398e4292 100644 --- a/Regression/Checksum/benchmarks_json/hard_edged_quadrupoles_moving.json +++ b/Regression/Checksum/benchmarks_json/hard_edged_quadrupoles_moving.json @@ -6,9 +6,9 @@ "Ex": 6.0282565190090465e-05, "Ey": 6.38479659567398e-05, "Ez": 7.880459213065183e-05, - "jx": 1.1659465170956616e-09, - "jy": 2.6115239381823616e-17, - "jz": 1.5293971084510288e-07 + "jx": 1.1659465170956563e-09, + "jy": 1.3057688751494639e-17, + "jz": 1.5293971084510282e-07 }, "electron": { "particle_momentum_x": 2.0819392998019267e-25, diff --git a/Source/Utils/WarpXAlgorithmSelection.cpp b/Source/Utils/WarpXAlgorithmSelection.cpp index d9cd5c138a8..ed8186a325c 100644 --- a/Source/Utils/WarpXAlgorithmSelection.cpp +++ b/Source/Utils/WarpXAlgorithmSelection.cpp @@ -158,7 +158,8 @@ GetAlgorithmInteger(const amrex::ParmParse& pp, const char* pp_search_key ){ } else if (0 == std::strcmp(pp_search_key, "current_deposition")) { algo_to_int = current_deposition_algo_to_int; if (WarpX::electromagnetic_solver_id == ElectromagneticSolverAlgo::PSATD || - WarpX::electromagnetic_solver_id == ElectromagneticSolverAlgo::HybridPIC) + WarpX::electromagnetic_solver_id == ElectromagneticSolverAlgo::HybridPIC || + WarpX::electrostatic_solver_id != ElectrostaticSolverAlgo::None) algo_to_int["default"] = CurrentDepositionAlgo::Direct; } else if (0 == std::strcmp(pp_search_key, "charge_deposition")) { algo_to_int = charge_deposition_algo_to_int; diff --git a/Source/WarpX.cpp b/Source/WarpX.cpp index 6be8d517775..2df53dc6d2c 100644 --- a/Source/WarpX.cpp +++ b/Source/WarpX.cpp @@ -1130,7 +1130,8 @@ WarpX::ReadParameters () } #endif - // note: current_deposition must be set after maxwell_solver is already determined, + // note: current_deposition must be set after maxwell_solver (electromagnetic_solver_id) or + // do_electrostatic (electrostatic_solver_id) are already determined, // because its default depends on the solver selection current_deposition_algo = GetAlgorithmInteger(pp_algo, "current_deposition"); charge_deposition_algo = GetAlgorithmInteger(pp_algo, "charge_deposition"); From a121b2aa9c51848a31c572e5a56c33882436f404 Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Sat, 14 Oct 2023 00:15:44 -0700 Subject: [PATCH 03/25] Python: Clean Out Old Bindings (#4233) * libwarpx: clean out old bindings * Docs: Update Wrappers * Update Tests: `getistep`, `set_potential_on_eb`, `deposit_charge_density` * getistep: lev argument * Apply suggestions from code review Co-authored-by: Roelof Groenewald <40245517+roelof-groenewald@users.noreply.github.com> * Fix capacitive_discharge & ohm_solver_ion_beam_instability * Update `ParticleContainerWrapper` to `ParticleBoundaryBufferWrapper` in docs --------- Co-authored-by: Roelof Groenewald <40245517+roelof-groenewald@users.noreply.github.com> --- Docs/source/usage/python.rst | 80 +++--- .../capacitive_discharge/PICMI_inputs_1d.py | 12 +- .../capacitive_discharge/PICMI_inputs_2d.py | 2 +- .../PICMI_inputs_3d.py | 2 +- Examples/Tests/langmuir/PICMI_inputs_rz.py | 2 +- .../Tests/ohm_solver_EM_modes/PICMI_inputs.py | 8 +- .../PICMI_inputs.py | 16 +- .../PICMI_inputs.py | 25 +- .../PICMI_inputs.py | 11 +- .../PICMI_inputs_scrape.py | 4 +- .../particle_data_python/PICMI_inputs_2d.py | 4 +- .../pass_mpi_communicator/PICMI_inputs_2d.py | 2 +- .../Tests/restart/PICMI_inputs_id_cpu_read.py | 2 +- .../PICMI_inputs_runtime_component_analyze.py | 2 +- .../restart_eb/PICMI_inputs_restart_eb.py | 2 +- Python/pywarpx/WarpX.py | 2 +- Python/pywarpx/_libwarpx.py | 234 ------------------ Python/pywarpx/particle_containers.py | 61 +++++ Source/Python/CMakeLists.txt | 3 - Source/Python/Make.package | 1 - Source/Python/WarpXWrappers.H | 80 ------ Source/Python/WarpXWrappers.cpp | 172 ------------- 22 files changed, 159 insertions(+), 568 deletions(-) delete mode 100644 Source/Python/WarpXWrappers.H delete mode 100644 Source/Python/WarpXWrappers.cpp diff --git a/Docs/source/usage/python.rst b/Docs/source/usage/python.rst index 90015a85b9a..dd44c4098fd 100644 --- a/Docs/source/usage/python.rst +++ b/Docs/source/usage/python.rst @@ -14,7 +14,7 @@ defining the simulation time, field solver, registered species, etc. .. _usage-picmi-parameters: Classes ----------- +------- Simulation and grid setup ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -222,6 +222,8 @@ where ```` is the number of MPI ranks used, and ```` is the name of the script. +.. _usage-picmi-extend: + Extending a Simulation from Python ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -235,85 +237,101 @@ Places in the WarpX loop where callbacks are available include: ``afterinit``, ``beforecollisions``, ``aftercollisions``, ``beforeEsolve``, ``afterEsolve``, ``beforeInitEsolve``, ``afterInitEsolve``, ``beforedeposition``, ``afterdeposition``, ``beforestep``, ``afterstep``, ``afterdiagnostics``,``afterrestart`` and ``oncheckpointsignal``. -See the examples in *Examples/Tests/ParticleDataPython* for references on how to use +See the examples in ``Examples/Tests/ParticleDataPython`` for references on how to use ``callbacks``. There are several "hooks" available via the ``libwarpx`` shared library to access and manipulate simulation objects (particles, fields and memory buffers) as well as general properties (such as processor number). These "hooks" are accessible through the `Simulation.extension` object. -.. autofunction:: pywarpx.picmi.Simulation.extension.getNProcs +An important object is ``Simulation.extension.warpx``, which is available during simulation run. +This object is the Python equivalent to the central ``WarpX`` simulation class and provides access to +field ``MultiFab`` and ``ParticleContainer`` data. -.. autofunction:: pywarpx.picmi.Simulation.extension.getMyProc +.. function:: pywarpx.picmi.Simulation.extension.warpx.getistep -.. autofunction:: pywarpx.picmi.Simulation.extension.get_nattr +.. function:: pywarpx.picmi.Simulation.extension.warpx.gett_new -.. autofunction:: pywarpx.picmi.Simulation.extension.get_nattr_species +.. function:: pywarpx.picmi.Simulation.extension.warpx.evolve -.. autofunction:: pywarpx.picmi.Simulation.extension.getistep +.. autofunction:: pywarpx.picmi.Simulation.extension.finalize -.. autofunction:: pywarpx.picmi.Simulation.extension.gett_new +These and other classes are provided through `pyAMReX `__. +After the simulation is initialized, pyAMReX can be accessed via -.. autofunction:: pywarpx.picmi.Simulation.extension.evolve +.. code-block:: python -.. autofunction:: pywarpx.picmi.Simulation.extension.finalize + from pywarpx import picmi, libwarpx + + # ... simulation definition ... + + # equivalent to + # import amrex.space3d as amr + # for a 3D simulation + amr = libwarpx.amr # picks the right 1d, 2d or 3d variant + +.. function:: amr.ParallelDescriptor.NProcs() -.. autofunction:: pywarpx.picmi.Simulation.extension.getProbLo +.. function:: amr.ParallelDescriptor.MyProc() -.. autofunction:: pywarpx.picmi.Simulation.extension.getProbHi +.. function:: amr.ParallelDescriptor.IOProcessor() -.. autofunction:: pywarpx.picmi.Simulation.extension.getCellSize +.. function:: amr.ParallelDescriptor.IOProcessorNumber() Particles can be added to the simulation at specific positions and with specific attribute values: -.. autofunction:: pywarpx.picmi.Simulation.extension.add_particles +.. code-block:: python + + from pywarpx import particle_containers, picmi + + # ... + + electron_wrapper = particle_containers.ParticleContainerWrapper("electrons") + +.. autofunction:: pywarpx.particle_containers.ParticleContainerWrapper.add_particles Properties of the particles already in the simulation can be obtained with various functions. -.. autofunction:: pywarpx.picmi.Simulation.extension.get_particle_count +.. autofunction:: pywarpx.particle_containers.ParticleContainerWrapper.get_particle_count -.. autofunction:: pywarpx.picmi.Simulation.extension.get_particle_structs +.. autofunction:: pywarpx.particle_containers.ParticleContainerWrapper.get_particle_structs -.. autofunction:: pywarpx.picmi.Simulation.extension.get_particle_arrays +.. autofunction:: pywarpx.particle_containers.ParticleContainerWrapper.get_particle_arrays The ``get_particle_structs()`` and ``get_particle_arrays()`` functions are called by several utility functions of the form ``get_particle_{comp_name}`` where ``comp_name`` is one of ``x``, ``y``, ``z``, ``r``, ``theta``, ``id``, ``cpu``, ``weight``, ``ux``, ``uy`` or ``uz``. -The index of some specific component of the particle data can be obtained. - -.. autofunction:: pywarpx.picmi.Simulation.extension.get_particle_comp_index - New components can be added via Python. -.. autofunction:: pywarpx.picmi.Simulation.extension.add_real_comp +.. autofunction:: pywarpx.particle_containers.ParticleContainerWrapper.add_real_comp Various diagnostics are also accessible from Python. This includes getting the deposited or total charge density from a given species as well as accessing the scraped particle buffer. See the example in -*Examples/Tests/ParticleBoudaryScrape* for a reference on how to interact +``Examples/Tests/ParticleBoundaryScrape`` for a reference on how to interact with scraped particle data. -.. autofunction:: pywarpx.picmi.Simulation.extension.get_species_charge_sum +.. autofunction:: pywarpx.particle_containers.ParticleContainerWrapper.get_species_charge_sum -.. autofunction:: pywarpx.picmi.Simulation.extension.depositChargeDensity +.. autofunction:: pywarpx.particle_containers.ParticleContainerWrapper.deposit_charge_density -.. autofunction:: pywarpx.picmi.Simulation.extension.get_particle_boundary_buffer_size +.. autofunction:: pywarpx.particle_containers.ParticleBoundaryBufferWrapper.get_particle_boundary_buffer_size -.. autofunction:: pywarpx.picmi.Simulation.extension.get_particle_boundary_buffer_structs +.. autofunction:: pywarpx.particle_containers.ParticleBoundaryBufferWrapper.get_particle_boundary_buffer_structs -.. autofunction:: pywarpx.picmi.Simulation.extension.get_particle_boundary_buffer +.. autofunction:: pywarpx.particle_containers.ParticleBoundaryBufferWrapper.get_particle_boundary_buffer -.. autofunction:: pywarpx.picmi.Simulation.extension.clearParticleBoundaryBuffer +.. autofunction:: pywarpx.particle_containers.ParticleBoundaryBufferWrapper.clearParticleBoundaryBuffer The embedded boundary conditions can be modified when using the electrostatic solver. -.. autofunction:: pywarpx.picmi.Simulation.extension.set_potential_EB +.. function:: pywarpx.picmi.Simulation.extension.warpx.set_potential_on_eb -Using Python input as a preprocessor +Using Python Input as a Preprocessor ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ In this case, only the pure Python version needs to be installed, as described :ref:`here `. diff --git a/Examples/Physics_applications/capacitive_discharge/PICMI_inputs_1d.py b/Examples/Physics_applications/capacitive_discharge/PICMI_inputs_1d.py index dc9428229a4..0c6f9828543 100644 --- a/Examples/Physics_applications/capacitive_discharge/PICMI_inputs_1d.py +++ b/Examples/Physics_applications/capacitive_discharge/PICMI_inputs_1d.py @@ -11,7 +11,7 @@ from scipy.sparse import csc_matrix from scipy.sparse import linalg as sla -from pywarpx import callbacks, fields, particle_containers, picmi +from pywarpx import callbacks, fields, libwarpx, particle_containers, picmi constants = picmi.constants @@ -108,7 +108,7 @@ def solve(self): calculating phi from rho.""" left_voltage = 0.0 - t = self.sim_ext.gett_new() + t = self.sim.extension.warpx.gett_new(0) right_voltage = eval(self.right_voltage) # Construct b vector @@ -300,6 +300,7 @@ def setup_run(self): warpx_load_balance_intervals=self.max_steps//5000, verbose=self.test ) + self.solver.sim = self.sim self.sim.add_species( self.electrons, @@ -313,7 +314,6 @@ def setup_run(self): n_macroparticle_per_cell=[self.seed_nppc], grid=self.grid ) ) - self.solver.sim_ext = self.sim.extension ####################################################################### # Add diagnostics for the CI test to be happy # @@ -325,6 +325,7 @@ def setup_run(self): file_prefix = 'Python_background_mcc_1d_tridiag_plt' particle_diag = picmi.ParticleDiagnostic( + species=[self.electrons, self.ions], name='diag1', period=0, write_dir='.', @@ -343,7 +344,8 @@ def setup_run(self): def _get_rho_ions(self): # deposit the ion density in rho_fp - self.sim.extension.depositChargeDensity('he_ions', 0) + he_ions_wrapper = particle_containers.ParticleContainerWrapper('he_ions') + he_ions_wrapper.deposit_charge_density(level=0) rho_data = self.rho_wrapper[...] self.ion_density_array += rho_data / constants.q_e / self.diag_steps @@ -357,7 +359,7 @@ def run_sim(self): self.sim.step(self.diag_steps) - if self.sim.extension.getMyProc() == 0: + if libwarpx.amr.ParallelDescriptor.MyProc() == 0: np.save(f'ion_density_case_{self.n+1}.npy', self.ion_density_array) # query the particle z-coordinates if this is run during CI testing diff --git a/Examples/Physics_applications/capacitive_discharge/PICMI_inputs_2d.py b/Examples/Physics_applications/capacitive_discharge/PICMI_inputs_2d.py index fd66ba34a04..71e1070ef2f 100755 --- a/Examples/Physics_applications/capacitive_discharge/PICMI_inputs_2d.py +++ b/Examples/Physics_applications/capacitive_discharge/PICMI_inputs_2d.py @@ -177,7 +177,7 @@ def solve(self): calculating phi from rho.""" right_voltage = eval( self.right_voltage, - {'t':sim.extension.gett_new(0), 'sin':np.sin, 'pi':np.pi} + {'t': sim.extension.warpx.gett_new(0), 'sin': np.sin, 'pi': np.pi} ) left_voltage = 0.0 diff --git a/Examples/Tests/electrostatic_sphere_eb/PICMI_inputs_3d.py b/Examples/Tests/electrostatic_sphere_eb/PICMI_inputs_3d.py index 4da7feeff3a..55fbc87bd9e 100755 --- a/Examples/Tests/electrostatic_sphere_eb/PICMI_inputs_3d.py +++ b/Examples/Tests/electrostatic_sphere_eb/PICMI_inputs_3d.py @@ -119,6 +119,6 @@ sim.step(1) -sim.extension.set_potential_EB("2.") +sim.extension.warpx.set_potential_on_eb("2.") sim.step(1) diff --git a/Examples/Tests/langmuir/PICMI_inputs_rz.py b/Examples/Tests/langmuir/PICMI_inputs_rz.py index 018303a9611..8328aba5185 100755 --- a/Examples/Tests/langmuir/PICMI_inputs_rz.py +++ b/Examples/Tests/langmuir/PICMI_inputs_rz.py @@ -178,7 +178,7 @@ def calcEz( z, r, k0, w0, wp, t, epsilons) : return( Ez_array ) # Current time of the simulation -t0 = sim.extension.gett_new(0) +t0 = sim.extension.warpx.gett_new(0) # Get the raw field data. Note that these are the real and imaginary # parts of the fields for each azimuthal mode. diff --git a/Examples/Tests/ohm_solver_EM_modes/PICMI_inputs.py b/Examples/Tests/ohm_solver_EM_modes/PICMI_inputs.py index b51d291e478..51dbb53ab43 100644 --- a/Examples/Tests/ohm_solver_EM_modes/PICMI_inputs.py +++ b/Examples/Tests/ohm_solver_EM_modes/PICMI_inputs.py @@ -15,7 +15,7 @@ from mpi4py import MPI as mpi import numpy as np -from pywarpx import callbacks, fields, picmi +from pywarpx import callbacks, fields, libwarpx, picmi constants = picmi.constants @@ -25,8 +25,6 @@ warpx_serialize_initial_conditions=True, verbose=0 ) -# make a shorthand for simulation.extension since we use it a lot -sim_ext = simulation.extension class EMModes(object): @@ -318,7 +316,7 @@ def _record_average_fields(self): similar format as the reduced diagnostic so that the same analysis script can be used regardless of the simulation dimension. """ - step = sim_ext.getistep() - 1 + step = simulation.extension.warpx.getistep(lev=0) - 1 if step % self.diag_steps != 0: return @@ -327,7 +325,7 @@ def _record_average_fields(self): By_warpx = fields.BxWrapper()[...] Ez_warpx = fields.EzWrapper()[...] - if sim_ext.getMyProc() != 0: + if libwarpx.amr.ParallelDescriptor.MyProc() != 0: return t = step * self.dt diff --git a/Examples/Tests/ohm_solver_ion_Landau_damping/PICMI_inputs.py b/Examples/Tests/ohm_solver_ion_Landau_damping/PICMI_inputs.py index ecad73d381c..bd28f46b087 100644 --- a/Examples/Tests/ohm_solver_ion_Landau_damping/PICMI_inputs.py +++ b/Examples/Tests/ohm_solver_ion_Landau_damping/PICMI_inputs.py @@ -14,7 +14,7 @@ from mpi4py import MPI as mpi import numpy as np -from pywarpx import callbacks, fields, particle_containers, picmi +from pywarpx import callbacks, fields, libwarpx, particle_containers, picmi constants = picmi.constants @@ -22,9 +22,8 @@ simulation = picmi.Simulation( warpx_serialize_initial_conditions=True, - verbose=0) -# make a shorthand for simulation.extension since we use it a lot -sim_ext = simulation.extension + verbose=0 +) class IonLandauDamping(object): @@ -266,7 +265,8 @@ def setup_run(self): def text_diag(self): """Diagnostic function to print out timing data and particle numbers.""" - step = sim_ext.getistep(0) + step = simulation.extension.warpx.getistep(lev=0) - 1 + if step % (self.total_steps // 10) != 0: return @@ -290,7 +290,7 @@ def text_diag(self): "{step_rate:4.2f} steps/s" ) - if sim_ext.getMyProc() == 0: + if libwarpx.amr.ParallelDescriptor.MyProc() == 0: print(diag_string.format(**status_dict)) self.prev_time = time.time() @@ -301,14 +301,14 @@ def _record_average_fields(self): similar format as the reduced diagnostic so that the same analysis script can be used regardless of the simulation dimension. """ - step = sim_ext.getistep() - 1 + step = simulation.extension.warpx.getistep(lev=0) - 1 if step % self.diag_steps != 0: return Ez_warpx = fields.EzWrapper()[...] - if sim_ext.getMyProc() != 0: + if libwarpx.amr.ParallelDescriptor.MyProc() != 0: return t = step * self.dt diff --git a/Examples/Tests/ohm_solver_ion_beam_instability/PICMI_inputs.py b/Examples/Tests/ohm_solver_ion_beam_instability/PICMI_inputs.py index 21f55fb1166..79f268f6e3b 100644 --- a/Examples/Tests/ohm_solver_ion_beam_instability/PICMI_inputs.py +++ b/Examples/Tests/ohm_solver_ion_beam_instability/PICMI_inputs.py @@ -15,7 +15,7 @@ from mpi4py import MPI as mpi import numpy as np -from pywarpx import callbacks, fields, particle_containers, picmi +from pywarpx import callbacks, fields, libwarpx, particle_containers, picmi constants = picmi.constants @@ -23,9 +23,8 @@ simulation = picmi.Simulation( warpx_serialize_initial_conditions=True, - verbose=0) -# make a shorthand for simulation.extension since we use it a lot -sim_ext = simulation.extension + verbose=0 +) class HybridPICBeamInstability(object): @@ -336,13 +335,17 @@ def _create_data_arrays(self): self.start_time = self.prev_time self.prev_step = 0 - if sim_ext.getMyProc() == 0: + if libwarpx.amr.ParallelDescriptor.MyProc() == 0: # allocate arrays for storing energy values self.energy_vals = np.zeros((self.total_steps//self.diag_steps, 4)) def text_diag(self): """Diagnostic function to print out timing data and particle numbers.""" - step = sim_ext.getistep(0) + step = simulation.extension.warpx.getistep(lev=0) - 1 + + if not hasattr(self, "prev_time"): + self._create_data_arrays() + if step % (self.total_steps // 10) != 0: return @@ -368,7 +371,7 @@ def text_diag(self): "{step_rate:4.2f} steps/s" ) - if sim_ext.getMyProc() == 0: + if libwarpx.amr.ParallelDescriptor.MyProc() == 0: print(diag_string.format(**status_dict)) self.prev_time = time.time() @@ -377,8 +380,8 @@ def text_diag(self): def energy_diagnostic(self): """Diangostic to get the total, magnetic and kinetic energies in the simulation.""" + step = simulation.extension.warpx.getistep(lev=0) - 1 - step = sim_ext.getistep(0) if step % self.diag_steps != 1: return @@ -391,7 +394,7 @@ def energy_diagnostic(self): Ec_par, Ec_perp = self._get_kinetic_energy(self.ion_container_wrapper) Eb_par, Eb_perp = self._get_kinetic_energy(self.beam_ion_container_wrapper) - if sim_ext.getMyProc() != 0: + if libwarpx.amr.ParallelDescriptor.MyProc() != 0: return self.energy_vals[idx, 0] = Ec_par @@ -426,14 +429,14 @@ def _record_average_fields(self): similar format as the reduced diagnostic so that the same analysis script can be used regardless of the simulation dimension. """ - step = sim_ext.getistep() - 1 + step = simulation.extension.warpx.getistep(lev=0) - 1 if step % self.diag_steps != 0: return By_warpx = fields.BxWrapper()[...] - if sim_ext.getMyProc() != 0: + if libwarpx.amr.ParallelDescriptor.MyProc() != 0: return t = step * self.dt diff --git a/Examples/Tests/ohm_solver_magnetic_reconnection/PICMI_inputs.py b/Examples/Tests/ohm_solver_magnetic_reconnection/PICMI_inputs.py index bdeef96e0a6..143f1f3e82e 100644 --- a/Examples/Tests/ohm_solver_magnetic_reconnection/PICMI_inputs.py +++ b/Examples/Tests/ohm_solver_magnetic_reconnection/PICMI_inputs.py @@ -16,7 +16,7 @@ from mpi4py import MPI as mpi import numpy as np -from pywarpx import callbacks, fields, picmi +from pywarpx import callbacks, fields, libwarpx, picmi constants = picmi.constants @@ -24,9 +24,8 @@ simulation = picmi.Simulation( warpx_serialize_initial_conditions=True, - verbose=0) -# make a shorthand for simulation.extension since we use it a lot -sim_ext = simulation.extension + verbose=0 +) class ForceFreeSheetReconnection(object): @@ -306,7 +305,7 @@ def setup_run(self): def check_fields(self): - step = sim_ext.getistep() + step = simulation.extension.warpx.getistep(lev=0) - 1 if not (step == 1 or step%self.diag_steps == 0): return @@ -318,7 +317,7 @@ def check_fields(self): By = fields.ByFPWrapper(include_ghosts=False)[...] / self.B0 Bz = fields.BzFPWrapper(include_ghosts=False)[...] / self.B0 - if sim_ext.getMyProc() != 0: + if libwarpx.amr.ParallelDescriptor.MyProc() != 0: return # save the fields to file diff --git a/Examples/Tests/particle_boundary_scrape/PICMI_inputs_scrape.py b/Examples/Tests/particle_boundary_scrape/PICMI_inputs_scrape.py index 618b01b1c46..9871bdac655 100755 --- a/Examples/Tests/particle_boundary_scrape/PICMI_inputs_scrape.py +++ b/Examples/Tests/particle_boundary_scrape/PICMI_inputs_scrape.py @@ -5,7 +5,7 @@ import numpy as np -from pywarpx import particle_containers, picmi +from pywarpx import libwarpx, particle_containers, picmi ########################## # numerics parameters @@ -125,7 +125,7 @@ from mpi4py import MPI as mpi -my_id = sim.extension.getMyProc() +my_id = libwarpx.amr.ParallelDescriptor.MyProc() particle_buffer = particle_containers.ParticleBoundaryBufferWrapper() diff --git a/Examples/Tests/particle_data_python/PICMI_inputs_2d.py b/Examples/Tests/particle_data_python/PICMI_inputs_2d.py index 877824715cb..a4b7d9e134e 100755 --- a/Examples/Tests/particle_data_python/PICMI_inputs_2d.py +++ b/Examples/Tests/particle_data_python/PICMI_inputs_2d.py @@ -4,7 +4,7 @@ import numpy as np -from pywarpx import callbacks, particle_containers, picmi +from pywarpx import callbacks, libwarpx, particle_containers, picmi # Create the parser and add the argument parser = argparse.ArgumentParser() @@ -119,7 +119,7 @@ elec_wrapper = particle_containers.ParticleContainerWrapper('electrons') elec_wrapper.add_real_comp('newPid') -my_id = sim.extension.getMyProc() +my_id = libwarpx.amr.ParallelDescriptor.MyProc() def add_particles(): diff --git a/Examples/Tests/pass_mpi_communicator/PICMI_inputs_2d.py b/Examples/Tests/pass_mpi_communicator/PICMI_inputs_2d.py index b420b71c3aa..66f259da2ef 100755 --- a/Examples/Tests/pass_mpi_communicator/PICMI_inputs_2d.py +++ b/Examples/Tests/pass_mpi_communicator/PICMI_inputs_2d.py @@ -143,4 +143,4 @@ # verify that amrex proc ranks are offset by -1 from # world comm proc ranks -# assert sim.extension.getMyProc() == rank - 1 +# assert libwarpx.amr.ParallelDescriptor.MyProc() == rank - 1 diff --git a/Examples/Tests/restart/PICMI_inputs_id_cpu_read.py b/Examples/Tests/restart/PICMI_inputs_id_cpu_read.py index 8835e341fc7..d400924a378 100755 --- a/Examples/Tests/restart/PICMI_inputs_id_cpu_read.py +++ b/Examples/Tests/restart/PICMI_inputs_id_cpu_read.py @@ -150,7 +150,7 @@ def add_particles(): # simulation run ########################## -step_number = sim.extension.getistep(0) +step_number = sim.extension.warpx.getistep(lev=0) sim.step(max_steps) ############################################### diff --git a/Examples/Tests/restart/PICMI_inputs_runtime_component_analyze.py b/Examples/Tests/restart/PICMI_inputs_runtime_component_analyze.py index deb3c6060f6..706dedb6959 100755 --- a/Examples/Tests/restart/PICMI_inputs_runtime_component_analyze.py +++ b/Examples/Tests/restart/PICMI_inputs_runtime_component_analyze.py @@ -150,7 +150,7 @@ def add_particles(): # simulation run ########################## -step_number = sim.extension.getistep(0) +step_number = sim.extension.warpx.getistep(lev=0) sim.step(max_steps - 1 - step_number) ########################## diff --git a/Examples/Tests/restart_eb/PICMI_inputs_restart_eb.py b/Examples/Tests/restart_eb/PICMI_inputs_restart_eb.py index 7ef8e26d1d6..a4727053334 100755 --- a/Examples/Tests/restart_eb/PICMI_inputs_restart_eb.py +++ b/Examples/Tests/restart_eb/PICMI_inputs_restart_eb.py @@ -132,5 +132,5 @@ # simulation run ########################## -step_number = sim.extension.getistep(0) +step_number = sim.extension.warpx.getistep(lev=0) sim.step(max_steps - step_number) diff --git a/Python/pywarpx/WarpX.py b/Python/pywarpx/WarpX.py index cfa55641427..3fa59285f26 100644 --- a/Python/pywarpx/WarpX.py +++ b/Python/pywarpx/WarpX.py @@ -98,7 +98,7 @@ def init(self, mpi_comm=None, **kw): libwarpx.initialize(argv, mpi_comm=mpi_comm) def evolve(self, nsteps=-1): - libwarpx.evolve(nsteps) + libwarpx.warpx.evolve(nsteps) def finalize(self, finalize_mpi=1): libwarpx.finalize(finalize_mpi) diff --git a/Python/pywarpx/_libwarpx.py b/Python/pywarpx/_libwarpx.py index bf3ec0ded1a..fa2044d4240 100755 --- a/Python/pywarpx/_libwarpx.py +++ b/Python/pywarpx/_libwarpx.py @@ -14,7 +14,6 @@ import atexit import os -import sys import numpy as np @@ -114,46 +113,6 @@ def load_library(self): self.__version__ = self.libwarpx_so.__version__ - def getNProcs(self): - ''' - - Get the number of processors - - ''' - return self.libwarpx_so.getNProcs() - - def getMyProc(self): - ''' - - Get the number of the processor - - ''' - return self.libwarpx_so.getMyProc() - - def get_nattr(self): - ''' - - Get the number of extra particle attributes. - - ''' - # --- The -3 is because the comps include the velocites - return self.libwarpx_so.warpx_nComps() - 3 - - def get_nattr_species(self, species_name): - ''' - Get the number of real attributes for the given species. - - Parameters - ---------- - - species_name: str - Name of the species - ''' - warpx = self.libwarpx_so.get_instance() - mpc = warpx.multi_particle_container() - pc = mpc.get_particle_container_from_name(species_name) - return pc.num_real_comps() - def amrex_init(self, argv, mpi_comm=None): if mpi_comm is None: # or MPI is None: self.libwarpx_so.amrex_init(argv) @@ -162,9 +121,7 @@ def amrex_init(self, argv, mpi_comm=None): def initialize(self, argv=None, mpi_comm=None): ''' - Initialize WarpX and AMReX. Must be called before doing anything else. - ''' if argv is None: argv = sys.argv @@ -180,9 +137,7 @@ def initialize(self, argv=None, mpi_comm=None): def finalize(self, finalize_mpi=1): ''' - Call finalize for WarpX and AMReX. Registered to run at program exit. - ''' # TODO: simplify, part of pyAMReX already if self.initialized: @@ -194,193 +149,4 @@ def finalize(self, finalize_mpi=1): from pywarpx import callbacks callbacks.clear_all() - def getistep(self, level=0): - ''' - Get the current time step number for the specified level - - Parameter - --------- - - level : int - The refinement level to reference - ''' - - return self.warpx.getistep(level) - - def gett_new(self, level=0): - ''' - - Get the next time for the specified level. - - Parameters - ---------- - - level : int - The refinement level to reference - ''' - - return self.warpx.gett_new(level) - - def evolve(self, num_steps=-1): - ''' - Evolve the simulation for num_steps steps. If num_steps=-1, - the simulation will be run until the end as specified in the - inputs file. - - Parameters - ---------- - - num_steps: int - The number of steps to take - ''' - - self.warpx.evolve(num_steps) - - def getProbLo(self, direction, level=0): - ''' - Get the values of the lower domain boundary. - - Parameters - ---------- - - direction : int - Direction of interest - ''' - - assert 0 <= direction < self.dim, 'Inappropriate direction specified' - return self.warpx.Geom(level).ProbLo(direction) - - def getProbHi(self, direction, level=0): - ''' - Get the values of the upper domain boundary. - - Parameters - ---------- - - direction : int - Direction of interest - ''' - - assert 0 <= direction < self.dim, 'Inappropriate direction specified' - return self.warpx.Geom(level).ProbHi(direction) - - def getCellSize(self, direction, level=0): - ''' - Get the cell size in the given direction and on the given level. - - Parameters - ---------- - - direction : int - Direction of interest - - level : int - The refinement level to reference - ''' - - assert 0 <= direction < 3, 'Inappropriate direction specified' - assert 0 <= level and level <= self.libwarpx_so.warpx_finestLevel(), 'Inappropriate level specified' - return self.libwarpx_so.warpx_getCellSize(direction, level) - - #def get_sigma(self, direction): - # ''' - # - # Return the 'sigma' PML coefficients for the electric field - # in a given direction. - # - # ''' - # - # size = ctypes.c_int(0) - # data = self.libwarpx_so.warpx_getPMLSigma(direction, ctypes.byref(size)) - # arr = np.ctypeslib.as_array(data, (size.value,)) - # arr.setflags(write=1) - # return arr - # - # - #def get_sigma_star(self, direction): - # ''' - # - # Return the 'sigma*' PML coefficients for the magnetic field - # in the given direction. - # - # ''' - # - # size = ctypes.c_int(0) - # data = self.libwarpx_so.warpx_getPMLSigmaStar(direction, ctypes.byref(size)) - # arr = np.ctypeslib.as_array(data, (size.value,)) - # arr.setflags(write=1) - # return arr - # - # - #def compute_pml_factors(self, lev, dt): - # ''' - # - # This recomputes the PML coefficients for a given level, using the - # time step dt. This needs to be called after modifying the coefficients - # from Python. - # - # ''' - # - # self.libwarpx_so.warpx_ComputePMLFactors(lev, dt) - - - - def depositChargeDensity(self, species_name, level, clear_rho=True, sync_rho=True): - ''' - Deposit the specified species' charge density in rho_fp in order to - access that data via pywarpx.fields.RhoFPWrapper(). - - Parameters - ---------- - - species_name : str - The species name that will be deposited. - - level : int - Which AMR level to retrieve scraped particle data from. - - clear_rho : bool - If True, zero out rho_fp before deposition. - - sync_rho : bool - If True, perform MPI exchange and properly set boundary cells for rho_fp. - ''' - rho_fp = self.warpx.multifab(f'rho_fp[level={level}]') - - if rho_fp is None: - raise RuntimeError("Multifab `rho_fp` is not allocated.") - # ablastr::warn_manager::WMRecordWarning( - # "WarpXWrappers", "rho_fp is not allocated", - # ablastr::warn_manager::WarnPriority::low - # ); - # return - - if clear_rho: - rho_fp.set_val(0.0) - - # deposit the charge density from the desired species - mypc = self.warpx.multi_particle_container() - myspc = mypc.get_particle_container_from_name(species_name) - myspc.deposit_charge(rho_fp, level) - - if self.geometry_dim == 'rz': - self.warpx.apply_inverse_volume_scaling_to_charge_density(rho_fp, level) - - if sync_rho: - self.warpx.sync_rho() - - - def set_potential_EB(self, potential): - """ - Set the expression string for the embedded boundary potential - - Parameters - ---------- - - potential : str - The expression string - """ - self.warpx.set_potential_on_eb(potential) - - libwarpx = LibWarpX() diff --git a/Python/pywarpx/particle_containers.py b/Python/pywarpx/particle_containers.py index c74549bcdb7..64c97499a01 100644 --- a/Python/pywarpx/particle_containers.py +++ b/Python/pywarpx/particle_containers.py @@ -29,6 +29,7 @@ def __init__(self, species_name): mypc = libwarpx.warpx.multi_particle_container() self.particle_container = mypc.get_particle_container_from_name(self.name) + def add_particles(self, x=None, y=None, z=None, ux=None, uy=None, uz=None, w=None, unique_particles=True, **kwargs): ''' @@ -149,6 +150,7 @@ def add_particles(self, x=None, y=None, z=None, ux=None, uy=None, nattr, attr, nattr_int, attr_int, unique_particles ) + def get_particle_count(self, local=False): ''' Get the number of particles of this species in the simulation. @@ -169,6 +171,7 @@ def get_particle_count(self, local=False): return self.particle_container.total_number_of_particles(True, local) nps = property(get_particle_count) + def add_real_comp(self, pid_name, comm=True): ''' Add a real component to the particle data array. @@ -184,6 +187,7 @@ def add_real_comp(self, pid_name, comm=True): ''' self.particle_container.add_real_comp(pid_name, comm) + def get_particle_structs(self, level, copy_to_host=False): ''' This returns a list of numpy or cupy arrays containing the particle struct data @@ -233,6 +237,7 @@ def get_particle_structs(self, level, copy_to_host=False): particle_data.append(aos_arr) return particle_data + def get_particle_arrays(self, comp_name, level, copy_to_host=False): ''' This returns a list of numpy or cupy arrays containing the particle array data @@ -278,6 +283,7 @@ def get_particle_arrays(self, comp_name, level, copy_to_host=False): return data_array + def get_particle_id(self, level=0, copy_to_host=False): ''' Return a list of numpy or cupy arrays containing the particle 'id' @@ -302,6 +308,7 @@ def get_particle_id(self, level=0, copy_to_host=False): structs = self.get_particle_structs(level, copy_to_host) return [libwarpx.amr.unpack_ids(struct['cpuid']) for struct in structs] + def get_particle_cpu(self, level=0, copy_to_host=False): ''' Return a list of numpy or cupy arrays containing the particle 'cpu' @@ -326,6 +333,7 @@ def get_particle_cpu(self, level=0, copy_to_host=False): structs = self.get_particle_structs(level, copy_to_host) return [libwarpx.amr.unpack_cpus(struct['cpuid']) for struct in structs] + def get_particle_x(self, level=0, copy_to_host=False): ''' Return a list of numpy or cupy arrays containing the particle 'x' @@ -363,6 +371,7 @@ def get_particle_x(self, level=0, copy_to_host=False): raise Exception('get_particle_x: There is no x coordinate with 1D Cartesian') xp = property(get_particle_x) + def get_particle_y(self, level=0, copy_to_host=False): ''' Return a list of numpy or cupy arrays containing the particle 'y' @@ -400,6 +409,7 @@ def get_particle_y(self, level=0, copy_to_host=False): raise Exception('get_particle_y: There is no y coordinate with 1D or 2D Cartesian') yp = property(get_particle_y) + def get_particle_r(self, level=0, copy_to_host=False): ''' Return a list of numpy or cupy arrays containing the particle 'r' @@ -432,6 +442,7 @@ def get_particle_r(self, level=0, copy_to_host=False): raise Exception('get_particle_r: There is no r coordinate with 1D or 2D Cartesian') rp = property(get_particle_r) + def get_particle_theta(self, level=0, copy_to_host=False): ''' Return a list of numpy or cupy arrays containing the particle @@ -464,6 +475,7 @@ def get_particle_theta(self, level=0, copy_to_host=False): raise Exception('get_particle_theta: There is no theta coordinate with 1D or 2D Cartesian') thetap = property(get_particle_theta) + def get_particle_z(self, level=0, copy_to_host=False): ''' Return a list of numpy or cupy arrays containing the particle 'z' @@ -494,6 +506,7 @@ def get_particle_z(self, level=0, copy_to_host=False): return [struct['x'] for struct in structs] zp = property(get_particle_z) + def get_particle_weight(self, level=0, copy_to_host=False): ''' Return a list of numpy or cupy arrays containing the particle @@ -518,6 +531,7 @@ def get_particle_weight(self, level=0, copy_to_host=False): return self.get_particle_arrays('w', level, copy_to_host=copy_to_host) wp = property(get_particle_weight) + def get_particle_ux(self, level=0, copy_to_host=False): ''' Return a list of numpy or cupy arrays containing the particle @@ -542,6 +556,7 @@ def get_particle_ux(self, level=0, copy_to_host=False): return self.get_particle_arrays('ux', level, copy_to_host=copy_to_host) uxp = property(get_particle_ux) + def get_particle_uy(self, level=0, copy_to_host=False): ''' Return a list of numpy or cupy arrays containing the particle @@ -566,6 +581,7 @@ def get_particle_uy(self, level=0, copy_to_host=False): return self.get_particle_arrays('uy', level, copy_to_host=copy_to_host) uyp = property(get_particle_uy) + def get_particle_uz(self, level=0, copy_to_host=False): ''' Return a list of numpy or cupy arrays containing the particle @@ -591,6 +607,7 @@ def get_particle_uz(self, level=0, copy_to_host=False): return self.get_particle_arrays('uz', level, copy_to_host=copy_to_host) uzp = property(get_particle_uz) + def get_species_charge_sum(self, local=False): ''' Returns the total charge in the simulation due to the given species. @@ -606,31 +623,70 @@ def get_species_charge_sum(self, local=False): ctypes.c_char_p(species_name.encode('utf-8')), local ) + def getex(self): raise NotImplementedError('Particle E fields not supported') ex = property(getex) + def getey(self): raise NotImplementedError('Particle E fields not supported') ey = property(getey) + def getez(self): raise NotImplementedError('Particle E fields not supported') ez = property(getez) + def getbx(self): raise NotImplementedError('Particle B fields not supported') bx = property(getbx) + def getby(self): raise NotImplementedError('Particle B fields not supported') by = property(getby) + def getbz(self): raise NotImplementedError('Particle B fields not supported') bz = property(getbz) + def deposit_charge_density(self, level, clear_rho=True, sync_rho=True): + ''' + Deposit this species' charge density in rho_fp in order to + access that data via pywarpx.fields.RhoFPWrapper(). + Parameters + ---------- + species_name : str + The species name that will be deposited. + level : int + Which AMR level to retrieve scraped particle data from. + clear_rho : bool + If True, zero out rho_fp before deposition. + sync_rho : bool + If True, perform MPI exchange and properly set boundary cells for rho_fp. + ''' + rho_fp = libwarpx.warpx.multifab(f'rho_fp[level={level}]') + + if rho_fp is None: + raise RuntimeError("Multifab `rho_fp` is not allocated.") + + if clear_rho: + rho_fp.set_val(0.0) + + # deposit the charge density from the desired species + self.particle_container.deposit_charge(rho_fp, level) + + if libwarpx.geometry_dim == 'rz': + libwarpx.warpx.apply_inverse_volume_scaling_to_charge_density(rho_fp, level) + + if sync_rho: + libwarpx.warpx.sync_rho() + + class ParticleBoundaryBufferWrapper(object): """Wrapper around particle boundary buffer containers. This provides a convenient way to query data in the particle boundary @@ -640,6 +696,7 @@ class ParticleBoundaryBufferWrapper(object): def __init__(self): self.particle_buffer = libwarpx.warpx.get_particle_boundary_buffer() + def get_particle_boundary_buffer_size(self, species_name, boundary, local=False): ''' This returns the number of particles that have been scraped so far in the simulation @@ -664,6 +721,7 @@ def get_particle_boundary_buffer_size(self, species_name, boundary, local=False) local=local ) + def get_particle_boundary_buffer_structs(self, species_name, boundary, level): ''' This returns a list of numpy or cupy arrays containing the particle struct data @@ -707,6 +765,7 @@ def get_particle_boundary_buffer_structs(self, species_name, boundary, level): _libc.free(data) return particle_data + def get_particle_boundary_buffer(self, species_name, boundary, comp_name, level): ''' This returns a list of numpy or cupy arrays containing the particle array data @@ -755,6 +814,7 @@ def get_particle_boundary_buffer(self, species_name, boundary, comp_name, level) return data_array + def clear_buffer(self): ''' @@ -763,6 +823,7 @@ def clear_buffer(self): ''' self.particle_buffer.clear_particles() + def _get_boundary_number(self, boundary): ''' diff --git a/Source/Python/CMakeLists.txt b/Source/Python/CMakeLists.txt index 4b4be199c31..d976e3d2c05 100644 --- a/Source/Python/CMakeLists.txt +++ b/Source/Python/CMakeLists.txt @@ -8,9 +8,6 @@ foreach(D IN LISTS WarpX_DIMS) PRIVATE # callback hooks WarpX_py.cpp - - # legacy C wrapper APIs - WarpXWrappers.cpp ) if(WarpX_PYTHON) target_sources(pyWarpX_${SD} diff --git a/Source/Python/Make.package b/Source/Python/Make.package index 9f421456b40..f107fbbfaaa 100644 --- a/Source/Python/Make.package +++ b/Source/Python/Make.package @@ -1,4 +1,3 @@ -CEXE_sources += WarpXWrappers.cpp CEXE_sources += WarpX_py.cpp VPATH_LOCATIONS += $(WARPX_HOME)/Source/Python diff --git a/Source/Python/WarpXWrappers.H b/Source/Python/WarpXWrappers.H deleted file mode 100644 index d2d57445880..00000000000 --- a/Source/Python/WarpXWrappers.H +++ /dev/null @@ -1,80 +0,0 @@ -/* Copyright 2019 Andrew Myers, David Grote, Maxence Thevenet - * Remi Lehe, Weiqun Zhang - * - * This file is part of WarpX. - * - * This file is a legacy file and will be removed soon. - * Please do NOT add new bindings here! Please see the other files - * in this directory for the new pybind11-based bindings! - * - * License: BSD-3-Clause-LBNL - */ -#ifndef WARPX_WRAPPERS_H_ -#define WARPX_WRAPPERS_H_ - -#include "Particles/WarpXParticleContainer.H" -#include "Evolve/WarpXDtType.H" -#include -#include - -#ifdef AMREX_USE_MPI -# include -#endif - -#ifdef __cplusplus -extern "C" { -#endif - - int warpx_Real_size(); - int warpx_ParticleReal_size(); - - int warpx_nSpecies(); - - bool warpx_use_fdtd_nci_corr(); - - int warpx_galerkin_interpolation(); - - void amrex_init_with_inited_mpi (int argc, char* argv[], MPI_Comm mpicomm); - - typedef void(*WARPX_CALLBACK_PY_FUNC_0)(); - - void warpx_ConvertLabParamsToBoost(); - - void warpx_ReadBCParams(); - - void warpx_CheckGriddingForRZSpectral(); - - amrex::Real warpx_getCellSize(int dir, int lev); - - amrex::Real warpx_sumParticleCharge(const char* char_species_name, bool local); - - void warpx_ComputeDt (); - void warpx_MoveWindow (int step, bool move_j); - - void warpx_EvolveE (amrex::Real dt); - void warpx_EvolveB (amrex::Real dt, DtType a_dt_type); - void warpx_FillBoundaryE (); - void warpx_FillBoundaryB (); - void warpx_SyncCurrent ( - const amrex::Vector,3>>& J_fp, - const amrex::Vector,3>>& J_cp, - const amrex::Vector,3>>& J_buffer); - void warpx_UpdateAuxilaryData (); - void warpx_PushParticlesandDepose (amrex::Real cur_time); - - void warpx_setistep (int lev, int ii); - void warpx_sett_new (int lev, amrex::Real time); - amrex::Real warpx_getdt (int lev); - - int warpx_maxStep (); - amrex::Real warpx_stopTime (); - - int warpx_finestLevel (); - - void mypc_Redistribute (); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/Source/Python/WarpXWrappers.cpp b/Source/Python/WarpXWrappers.cpp deleted file mode 100644 index 44820dd1f53..00000000000 --- a/Source/Python/WarpXWrappers.cpp +++ /dev/null @@ -1,172 +0,0 @@ -/* Copyright 2019 Andrew Myers, Axel Huebl, David Grote - * Luca Fedeli, Maxence Thevenet, Remi Lehe - * Weiqun Zhang - * - * This file is part of WarpX. - * - * License: BSD-3-Clause-LBNL - */ -#include "BoundaryConditions/PML.H" -#include "FieldSolver/FiniteDifferenceSolver/HybridPICModel/HybridPICModel.H" -#include "Initialization/WarpXAMReXInit.H" -#include "Particles/MultiParticleContainer.H" -#include "Particles/ParticleBoundaryBuffer.H" -#include "Particles/WarpXParticleContainer.H" -#include "Utils/WarpXProfilerWrapper.H" -#include "Utils/WarpXUtil.H" -#include "WarpX.H" -#include "WarpXWrappers.H" -#include "WarpX_py.H" - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - - int warpx_Real_size() - { - return (int)sizeof(amrex::Real); - } - - int warpx_ParticleReal_size() - { - return (int)sizeof(amrex::ParticleReal); - } - - int warpx_nSpecies() - { - const auto & mypc = WarpX::GetInstance().GetPartContainer(); - return mypc.nSpecies(); - } - - bool warpx_use_fdtd_nci_corr() - { - return WarpX::use_fdtd_nci_corr; - } - - int warpx_galerkin_interpolation() - { - return WarpX::galerkin_interpolation; - } - - void amrex_init_with_inited_mpi (int argc, char* argv[], MPI_Comm /* mpicomm */) - { - warpx::initialization::amrex_init(argc, argv, true); - } - - void warpx_ConvertLabParamsToBoost() - { - ConvertLabParamsToBoost(); - } - - void warpx_ReadBCParams() - { - ReadBCParams(); - } - - void warpx_CheckGriddingForRZSpectral() - { - CheckGriddingForRZSpectral(); - } - - amrex::Real warpx_getCellSize(int dir, int lev) { - const std::array& dx = WarpX::CellSize(lev); - return dx[dir]; - } - - amrex::Real warpx_sumParticleCharge(const char* char_species_name, const bool local) - { - auto & mypc = WarpX::GetInstance().GetPartContainer(); - const std::string species_name(char_species_name); - auto & myspc = mypc.GetParticleContainerFromName(species_name); - return myspc.sumParticleCharge(local); - } - - void warpx_ComputeDt () { - WarpX& warpx = WarpX::GetInstance(); - warpx.ComputeDt(); - } - void warpx_MoveWindow (int step,bool move_j) { - WarpX& warpx = WarpX::GetInstance(); - warpx.MoveWindow(step, move_j); - } - - void warpx_EvolveE (amrex::Real dt) { - WarpX& warpx = WarpX::GetInstance(); - warpx.EvolveE(dt); - } - void warpx_EvolveB (amrex::Real dt, DtType a_dt_type) { - WarpX& warpx = WarpX::GetInstance(); - warpx.EvolveB(dt, a_dt_type); - } - void warpx_FillBoundaryE () { - WarpX& warpx = WarpX::GetInstance(); - warpx.FillBoundaryE(warpx.getngEB()); - } - void warpx_FillBoundaryB () { - WarpX& warpx = WarpX::GetInstance(); - warpx.FillBoundaryB(warpx.getngEB()); - } - void warpx_SyncCurrent ( - const amrex::Vector,3>>& J_fp, - const amrex::Vector,3>>& J_cp, - const amrex::Vector,3>>& J_buffer) { - WarpX& warpx = WarpX::GetInstance(); - warpx.SyncCurrent(J_fp, J_cp, J_buffer); - } - void warpx_UpdateAuxilaryData () { - WarpX& warpx = WarpX::GetInstance(); - warpx.UpdateAuxilaryData(); - } - void warpx_PushParticlesandDepose (amrex::Real cur_time) { - WarpX& warpx = WarpX::GetInstance(); - warpx.PushParticlesandDepose(cur_time); - } - - void warpx_setistep (int lev, int ii) { - WarpX& warpx = WarpX::GetInstance(); - warpx.setistep(lev, ii); - } - void warpx_sett_new (int lev, amrex::Real time) { - WarpX& warpx = WarpX::GetInstance(); - warpx.sett_new(lev, time); - } - amrex::Real warpx_getdt (int lev) { - const WarpX& warpx = WarpX::GetInstance(); - return warpx.getdt(lev); - } - - int warpx_maxStep () { - const WarpX& warpx = WarpX::GetInstance(); - return warpx.maxStep(); - } - amrex::Real warpx_stopTime () { - const WarpX& warpx = WarpX::GetInstance(); - return warpx.stopTime(); - } - - int warpx_finestLevel () { - const WarpX& warpx = WarpX::GetInstance(); - return warpx.finestLevel(); - } - - void mypc_Redistribute () { - auto & mypc = WarpX::GetInstance().GetPartContainer(); - mypc.Redistribute(); - } From df9fbaa665eb7992f010f3339ae085550bb39a62 Mon Sep 17 00:00:00 2001 From: Roelof Groenewald <40245517+roelof-groenewald@users.noreply.github.com> Date: Mon, 16 Oct 2023 13:26:04 -0700 Subject: [PATCH 04/25] Restore `get_particle_boundary_buffer_structs` functionality from before pyamrex transition (#4367) --- Python/pywarpx/particle_containers.py | 64 +++++++++++++++++---------- 1 file changed, 41 insertions(+), 23 deletions(-) diff --git a/Python/pywarpx/particle_containers.py b/Python/pywarpx/particle_containers.py index 64c97499a01..c77781f6544 100644 --- a/Python/pywarpx/particle_containers.py +++ b/Python/pywarpx/particle_containers.py @@ -722,15 +722,23 @@ def get_particle_boundary_buffer_size(self, species_name, boundary, local=False) ) - def get_particle_boundary_buffer_structs(self, species_name, boundary, level): + def get_particle_boundary_buffer_structs( + self, species_name, boundary, level, copy_to_host=False + ): ''' This returns a list of numpy or cupy arrays containing the particle struct data for a species that has been scraped by a specific simulation boundary. The particle data is represented as a structured array and contains the particle 'x', 'y', 'z', and 'idcpu'. - The data for the arrays are not copied, but share the underlying - memory buffer with WarpX. The arrays are fully writeable. + Unless copy_to_host is specified, the data for the structs are + not copied, but share the underlying memory buffer with WarpX. The + arrays are fully writeable. + + Note that cupy does not support structs: + https://github.com/cupy/cupy/issues/2031 + and will return arrays of binary blobs for the AoS (DP: "|V24"). If copied + to host via copy_to_host, we correct for the right numpy AoS type. Parameters ---------- @@ -743,26 +751,38 @@ def get_particle_boundary_buffer_structs(self, species_name, boundary, level): form x/y/z_hi/lo or eb. level : int - Which AMR level to retrieve scraped particle data from. - ''' + The refinement level to reference (default=0) + + copy_to_host : bool + For GPU-enabled runs, one can either return the GPU + arrays (the default) or force a device-to-host copy. + + Returns + ------- - particles_per_tile = _LP_c_int() - num_tiles = ctypes.c_int(0) - data = self.libwarpx_so.warpx_getParticleBoundaryBufferStructs( - ctypes.c_char_p(species_name.encode('utf-8')), - self._get_boundary_number(boundary), level, - ctypes.byref(num_tiles), ctypes.byref(particles_per_tile) + List of arrays + The requested particle struct data + ''' + particle_container = self.particle_buffer.get_particle_container( + species_name, self._get_boundary_number(boundary) ) particle_data = [] - for i in range(num_tiles.value): - if particles_per_tile[i] == 0: - continue - arr = self._array1d_from_pointer(data[i], self._p_dtype, particles_per_tile[i]) - particle_data.append(arr) - - _libc.free(particles_per_tile) - _libc.free(data) + for pti in libwarpx.libwarpx_so.BoundaryBufferParIter(particle_container, level): + if copy_to_host: + particle_data.append(pti.aos().to_numpy(copy=True)) + else: + if libwarpx.amr.Config.have_gpu: + libwarpx.amr.Print( + "get_particle_structs: cupy does not yet support structs. " + "https://github.com/cupy/cupy/issues/2031" + "Did you mean copy_to_host=True?" + ) + xp, cupy_status = load_cupy() + if cupy_status is not None: + libwarpx.amr.Print(cupy_status) + aos_arr = xp.array(pti.aos(), copy=False) # void blobs for cupy + particle_data.append(aos_arr) return particle_data @@ -805,13 +825,11 @@ def get_particle_boundary_buffer(self, species_name, boundary, comp_name, level) soa = pti.soa() data_array.append(xp.array(soa.GetIntData(comp_idx), copy=False)) else: - mypc = libwarpx.warpx.multi_particle_container() - sim_part_container_wrapper = mypc.get_particle_container_from_name(species_name) - comp_idx = sim_part_container_wrapper.get_comp_index(comp_name) + container_wrapper = ParticleContainerWrapper(species_name) + comp_idx = container_wrapper.particle_container.get_comp_index(comp_name) for ii, pti in enumerate(libwarpx.libwarpx_so.BoundaryBufferParIter(part_container, level)): soa = pti.soa() data_array.append(xp.array(soa.GetRealData(comp_idx), copy=False)) - return data_array From 363d00e63db46302f7f0eb9f3045968267c4e8a4 Mon Sep 17 00:00:00 2001 From: Luca Fedeli Date: Mon, 16 Oct 2023 23:10:45 +0200 Subject: [PATCH 05/25] Fix bug in clang-tidy configuration file (#4321) * fix issue in clang-tidy * address most of the issues found with clang-tidy * address issues found with clang-tidy * address issues found with clang-tidy * address issues found with clang-tidy * fix issues found with clang-tidy * fix issues found with clang-tidy * refactor variable name * fix residual issues found with clang-tidy * revert jn -> cyl_bessel change * cleaning * fix bug * fix issues found by clang-tidy in new code * address issues found by clang-tidy in new code * fixed issues * address residual issues found with clang-tidy --- .clang-tidy | 14 +- Source/BoundaryConditions/PML.cpp | 6 +- Source/Diagnostics/BTDiagnostics.cpp | 31 ++-- .../BoundaryScrapingDiagnostics.cpp | 2 +- .../BackTransformParticleFunctor.cpp | 2 +- .../ParticleReductionFunctor.cpp | 2 +- .../FlushFormats/FlushFormatOpenPMD.cpp | 5 +- .../FlushFormats/FlushFormatPlotfile.cpp | 2 +- Source/Diagnostics/FullDiagnostics.cpp | 7 +- Source/Diagnostics/ParticleIO.cpp | 2 +- .../Diagnostics/ReducedDiags/BeamRelevant.cpp | 4 +- .../ReducedDiags/ColliderRelevant.cpp | 4 +- .../Diagnostics/ReducedDiags/FieldProbe.cpp | 2 +- .../FieldProbeParticleContainer.cpp | 2 +- .../ReducedDiags/LoadBalanceCosts.cpp | 12 +- .../ReducedDiags/ParticleHistogram.cpp | 4 +- .../Diagnostics/ReducedDiags/RhoMaximum.cpp | 2 +- Source/Diagnostics/WarpXOpenPMD.cpp | 18 +-- Source/Evolve/WarpXEvolve.cpp | 4 +- .../ApplySilverMuellerBoundary.cpp | 2 +- .../FiniteDifferenceSolver/ComputeDivE.cpp | 10 +- .../FiniteDifferenceSolver/EvolveB.cpp | 24 +-- .../FiniteDifferenceSolver/EvolveBPML.cpp | 6 +- .../FiniteDifferenceSolver/EvolveE.cpp | 20 +-- .../FiniteDifferenceSolver/EvolveECTRho.cpp | 4 +- .../FiniteDifferenceSolver/EvolveEPML.cpp | 6 +- .../FiniteDifferenceSolver/EvolveF.cpp | 10 +- .../FiniteDifferenceSolver/EvolveFPML.cpp | 6 +- .../FiniteDifferenceSolver/EvolveG.cpp | 6 +- .../HybridPICModel/HybridPICModel.H | 2 +- .../HybridPICSolveE.cpp | 24 +-- .../MacroscopicEvolveE.cpp | 6 +- .../SpectralSolver/SpectralBinomialFilter.cpp | 4 +- .../SpectralSolver/SpectralFieldData.cpp | 12 +- .../SpectralSolver/SpectralFieldDataRZ.cpp | 32 ++-- .../SpectralHankelTransform/BesselRoots.cpp | 16 +- .../HankelTransform.cpp | 7 +- .../SpectralSolver/SpectralKSpace.cpp | 10 +- Source/FieldSolver/WarpXPushFieldsEM.cpp | 18 +-- .../FieldSolver/WarpXPushFieldsHybridPIC.cpp | 4 +- Source/FieldSolver/WarpX_FDTD.H | 7 +- Source/Filter/BilinearFilter.cpp | 4 +- Source/Filter/Filter.cpp | 8 +- Source/Fluids/MultiFluidContainer.H | 2 +- Source/Fluids/MusclHancockUtils.H | 149 +++++++++++------- Source/Fluids/WarpXFluidContainer.cpp | 88 +++++------ Source/Initialization/InjectorMomentum.H | 8 +- Source/Initialization/PlasmaInjector.cpp | 4 +- Source/Initialization/WarpXInitData.cpp | 38 ++--- .../LaserProfileFromFile.cpp | 76 +++++---- Source/Parallelization/GuardCellManager.cpp | 2 +- .../BackgroundMCC/BackgroundMCCCollision.cpp | 28 ++-- .../BackgroundMCC/ImpactIonization.H | 6 +- .../Collision/BackgroundMCC/MCCProcess.cpp | 2 +- .../BackgroundStopping/BackgroundStopping.cpp | 4 +- .../BinaryCollision/BinaryCollision.H | 12 +- .../Coulomb/ElasticCollisionPerez.H | 24 +-- .../NuclearFusion/NuclearFusionFunc.H | 31 ++-- .../ProtonBoronFusionInitializeMomentum.H | 42 ++--- .../BinaryCollision/ParticleCreationFunc.H | 10 +- .../BreitWheelerEngineWrapper.cpp | 4 +- .../QEDInternals/QuantumSyncEngineWrapper.cpp | 4 +- Source/Particles/Gather/GetExternalFields.H | 2 +- Source/Particles/Gather/GetExternalFields.cpp | 4 +- Source/Particles/LaserParticleContainer.cpp | 18 ++- Source/Particles/MultiParticleContainer.H | 10 +- Source/Particles/MultiParticleContainer.cpp | 28 ++-- Source/Particles/ParticleBoundaryBuffer.H | 2 +- Source/Particles/ParticleBoundaryBuffer.cpp | 12 +- .../Particles/ParticleCreation/SmartUtils.H | 2 +- .../Particles/PhysicalParticleContainer.cpp | 59 ++++--- Source/Particles/Pusher/CopyParticleAttribs.H | 4 +- Source/Particles/Pusher/GetAndSetPosition.H | 12 +- .../Particles/Resampling/LevelingThinning.cpp | 4 +- Source/Particles/WarpXParticleContainer.H | 2 +- Source/Particles/WarpXParticleContainer.cpp | 24 +-- Source/Utils/Parser/IntervalsParser.cpp | 4 +- Source/Utils/Parser/ParserUtils.H | 30 ++-- Source/Utils/ParticleUtils.H | 4 +- Source/Utils/WarpXMovingWindow.cpp | 7 +- Source/WarpX.cpp | 32 ++-- Source/ablastr/fields/PoissonSolver.H | 12 +- Source/ablastr/fields/VectorPoissonSolver.H | 2 +- Source/ablastr/utils/SignalHandling.cpp | 2 +- Source/ablastr/utils/timer/Timer.H | 10 +- Source/ablastr/utils/timer/Timer.cpp | 4 +- 86 files changed, 633 insertions(+), 564 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index f40dd987add..2d45d750ddc 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,10 +1,11 @@ -Checks: '-*, - bugprone-* +Checks: ' + -*, + bugprone-*, -bugprone-easily-swappable-parameters, -bugprone-implicit-widening-of-multiplication-result, -bugprone-misplaced-widening-cast, -bugprone-unchecked-optional-access, - cert-* + cert-*, -cert-err58-cpp, cppcoreguidelines-avoid-goto, cppcoreguidelines-interfaces-global-init, @@ -74,9 +75,12 @@ Checks: '-*, ' CheckOptions: -- key: modernize-pass-by-value.ValuesOnly - value: 'true' +- key: bugprone-narrowing-conversions.WarnOnIntegerToFloatingPointNarrowingConversion + value: "false" - key: misc-definitions-in-headers.HeaderFileExtensions value: "H," +- key: modernize-pass-by-value.ValuesOnly + value: "true" + HeaderFilterRegex: 'Source[a-z_A-Z0-9\/]+\.H$' diff --git a/Source/BoundaryConditions/PML.cpp b/Source/BoundaryConditions/PML.cpp index 811d1aa469d..98f2b9fa546 100644 --- a/Source/BoundaryConditions/PML.cpp +++ b/Source/BoundaryConditions/PML.cpp @@ -877,7 +877,8 @@ PML::MakeBoxArray_single (const amrex::Box& regular_domain, const amrex::BoxArra const amrex::IntVect& do_pml_Hi) { BoxList bl; - for (int i = 0, N = grid_ba.size(); i < N; ++i) { + const auto grid_ba_size = static_cast(grid_ba.size()); + for (int i = 0; i < grid_ba_size; ++i) { Box const& b = grid_ba[i]; for (OrientationIter oit; oit.isValid(); ++oit) { // In 3d, a Box has 6 faces. This iterates over the 6 faces. @@ -926,7 +927,8 @@ PML::MakeBoxArray_multiple (const amrex::Geometry& geom, const amrex::BoxArray& } } BoxList bl; - for (int i = 0, N = grid_ba.size(); i < N; ++i) + const auto grid_ba_size = static_cast(grid_ba.size()); + for (int i = 0; i < grid_ba_size; ++i) { const Box& grid_bx = grid_ba[i]; const IntVect& grid_bx_sz = grid_bx.size(); diff --git a/Source/Diagnostics/BTDiagnostics.cpp b/Source/Diagnostics/BTDiagnostics.cpp index 34bd720be96..6f976d9ee11 100644 --- a/Source/Diagnostics/BTDiagnostics.cpp +++ b/Source/Diagnostics/BTDiagnostics.cpp @@ -394,7 +394,7 @@ BTDiagnostics::InitializeBufferData ( int i_buffer , int lev, bool restart) diag_dom.setLo( idim, warpx.Geom(lev).ProbLo(idim) + diag_ba.getCellCenteredBox(0).smallEnd(idim) * warpx.Geom(lev).CellSize(idim)); diag_dom.setHi( idim, warpx.Geom(lev).ProbLo(idim) + - (diag_ba.getCellCenteredBox( diag_ba.size()-1 ).bigEnd(idim) + 1) * warpx.Geom(lev).CellSize(idim)); + (diag_ba.getCellCenteredBox( static_cast(diag_ba.size()-1) ).bigEnd(idim) + 1) * warpx.Geom(lev).CellSize(idim)); } // Define buffer_domain in lab-frame for the i^th snapshot. @@ -561,7 +561,9 @@ BTDiagnostics::InitializeFieldFunctors (int lev) // Fill vector of cell-center functors for all field-components, namely, // Ex, Ey, Ez, Bx, By, Bz, jx, jy, jz, and rho are included in the // cell-center functors for BackTransform Diags - for (int comp=0, n=m_cell_center_functors.at(lev).size(); comp( + m_cell_center_functors.at(lev).size()); + for (int comp=0; comp(warpx.get_pointer_Efield_aux(lev, 0), lev, m_crse_ratio); } else if ( m_cellcenter_varnames[comp] == "Ey" ){ @@ -600,13 +602,14 @@ BTDiagnostics::UpdateVarnamesForRZopenPMD () const bool update_varnames = true; if (update_varnames) { - const int n_rz = ncomp * m_varnames_fields.size(); + const auto n_rz = ncomp * static_cast(m_varnames_fields.size()); m_varnames.clear(); m_varnames.reserve(n_rz); } // AddRZ modes to output names for the back-transformed data if (update_varnames) { - for (int comp=0, n=m_varnames_fields.size(); comp(m_varnames_fields.size()); + for (int comp=0; comp(m_cellcenter_varnames.size()); m_cellcenter_varnames.clear(); m_cellcenter_varnames.reserve(n_rz); - for (int comp=0, n=m_cellcenter_varnames_fields.size(); comp(m_cellcenter_varnames_fields.size()); + for (int comp=0; comp(m_cell_center_functors.at(lev).size()); + for (int comp=0; comp(warpx.get_pointer_Efield_aux(lev, 0), lev, m_crse_ratio, false, ncomp); } else if ( m_cellcenter_varnames_fields[comp] == "Et" ){ @@ -786,7 +791,8 @@ BTDiagnostics::PrepareFieldDataForOutput () // Call m_cell_center_functors->operator for (int lev = 0; lev < nmax_lev; ++lev) { int icomp_dst = 0; - for (int icomp = 0, n=m_cell_center_functors.at(lev).size(); icomp(m_cell_center_functors.at(lev).size()); + for (int icomp = 0; icomp 0; --lev) { ablastr::coarsen::sample::Coarsen(*m_cell_centered_data[lev - 1], *m_cell_centered_data[lev], 0, 0, - m_cellcenter_varnames.size(), 0, WarpX::RefRatio(lev-1) ); + static_cast(m_cellcenter_varnames.size()), 0, WarpX::RefRatio(lev-1) ); } const int num_BT_functors = 1; @@ -901,7 +907,7 @@ BTDiagnostics::DefineFieldBufferMultiFab (const int i_buffer, const int lev) // Unlike FullDiagnostics, "m_format == sensei" option is not included here. const int ngrow = 0; m_mf_output[i_buffer][lev] = amrex::MultiFab( buffer_ba, buffer_dmap, - m_varnames.size(), ngrow ); + static_cast(m_varnames.size()), ngrow ); m_mf_output[i_buffer][lev].setVal(0.); amrex::IntVect ref_ratio = amrex::IntVect(1); @@ -915,7 +921,7 @@ BTDiagnostics::DefineFieldBufferMultiFab (const int i_buffer, const int lev) - m_snapshot_box[i_buffer].smallEnd(idim) ) * cellsize; const amrex::Real buffer_hi = m_snapshot_domain_lab[i_buffer].lo(idim) - + ( buffer_ba.getCellCenteredBox( buffer_ba.size()-1 ).bigEnd(idim) + + ( buffer_ba.getCellCenteredBox( static_cast(buffer_ba.size()-1) ).bigEnd(idim) - m_snapshot_box[i_buffer].smallEnd(idim) + 1 ) * cellsize; m_buffer_domain_lab[i_buffer].setLo(idim, buffer_lo); @@ -1482,7 +1488,8 @@ void BTDiagnostics::UpdateTotalParticlesFlushed(int i_buffer) { for (int isp = 0; isp < m_totalParticles_flushed_already[i_buffer].size(); ++isp) { - m_totalParticles_flushed_already[i_buffer][isp] += m_particles_buffer[i_buffer][isp]->TotalNumberOfParticles(); + m_totalParticles_flushed_already[i_buffer][isp] += static_cast( + m_particles_buffer[i_buffer][isp]->TotalNumberOfParticles()); } } diff --git a/Source/Diagnostics/BoundaryScrapingDiagnostics.cpp b/Source/Diagnostics/BoundaryScrapingDiagnostics.cpp index a9b75481bb7..a3ea097352c 100644 --- a/Source/Diagnostics/BoundaryScrapingDiagnostics.cpp +++ b/Source/Diagnostics/BoundaryScrapingDiagnostics.cpp @@ -105,7 +105,7 @@ BoundaryScrapingDiagnostics::InitializeParticleBuffer () // Initialize total number of particles flushed m_totalParticles_flushed_already.resize(m_num_buffers); for (int i_buffer = 0; i_buffer < m_num_buffers; ++i_buffer) { - int const n_species = m_output_species_names.size(); + int const n_species = static_cast(m_output_species_names.size()); m_totalParticles_flushed_already[i_buffer].resize(n_species); for (int i_species=0; i_species(pc_dst.TotalNumberOfParticles()); } diff --git a/Source/Diagnostics/ComputeDiagFunctors/ParticleReductionFunctor.cpp b/Source/Diagnostics/ComputeDiagFunctors/ParticleReductionFunctor.cpp index 203872b1372..60b62181c4b 100644 --- a/Source/Diagnostics/ComputeDiagFunctors/ParticleReductionFunctor.cpp +++ b/Source/Diagnostics/ComputeDiagFunctors/ParticleReductionFunctor.cpp @@ -135,7 +135,7 @@ ParticleReductionFunctor::operator() (amrex::MultiFab& mf_dst, const int dcomp, const amrex::ParticleReal uy = p.rdata(PIdx::uy) / PhysConst::c; const amrex::ParticleReal uz = p.rdata(PIdx::uz) / PhysConst::c; amrex::Real filter; - if ((do_filter) && (!filter_fn(xw, yw, zw, ux, uy, uz))) filter = 0._rt; + if ((do_filter) && (filter_fn(xw, yw, zw, ux, uy, uz) == 0._rt)) filter = 0._rt; else filter = 1._rt; amrex::Gpu::Atomic::AddNoRet(&out_array(ii, jj, kk, 0), (amrex::Real)(p.rdata(PIdx::w) * filter)); }); diff --git a/Source/Diagnostics/FlushFormats/FlushFormatOpenPMD.cpp b/Source/Diagnostics/FlushFormats/FlushFormatOpenPMD.cpp index 3832bf5e9c0..2185d4b4cca 100644 --- a/Source/Diagnostics/FlushFormats/FlushFormatOpenPMD.cpp +++ b/Source/Diagnostics/FlushFormats/FlushFormatOpenPMD.cpp @@ -155,10 +155,11 @@ FlushFormatOpenPMD::WriteToFile ( // fields: only dumped for coarse level m_OpenPMDPlotWriter->WriteOpenPMDFieldsAll( - varnames, mf, geom, output_levels, output_iteration, time, isBTD, full_BTD_snapshot); + varnames, mf, geom, output_levels, output_iteration, static_cast(time), isBTD, full_BTD_snapshot); // particles: all (reside only on locally finest level) - m_OpenPMDPlotWriter->WriteOpenPMDParticles(particle_diags, time, use_pinned_pc, isBTD, isLastBTDFlush, totalParticlesFlushedAlready); + m_OpenPMDPlotWriter->WriteOpenPMDParticles( + particle_diags, static_cast(time), use_pinned_pc, isBTD, isLastBTDFlush, totalParticlesFlushedAlready); // signal that no further updates will be written to this iteration m_OpenPMDPlotWriter->CloseStep(isBTD, isLastBTDFlush); diff --git a/Source/Diagnostics/FlushFormats/FlushFormatPlotfile.cpp b/Source/Diagnostics/FlushFormats/FlushFormatPlotfile.cpp index db5dea10adc..a18bab25308 100644 --- a/Source/Diagnostics/FlushFormats/FlushFormatPlotfile.cpp +++ b/Source/Diagnostics/FlushFormats/FlushFormatPlotfile.cpp @@ -99,7 +99,7 @@ FlushFormatPlotfile::WriteToFile ( WriteAllRawFields(plot_raw_fields, nlev, filename, plot_raw_fields_guards); - WriteParticles(filename, particle_diags, time, isBTD); + WriteParticles(filename, particle_diags, static_cast(time), isBTD); WriteJobInfo(filename); diff --git a/Source/Diagnostics/FullDiagnostics.cpp b/Source/Diagnostics/FullDiagnostics.cpp index d5109277de2..6848f9e1a18 100644 --- a/Source/Diagnostics/FullDiagnostics.cpp +++ b/Source/Diagnostics/FullDiagnostics.cpp @@ -191,7 +191,7 @@ FullDiagnostics::InitializeFieldFunctorsRZopenPMD (int lev) const bool update_varnames = (lev==0); if (update_varnames) { m_varnames.clear(); - const int n_rz = ncomp * m_varnames.size(); + const auto n_rz = ncomp * static_cast(m_varnames.size()); m_varnames.reserve(n_rz); } @@ -209,7 +209,8 @@ FullDiagnostics::InitializeFieldFunctorsRZopenPMD (int lev) bool deposit_current = !m_solver_deposits_current; // Fill vector of functors for all components except individual cylindrical modes. - for (int comp=0, n=m_varnames_fields.size(); comp(m_varnames_fields.size()); + for (int comp=0; comp(warpx.get_pointer_Efield_aux(lev, 0), lev, m_crse_ratio, false, ncomp); @@ -392,7 +393,7 @@ FullDiagnostics::AddRZModesToDiags (int lev) bool deposit_current = !m_solver_deposits_current; // First index of m_all_field_functors[lev] where RZ modes are stored - int icomp = m_all_field_functors[0].size(); + auto icomp =static_cast(m_all_field_functors[0].size()); const std::array coord {"r", "theta", "z"}; // Er, Etheta, Ez, Br, Btheta, Bz, jr, jtheta, jz diff --git a/Source/Diagnostics/ParticleIO.cpp b/Source/Diagnostics/ParticleIO.cpp index c10e3468a71..7ca5e6541d7 100644 --- a/Source/Diagnostics/ParticleIO.cpp +++ b/Source/Diagnostics/ParticleIO.cpp @@ -95,7 +95,7 @@ RigidInjectedParticleContainer::WriteHeader (std::ostream& os) const PhysicalParticleContainer::WriteHeader( os ); // Write quantities that are specific to the rigid-injected species - const int nlevs = zinject_plane_levels.size(); + const auto nlevs = static_cast(zinject_plane_levels.size()); os << nlevs << "\n"; for (int i = 0; i < nlevs; ++i) { diff --git a/Source/Diagnostics/ReducedDiags/BeamRelevant.cpp b/Source/Diagnostics/ReducedDiags/BeamRelevant.cpp index ac5f3fd6632..2a29748b3e1 100644 --- a/Source/Diagnostics/ReducedDiags/BeamRelevant.cpp +++ b/Source/Diagnostics/ReducedDiags/BeamRelevant.cpp @@ -250,7 +250,7 @@ void BeamRelevant::ComputeDiags (int step) // reduced sum over mpi ranks (allreduce) amrex::ParallelAllReduce::Sum - ( values_per_rank_1st.data(), values_per_rank_1st.size(), ParallelDescriptor::Communicator()); + ( values_per_rank_1st.data(), static_cast(values_per_rank_1st.size()), ParallelDescriptor::Communicator()); const ParticleReal w_sum = values_per_rank_1st.at(0); const ParticleReal x_mean = values_per_rank_1st.at(1) /= w_sum; @@ -345,7 +345,7 @@ void BeamRelevant::ComputeDiags (int step) // reduced sum over mpi ranks (reduce to IO rank) ParallelDescriptor::ReduceRealSum - ( values_per_rank_2nd.data(), values_per_rank_2nd.size(), ParallelDescriptor::IOProcessorNumber()); + ( values_per_rank_2nd.data(), static_cast(values_per_rank_2nd.size()), ParallelDescriptor::IOProcessorNumber()); const ParticleReal x_ms = values_per_rank_2nd.at(0) /= w_sum; const ParticleReal y_ms = values_per_rank_2nd.at(1) /= w_sum; diff --git a/Source/Diagnostics/ReducedDiags/ColliderRelevant.cpp b/Source/Diagnostics/ReducedDiags/ColliderRelevant.cpp index 1e2c16ac737..188b5f3f76f 100644 --- a/Source/Diagnostics/ReducedDiags/ColliderRelevant.cpp +++ b/Source/Diagnostics/ReducedDiags/ColliderRelevant.cpp @@ -222,7 +222,7 @@ void ColliderRelevant::ComputeDiags (int step) using PType = typename WarpXParticleContainer::SuperParticleType; num_dens[i_s] = myspc.GetChargeDensity(0); - num_dens[i_s]->mult(1./q); + num_dens[i_s]->mult(1._prt/q); #if defined(WARPX_DIM_1D_Z) // w_tot @@ -542,7 +542,7 @@ void ColliderRelevant::ComputeDiags (int step) // compute luminosity amrex::Real const n1_dot_n2 = amrex::MultiFab::Dot(mf_dst1, 0, mf_dst2, 0, 1, 0); - amrex::Real const lumi = 2. * PhysConst::c * n1_dot_n2 * dV; + amrex::Real const lumi = 2._rt * PhysConst::c * n1_dot_n2 * dV; m_data[get_idx("dL_dt")] = lumi; #endif // not RZ } diff --git a/Source/Diagnostics/ReducedDiags/FieldProbe.cpp b/Source/Diagnostics/ReducedDiags/FieldProbe.cpp index 7749d5ecc8d..11975ef0483 100644 --- a/Source/Diagnostics/ReducedDiags/FieldProbe.cpp +++ b/Source/Diagnostics/ReducedDiags/FieldProbe.cpp @@ -591,7 +591,7 @@ void FieldProbe::ComputeDiags (int step) if (amrex::ParallelDescriptor::IOProcessor()) { length_vector.resize(mpisize, 0); } - localsize.resize(1, m_data.size()); + localsize.resize(1, static_cast(m_data.size())); // gather size of m_data from each processor amrex::ParallelDescriptor::Gather(localsize.data(), 1, diff --git a/Source/Diagnostics/ReducedDiags/FieldProbeParticleContainer.cpp b/Source/Diagnostics/ReducedDiags/FieldProbeParticleContainer.cpp index d928bd33fb9..5d990b9eb07 100644 --- a/Source/Diagnostics/ReducedDiags/FieldProbeParticleContainer.cpp +++ b/Source/Diagnostics/ReducedDiags/FieldProbeParticleContainer.cpp @@ -76,7 +76,7 @@ FieldProbeParticleContainer::AddNParticles (int lev, AMREX_ALWAYS_ASSERT(x.size() == z.size()); // number of particles to add - int const np = x.size(); + auto const np = static_cast(x.size()); // have to resize here, not in the constructor because grids have not // been built when constructor was called. diff --git a/Source/Diagnostics/ReducedDiags/LoadBalanceCosts.cpp b/Source/Diagnostics/ReducedDiags/LoadBalanceCosts.cpp index 1ce88d043ff..7843527cbf5 100644 --- a/Source/Diagnostics/ReducedDiags/LoadBalanceCosts.cpp +++ b/Source/Diagnostics/ReducedDiags/LoadBalanceCosts.cpp @@ -144,7 +144,7 @@ void LoadBalanceCosts::ComputeDiags (int step) #else m_data[shift_m_data + mfi.index()*m_nDataFields + 5] = 0.; #endif - m_data[shift_m_data + mfi.index()*m_nDataFields + 6] = tbx.d_numPts(); // note: difference to volume + m_data[shift_m_data + mfi.index()*m_nDataFields + 6] = static_cast(tbx.d_numPts()); // note: difference to volume m_data[shift_m_data + mfi.index()*m_nDataFields + 7] = countBoxMacroParticles(mfi, lev); #ifdef AMREX_USE_GPU m_data[shift_m_data + mfi.index()*m_nDataFields + 8] = amrex::Gpu::Device::deviceId(); @@ -158,7 +158,7 @@ void LoadBalanceCosts::ComputeDiags (int step) // parallel reduce to IO proc and get data over all procs ParallelDescriptor::ReduceRealSum(m_data.data(), - m_data.size(), + static_cast(m_data.size()), ParallelDescriptor::IOProcessorNumber()); #ifdef AMREX_USE_MPI @@ -367,7 +367,11 @@ void LoadBalanceCosts::WriteToFile (int step) const ofstmp.close(); // remove the original, rename tmp file - std::remove(fileDataName.c_str()); - std::rename(fileTmpName.c_str(), fileDataName.c_str()); + WARPX_ALWAYS_ASSERT_WITH_MESSAGE( + std::remove(fileDataName.c_str()) == EXIT_SUCCESS, + "Failed to remove " + fileDataName); + WARPX_ALWAYS_ASSERT_WITH_MESSAGE( + std::rename(fileTmpName.c_str(), fileDataName.c_str()) == EXIT_SUCCESS, + "Failed to rename " + fileTmpName + " into " + fileDataName); } } diff --git a/Source/Diagnostics/ReducedDiags/ParticleHistogram.cpp b/Source/Diagnostics/ReducedDiags/ParticleHistogram.cpp index 242659236d6..1cbbbaaebff 100644 --- a/Source/Diagnostics/ReducedDiags/ParticleHistogram.cpp +++ b/Source/Diagnostics/ReducedDiags/ParticleHistogram.cpp @@ -219,7 +219,7 @@ void ParticleHistogram::ComputeDiags (int step) // don't count a particle if it is filtered out if (do_parser_filter) - if (!fun_filterparser(t, x, y, z, ux, uy, uz)) + if (fun_filterparser(t, x, y, z, ux, uy, uz) == 0._rt) return; // continue function if particle is not filtered out auto const f = fun_partparser(t, x, y, z, ux, uy, uz); @@ -247,7 +247,7 @@ void ParticleHistogram::ComputeDiags (int step) // reduced sum over mpi ranks ParallelDescriptor::ReduceRealSum - (m_data.data(), m_data.size(), ParallelDescriptor::IOProcessorNumber()); + (m_data.data(), static_cast(m_data.size()), ParallelDescriptor::IOProcessorNumber()); // normalize the maximum value to be one if ( m_norm == NormalizationType::max_to_unity ) diff --git a/Source/Diagnostics/ReducedDiags/RhoMaximum.cpp b/Source/Diagnostics/ReducedDiags/RhoMaximum.cpp index 79698682b97..787a95ce412 100644 --- a/Source/Diagnostics/ReducedDiags/RhoMaximum.cpp +++ b/Source/Diagnostics/ReducedDiags/RhoMaximum.cpp @@ -133,7 +133,7 @@ void RhoMaximum::ComputeDiags (int step) // get number of levels const auto nLevel = warpx.finestLevel() + 1; - const int n_charged_species = m_rho_functors[0].size() - 1; + const auto n_charged_species = static_cast(m_rho_functors[0].size() - 1); // Min and max of total rho + max of |rho| for each species const int noutputs_per_level = 2+n_charged_species; diff --git a/Source/Diagnostics/WarpXOpenPMD.cpp b/Source/Diagnostics/WarpXOpenPMD.cpp index 69163b9c529..458760d3664 100644 --- a/Source/Diagnostics/WarpXOpenPMD.cpp +++ b/Source/Diagnostics/WarpXOpenPMD.cpp @@ -69,7 +69,7 @@ namespace detail snakeToCamel (const std::string& snake_string) { std::string camelString = snake_string; - const int n = camelString.length(); + const auto n = static_cast(camelString.length()); for (int x = 0; x < n; x++) { if (x == 0) @@ -217,10 +217,8 @@ namespace detail getParticlePositionComponentLabels (bool ignore_dims=false) { using vs = std::vector< std::string >; - vs positionComponents; - if (ignore_dims) { - positionComponents = vs{"x", "y", "z"}; - } else { + auto positionComponents = vs{"x", "y", "z"}; + if (!ignore_dims) { #if defined(WARPX_DIM_1D_Z) positionComponents = vs{"z"}; #elif defined(WARPX_DIM_XZ) @@ -783,7 +781,7 @@ WarpXOpenPMDPlot::DumpToFile (ParticleContainer* pc, [](uint64_t const *p) { delete[] p; } ); for (auto i = 0; i < numParticleOnTile; i++) { - ids.get()[i] = ablastr::particles::localIDtoGlobal(aos[i].id(), aos[i].cpu()); + ids.get()[i] = ablastr::particles::localIDtoGlobal(static_cast(aos[i].id()), static_cast(aos[i].cpu())); } auto const scalar = openPMD::RecordComponent::SCALAR; currSpecies["id"][scalar].storeChunk(ids, {offset}, {numParticleOnTile64}); @@ -1148,11 +1146,13 @@ WarpXOpenPMDPlot::SetupFields ( openPMD::Container< openPMD::Mesh >& meshes, fieldBoundary.resize(AMREX_SPACEDIM * 2); particleBoundary.resize(AMREX_SPACEDIM * 2); - for (auto i = 0u; i < fieldBoundary.size() / 2u; ++i) + const auto HalfFieldBoundarySize = static_cast(fieldBoundary.size() / 2u); + + for (auto i = 0; i < HalfFieldBoundarySize; ++i) if (m_fieldPMLdirections.at(i)) fieldBoundary.at(i) = "open"; - for (auto i = 0u; i < fieldBoundary.size() / 2u; ++i) + for (int i = 0; i < HalfFieldBoundarySize; ++i) if (period.isPeriodic(i)) { fieldBoundary.at(2u * i) = "periodic"; fieldBoundary.at(2u * i + 1u) = "periodic"; @@ -1540,7 +1540,7 @@ WarpXParticleCounter::GetParticleOffsetOfProcessor ( amrex::ParallelGather::Gather (numParticles, result.data(), -1, amrex::ParallelDescriptor::Communicator()); sum = 0; - int const num_results = result.size(); + auto const num_results = static_cast(result.size()); for (int i=0; i(amrex::second()); //Check and clear signal flags and asynchronously broadcast them from process 0 SignalHandling::CheckSignals(); @@ -378,7 +378,7 @@ WarpX::Evolve (int numsteps) } // create ending time stamp for calculating elapsed time each iteration - const Real evolve_time_end_step = amrex::second(); + const auto evolve_time_end_step = static_cast(amrex::second()); evolve_time += evolve_time_end_step - evolve_time_beg_step; HandleSignals(); diff --git a/Source/FieldSolver/FiniteDifferenceSolver/ApplySilverMuellerBoundary.cpp b/Source/FieldSolver/FiniteDifferenceSolver/ApplySilverMuellerBoundary.cpp index 4c6748cfbce..b447d4e06a3 100644 --- a/Source/FieldSolver/FiniteDifferenceSolver/ApplySilverMuellerBoundary.cpp +++ b/Source/FieldSolver/FiniteDifferenceSolver/ApplySilverMuellerBoundary.cpp @@ -64,7 +64,7 @@ void FiniteDifferenceSolver::ApplySilverMuellerBoundary ( // Extract stencil coefficients Real const * const AMREX_RESTRICT coefs_z = m_stencil_coefs_z.dataPtr(); - int const n_coefs_z = m_h_stencil_coefs_z.size(); + auto const n_coefs_z = static_cast(m_h_stencil_coefs_z.size()); // Extract cylindrical specific parameters Real const dr = m_dr; diff --git a/Source/FieldSolver/FiniteDifferenceSolver/ComputeDivE.cpp b/Source/FieldSolver/FiniteDifferenceSolver/ComputeDivE.cpp index 163792a2737..62ba35faea8 100644 --- a/Source/FieldSolver/FiniteDifferenceSolver/ComputeDivE.cpp +++ b/Source/FieldSolver/FiniteDifferenceSolver/ComputeDivE.cpp @@ -94,11 +94,11 @@ void FiniteDifferenceSolver::ComputeDivECartesian ( // Extract stencil coefficients Real const * const AMREX_RESTRICT coefs_x = m_stencil_coefs_x.dataPtr(); - int const n_coefs_x = m_stencil_coefs_x.size(); + auto const n_coefs_x = static_cast(m_stencil_coefs_x.size()); Real const * const AMREX_RESTRICT coefs_y = m_stencil_coefs_y.dataPtr(); - int const n_coefs_y = m_stencil_coefs_y.size(); + auto const n_coefs_y = static_cast(m_stencil_coefs_y.size()); Real const * const AMREX_RESTRICT coefs_z = m_stencil_coefs_z.dataPtr(); - int const n_coefs_z = m_stencil_coefs_z.size(); + auto const n_coefs_z = static_cast(m_stencil_coefs_z.size()); // Extract tileboxes for which to loop Box const& tdive = mfi.tilebox(divEfield.ixType().toIntVect()); @@ -140,9 +140,9 @@ void FiniteDifferenceSolver::ComputeDivECylindrical ( // Extract stencil coefficients Real const * const AMREX_RESTRICT coefs_r = m_stencil_coefs_r.dataPtr(); - int const n_coefs_r = m_stencil_coefs_r.size(); + auto const n_coefs_r = static_cast(m_stencil_coefs_r.size()); Real const * const AMREX_RESTRICT coefs_z = m_stencil_coefs_z.dataPtr(); - int const n_coefs_z = m_stencil_coefs_z.size(); + auto const n_coefs_z = static_cast(m_stencil_coefs_z.size()); // Extract cylindrical specific parameters Real const dr = m_dr; diff --git a/Source/FieldSolver/FiniteDifferenceSolver/EvolveB.cpp b/Source/FieldSolver/FiniteDifferenceSolver/EvolveB.cpp index 0cbad684c68..0ccff8bac9a 100644 --- a/Source/FieldSolver/FiniteDifferenceSolver/EvolveB.cpp +++ b/Source/FieldSolver/FiniteDifferenceSolver/EvolveB.cpp @@ -120,7 +120,7 @@ void FiniteDifferenceSolver::EvolveBCartesian ( { amrex::Gpu::synchronize(); } - Real wt = amrex::second(); + auto wt = static_cast(amrex::second()); // Extract field data for this grid/tile Array4 const& Bx = Bfield[0]->array(mfi); @@ -132,11 +132,11 @@ void FiniteDifferenceSolver::EvolveBCartesian ( // Extract stencil coefficients Real const * const AMREX_RESTRICT coefs_x = m_stencil_coefs_x.dataPtr(); - int const n_coefs_x = m_stencil_coefs_x.size(); + auto const n_coefs_x = static_cast(m_stencil_coefs_x.size()); Real const * const AMREX_RESTRICT coefs_y = m_stencil_coefs_y.dataPtr(); - int const n_coefs_y = m_stencil_coefs_y.size(); + auto const n_coefs_y = static_cast(m_stencil_coefs_y.size()); Real const * const AMREX_RESTRICT coefs_z = m_stencil_coefs_z.dataPtr(); - int const n_coefs_z = m_stencil_coefs_z.size(); + auto const n_coefs_z = static_cast(m_stencil_coefs_z.size()); // Extract tileboxes for which to loop Box const& tbx = mfi.tilebox(Bfield[0]->ixType().toIntVect()); @@ -195,7 +195,7 @@ void FiniteDifferenceSolver::EvolveBCartesian ( if (cost && WarpX::load_balance_costs_update_algo == LoadBalanceCostsUpdateAlgo::Timers) { amrex::Gpu::synchronize(); - wt = amrex::second() - wt; + wt = static_cast(amrex::second()) - wt; amrex::HostDevice::Atomic::Add( &(*cost)[mfi.index()], wt); } } @@ -233,7 +233,7 @@ void FiniteDifferenceSolver::EvolveBCartesianECT ( if (cost && WarpX::load_balance_costs_update_algo == LoadBalanceCostsUpdateAlgo::Timers) { amrex::Gpu::synchronize(); } - Real wt = amrex::second(); + auto wt = static_cast(amrex::second()); for (int idim = 0; idim < AMREX_SPACEDIM; ++idim) { // Extract field data for this grid/tile @@ -356,7 +356,7 @@ void FiniteDifferenceSolver::EvolveBCartesianECT ( if (cost && WarpX::load_balance_costs_update_algo == LoadBalanceCostsUpdateAlgo::Timers) { amrex::Gpu::synchronize(); - wt = amrex::second() - wt; + wt = static_cast(amrex::second()) - wt; amrex::HostDevice::Atomic::Add( &(*cost)[mfi.index()], wt); } } @@ -385,7 +385,7 @@ void FiniteDifferenceSolver::EvolveBCylindrical ( { amrex::Gpu::synchronize(); } - Real wt = amrex::second(); + auto wt = static_cast(amrex::second()); // Extract field data for this grid/tile Array4 const& Br = Bfield[0]->array(mfi); @@ -397,9 +397,9 @@ void FiniteDifferenceSolver::EvolveBCylindrical ( // Extract stencil coefficients Real const * const AMREX_RESTRICT coefs_r = m_stencil_coefs_r.dataPtr(); - int const n_coefs_r = m_stencil_coefs_r.size(); + auto const n_coefs_r = static_cast(m_stencil_coefs_r.size()); Real const * const AMREX_RESTRICT coefs_z = m_stencil_coefs_z.dataPtr(); - int const n_coefs_z = m_stencil_coefs_z.size(); + auto const n_coefs_z = static_cast(m_stencil_coefs_z.size()); // Extract cylindrical specific parameters Real const dr = m_dr; @@ -462,7 +462,7 @@ void FiniteDifferenceSolver::EvolveBCylindrical ( }, [=] AMREX_GPU_DEVICE (int i, int j, int /*k*/){ - Real const r = rmin + (i + 0.5)*dr; // r on a cell-centered grid (Bz is cell-centered in r) + Real const r = rmin + (i + 0.5_rt)*dr; // r on a cell-centered grid (Bz is cell-centered in r) Bz(i, j, 0, 0) += dt*( - T_Algo::UpwardDrr_over_r(Et, r, dr, coefs_r, n_coefs_r, i, j, 0, 0)); for (int m=1 ; m(amrex::second()) - wt; amrex::HostDevice::Atomic::Add( &(*cost)[mfi.index()], wt); } } diff --git a/Source/FieldSolver/FiniteDifferenceSolver/EvolveBPML.cpp b/Source/FieldSolver/FiniteDifferenceSolver/EvolveBPML.cpp index 9ae67d4f960..35cbb6ede93 100644 --- a/Source/FieldSolver/FiniteDifferenceSolver/EvolveBPML.cpp +++ b/Source/FieldSolver/FiniteDifferenceSolver/EvolveBPML.cpp @@ -98,11 +98,11 @@ void FiniteDifferenceSolver::EvolveBPMLCartesian ( // Extract stencil coefficients Real const * const AMREX_RESTRICT coefs_x = m_stencil_coefs_x.dataPtr(); - int const n_coefs_x = m_stencil_coefs_x.size(); + auto const n_coefs_x = static_cast(m_stencil_coefs_x.size()); Real const * const AMREX_RESTRICT coefs_y = m_stencil_coefs_y.dataPtr(); - int const n_coefs_y = m_stencil_coefs_y.size(); + auto const n_coefs_y = static_cast(m_stencil_coefs_y.size()); Real const * const AMREX_RESTRICT coefs_z = m_stencil_coefs_z.dataPtr(); - int const n_coefs_z = m_stencil_coefs_z.size(); + auto const n_coefs_z = static_cast(m_stencil_coefs_z.size()); // Extract tileboxes for which to loop Box const& tbx = mfi.tilebox(Bfield[0]->ixType().ixType()); diff --git a/Source/FieldSolver/FiniteDifferenceSolver/EvolveE.cpp b/Source/FieldSolver/FiniteDifferenceSolver/EvolveE.cpp index b044986383e..74922650a42 100644 --- a/Source/FieldSolver/FiniteDifferenceSolver/EvolveE.cpp +++ b/Source/FieldSolver/FiniteDifferenceSolver/EvolveE.cpp @@ -117,7 +117,7 @@ void FiniteDifferenceSolver::EvolveECartesian ( { amrex::Gpu::synchronize(); } - Real wt = amrex::second(); + auto wt = static_cast(amrex::second()); // Extract field data for this grid/tile Array4 const& Ex = Efield[0]->array(mfi); @@ -138,11 +138,11 @@ void FiniteDifferenceSolver::EvolveECartesian ( // Extract stencil coefficients Real const * const AMREX_RESTRICT coefs_x = m_stencil_coefs_x.dataPtr(); - int const n_coefs_x = m_stencil_coefs_x.size(); + auto const n_coefs_x = static_cast(m_stencil_coefs_x.size()); Real const * const AMREX_RESTRICT coefs_y = m_stencil_coefs_y.dataPtr(); - int const n_coefs_y = m_stencil_coefs_y.size(); + auto const n_coefs_y = static_cast(m_stencil_coefs_y.size()); Real const * const AMREX_RESTRICT coefs_z = m_stencil_coefs_z.dataPtr(); - int const n_coefs_z = m_stencil_coefs_z.size(); + auto const n_coefs_z = static_cast(m_stencil_coefs_z.size()); // Extract tileboxes for which to loop Box const& tex = mfi.tilebox(Efield[0]->ixType().toIntVect()); @@ -221,7 +221,7 @@ void FiniteDifferenceSolver::EvolveECartesian ( if (cost && WarpX::load_balance_costs_update_algo == LoadBalanceCostsUpdateAlgo::Timers) { amrex::Gpu::synchronize(); - wt = amrex::second() - wt; + wt = static_cast(amrex::second()) - wt; amrex::HostDevice::Atomic::Add( &(*cost)[mfi.index()], wt); } } @@ -249,7 +249,7 @@ void FiniteDifferenceSolver::EvolveECylindrical ( { amrex::Gpu::synchronize(); } - Real wt = amrex::second(); + auto wt = static_cast(amrex::second()); // Extract field data for this grid/tile Array4 const& Er = Efield[0]->array(mfi); @@ -264,9 +264,9 @@ void FiniteDifferenceSolver::EvolveECylindrical ( // Extract stencil coefficients Real const * const AMREX_RESTRICT coefs_r = m_stencil_coefs_r.dataPtr(); - int const n_coefs_r = m_stencil_coefs_r.size(); + auto const n_coefs_r = static_cast(m_stencil_coefs_r.size()); Real const * const AMREX_RESTRICT coefs_z = m_stencil_coefs_z.dataPtr(); - int const n_coefs_z = m_stencil_coefs_z.size(); + auto const n_coefs_z = static_cast(m_stencil_coefs_z.size()); // Extract cylindrical specific parameters Real const dr = m_dr; @@ -284,7 +284,7 @@ void FiniteDifferenceSolver::EvolveECylindrical ( amrex::ParallelFor(ter, tet, tez, [=] AMREX_GPU_DEVICE (int i, int j, int /*k*/){ - Real const r = rmin + (i + 0.5)*dr; // r on cell-centered point (Er is cell-centered in r) + Real const r = rmin + (i + 0.5_rt)*dr; // r on cell-centered point (Er is cell-centered in r) Er(i, j, 0, 0) += c2 * dt*( - T_Algo::DownwardDz(Bt, coefs_z, n_coefs_z, i, j, 0, 0) - PhysConst::mu0 * jr(i, j, 0, 0) ); // Mode m=0 @@ -423,7 +423,7 @@ void FiniteDifferenceSolver::EvolveECylindrical ( if (cost && WarpX::load_balance_costs_update_algo == LoadBalanceCostsUpdateAlgo::Timers) { amrex::Gpu::synchronize(); - wt = amrex::second() - wt; + wt = static_cast(amrex::second()) - wt; amrex::HostDevice::Atomic::Add( &(*cost)[mfi.index()], wt); } } // end of loop over grid/tiles diff --git a/Source/FieldSolver/FiniteDifferenceSolver/EvolveECTRho.cpp b/Source/FieldSolver/FiniteDifferenceSolver/EvolveECTRho.cpp index b7a42ad28b7..95f899c98e1 100644 --- a/Source/FieldSolver/FiniteDifferenceSolver/EvolveECTRho.cpp +++ b/Source/FieldSolver/FiniteDifferenceSolver/EvolveECTRho.cpp @@ -88,7 +88,7 @@ void FiniteDifferenceSolver::EvolveRhoCartesianECT ( if (cost && WarpX::load_balance_costs_update_algo == LoadBalanceCostsUpdateAlgo::Timers) { amrex::Gpu::synchronize(); } - amrex::Real wt = amrex::second(); + auto wt = static_cast(amrex::second()); // Extract field data for this grid/tile amrex::Array4 const &Ex = Efield[0]->array(mfi); @@ -149,7 +149,7 @@ void FiniteDifferenceSolver::EvolveRhoCartesianECT ( if (cost && WarpX::load_balance_costs_update_algo == LoadBalanceCostsUpdateAlgo::Timers) { amrex::Gpu::synchronize(); - wt = amrex::second() - wt; + wt = static_cast(amrex::second()) - wt; amrex::HostDevice::Atomic::Add( &(*cost)[mfi.index()], wt); } #ifdef WARPX_DIM_XZ diff --git a/Source/FieldSolver/FiniteDifferenceSolver/EvolveEPML.cpp b/Source/FieldSolver/FiniteDifferenceSolver/EvolveEPML.cpp index 2ecc9ee0e04..87145daa79b 100644 --- a/Source/FieldSolver/FiniteDifferenceSolver/EvolveEPML.cpp +++ b/Source/FieldSolver/FiniteDifferenceSolver/EvolveEPML.cpp @@ -117,11 +117,11 @@ void FiniteDifferenceSolver::EvolveEPMLCartesian ( // Extract stencil coefficients Real const * const AMREX_RESTRICT coefs_x = m_stencil_coefs_x.dataPtr(); - int const n_coefs_x = m_stencil_coefs_x.size(); + auto const n_coefs_x = static_cast(m_stencil_coefs_x.size()); Real const * const AMREX_RESTRICT coefs_y = m_stencil_coefs_y.dataPtr(); - int const n_coefs_y = m_stencil_coefs_y.size(); + auto const n_coefs_y = static_cast(m_stencil_coefs_y.size()); Real const * const AMREX_RESTRICT coefs_z = m_stencil_coefs_z.dataPtr(); - int const n_coefs_z = m_stencil_coefs_z.size(); + auto const n_coefs_z = static_cast(m_stencil_coefs_z.size()); // Extract tileboxes for which to loop Box const& tex = mfi.tilebox(Efield[0]->ixType().ixType()); diff --git a/Source/FieldSolver/FiniteDifferenceSolver/EvolveF.cpp b/Source/FieldSolver/FiniteDifferenceSolver/EvolveF.cpp index c43d965b3a4..752adb8e628 100644 --- a/Source/FieldSolver/FiniteDifferenceSolver/EvolveF.cpp +++ b/Source/FieldSolver/FiniteDifferenceSolver/EvolveF.cpp @@ -103,11 +103,11 @@ void FiniteDifferenceSolver::EvolveFCartesian ( // Extract stencil coefficients Real const * const AMREX_RESTRICT coefs_x = m_stencil_coefs_x.dataPtr(); - int const n_coefs_x = m_stencil_coefs_x.size(); + auto const n_coefs_x = static_cast(m_stencil_coefs_x.size()); Real const * const AMREX_RESTRICT coefs_y = m_stencil_coefs_y.dataPtr(); - int const n_coefs_y = m_stencil_coefs_y.size(); + auto const n_coefs_y = static_cast(m_stencil_coefs_y.size()); Real const * const AMREX_RESTRICT coefs_z = m_stencil_coefs_z.dataPtr(); - int const n_coefs_z = m_stencil_coefs_z.size(); + auto const n_coefs_z =static_cast(m_stencil_coefs_z.size()); // Extract tileboxes for which to loop Box const& tf = mfi.tilebox(Ffield->ixType().toIntVect()); @@ -156,9 +156,9 @@ void FiniteDifferenceSolver::EvolveFCylindrical ( // Extract stencil coefficients Real const * const AMREX_RESTRICT coefs_r = m_stencil_coefs_r.dataPtr(); - int const n_coefs_r = m_stencil_coefs_r.size(); + auto const n_coefs_r = static_cast(m_stencil_coefs_r.size()); Real const * const AMREX_RESTRICT coefs_z = m_stencil_coefs_z.dataPtr(); - int const n_coefs_z = m_stencil_coefs_z.size(); + auto const n_coefs_z = static_cast(m_stencil_coefs_z.size()); // Extract cylindrical specific parameters Real const dr = m_dr; diff --git a/Source/FieldSolver/FiniteDifferenceSolver/EvolveFPML.cpp b/Source/FieldSolver/FiniteDifferenceSolver/EvolveFPML.cpp index 5b69737c79c..ee9b7ec368e 100644 --- a/Source/FieldSolver/FiniteDifferenceSolver/EvolveFPML.cpp +++ b/Source/FieldSolver/FiniteDifferenceSolver/EvolveFPML.cpp @@ -92,11 +92,11 @@ void FiniteDifferenceSolver::EvolveFPMLCartesian ( // Extract stencil coefficients Real const * const AMREX_RESTRICT coefs_x = m_stencil_coefs_x.dataPtr(); - int const n_coefs_x = m_stencil_coefs_x.size(); + auto const n_coefs_x = static_cast(m_stencil_coefs_x.size()); Real const * const AMREX_RESTRICT coefs_y = m_stencil_coefs_y.dataPtr(); - int const n_coefs_y = m_stencil_coefs_y.size(); + auto const n_coefs_y = static_cast(m_stencil_coefs_y.size()); Real const * const AMREX_RESTRICT coefs_z = m_stencil_coefs_z.dataPtr(); - int const n_coefs_z = m_stencil_coefs_z.size(); + auto const n_coefs_z = static_cast(m_stencil_coefs_z.size()); // Extract tileboxes for which to loop Box const& tf = mfi.tilebox(Ffield->ixType().ixType()); diff --git a/Source/FieldSolver/FiniteDifferenceSolver/EvolveG.cpp b/Source/FieldSolver/FiniteDifferenceSolver/EvolveG.cpp index 30d19efe008..b6bc8fdca7f 100644 --- a/Source/FieldSolver/FiniteDifferenceSolver/EvolveG.cpp +++ b/Source/FieldSolver/FiniteDifferenceSolver/EvolveG.cpp @@ -95,9 +95,9 @@ void FiniteDifferenceSolver::EvolveGCartesian ( amrex::Real const* const AMREX_RESTRICT coefs_y = m_stencil_coefs_y.dataPtr(); amrex::Real const* const AMREX_RESTRICT coefs_z = m_stencil_coefs_z.dataPtr(); - const int n_coefs_x = m_stencil_coefs_x.size(); - const int n_coefs_y = m_stencil_coefs_y.size(); - const int n_coefs_z = m_stencil_coefs_z.size(); + const auto n_coefs_x = static_cast(m_stencil_coefs_x.size()); + const auto n_coefs_y = static_cast(m_stencil_coefs_y.size()); + const auto n_coefs_z = static_cast(m_stencil_coefs_z.size()); // Extract tilebox to loop over amrex::Box const& tf = mfi.tilebox(Gfield->ixType().toIntVect()); diff --git a/Source/FieldSolver/FiniteDifferenceSolver/HybridPICModel/HybridPICModel.H b/Source/FieldSolver/FiniteDifferenceSolver/HybridPICModel/HybridPICModel.H index 51e11aa46f3..452dbc3057a 100644 --- a/Source/FieldSolver/FiniteDifferenceSolver/HybridPICModel/HybridPICModel.H +++ b/Source/FieldSolver/FiniteDifferenceSolver/HybridPICModel/HybridPICModel.H @@ -176,7 +176,7 @@ struct ElectronPressure { amrex::Real const T0, amrex::Real const gamma, amrex::Real const rho) { - return n0 * T0 * pow((rho/PhysConst::q_e)/n0, gamma); + return n0 * T0 * std::pow((rho/PhysConst::q_e)/n0, gamma); } }; diff --git a/Source/FieldSolver/FiniteDifferenceSolver/HybridPICSolveE.cpp b/Source/FieldSolver/FiniteDifferenceSolver/HybridPICSolveE.cpp index f4f236e61d1..38ca6c67fff 100644 --- a/Source/FieldSolver/FiniteDifferenceSolver/HybridPICSolveE.cpp +++ b/Source/FieldSolver/FiniteDifferenceSolver/HybridPICSolveE.cpp @@ -98,7 +98,7 @@ void FiniteDifferenceSolver::CalculateCurrentAmpereCartesian ( { amrex::Gpu::synchronize(); } - Real wt = amrex::second(); + auto wt = static_cast(amrex::second()); // Extract field data for this grid/tile Array4 const& Jx = Jfield[0]->array(mfi); @@ -116,11 +116,11 @@ void FiniteDifferenceSolver::CalculateCurrentAmpereCartesian ( // Extract stencil coefficients Real const * const AMREX_RESTRICT coefs_x = m_stencil_coefs_x.dataPtr(); - int const n_coefs_x = m_stencil_coefs_x.size(); + auto const n_coefs_x = static_cast(m_stencil_coefs_x.size()); Real const * const AMREX_RESTRICT coefs_y = m_stencil_coefs_y.dataPtr(); - int const n_coefs_y = m_stencil_coefs_y.size(); + auto const n_coefs_y = static_cast(m_stencil_coefs_y.size()); Real const * const AMREX_RESTRICT coefs_z = m_stencil_coefs_z.dataPtr(); - int const n_coefs_z = m_stencil_coefs_z.size(); + auto const n_coefs_z = static_cast(m_stencil_coefs_z.size()); // Extract tileboxes for which to loop Box const& tjx = mfi.tilebox(Jfield[0]->ixType().toIntVect()); @@ -179,7 +179,7 @@ void FiniteDifferenceSolver::CalculateCurrentAmpereCartesian ( if (cost && WarpX::load_balance_costs_update_algo == LoadBalanceCostsUpdateAlgo::Timers) { amrex::Gpu::synchronize(); - wt = amrex::second() - wt; + wt = static_cast(amrex::second()) - wt; amrex::HostDevice::Atomic::Add( &(*cost)[mfi.index()], wt); } } @@ -316,7 +316,7 @@ void FiniteDifferenceSolver::HybridPICSolveECartesian ( { amrex::Gpu::synchronize(); } - Real wt = amrex::second(); + auto wt = static_cast(amrex::second()); Array4 const& enE_nodal = enE_nodal_mf.array(mfi); Array4 const& Jx = Jfield[0]->const_array(mfi); @@ -365,7 +365,7 @@ void FiniteDifferenceSolver::HybridPICSolveECartesian ( if (cost && WarpX::load_balance_costs_update_algo == LoadBalanceCostsUpdateAlgo::Timers) { amrex::Gpu::synchronize(); - wt = amrex::second() - wt; + wt = static_cast(amrex::second()) - wt; amrex::HostDevice::Atomic::Add( &(*cost)[mfi.index()], wt); } } @@ -380,7 +380,7 @@ void FiniteDifferenceSolver::HybridPICSolveECartesian ( { amrex::Gpu::synchronize(); } - Real wt = amrex::second(); + auto wt = static_cast(amrex::second()); // Extract field data for this grid/tile Array4 const& Ex = Efield[0]->array(mfi); @@ -401,11 +401,11 @@ void FiniteDifferenceSolver::HybridPICSolveECartesian ( // Extract stencil coefficients Real const * const AMREX_RESTRICT coefs_x = m_stencil_coefs_x.dataPtr(); - int const n_coefs_x = m_stencil_coefs_x.size(); + auto const n_coefs_x = static_cast(m_stencil_coefs_x.size()); Real const * const AMREX_RESTRICT coefs_y = m_stencil_coefs_y.dataPtr(); - int const n_coefs_y = m_stencil_coefs_y.size(); + auto const n_coefs_y = static_cast(m_stencil_coefs_y.size()); Real const * const AMREX_RESTRICT coefs_z = m_stencil_coefs_z.dataPtr(); - int const n_coefs_z = m_stencil_coefs_z.size(); + auto const n_coefs_z = static_cast(m_stencil_coefs_z.size()); Box const& tex = mfi.tilebox(Efield[0]->ixType().toIntVect()); Box const& tey = mfi.tilebox(Efield[1]->ixType().toIntVect()); @@ -497,7 +497,7 @@ void FiniteDifferenceSolver::HybridPICSolveECartesian ( if (cost && WarpX::load_balance_costs_update_algo == LoadBalanceCostsUpdateAlgo::Timers) { amrex::Gpu::synchronize(); - wt = amrex::second() - wt; + wt = static_cast(amrex::second()) - wt; amrex::HostDevice::Atomic::Add( &(*cost)[mfi.index()], wt); } } diff --git a/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveE.cpp b/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveE.cpp index fe9aa979a7e..3c9dc8db1c1 100644 --- a/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveE.cpp +++ b/Source/FieldSolver/FiniteDifferenceSolver/MacroscopicEvolveE.cpp @@ -152,11 +152,11 @@ void FiniteDifferenceSolver::MacroscopicEvolveECartesian ( // Extract stencil coefficients Real const * const AMREX_RESTRICT coefs_x = m_stencil_coefs_x.dataPtr(); - int const n_coefs_x = m_stencil_coefs_x.size(); + auto const n_coefs_x = static_cast(m_stencil_coefs_x.size()); Real const * const AMREX_RESTRICT coefs_y = m_stencil_coefs_y.dataPtr(); - int const n_coefs_y = m_stencil_coefs_y.size(); + auto const n_coefs_y = static_cast(m_stencil_coefs_y.size()); Real const * const AMREX_RESTRICT coefs_z = m_stencil_coefs_z.dataPtr(); - int const n_coefs_z = m_stencil_coefs_z.size(); + auto const n_coefs_z = static_cast(m_stencil_coefs_z.size()); // This functor computes Hx = Bx/mu // Note that mu is cell-centered here and will be interpolated/averaged diff --git a/Source/FieldSolver/SpectralSolver/SpectralBinomialFilter.cpp b/Source/FieldSolver/SpectralSolver/SpectralBinomialFilter.cpp index 14246b5be13..2fbab2422ea 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralBinomialFilter.cpp +++ b/Source/FieldSolver/SpectralSolver/SpectralBinomialFilter.cpp @@ -21,7 +21,7 @@ SpectralBinomialFilter::InitFilterArray (HankelTransform::RealVector const & kve bool const compensation, KFilterArray & filter) { - const int N = kvec.size(); + const auto N = static_cast(kvec.size()); filter.resize(N); amrex::Real* p_filter = filter.data(); amrex::Real const* p_kvec = kvec.data(); @@ -30,7 +30,7 @@ SpectralBinomialFilter::InitFilterArray (HankelTransform::RealVector const & kve { amrex::Real const ss = std::sin(0.5_rt*p_kvec[i]*dels); amrex::Real const ss2 = ss*ss; - amrex::Real filt = std::pow(1._rt - ss2, npasses); + auto filt = static_cast(std::pow(1._rt - ss2, npasses)); if (compensation) { filt *= (1._rt + npasses*ss2); } diff --git a/Source/FieldSolver/SpectralSolver/SpectralFieldData.cpp b/Source/FieldSolver/SpectralSolver/SpectralFieldData.cpp index 0cd7a346352..3547a5a55f5 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralFieldData.cpp +++ b/Source/FieldSolver/SpectralSolver/SpectralFieldData.cpp @@ -173,7 +173,7 @@ SpectralFieldData::SpectralFieldData( const int lev, { amrex::Gpu::synchronize(); } - Real wt = amrex::second(); + auto wt = static_cast(amrex::second()); // Note: the size of the real-space box and spectral-space box // differ when using real-to-complex FFT. When initializing @@ -193,7 +193,7 @@ SpectralFieldData::SpectralFieldData( const int lev, if (do_costs) { amrex::Gpu::synchronize(); - wt = amrex::second() - wt; + wt = static_cast(amrex::second()) - wt; amrex::HostDevice::Atomic::Add( &(*cost)[mfi.index()], wt); } } @@ -242,7 +242,7 @@ SpectralFieldData::ForwardTransform (const int lev, { amrex::Gpu::synchronize(); } - Real wt = amrex::second(); + auto wt = static_cast(amrex::second()); // Copy the real-space field `mf` to the temporary field `tmpRealField` // This ensures that all fields have the same number of points @@ -309,7 +309,7 @@ SpectralFieldData::ForwardTransform (const int lev, if (do_costs) { amrex::Gpu::synchronize(); - wt = amrex::second() - wt; + wt = static_cast(amrex::second()) - wt; amrex::HostDevice::Atomic::Add( &(*cost)[mfi.index()], wt); } } @@ -367,7 +367,7 @@ SpectralFieldData::BackwardTransform (const int lev, { amrex::Gpu::synchronize(); } - Real wt = amrex::second(); + auto wt = static_cast(amrex::second()); // Copy the spectral-space field `tmpSpectralField` to the appropriate // field (specified by the input argument field_index) @@ -470,7 +470,7 @@ SpectralFieldData::BackwardTransform (const int lev, if (do_costs) { amrex::Gpu::synchronize(); - wt = amrex::second() - wt; + wt = static_cast(amrex::second()) - wt; amrex::HostDevice::Atomic::Add( &(*cost)[mfi.index()], wt); } } diff --git a/Source/FieldSolver/SpectralSolver/SpectralFieldDataRZ.cpp b/Source/FieldSolver/SpectralSolver/SpectralFieldDataRZ.cpp index db189f4287a..cc0e64fd1de 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralFieldDataRZ.cpp +++ b/Source/FieldSolver/SpectralSolver/SpectralFieldDataRZ.cpp @@ -470,7 +470,7 @@ SpectralFieldDataRZ::ForwardTransform (const int lev, { amrex::Gpu::synchronize(); } - amrex::Real wt = amrex::second(); + auto wt = static_cast(amrex::second()); // Perform the Hankel transform first. // tempHTransformedSplit includes the imaginary component of mode 0. @@ -490,7 +490,7 @@ SpectralFieldDataRZ::ForwardTransform (const int lev, if (do_costs) { amrex::Gpu::synchronize(); - wt = amrex::second() - wt; + wt = static_cast(amrex::second()) - wt; amrex::HostDevice::Atomic::Add( &(*cost)[mfi.index()], wt); } } @@ -527,7 +527,7 @@ SpectralFieldDataRZ::ForwardTransform (const int lev, { amrex::Gpu::synchronize(); } - amrex::Real wt = amrex::second(); + auto wt = static_cast(amrex::second()); amrex::Box const& realspace_bx = tempHTransformed[mfi].box(); @@ -556,7 +556,7 @@ SpectralFieldDataRZ::ForwardTransform (const int lev, if (do_costs) { amrex::Gpu::synchronize(); - wt = amrex::second() - wt; + wt = static_cast(amrex::second()) - wt; amrex::HostDevice::Atomic::Add( &(*cost)[mfi.index()], wt); } } @@ -589,7 +589,7 @@ SpectralFieldDataRZ::BackwardTransform (const int lev, { amrex::Gpu::synchronize(); } - amrex::Real wt = amrex::second(); + auto wt = static_cast(amrex::second()); amrex::Box realspace_bx = tempHTransformed[mfi].box(); @@ -629,18 +629,18 @@ SpectralFieldDataRZ::BackwardTransform (const int lev, sign = +1._rt; } else { // Odd modes are anti-symmetric - int imode = (icomp + 1)/2; - sign = std::pow(-1._rt, imode); + const auto imode = (icomp + 1)/2; + sign = static_cast(std::pow(-1._rt, imode)); } } - int ic = icomp + i_comp; + const auto ic = icomp + i_comp; field_mf_array(i,j,k,ic) = sign*field_mf_copy_array(ii,j,k,icomp); }); if (do_costs) { amrex::Gpu::synchronize(); - wt = amrex::second() - wt; + wt = static_cast(amrex::second()) - wt; amrex::HostDevice::Atomic::Add( &(*cost)[mfi.index()], wt); } } @@ -674,7 +674,7 @@ SpectralFieldDataRZ::BackwardTransform (const int lev, { amrex::Gpu::synchronize(); } - amrex::Real wt = amrex::second(); + auto wt = static_cast(amrex::second()); amrex::Box realspace_bx = tempHTransformed[mfi].box(); @@ -720,7 +720,7 @@ SpectralFieldDataRZ::BackwardTransform (const int lev, } else { // Even modes are anti-symmetric int imode = (icomp + 1)/2; - sign = std::pow(-1._rt, imode+1); + sign = static_cast(std::pow(-1._rt, imode+1)); } } if (icomp == 0) { @@ -736,7 +736,7 @@ SpectralFieldDataRZ::BackwardTransform (const int lev, if (do_costs) { amrex::Gpu::synchronize(); - wt = amrex::second() - wt; + wt = static_cast(amrex::second()) - wt; amrex::HostDevice::Atomic::Add( &(*cost)[mfi.index()], wt); } } @@ -773,7 +773,7 @@ SpectralFieldDataRZ::ApplyFilter (const int lev, int const field_index) { amrex::Gpu::synchronize(); } - amrex::Real wt = amrex::second(); + auto wt = static_cast(amrex::second()); auto const & filter_r = binomialfilter[mfi].getFilterArrayR(); auto const & filter_z = binomialfilter[mfi].getFilterArrayZ(); @@ -798,7 +798,7 @@ SpectralFieldDataRZ::ApplyFilter (const int lev, int const field_index) if (do_costs) { amrex::Gpu::synchronize(); - wt = amrex::second() - wt; + wt = static_cast(amrex::second()) - wt; amrex::HostDevice::Atomic::Add( &(*cost)[mfi.index()], wt); } } @@ -818,7 +818,7 @@ SpectralFieldDataRZ::ApplyFilter (const int lev, int const field_index1, { amrex::Gpu::synchronize(); } - amrex::Real wt = amrex::second(); + auto wt = static_cast(amrex::second()); auto const & filter_r = binomialfilter[mfi].getFilterArrayR(); auto const & filter_z = binomialfilter[mfi].getFilterArrayZ(); @@ -847,7 +847,7 @@ SpectralFieldDataRZ::ApplyFilter (const int lev, int const field_index1, if (do_costs) { amrex::Gpu::synchronize(); - wt = amrex::second() - wt; + wt = static_cast(amrex::second()) - wt; amrex::HostDevice::Atomic::Add( &(*cost)[mfi.index()], wt); } } diff --git a/Source/FieldSolver/SpectralSolver/SpectralHankelTransform/BesselRoots.cpp b/Source/FieldSolver/SpectralSolver/SpectralHankelTransform/BesselRoots.cpp index 210a4baffc7..7a74acfadf0 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralHankelTransform/BesselRoots.cpp +++ b/Source/FieldSolver/SpectralSolver/SpectralHankelTransform/BesselRoots.cpp @@ -55,8 +55,8 @@ namespace{ p0 = c[ntry]*(*zeroj); p1 = *zeroj; - q0 = jn(n, p0); - q1 = jn(n, p1); + q0 = static_cast(jn(n, p0)); + q1 = static_cast(jn(n, p1)); for (int it=1; it <= nitmx; it++) { if (q1 == q0) break; p = p1 - q1*(p1 - p0)/(q1 - q0); @@ -68,7 +68,7 @@ namespace{ p0 = p1; q0 = q1; p1 = p; - q1 = jn(n, p1); + q1 = static_cast(jn(n, p1)); } } *ier = 3; @@ -84,7 +84,7 @@ void GetBesselRoots(int n, int nk, amrex::Vector& roots, amrex::Vec int ierror, ik, k; const amrex::Real tol = 1e-14_rt; - const amrex::Real nitmx = 10; + const int nitmx = 10; const amrex::Real c1 = 1.8557571_rt; const amrex::Real c2 = 1.033150_rt; @@ -113,9 +113,9 @@ void GetBesselRoots(int n, int nk, amrex::Vector& roots, amrex::Vec // Include the trivial root ier[0] = 0; roots[0] = 0.; - const amrex::Real f1 = std::pow(n, (1.0_rt/3.0_rt)); - const amrex::Real f2 = f1*f1*n; - const amrex::Real f3 = f1*n*n; + const auto f1 = static_cast(std::pow(n, (1.0_rt/3.0_rt))); + const auto f2 = f1*f1*n; + const auto f3 = f1*n*n; zeroj = n + c1*f1 + (c2/f1) - (c3/n) - (c4/f2) + (c5/f3); ::SecantRootFinder(n, nitmx, tol, &zeroj, &ierror); ier[1] = ierror; @@ -139,7 +139,7 @@ void GetBesselRoots(int n, int nk, amrex::Vector& roots, amrex::Vec zeroj = b0 - (t1/b1) - (t3/b3) - (t5/b5) - (t7/b7); - const amrex::Real errj = std::abs(jn(n, zeroj)); + const amrex::Real errj = static_cast(std::abs(jn(n, zeroj))); // improve solution using procedure SecantRootFinder if (errj > tol) ::SecantRootFinder(n, nitmx, tol, &zeroj, &ierror); diff --git a/Source/FieldSolver/SpectralSolver/SpectralHankelTransform/HankelTransform.cpp b/Source/FieldSolver/SpectralSolver/SpectralHankelTransform/HankelTransform.cpp index da62382dffa..aff5ad25fcc 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralHankelTransform/HankelTransform.cpp +++ b/Source/FieldSolver/SpectralSolver/SpectralHankelTransform/HankelTransform.cpp @@ -68,7 +68,7 @@ HankelTransform::HankelTransform (int const hankel_order, amrex::Vector denom(m_nk); for (int ik=0 ; ik < m_nk ; ik++) { - const amrex::Real jna = jn(p_denom, alphas[ik]); + const auto jna = static_cast(jn(p_denom, alphas[ik])); denom[ik] = MathConst::pi*rmax*rmax*jna*jna; } @@ -76,7 +76,7 @@ HankelTransform::HankelTransform (int const hankel_order, for (int ir=0 ; ir < m_nr ; ir++) { for (int ik=0 ; ik < m_nk ; ik++) { int const ii = ik + ir*m_nk; - num[ii] = jn(hankel_order, rmesh[ir]*kr[ik]); + num[ii] = static_cast(jn(hankel_order, rmesh[ir]*kr[ik])); } } @@ -99,7 +99,8 @@ HankelTransform::HankelTransform (int const hankel_order, if (hankel_order == azimuthal_mode-1) { for (int ir=0 ; ir < m_nr ; ir++) { int const ii = ir*m_nk; - invM[ii] = std::pow(rmesh[ir], (azimuthal_mode-1))/(MathConst::pi*std::pow(rmax, (azimuthal_mode+1))); + invM[ii] = static_cast( + std::pow(rmesh[ir], (azimuthal_mode-1))/(MathConst::pi*std::pow(rmax, (azimuthal_mode+1)))); } } else { for (int ir=0 ; ir < m_nr ; ir++) { diff --git a/Source/FieldSolver/SpectralSolver/SpectralKSpace.cpp b/Source/FieldSolver/SpectralSolver/SpectralKSpace.cpp index b8d81000cda..d882d32d758 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralKSpace.cpp +++ b/Source/FieldSolver/SpectralSolver/SpectralKSpace.cpp @@ -154,7 +154,7 @@ SpectralKSpace::getSpectralShiftFactor( const DistributionMapping& dm, Gpu::DeviceVector& shift = shift_factor[mfi]; // Allocate shift coefficients - const int N = k.size(); + const auto N = static_cast(k.size()); shift.resize(N); Real const* pk = k.data(); Complex* pshift = shift.data(); @@ -202,7 +202,7 @@ SpectralKSpace::getModifiedKComponent( const DistributionMapping& dm, Gpu::DeviceVector& modified_k = modified_k_comp[mfi]; // Allocate modified_k to the same size as k - const int N = k.size(); + const auto N = static_cast(k.size());; modified_k.resize(N); // Fill the modified k vector @@ -216,7 +216,7 @@ SpectralKSpace::getModifiedKComponent( const DistributionMapping& dm, Gpu::copyAsync(Gpu::hostToDevice, h_stencil_coef.begin(), h_stencil_coef.end(), d_stencil_coef.begin()); Gpu::synchronize(); - const int nstencil = d_stencil_coef.size(); + const auto nstencil = static_cast(d_stencil_coef.size()); Real const* p_stencil_coef = d_stencil_coef.data(); // Loop over boxes and allocate the corresponding DeviceVector @@ -227,7 +227,7 @@ SpectralKSpace::getModifiedKComponent( const DistributionMapping& dm, Gpu::DeviceVector& modified_k = modified_k_comp[mfi]; // Allocate modified_k to the same size as k - const int N = k.size(); + const auto N = static_cast(k.size());; modified_k.resize(N); Real const* p_k = k.data(); Real * p_modified_k = modified_k.data(); @@ -242,7 +242,7 @@ SpectralKSpace::getModifiedKComponent( const DistributionMapping& dm, std::sin( p_k[i]*(n+1)*delta_x )/( (n+1)*delta_x ); } else { p_modified_k[i] += p_stencil_coef[n]* \ - std::sin( p_k[i]*(n+0.5)*delta_x )/( (n+0.5)*delta_x ); + std::sin( p_k[i]*(n+0.5_rt)*delta_x )/( (n+0.5_rt)*delta_x ); } } diff --git a/Source/FieldSolver/WarpXPushFieldsEM.cpp b/Source/FieldSolver/WarpXPushFieldsEM.cpp index d515462d730..af1c5224df0 100644 --- a/Source/FieldSolver/WarpXPushFieldsEM.cpp +++ b/Source/FieldSolver/WarpXPushFieldsEM.cpp @@ -1291,8 +1291,8 @@ WarpX::ApplyInverseVolumeScalingToCurrentDensity (MultiFab* Jx, MultiFab* Jy, Mu // Wrap the current density deposited in the guard cells around // to the cells above the axis. if (rmin == 0._rt && 1-ishift_r <= i && i < ngJ[0]-ishift_r) { - Jr_arr(i,j,0,2*imode-1) += std::pow(-1, imode+1)*Jr_arr(-ishift_r-i,j,0,2*imode-1); - Jr_arr(i,j,0,2*imode) += std::pow(-1, imode+1)*Jr_arr(-ishift_r-i,j,0,2*imode); + Jr_arr(i,j,0,2*imode-1) += static_cast(std::pow(-1, imode+1)*Jr_arr(-ishift_r-i,j,0,2*imode-1)); + Jr_arr(i,j,0,2*imode) += static_cast(std::pow(-1, imode+1)*Jr_arr(-ishift_r-i,j,0,2*imode)); } // Apply the inverse volume scaling // Jr is forced to zero on axis. @@ -1328,8 +1328,8 @@ WarpX::ApplyInverseVolumeScalingToCurrentDensity (MultiFab* Jx, MultiFab* Jy, Mu // Wrap the current density deposited in the guard cells around // to the cells above the axis. if (rmin == 0._rt && 1-ishift_t <= i && i <= ngJ[0]-ishift_t) { - Jt_arr(i,j,0,2*imode-1) += std::pow(-1, imode+1)*Jt_arr(-ishift_t-i,j,0,2*imode-1); - Jt_arr(i,j,0,2*imode) += std::pow(-1, imode+1)*Jt_arr(-ishift_t-i,j,0,2*imode); + Jt_arr(i,j,0,2*imode-1) += static_cast(std::pow(-1, imode+1)*Jt_arr(-ishift_t-i,j,0,2*imode-1)); + Jt_arr(i,j,0,2*imode) += static_cast(std::pow(-1, imode+1)*Jt_arr(-ishift_t-i,j,0,2*imode)); } // Apply the inverse volume scaling @@ -1365,8 +1365,8 @@ WarpX::ApplyInverseVolumeScalingToCurrentDensity (MultiFab* Jx, MultiFab* Jy, Mu // Wrap the current density deposited in the guard cells around // to the cells above the axis. if (rmin == 0._rt && 1-ishift_z <= i && i <= ngJ[0]-ishift_z) { - Jz_arr(i,j,0,2*imode-1) -= std::pow(-1, imode+1)*Jz_arr(-ishift_z-i,j,0,2*imode-1); - Jz_arr(i,j,0,2*imode) -= std::pow(-1, imode+1)*Jz_arr(-ishift_z-i,j,0,2*imode); + Jz_arr(i,j,0,2*imode-1) -= static_cast(std::pow(-1, imode+1)*Jz_arr(-ishift_z-i,j,0,2*imode-1)); + Jz_arr(i,j,0,2*imode) -= static_cast(std::pow(-1, imode+1)*Jz_arr(-ishift_z-i,j,0,2*imode)); } // Apply the inverse volume scaling @@ -1411,7 +1411,7 @@ WarpX::ApplyInverseVolumeScalingToChargeDensity (MultiFab* Rho, int lev) const std::array& xyzmin = WarpX::LowerCorner(tilebox, lev, 0._rt); const Dim3 lo = lbound(tilebox); const Real rmin = xyzmin[0]; - const Real rminr = xyzmin[0] + (tb.type(0) == NODE ? 0. : 0.5*dx[0]); + const Real rminr = xyzmin[0] + (tb.type(0) == NODE ? 0._rt : 0.5_rt*dx[0]); const int irmin = lo.x; const int ishift = (rminr > rmin ? 1 : 0); @@ -1445,7 +1445,7 @@ WarpX::ApplyInverseVolumeScalingToChargeDensity (MultiFab* Rho, int lev) else { imode = (icomp - ncomp/2 + 1)/2; } - Rho_arr(i,j,0,icomp) -= std::pow(-1, imode+1)*Rho_arr(-ishift-i,j,0,icomp); + Rho_arr(i,j,0,icomp) -= static_cast(std::pow(-1, imode+1)*Rho_arr(-ishift-i,j,0,icomp)); } // Apply the inverse volume scaling @@ -1453,7 +1453,7 @@ WarpX::ApplyInverseVolumeScalingToChargeDensity (MultiFab* Rho, int lev) if (r == 0.) { Rho_arr(i,j,0,icomp) /= (MathConst::pi*dr*axis_volume_factor); } else { - Rho_arr(i,j,0,icomp) /= (2.*MathConst::pi*r); + Rho_arr(i,j,0,icomp) /= (2._rt*MathConst::pi*r); } }); } diff --git a/Source/FieldSolver/WarpXPushFieldsHybridPIC.cpp b/Source/FieldSolver/WarpXPushFieldsHybridPIC.cpp index 36029e7d3eb..9a5449dfef8 100644 --- a/Source/FieldSolver/WarpXPushFieldsHybridPIC.cpp +++ b/Source/FieldSolver/WarpXPushFieldsHybridPIC.cpp @@ -101,7 +101,7 @@ void WarpX::HybridPICEvolveFields () true ); FillBoundaryE(guard_cells.ng_FieldSolver, WarpX::sync_nodal_points); - EvolveB(0.5 / sub_steps * dt[0], DtType::FirstHalf); + EvolveB(0.5_rt / sub_steps * dt[0], DtType::FirstHalf); FillBoundaryB(guard_cells.ng_FieldSolver, WarpX::sync_nodal_points); } @@ -129,7 +129,7 @@ void WarpX::HybridPICEvolveFields () true ); FillBoundaryE(guard_cells.ng_FieldSolver, WarpX::sync_nodal_points); - EvolveB(0.5 / sub_steps * dt[0], DtType::SecondHalf); + EvolveB(0.5_rt / sub_steps * dt[0], DtType::SecondHalf); FillBoundaryB(guard_cells.ng_FieldSolver, WarpX::sync_nodal_points); } diff --git a/Source/FieldSolver/WarpX_FDTD.H b/Source/FieldSolver/WarpX_FDTD.H index 6f1ebad7819..c6f3c16a2c4 100644 --- a/Source/FieldSolver/WarpX_FDTD.H +++ b/Source/FieldSolver/WarpX_FDTD.H @@ -24,6 +24,9 @@ void warpx_computedivb(int i, int j, int k, int dcomp, #endif ) { + + using namespace amrex; + #if defined WARPX_DIM_3D divB(i,j,k,dcomp) = (Bx(i+1,j ,k ) - Bx(i,j,k))*dxinv + (By(i ,j+1,k ) - By(i,j,k))*dyinv @@ -37,8 +40,8 @@ void warpx_computedivb(int i, int j, int k, int dcomp, amrex::ignore_unused(j, Bx, dxinv); amrex::ignore_unused(k, By, dyinv); #elif defined WARPX_DIM_RZ - const amrex::Real ru = 1. + 0.5/(rmin*dxinv + i + 0.5); - const amrex::Real rd = 1. - 0.5/(rmin*dxinv + i + 0.5); + const amrex::Real ru = 1._rt + 0.5_rt/(rmin*dxinv + i + 0.5_rt); + const amrex::Real rd = 1._rt - 0.5_rt/(rmin*dxinv + i + 0.5_rt); divB(i,j,0,dcomp) = (ru*Bx(i+1,j,0) - rd*Bx(i,j,0))*dxinv + (Bz(i,j+1,0) - Bz(i,j,0))*dzinv; amrex::ignore_unused(k, By, dyinv); diff --git a/Source/Filter/BilinearFilter.cpp b/Source/Filter/BilinearFilter.cpp index c8e921aad31..ecfee2cd7c9 100644 --- a/Source/Filter/BilinearFilter.cpp +++ b/Source/Filter/BilinearFilter.cpp @@ -63,8 +63,8 @@ namespace { void BilinearFilter::ComputeStencils(){ WARPX_PROFILE("BilinearFilter::ComputeStencils()"); int i = 0; - for (auto el : npass_each_dir ) - stencil_length_each_dir[i++] = el; + for (const auto& el : npass_each_dir ) + stencil_length_each_dir[i++] = static_cast(el); stencil_length_each_dir += 1.; #if defined(WARPX_DIM_3D) // npass_each_dir = npass_x npass_y npass_z diff --git a/Source/Filter/Filter.cpp b/Source/Filter/Filter.cpp index b6d5c503953..5952ffde59c 100644 --- a/Source/Filter/Filter.cpp +++ b/Source/Filter/Filter.cpp @@ -47,7 +47,7 @@ Filter::ApplyStencil (MultiFab& dstmf, const MultiFab& srcmf, const int lev, int { amrex::Gpu::synchronize(); } - amrex::Real wt = amrex::second(); + auto wt = static_cast(amrex::second()); const auto& src = srcmf.array(mfi); const auto& dst = dstmf.array(mfi); @@ -59,7 +59,7 @@ Filter::ApplyStencil (MultiFab& dstmf, const MultiFab& srcmf, const int lev, int if (cost && WarpX::load_balance_costs_update_algo == LoadBalanceCostsUpdateAlgo::Timers) { amrex::Gpu::synchronize(); - wt = amrex::second() - wt; + wt = static_cast(amrex::second()) - wt; amrex::HostDevice::Atomic::Add( &(*cost)[mfi.index()], wt); } } @@ -218,7 +218,7 @@ Filter::ApplyStencil (amrex::MultiFab& dstmf, const amrex::MultiFab& srcmf, cons { amrex::Gpu::synchronize(); } - amrex::Real wt = amrex::second(); + auto wt = static_cast(amrex::second()); const auto& srcfab = srcmf[mfi]; auto& dstfab = dstmf[mfi]; @@ -236,7 +236,7 @@ Filter::ApplyStencil (amrex::MultiFab& dstmf, const amrex::MultiFab& srcmf, cons if (cost && WarpX::load_balance_costs_update_algo == LoadBalanceCostsUpdateAlgo::Timers) { amrex::Gpu::synchronize(); - wt = amrex::second() - wt; + wt = static_cast(amrex::second()) - wt; amrex::HostDevice::Atomic::Add( &(*cost)[mfi.index()], wt); } } diff --git a/Source/Fluids/MultiFluidContainer.H b/Source/Fluids/MultiFluidContainer.H index 94d95d179e5..ef6cc6115cb 100644 --- a/Source/Fluids/MultiFluidContainer.H +++ b/Source/Fluids/MultiFluidContainer.H @@ -61,7 +61,7 @@ public: amrex::MultiFab* rho, amrex::MultiFab& jx, amrex::MultiFab& jy, amrex::MultiFab& jz, amrex::Real cur_time, bool skip_deposition=false); - int nSpecies() const {return species_names.size();} + int nSpecies() const {return static_cast(species_names.size());} void DepositCharge (int lev, amrex::MultiFab &rho); void DepositCurrent (int lev, diff --git a/Source/Fluids/MusclHancockUtils.H b/Source/Fluids/MusclHancockUtils.H index d0c37f9c58f..764143a7220 100644 --- a/Source/Fluids/MusclHancockUtils.H +++ b/Source/Fluids/MusclHancockUtils.H @@ -18,7 +18,8 @@ AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real F_r (amrex::Real r, amrex::Real u_r, amrex::Real u_theta, amrex::Real u_z, amrex::Real dt) { - return dt*(-u_theta*u_theta/r)/sqrt(1.0 + u_r*u_r + u_theta*u_theta + u_z*u_z) + u_r; + using namespace amrex::literals; + return dt*(-u_theta*u_theta/r)/std::sqrt(1.0_rt + u_r*u_r + u_theta*u_theta + u_z*u_z) + u_r; } // Euler push for momentum source (theta-direction) @@ -26,26 +27,29 @@ amrex::Real F_r (amrex::Real r, amrex::Real u_r, amrex::Real u_theta, amrex::Rea AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real F_theta (amrex::Real r, amrex::Real u_r, amrex::Real u_theta, amrex::Real u_z, amrex::Real dt) { - return dt*(u_theta*u_r/r)/sqrt(1.0 + u_r*u_r + u_theta*u_theta + u_z*u_z) + u_theta; + using namespace amrex::literals; + return dt*(u_theta*u_r/r)/std::sqrt(1.0_rt + u_r*u_r + u_theta*u_theta + u_z*u_z) + u_theta; } // Velocity at the half step AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real V_calc (const amrex::Array4& U, int i, int j, int k, int comp, amrex::Real c) { + using namespace amrex::literals; // comp -> x, y, z -> 0, 1, 2, return Vx, Vy, or Vz: - amrex::Real gamma = std::sqrt(1.0 + (U(i,j,k,1)*U(i,j,k,1) + U(i,j,k,2)*U(i,j,k,2) + U(i,j,k,3)*U(i,j,k,3))/(c*c)); + amrex::Real gamma = std::sqrt(1.0_rt + (U(i,j,k,1)*U(i,j,k,1) + U(i,j,k,2)*U(i,j,k,2) + U(i,j,k,3)*U(i,j,k,3))/(c*c)); return U(i,j,k,comp+1)/gamma; } // mindmod AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real minmod (amrex::Real a, amrex::Real b) { - if (a > 0.0 && b > 0.0) + using namespace amrex::literals; + if (a > 0.0_rt && b > 0.0_rt) return std::min(a, b); - else if (a < 0.0 && b < 0.0) + else if (a < 0.0_rt && b < 0.0_rt) return std::max(a, b); else - return 0.0; + return 0.0_rt; } // Min of 3 inputs AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE @@ -63,9 +67,10 @@ amrex::Real max3 (amrex::Real a, amrex::Real b, amrex::Real c) AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real minmod3 (amrex::Real a, amrex::Real b , amrex::Real c) { - if (a > 0.0 && b > 0.0 && c > 0.0) + using namespace amrex::literals; + if (a > 0.0_rt && b > 0.0_rt && c > 0.0_rt) return min3(a,b,c); - else if (a < 0.0 && b < 0.0 && c < 0.0) + else if (a < 0.0_rt && b < 0.0_rt && c < 0.0_rt) return max3(a,b,c); else return 0.0; @@ -74,89 +79,99 @@ amrex::Real minmod3 (amrex::Real a, amrex::Real b , amrex::Real c) AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real maxmod (amrex::Real a, amrex::Real b) { - if (a > 0.0 && b > 0.0) + using namespace amrex::literals; + if (a > 0.0_rt && b > 0.0_rt) return std::max(a, b); - else if (a < 0.0 && b < 0.0) + else if (a < 0.0_rt && b < 0.0_rt) return std::min(a, b); else - return 0.0; + return 0.0_rt; } // Rusanov Flux (density) AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real flux_N (const amrex::Array4& Um, const amrex::Array4& Up, int i, int j, int k, amrex::Real Vm, amrex::Real Vp) { + using namespace amrex::literals; amrex::Real c = std::max( std::abs(Vm) , std::abs(Vp) ); - return 0.5*(Vm*Um(i,j,k,0) + Vp*Up(i,j,k,0)) - (0.5*c)*(Up(i,j,k,0) - Um(i,j,k,0)); + return 0.5_rt*(Vm*Um(i,j,k,0) + Vp*Up(i,j,k,0)) - (0.5_rt*c)*(Up(i,j,k,0) - Um(i,j,k,0)); } // Rusanov Flux (Momentum density x) AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real flux_NUx (const amrex::Array4& Um, const amrex::Array4& Up, int i, int j, int k, amrex::Real Vm, amrex::Real Vp) { + using namespace amrex::literals; amrex::Real c = std::max( std::abs(Vm) , std::abs(Vp) ); - return 0.5*(Vm*Um(i,j,k,0)*Um(i,j,k,1) + Vp*Up(i,j,k,0)*Up(i,j,k,1)) - - (0.5*c)*(Up(i,j,k,0)*Up(i,j,k,1) - Um(i,j,k,0)*Um(i,j,k,1)); + return 0.5_rt*(Vm*Um(i,j,k,0)*Um(i,j,k,1) + Vp*Up(i,j,k,0)*Up(i,j,k,1)) + - (0.5_rt*c)*(Up(i,j,k,0)*Up(i,j,k,1) - Um(i,j,k,0)*Um(i,j,k,1)); } // Rusanov Flux (Momentum density y) AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real flux_NUy (const amrex::Array4& Um, const amrex::Array4& Up, int i, int j, int k, amrex::Real Vm, amrex::Real Vp) { + using namespace amrex::literals; amrex::Real c = std::max( std::abs(Vm) , std::abs(Vp) ); - return 0.5*(Vm*Um(i,j,k,0)*Um(i,j,k,2) + Vp*Up(i,j,k,0)*Up(i,j,k,2)) - - (0.5*c)*(Up(i,j,k,0)*Up(i,j,k,2) - Um(i,j,k,0)*Um(i,j,k,2)); + return 0.5_rt*(Vm*Um(i,j,k,0)*Um(i,j,k,2) + Vp*Up(i,j,k,0)*Up(i,j,k,2)) + - (0.5_rt*c)*(Up(i,j,k,0)*Up(i,j,k,2) - Um(i,j,k,0)*Um(i,j,k,2)); } // Rusanov Flux (Momentum density z) AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real flux_NUz (const amrex::Array4& Um, const amrex::Array4& Up, int i, int j, int k, amrex::Real Vm, amrex::Real Vp) { + using namespace amrex::literals; amrex::Real c = std::max( std::abs(Vm) , std::abs(Vp) ); - return 0.5*(Vm*Um(i,j,k,0)*Um(i,j,k,3) + Vp*Up(i,j,k,0)*Up(i,j,k,3)) - - (0.5*c)*(Up(i,j,k,0)*Up(i,j,k,3) - Um(i,j,k,0)*Um(i,j,k,3)); + return 0.5_rt*(Vm*Um(i,j,k,0)*Um(i,j,k,3) + Vp*Up(i,j,k,0)*Up(i,j,k,3)) + - (0.5_rt*c)*(Up(i,j,k,0)*Up(i,j,k,3) - Um(i,j,k,0)*Um(i,j,k,3)); } // ave_minmod high diffusivity, sigma can be between [1,2] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real ave_adjustable_diff (amrex::Real a, amrex::Real b) { - amrex::Real sigma = 2.0*0.732050807568877; - if (a*b > 0.0) - return minmod3( (a+b)/2.0, sigma*a, sigma*b ); + using namespace amrex::literals; + constexpr auto sigma = static_cast(2.0*0.732050807568877); + if (a*b > 0.0_rt) + return minmod3( (a+b)/2.0_rt, sigma*a, sigma*b ); else - return 0.0; + return 0.0_rt; } // ave_minmod Low diffusivity AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real ave (amrex::Real a, amrex::Real b) { - if (a*b > 0.0) - return minmod3( (a+b)/2.0, 2.0*a, 2.0*b ); + using namespace amrex::literals; + if (a*b > 0.0_rt) + return minmod3( (a+b)/2.0_rt, 2.0_rt*a, 2.0_rt*b ); else - return 0.0; + return 0.0_rt; } // ave_superbee AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real ave_superbee (amrex::Real a, amrex::Real b) { - if (a*b > 0.0) - return minmod( maxmod(a,b), minmod(2.0*a,2.0*b)); + using namespace amrex::literals; + if (a*b > 0.0_rt) + return minmod( maxmod(a,b), minmod(2.0_rt*a,2.0_rt*b)); else - return 0.0; + return 0.0_rt; } // stage2 slope limiting AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real ave_stage2 (amrex::Real dQ, amrex::Real a, amrex::Real b, amrex::Real c) { + using namespace amrex::literals; // sigma = sqrt(3) -1 - amrex::Real sigma = 0.732050807568877; - amrex::Real dq_min = 2.0*std::min( b - min3(a,b,c), max3(a,b,c) - b); + constexpr auto sigma = 0.732050807568877_rt; + amrex::Real dq_min = 2.0_rt*std::min( b - min3(a,b,c), max3(a,b,c) - b); return ( std::abs(dQ)/dQ ) * std::min( std::abs(dQ) , sigma*std::abs(dq_min) ); } // Returns the offset indices for the "plus" grid AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void plus_index_offsets (int i, int j, int k, int& ip, int& jp, int& kp, int comp) { + using namespace amrex::literals; // Find the correct offsets #if defined(WARPX_DIM_3D) if (comp == 0) { //x @@ -184,23 +199,23 @@ void compute_U_edges (const amrex::Array4& Um, const amrex::Array4< amrex::Real U_tilde0, amrex::Real U_tilde1, amrex::Real U_tilde2, amrex::Real U_tilde3, amrex::Real dU0x, amrex::Real dU1x, amrex::Real dU2x, amrex::Real dU3x, int comp) { - + using namespace amrex::literals; // comp -> x, y, z -> 0, 1, 2 int ip, jp, kp; plus_index_offsets(i, j, k, ip, jp, kp, comp); if ( box.contains(i,j,k) ) { - Um(i,j,k,0) = U_tilde0 + dU0x/2.0; - Um(i,j,k,1) = U_tilde1 + dU1x/2.0; - Um(i,j,k,2) = U_tilde2 + dU2x/2.0; - Um(i,j,k,3) = U_tilde3 + dU3x/2.0; + Um(i,j,k,0) = U_tilde0 + dU0x/2.0_rt; + Um(i,j,k,1) = U_tilde1 + dU1x/2.0_rt; + Um(i,j,k,2) = U_tilde2 + dU2x/2.0_rt; + Um(i,j,k,3) = U_tilde3 + dU3x/2.0_rt; } if ( box.contains(ip,jp,kp) ) { - Up(ip,jp,kp,0) = U_tilde0 - dU0x/2.0; - Up(ip,jp,kp,1) = U_tilde1 - dU1x/2.0; - Up(ip,jp,kp,2) = U_tilde2 - dU2x/2.0; - Up(ip,jp,kp,3) = U_tilde3 - dU3x/2.0; + Up(ip,jp,kp,0) = U_tilde0 - dU0x/2.0_rt; + Up(ip,jp,kp,1) = U_tilde1 - dU1x/2.0_rt; + Up(ip,jp,kp,2) = U_tilde2 - dU2x/2.0_rt; + Up(ip,jp,kp,3) = U_tilde3 - dU3x/2.0_rt; } } // Compute the zero edges @@ -208,23 +223,23 @@ AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void set_U_edges_to_zero (const amrex::Array4& Um, const amrex::Array4& Up, int i, int j, int k, amrex::Box box, int comp) { - + using namespace amrex::literals; // comp -> x, y, z -> 0, 1, 2 int ip, jp, kp; plus_index_offsets(i, j, k, ip, jp, kp, comp); if ( box.contains(i,j,k) ) { - Um(i,j,k,0) = 0.0; - Um(i,j,k,1) = 0.0; - Um(i,j,k,2) = 0.0; - Um(i,j,k,3) = 0.0; + Um(i,j,k,0) = 0.0_rt; + Um(i,j,k,1) = 0.0_rt; + Um(i,j,k,2) = 0.0_rt; + Um(i,j,k,3) = 0.0_rt; } if ( box.contains(ip,jp,kp) ) { - Up(ip,jp,kp,0) = 0.0; - Up(ip,jp,kp,1) = 0.0; - Up(ip,jp,kp,2) = 0.0; - Up(ip,jp,kp,3) = 0.0; + Up(ip,jp,kp,0) = 0.0_rt; + Up(ip,jp,kp,1) = 0.0_rt; + Up(ip,jp,kp,2) = 0.0_rt; + Up(ip,jp,kp,3) = 0.0_rt; } } // Positivity Limiter @@ -236,6 +251,7 @@ int i, int j, int k, amrex::Box box, amrex::Real Ux, amrex::Real Uy, amrex::Real int comp) { + using namespace amrex::literals; // comp -> x, y, z -> 0, 1, 2 int ip, jp, kp; plus_index_offsets(i, j, k, ip, jp, kp, comp); @@ -244,7 +260,7 @@ int comp) // set the slope to zero (hence why we have the three cases, the first is when // both points exist, and the second two are are edge cases) if (( box.contains(i,j,k) ) && ( box.contains(ip,jp,kp) )) { - if ((U_edge_minus(i,j,k,0) < 0.0) || (U_edge_plus(ip,jp,kp,0) < 0.0)) { + if ((U_edge_minus(i,j,k,0) < 0.0_rt) || (U_edge_plus(ip,jp,kp,0) < 0.0_rt)) { U_edge_minus(i,j,k,0) = N_arr(i,j,k); U_edge_minus(i,j,k,1) = Ux; U_edge_minus(i,j,k,2) = Uy; @@ -255,14 +271,14 @@ int comp) U_edge_plus(ip,jp,kp,3) = Uz; } } else if (( box.contains(i,j,k) ) && ( box.contains(ip,jp,kp) != 1)) { - if (U_edge_minus(i,j,k,0) < 0.0) { + if (U_edge_minus(i,j,k,0) < 0.0_rt) { U_edge_minus(i,j,k,0) = N_arr(i,j,k); U_edge_minus(i,j,k,1) = Ux; U_edge_minus(i,j,k,2) = Uy; U_edge_minus(i,j,k,3) = Uz; } } else if (( box.contains(i,j,k) != 1 ) && ( box.contains(ip,jp,kp) )) { - if (U_edge_plus(ip,jp,kp,0) < 0.0){ + if (U_edge_plus(ip,jp,kp,0) < 0.0_rt){ U_edge_plus(ip,jp,kp,0) = N_arr(i,j,k); U_edge_plus(ip,jp,kp,1) = Ux; U_edge_plus(ip,jp,kp,2) = Uy; @@ -275,54 +291,59 @@ int comp) AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real DownDx_N (const amrex::Array4& N, int i, int j, int k) { + using namespace amrex::literals; // Write the correct differences #if defined(WARPX_DIM_3D) || defined(WARPX_DIM_RZ) || defined(WARPX_DIM_XZ) return N(i,j,k) - N(i-1,j,k); #else amrex::ignore_unused(N, i, j, k); - return 0.0; + return 0.0_rt; #endif } // Compute the difference in N (up-x) AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real UpDx_N (const amrex::Array4& N, int i, int j, int k) { + using namespace amrex::literals; // Write the correct differences #if defined(WARPX_DIM_3D) || defined(WARPX_DIM_RZ) || defined(WARPX_DIM_XZ) return N(i+1,j,k) - N(i,j,k); #else amrex::ignore_unused(N, i, j, k); - return 0.0; + return 0.0_rt; #endif } // Compute the difference in N (down-y) AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real DownDy_N (const amrex::Array4& N, int i, int j, int k) { + using namespace amrex::literals; // Write the correct differences #if defined(WARPX_DIM_3D) return N(i,j,k) - N(i,j-1,k); #else amrex::ignore_unused(N, i, j, k); - return 0.0; + return 0.0_rt; #endif } // Compute the difference in N (up-y) AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real UpDy_N (const amrex::Array4& N, int i, int j, int k) { + using namespace amrex::literals; // Write the correct differences #if defined(WARPX_DIM_3D) return N(i,j+1,k) - N(i,j,k); #else amrex::ignore_unused(N, i, j, k); - return 0.0; + return 0.0_rt; #endif } // Compute the difference in N (down-z) AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real DownDz_N (const amrex::Array4& N, int i, int j, int k) { + using namespace amrex::literals; // Write the correct differences #if defined(WARPX_DIM_3D) return N(i,j,k) - N(i,j,k-1); @@ -336,6 +357,7 @@ amrex::Real DownDz_N (const amrex::Array4& N, int i, int j, int k) AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real UpDz_N (const amrex::Array4& N, int i, int j, int k) { + using namespace amrex::literals; // Write the correct differences #if defined(WARPX_DIM_3D) return N(i,j,k+1) - N(i,j,k); @@ -352,6 +374,7 @@ AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real DownDx_U (const amrex::Array4& N, const amrex::Array4& NU, amrex::Real& U, int i, int j, int k) { + using namespace amrex::literals; // Write the correct differences #if defined(WARPX_DIM_3D) || defined(WARPX_DIM_RZ) || defined(WARPX_DIM_XZ) // U is zero if N is zero, Check positivity before dividing @@ -360,7 +383,7 @@ const amrex::Array4& NU, amrex::Real& U, int i, int j, int k) return U - U_m; #else amrex::ignore_unused(N, NU, U, i, j, k); - return 0.0; + return 0.0_rt; #endif } // Compute the difference in U (up-x) @@ -368,6 +391,7 @@ AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real UpDx_U (const amrex::Array4& N, const amrex::Array4& NU, amrex::Real& U, int i, int j, int k) { + using namespace amrex::literals; // Write the correct differences #if defined(WARPX_DIM_3D) || defined(WARPX_DIM_RZ) || defined(WARPX_DIM_XZ) // U is zero if N is zero, Check positivity before dividing @@ -376,7 +400,7 @@ const amrex::Array4& NU, amrex::Real& U, int i, int j, int k) return U_p - U; #else amrex::ignore_unused(N, NU, U, i, j, k); - return 0.0; + return 0.0_rt; #endif } @@ -385,6 +409,7 @@ AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real DownDy_U (const amrex::Array4& N, const amrex::Array4& NU, amrex::Real& U, int i, int j, int k) { + using namespace amrex::literals; // Write the correct differences #if defined(WARPX_DIM_3D) // U is zero if N is zero, Check positivity before dividing @@ -393,7 +418,7 @@ const amrex::Array4& NU, amrex::Real& U, int i, int j, int k) return U - U_m; #else amrex::ignore_unused(N, NU, U, i, j, k); - return 0.0; + return 0.0_rt; #endif } // Compute the difference in U (up-y) @@ -401,6 +426,7 @@ AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real UpDy_U (const amrex::Array4& N, const amrex::Array4& NU, amrex::Real& U, int i, int j, int k) { + using namespace amrex::literals; // Write the correct differences #if defined(WARPX_DIM_3D) // U is zero if N is zero, Check positivity before dividing @@ -409,7 +435,7 @@ const amrex::Array4& NU, amrex::Real& U, int i, int j, int k) return U_p - U; #else amrex::ignore_unused(N, NU, U, i, j, k); - return 0.0; + return 0.0_rt; #endif } @@ -418,8 +444,9 @@ AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real DownDz_U (const amrex::Array4& N, const amrex::Array4& NU, amrex::Real& U, int i, int j, int k) { + using namespace amrex::literals; // Write the correct differences - amrex::Real U_m = 0; + amrex::Real U_m = 0_rt; // U is zero if N is zero, Check positivity before dividing #if defined(WARPX_DIM_3D) @@ -438,6 +465,7 @@ AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real UpDz_U (const amrex::Array4& N, const amrex::Array4& NU, amrex::Real& U, int i, int j, int k) { + using namespace amrex::literals; // Write the correct differences amrex::Real U_p = 0; @@ -460,6 +488,7 @@ AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real dF (const amrex::Array4& U_minus, const amrex::Array4& U_plus,int i,int j,int k,amrex::Real clight, int comp, int dir) { + using namespace amrex::literals; // dir -> x, y, z -> 0, 1, 2 int ip, jp, kp; plus_index_offsets(i, j, k, ip, jp, kp, dir); diff --git a/Source/Fluids/WarpXFluidContainer.cpp b/Source/Fluids/WarpXFluidContainer.cpp index 758e353208e..48631035397 100644 --- a/Source/Fluids/WarpXFluidContainer.cpp +++ b/Source/Fluids/WarpXFluidContainer.cpp @@ -233,8 +233,8 @@ void WarpXFluidContainer::InitData(int lev, amrex::Box init_box, amrex::Real cur // Lorentz transform n, u (from lab to boosted frame) if (n > 0.0){ if (gamma_boost > 1._rt){ - amrex::Real gamma = sqrt(1.0 + (u.x*u.x + u.y*u.y + u.z*u.z)/(clight*clight)); - amrex::Real n_boosted = gamma_boost*n*( 1.0 - beta_boost*u.z/(gamma*clight) ); + amrex::Real gamma = std::sqrt(1.0_rt + (u.x*u.x + u.y*u.y + u.z*u.z)/(clight*clight)); + amrex::Real n_boosted = gamma_boost*n*( 1.0_rt - beta_boost*u.z/(gamma*clight) ); amrex::Real uz_boosted = gamma_boost*(u.z - beta_boost*clight*gamma); u.z = uz_boosted; n = n_boosted; @@ -417,22 +417,22 @@ void WarpXFluidContainer::AdvectivePush_Muscl (int lev) amrex::Real dt_over_dx = (dt/dx[0]); amrex::Real dt_over_dy = (dt/dx[1]); amrex::Real dt_over_dz = (dt/dx[2]); - amrex::Real dt_over_dx_half = 0.5*(dt/dx[0]); - amrex::Real dt_over_dy_half = 0.5*(dt/dx[1]); - amrex::Real dt_over_dz_half = 0.5*(dt/dx[2]); + amrex::Real dt_over_dx_half = 0.5_rt*(dt/dx[0]); + amrex::Real dt_over_dy_half = 0.5_rt*(dt/dx[1]); + amrex::Real dt_over_dz_half = 0.5_rt*(dt/dx[2]); #elif defined(WARPX_DIM_XZ) - amrex::Real dt_over_dx_half = 0.5*(dt/dx[0]); - amrex::Real dt_over_dz_half = 0.5*(dt/dx[1]); + amrex::Real dt_over_dx_half = 0.5_rt*(dt/dx[0]); + amrex::Real dt_over_dz_half = 0.5_rt*(dt/dx[1]); amrex::Real dt_over_dx = (dt/dx[0]); amrex::Real dt_over_dz = (dt/dx[1]); #elif defined(WARPX_DIM_RZ) const auto problo = geom.ProbLoArray(); - amrex::Real dt_over_dx_half = 0.5*(dt/dx[0]); - amrex::Real dt_over_dz_half = 0.5*(dt/dx[1]); + amrex::Real dt_over_dx_half = 0.5_rt*(dt/dx[0]); + amrex::Real dt_over_dz_half = 0.5_rt*(dt/dx[1]); amrex::Box const& domain = geom.Domain(); #else amrex::Real dt_over_dz = (dt/dx[0]); - amrex::Real dt_over_dz_half = 0.5*(dt/dx[0]); + amrex::Real dt_over_dz_half = 0.5_rt*(dt/dx[0]); #endif amrex::BoxArray ba = N[lev]->boxArray(); @@ -532,8 +532,8 @@ void WarpXFluidContainer::AdvectivePush_Muscl (int lev) // Compute useful quantities for J amrex::Real c_sq = clight*clight; - amrex::Real gamma = sqrt(1.0 + (Ux*Ux + Uy*Uy + Uz*Uz)/(c_sq) ); - amrex::Real inv_c2_gamma3 = 1./(c_sq*gamma*gamma*gamma); + amrex::Real gamma = std::sqrt(1.0_rt + (Ux*Ux + Uy*Uy + Uz*Uz)/(c_sq) ); + amrex::Real inv_c2_gamma3 = 1._rt/(c_sq*gamma*gamma*gamma); // J represents are 4x4 matrices that show up in the advection // equations written as a function of U = {N, Ux, Uy, Uz}: @@ -654,14 +654,14 @@ void WarpXFluidContainer::AdvectivePush_Muscl (int lev) dU0x = ave( -UpDx_N(N_arr,i,j,k) , UpDx_N(N_arr,i,j,k) ); // First term in the ave is: U_{x,y} + U_{x,y}_p, // which can be writen as 2*U_{x,y} + UpDx_U(U_{x,y}) - dU1x = ave( 2.0*Ux + UpDx_U(N_arr,NUx_arr,Ux,i,j,k) , UpDx_U(N_arr,NUx_arr,Ux,i,j,k) ); - dU2x = ave( 2.0*Uy + UpDx_U(N_arr,NUy_arr,Uy,i,j,k) , UpDx_U(N_arr,NUy_arr,Uy,i,j,k) ); + dU1x = ave( 2.0_rt*Ux + UpDx_U(N_arr,NUx_arr,Ux,i,j,k) , UpDx_U(N_arr,NUx_arr,Ux,i,j,k) ); + dU2x = ave( 2.0_rt*Uy + UpDx_U(N_arr,NUy_arr,Uy,i,j,k) , UpDx_U(N_arr,NUy_arr,Uy,i,j,k) ); dU3x = ave( -UpDx_U(N_arr,NUz_arr,Uz,i,j,k) , UpDx_U(N_arr,NUz_arr,Uz,i,j,k) ); } else if (i == domain.bigEnd(0)+1) { - dU0x = ave( DownDx_N(N_arr,i,j,k) , 0.0 ); - dU1x = ave( DownDx_U(N_arr,NUx_arr,Ux,i,j,k) , 0.0 ); - dU2x = ave( DownDx_U(N_arr,NUy_arr,Uy,i,j,k) , 0.0 ); - dU3x = ave( DownDx_U(N_arr,NUz_arr,Uz,i,j,k) , 0.0 ); + dU0x = ave( DownDx_N(N_arr,i,j,k) , 0.0_rt ); + dU1x = ave( DownDx_U(N_arr,NUx_arr,Ux,i,j,k) , 0.0_rt ); + dU2x = ave( DownDx_U(N_arr,NUy_arr,Uy,i,j,k) , 0.0_rt ); + dU3x = ave( DownDx_U(N_arr,NUz_arr,Uz,i,j,k) , 0.0_rt ); } // RZ sources: @@ -679,7 +679,7 @@ void WarpXFluidContainer::AdvectivePush_Muscl (int lev) amrex::Real JdU1z = J11z*dU1z; amrex::Real JdU2z = J22z*dU2z; amrex::Real JdU3z = J33z*dU3z; - amrex::Real U_tilde0 = N_arr(i,j,k) - dt_over_dx_half*JdU0x - dt_over_dz_half*JdU0z - (dt/2.0)*N_source; + amrex::Real U_tilde0 = N_arr(i,j,k) - dt_over_dx_half*JdU0x - dt_over_dz_half*JdU0z - (dt/2.0_rt)*N_source; amrex::Real U_tilde1 = Ux - dt_over_dx_half*JdU1x - dt_over_dz_half*JdU1z; amrex::Real U_tilde2 = Uy - dt_over_dx_half*JdU2x - dt_over_dz_half*JdU2z; amrex::Real U_tilde3 = Uz - dt_over_dx_half*JdU3x - dt_over_dz_half*JdU3z; @@ -804,28 +804,28 @@ void WarpXFluidContainer::AdvectivePush_Muscl (int lev) amrex::Real dr = dx[0]; amrex::Real dz = dx[1]; amrex::Real r = problo[0] + i * dr; - amrex::Real Vij = 0.0; - amrex::Real S_Az = 0.0; + amrex::Real Vij = 0.0_rt; + amrex::Real S_Az = 0.0_rt; // Volume element and z-facing surfaces if (i == domain.smallEnd(0)) { - Vij = 2.0*MathConst::pi*(dr/2.0)*(dr/4.0)*dz; - S_Az = 2.0*MathConst::pi*(dr/4.0)*(dr/2.0); + Vij = 2.0_rt*MathConst::pi*(dr/2.0_rt)*(dr/4.0_rt)*dz; + S_Az = 2.0_rt*MathConst::pi*(dr/4.0_rt)*(dr/2.0_rt); } else if (i == domain.bigEnd(0)+1) { - Vij = 2.0*MathConst::pi*(r - dr/4.0)*(dr/2.0)*dz; - S_Az = 2.0*MathConst::pi*(r - dr/4.0)*(dr/2.0); + Vij = 2.0_rt*MathConst::pi*(r - dr/4.0_rt)*(dr/2.0_rt)*dz; + S_Az = 2.0_rt*MathConst::pi*(r - dr/4.0_rt)*(dr/2.0_rt); } else { - Vij = 2.0*MathConst::pi*r*dr*dz; - S_Az = 2.0*MathConst::pi*(r)*dr; + Vij = 2.0_rt*MathConst::pi*r*dr*dz; + S_Az = 2.0_rt*MathConst::pi*(r)*dr; } // Radial Surfaces - amrex::Real S_Ar_plus = 2.0*MathConst::pi*(r + dr/2.0)*dz; - amrex::Real S_Ar_minus = 2.0*MathConst::pi*(r - dr/2.0)*dz; + amrex::Real S_Ar_plus = 2.0_rt*MathConst::pi*(r + dr/2.0_rt)*dz; + amrex::Real S_Ar_minus = 2.0_rt*MathConst::pi*(r - dr/2.0_rt)*dz; if (i == domain.smallEnd(0)) - S_Ar_minus = 0.0; + S_Ar_minus = 0.0_rt; if (i == domain.bigEnd(0)+1) - S_Ar_plus = 2.0*MathConst::pi*(r)*dz; + S_Ar_plus = 2.0_rt*MathConst::pi*(r)*dz; // Impose "none" boundaries // Condition: Vx(r) = 0 at boundaries @@ -834,9 +834,9 @@ void WarpXFluidContainer::AdvectivePush_Muscl (int lev) // compute the fluxes: // (note that _plus is shifted due to grid location) - amrex::Real Vx_L_minus = 0.0, Vx_I_plus = 0.0; - amrex::Real F0_minusx = 0.0, F1_minusx = 0.0, F2_minusx = 0.0, F3_minusx = 0.0; - amrex::Real F0_plusx = 0.0, F1_plusx = 0.0, F2_plusx = 0.0, F3_plusx = 0.0; + amrex::Real Vx_L_minus = 0.0_rt, Vx_I_plus = 0.0_rt; + amrex::Real F0_minusx = 0.0_rt, F1_minusx = 0.0_rt, F2_minusx = 0.0_rt, F3_minusx = 0.0_rt; + amrex::Real F0_plusx = 0.0_rt, F1_plusx = 0.0_rt, F2_plusx = 0.0_rt, F3_plusx = 0.0_rt; if (i != domain.smallEnd(0)) { Vx_L_minus = V_calc(U_minus_x,i-1,j,k,0,clight); F0_minusx = flux_N( U_minus_x, U_plus_x, i-1, j, k, Vx_L_minus, Vx_L_plus)*S_Ar_minus; @@ -905,7 +905,7 @@ void WarpXFluidContainer::centrifugal_source_rz (int lev) { // Verify density is non-zero - if (N_arr(i,j,k)>0.0) { + if (N_arr(i,j,k)>0.0_rt) { // Compute r amrex::Real r = problo[0] + i * dx[0]; @@ -920,10 +920,10 @@ void WarpXFluidContainer::centrifugal_source_rz (int lev) if (i != domain.smallEnd(0)) { amrex::Real u_r_1 = F_r(r,u_r,u_theta,u_z,dt); amrex::Real u_theta_1 = F_theta(r,u_r,u_theta,u_z,dt); - amrex::Real u_r_2 = (0.75)*(u_r) + (0.25)*F_r(r,u_r_1,u_theta_1,u_z,dt); - amrex::Real u_theta_2 = (0.75)*(u_theta) + (0.25)*F_theta(r,u_r_1,u_theta_1,u_z,dt); - u_r = (1.0/3.0)*(u_r) + (2.0/3.0)*F_r(r,u_r_2,u_theta_2,u_z,dt); - u_theta = (1.0/3.0)*(u_theta) + (2.0/3.0)*F_theta(r,u_r_2,u_theta_2,u_z,dt); + amrex::Real u_r_2 = (0.75_rt)*(u_r) + (0.25_rt)*F_r(r,u_r_1,u_theta_1,u_z,dt); + amrex::Real u_theta_2 = (0.75_rt)*(u_theta) + (0.25_rt)*F_theta(r,u_r_1,u_theta_1,u_z,dt); + u_r = (1.0_rt/3.0_rt)*(u_r) + (2.0_rt/3.0_rt)*F_r(r,u_r_2,u_theta_2,u_z,dt); + u_theta = (1.0_rt/3.0_rt)*(u_theta) + (2.0_rt/3.0_rt)*F_theta(r,u_r_2,u_theta_2,u_z,dt); // Calculate NU, save NUr, NUtheta NUx_arr(i,j,k) = N_arr(i,j,k)*u_r*clight; @@ -931,8 +931,8 @@ void WarpXFluidContainer::centrifugal_source_rz (int lev) // BC r = 0, u_theta = 0, and there is no extra source terms } else { - NUx_arr(i,j,k) = 0.0; - NUy_arr(i,j,k) = 0.0; + NUx_arr(i,j,k) = 0.0_rt; + NUy_arr(i,j,k) = 0.0_rt; } } } @@ -1286,12 +1286,12 @@ void WarpXFluidContainer::DepositCurrent( [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept { // Calculate J from fluid quantities - amrex::Real gamma = 1.0, Ux = 0.0, Uy = 0.0, Uz = 0.0; - if (N_arr(i, j, k)>0.0){ + amrex::Real gamma = 1.0_rt, Ux = 0.0_rt, Uy = 0.0_rt, Uz = 0.0_rt; + if (N_arr(i, j, k)>0.0_rt){ Ux = NUx_arr(i, j, k)/N_arr(i, j, k); Uy = NUy_arr(i, j, k)/N_arr(i, j, k); Uz = NUz_arr(i, j, k)/N_arr(i, j, k); - gamma = std::sqrt(1.0 + ( Ux*Ux + Uy*Uy + Uz*Uz) * inv_clight_sq ) ; + gamma = std::sqrt(1.0_rt + ( Ux*Ux + Uy*Uy + Uz*Uz) * inv_clight_sq ) ; } tmp_jx_fluid_arr(i, j, k) = q * (NUx_arr(i, j, k) / gamma); tmp_jy_fluid_arr(i, j, k) = q * (NUy_arr(i, j, k) / gamma); diff --git a/Source/Initialization/InjectorMomentum.H b/Source/Initialization/InjectorMomentum.H index b0afafa730b..b597e361dfa 100644 --- a/Source/Initialization/InjectorMomentum.H +++ b/Source/Initialization/InjectorMomentum.H @@ -231,12 +231,14 @@ struct InjectorMomentumUniform : 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 * (m_ux_max + m_ux_min); - m_uy_h = 0.5 * (m_uy_max + m_uy_min); - m_uz_h = 0.5 * (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); } AMREX_GPU_HOST_DEVICE diff --git a/Source/Initialization/PlasmaInjector.cpp b/Source/Initialization/PlasmaInjector.cpp index 56d29a8a1bb..0486f6e9537 100644 --- a/Source/Initialization/PlasmaInjector.cpp +++ b/Source/Initialization/PlasmaInjector.cpp @@ -487,7 +487,7 @@ void PlasmaInjector::setupExternalFile (const amrex::ParmParse& pp_species_name) ps["charge"][openPMD::RecordComponent::SCALAR].loadChunk(); m_openpmd_input_series->flush(); amrex::ParticleReal const p_q = p_q_ptr.get()[0]; - double const charge_unit = ps["charge"][openPMD::RecordComponent::SCALAR].unitSI(); + auto const charge_unit = static_cast(ps["charge"][openPMD::RecordComponent::SCALAR].unitSI()); charge = p_q * charge_unit; } if (mass_is_specified) { @@ -508,7 +508,7 @@ void PlasmaInjector::setupExternalFile (const amrex::ParmParse& pp_species_name) ps["mass"][openPMD::RecordComponent::SCALAR].loadChunk(); m_openpmd_input_series->flush(); amrex::ParticleReal const p_m = p_m_ptr.get()[0]; - double const mass_unit = ps["mass"][openPMD::RecordComponent::SCALAR].unitSI(); + auto const mass_unit = static_cast(ps["mass"][openPMD::RecordComponent::SCALAR].unitSI()); mass = p_m * mass_unit; } } // IOProcessor diff --git a/Source/Initialization/WarpXInitData.cpp b/Source/Initialization/WarpXInitData.cpp index bfac6db544d..4e82ed0dfb5 100644 --- a/Source/Initialization/WarpXInitData.cpp +++ b/Source/Initialization/WarpXInitData.cpp @@ -1415,27 +1415,27 @@ WarpX::ReadExternalFieldFromFile ( #endif const auto offset = F.gridGlobalOffset(); - const amrex::Real offset0 = offset[0]; - const amrex::Real offset1 = offset[1]; + const auto offset0 = static_cast(offset[0]); + const auto offset1 = static_cast(offset[1]); #if defined(WARPX_DIM_3D) - const amrex::Real offset2 = offset[2]; + const auto offset2 = static_cast(offset[2]); #endif const auto d = F.gridSpacing(); #if defined(WARPX_DIM_RZ) - const amrex::Real file_dr = d[0]; - const amrex::Real file_dz = d[1]; + const auto file_dr = static_cast(d[0]); + const auto file_dz = static_cast(d[1]); #elif defined(WARPX_DIM_3D) - const amrex::Real file_dx = d[0]; - const amrex::Real file_dy = d[1]; - const amrex::Real file_dz = d[2]; + const auto file_dx = static_cast(d[0]); + const auto file_dy = static_cast(d[1]); + const auto file_dz = static_cast(d[2]); #endif auto FC = F[F_component]; const auto extent = FC.getExtent(); - const int extent0 = extent[0]; - const int extent1 = extent[1]; - const int extent2 = extent[2]; + const auto extent0 = static_cast(extent[0]); + const auto extent1 = static_cast(extent[1]); + const auto extent2 = static_cast(extent[2]); // Determine the chunk data that will be loaded. // Now, the full range of data is loaded. @@ -1482,11 +1482,11 @@ WarpX::ReadExternalFieldFromFile ( // 0,1 denote r,z in 2D rz. amrex::Real x0, x1; if ( box.type(0)==amrex::IndexType::CellIndex::NODE ) - { x0 = real_box.lo(0) + ii*dx[0]; } - else { x0 = real_box.lo(0) + ii*dx[0] + 0.5*dx[0]; } + { x0 = static_cast(real_box.lo(0)) + ii*dx[0]; } + else { x0 = static_cast(real_box.lo(0)) + ii*dx[0] + 0.5_rt*dx[0]; } if ( box.type(1)==amrex::IndexType::CellIndex::NODE ) { x1 = real_box.lo(1) + j*dx[1]; } - else { x1 = real_box.lo(1) + j*dx[1] + 0.5*dx[1]; } + else { x1 = real_box.lo(1) + j*dx[1] + 0.5_rt*dx[1]; } #if defined(WARPX_DIM_RZ) // Get index of the external field array @@ -1501,7 +1501,7 @@ WarpX::ReadExternalFieldFromFile ( amrex::Real x2; if ( box.type(2)==amrex::IndexType::CellIndex::NODE ) { x2 = real_box.lo(2) + k*dx[2]; } - else { x2 = real_box.lo(2) + k*dx[2] + 0.5*dx[2]; } + else { x2 = real_box.lo(2) + k*dx[2] + 0.5_rt*dx[2]; } // Get index of the external field array int const ix = floor( (x0-offset0)/file_dx ); @@ -1521,10 +1521,10 @@ WarpX::ReadExternalFieldFromFile ( f01 = fc_array(0, iz , ir+1), f10 = fc_array(0, iz+1, ir ), f11 = fc_array(0, iz+1, ir+1); - mffab(i,j,k) = utils::algorithms::bilinear_interp + mffab(i,j,k) = static_cast(utils::algorithms::bilinear_interp (xx0, xx0+file_dr, xx1, xx1+file_dz, f00, f01, f10, f11, - x0, x1); + x0, x1)); #elif defined(WARPX_DIM_3D) const amrex::Array4 fc_array(FC_data, {0,0,0}, {extent2, extent1, extent0}, 1); const double @@ -1536,10 +1536,10 @@ WarpX::ReadExternalFieldFromFile ( f101 = fc_array(iz+1, iy , ix+1), f110 = fc_array(iz , iy+1, ix+1), f111 = fc_array(iz+1, iy+1, ix+1); - mffab(i,j,k) = utils::algorithms::trilinear_interp + mffab(i,j,k) = static_cast(utils::algorithms::trilinear_interp (xx0, xx0+file_dx, xx1, xx1+file_dy, xx2, xx2+file_dz, f000, f001, f010, f011, f100, f101, f110, f111, - x0, x1, x2); + x0, x1, x2)); #endif } diff --git a/Source/Laser/LaserProfilesImpl/LaserProfileFromFile.cpp b/Source/Laser/LaserProfilesImpl/LaserProfileFromFile.cpp index fbac9d9707f..714e4bd52e1 100644 --- a/Source/Laser/LaserProfilesImpl/LaserProfileFromFile.cpp +++ b/Source/Laser/LaserProfilesImpl/LaserProfileFromFile.cpp @@ -183,33 +183,33 @@ WarpXLaserProfiles::FromFileLaserProfile::parse_lasy_file(std::string lasy_file_ //Dimensions of lasy file data: {m,t,r} amrex::Print() << Utils::TextMsg::Info( "Found lasy file in RZ geometry" ); m_params.file_in_cartesian_geom = 0; - m_params.n_rz_azimuthal_components = extent[0]; - m_params.nt = extent[1]; - m_params.nr = extent[2]; + m_params.n_rz_azimuthal_components = static_cast(extent[0]); + m_params.nt = static_cast(extent[1]); + m_params.nr = static_cast(extent[2]); if(m_params.nt <= 1) WARPX_ABORT_WITH_MESSAGE("nt in lasy file must be >=2"); if(m_params.nr <= 1) WARPX_ABORT_WITH_MESSAGE("nr in lasy file must be >=2"); // Calculate the min and max of the grid - m_params.t_min = offset[0] + position[0]*spacing[0]; - m_params.t_max = m_params.t_min + (m_params.nt-1)*spacing[0]; - m_params.r_min = offset[1] + position[1]*spacing[1]; - m_params.r_max = m_params.r_min + (m_params.nr-1)*spacing[1]; + m_params.t_min = static_cast(offset[0] + position[0]*spacing[0]); + m_params.t_max = static_cast(m_params.t_min + (m_params.nt-1)*spacing[0]); + m_params.r_min = static_cast(offset[1] + position[1]*spacing[1]); + m_params.r_max = static_cast(m_params.r_min + (m_params.nr-1)*spacing[1]); } else if (fileGeom=="cartesian"){ //Dimensions of lasy file data: {t,y,x} amrex::Print() << Utils::TextMsg::Info( "Found lasy file in 3D cartesian geometry"); m_params.file_in_cartesian_geom = 1; - m_params.nt = extent[0]; - m_params.ny = extent[1]; - m_params.nx = extent[2]; + m_params.nt = static_cast(extent[0]); + m_params.ny = static_cast(extent[1]); + m_params.nx = static_cast(extent[2]); WARPX_ALWAYS_ASSERT_WITH_MESSAGE(m_params.nt > 1, "nt in lasy file must be >=2"); WARPX_ALWAYS_ASSERT_WITH_MESSAGE(m_params.nx > 1, "nx in lasy file must be >=2"); WARPX_ALWAYS_ASSERT_WITH_MESSAGE(m_params.ny > 1, "ny in lasy file must be >=2 in 3D"); // Calculate the min and max of the grid - m_params.t_min = offset[0] + position[0]*spacing[0]; - m_params.t_max = m_params.t_min + (m_params.nt-1)*spacing[0]; - m_params.y_min = offset[1] + position[1]*spacing[1]; - m_params.y_max = m_params.y_min + (m_params.ny-1)*spacing[1]; - m_params.x_min = offset[2] + position[2]*spacing[2]; - m_params.x_max = m_params.x_min + (m_params.nx-1)*spacing[2]; + m_params.t_min = static_cast(offset[0] + position[0]*spacing[0]); + m_params.t_max = static_cast(m_params.t_min + (m_params.nt-1)*spacing[0]); + m_params.y_min = static_cast(offset[1] + position[1]*spacing[1]); + m_params.y_max = static_cast(m_params.y_min + (m_params.ny-1)*spacing[1]); + m_params.x_min = static_cast(offset[2] + position[2]*spacing[2]); + m_params.x_max = static_cast(m_params.x_min + (m_params.nx-1)*spacing[2]); } else{ WARPX_ABORT_WITH_MESSAGE("The lasy file's geometry has to be in either RZ or 3D cartesian coordinates"); } @@ -269,11 +269,11 @@ WarpXLaserProfiles::FromFileLaserProfile::parse_binary_file (std::string binary_ dbuf_y.resize(1); #endif inp.read(reinterpret_cast(dbuf_t.dataPtr()), - dbuf_t.size()*sizeof(double)); + static_cast(dbuf_t.size()*sizeof(double))); inp.read(reinterpret_cast(dbuf_x.dataPtr()), - dbuf_x.size()*sizeof(double)); + static_cast(dbuf_x.size()*sizeof(double))); inp.read(reinterpret_cast(dbuf_y.dataPtr()), - dbuf_y.size()*sizeof(double)); + static_cast(dbuf_y.size()*sizeof(double))); if(!inp) WARPX_ABORT_WITH_MESSAGE("Failed to read coords from binary file"); m_params.t_min = static_cast(dbuf_t[0]); @@ -313,17 +313,15 @@ WarpXLaserProfiles::FromFileLaserProfile::read_data_t_chunk (int t_begin, int t_ { #ifdef WARPX_USE_OPENPMD //Indices of the first and last timestep to read - std::uint64_t const i_first = max(0, t_begin); - std::uint64_t const i_last = min(t_end-1, m_params.nt-1); + auto const i_first = static_cast(max(0, t_begin)); + auto const i_last = static_cast(min(t_end-1, m_params.nt-1)); amrex::Print() << Utils::TextMsg::Info( "Reading [" + std::to_string(i_first) + ", " + std::to_string(i_last) + "] data chunk from " + m_params.lasy_file_name); - int data_size; - if (m_params.file_in_cartesian_geom==0) { - data_size = m_params.n_rz_azimuthal_components*(i_last-i_first+1)*m_params.nr; - } else { - data_size = (i_last-i_first+1)*m_params.nx*m_params.ny; - } + const auto data_size = + (m_params.file_in_cartesian_geom==0)? + (m_params.n_rz_azimuthal_components*(i_last-i_first+1)*m_params.nr) : + (i_last-i_first+1)*m_params.nx*m_params.ny; m_params.E_lasy_data.resize(data_size); Vector h_E_lasy_data(m_params.E_lasy_data.size()); if(ParallelDescriptor::IOProcessor()){ @@ -335,10 +333,10 @@ WarpXLaserProfiles::FromFileLaserProfile::read_data_t_chunk (int t_begin, int t_ if (m_params.file_in_cartesian_geom==0) { const openPMD::Extent read_extent = { full_extent[0], (i_last - i_first + 1), full_extent[2]}; auto r_data = E_laser.loadChunk< std::complex >(io::Offset{ 0, i_first, 0}, read_extent); - const int read_size = (i_last - i_first + 1)*m_params.nr; + const auto read_size = (i_last - i_first + 1)*m_params.nr; series.flush(); for (int m=0; m(r_data.get()[j+m*read_size].real()), static_cast(r_data.get()[j+m*read_size].imag())}; @@ -347,9 +345,9 @@ WarpXLaserProfiles::FromFileLaserProfile::read_data_t_chunk (int t_begin, int t_ } else{ const openPMD::Extent read_extent = {(i_last - i_first + 1), full_extent[1], full_extent[2]}; auto x_data = E_laser.loadChunk< std::complex >(io::Offset{i_first, 0, 0}, read_extent); - const int read_size = (i_last - i_first + 1)*m_params.nx*m_params.ny; + const auto read_size = (i_last - i_first + 1)*m_params.nx*m_params.ny; series.flush(); - for (int j=0; j(x_data.get()[j].real()), static_cast(x_data.get()[j].imag())}; @@ -362,8 +360,8 @@ WarpXLaserProfiles::FromFileLaserProfile::read_data_t_chunk (int t_begin, int t_ Gpu::copyAsync(Gpu::hostToDevice,h_E_lasy_data.begin(),h_E_lasy_data.end(),m_params.E_lasy_data.begin()); Gpu::synchronize(); //Update first and last indices - m_params.first_time_index = i_first; - m_params.last_time_index = i_last; + m_params.first_time_index = static_cast(i_first); + m_params.last_time_index = static_cast(i_last); #else amrex::ignore_unused(t_begin, t_end); #endif @@ -402,12 +400,12 @@ WarpXLaserProfiles::FromFileLaserProfile::read_binary_data_t_chunk (int t_begin, 1*sizeof(double) + sizeof(double)*t_begin*m_params.nx*m_params.ny; #endif - inp.seekg(skip_amount); + inp.seekg(static_cast(skip_amount)); if(!inp) WARPX_ABORT_WITH_MESSAGE("Failed to read field data from binary file"); const int read_size = (i_last - i_first + 1)* m_params.nx*m_params.ny; Vector buf_e(read_size); - inp.read(reinterpret_cast(buf_e.dataPtr()), read_size*sizeof(double)); + inp.read(reinterpret_cast(buf_e.dataPtr()), static_cast(read_size*sizeof(double))); if(!inp) WARPX_ABORT_WITH_MESSAGE("Failed to read field data from binary file"); std::transform(buf_e.begin(), buf_e.end(), h_E_binary_data.begin(), [](auto x) {return static_cast(x);} ); @@ -421,8 +419,8 @@ WarpXLaserProfiles::FromFileLaserProfile::read_binary_data_t_chunk (int t_begin, Gpu::synchronize(); //Update first and last indices - m_params.first_time_index = i_first; - m_params.last_time_index = i_last; + m_params.first_time_index = static_cast(i_first); + m_params.last_time_index = static_cast(i_last); } void @@ -434,7 +432,7 @@ WarpXLaserProfiles::FromFileLaserProfile::internal_fill_amplitude_uniform_cartes { // Copy member variables to tmp copies // and get pointers to underlying data for GPU. - const amrex::Real omega_t = 2.*MathConst::pi*PhysConst::c*t/m_common_params.wavelength; + const amrex::Real omega_t = 2._rt*MathConst::pi*PhysConst::c*t/m_common_params.wavelength; const Complex exp_omega_t = Complex{ std::cos(-omega_t), std::sin(-omega_t) }; const auto tmp_x_min = m_params.x_min; const auto tmp_x_max = m_params.x_max; @@ -519,7 +517,7 @@ WarpXLaserProfiles::FromFileLaserProfile::internal_fill_amplitude_uniform_cylind { // Copy member variables to tmp copies // and get pointers to underlying data for GPU. - const amrex::Real omega_t = 2.*MathConst::pi*PhysConst::c*t/m_common_params.wavelength; + const amrex::Real omega_t = 2._rt*MathConst::pi*PhysConst::c*t/m_common_params.wavelength; const Complex exp_omega_t = Complex{ std::cos(-omega_t), std::sin(-omega_t) }; const auto tmp_r_min = m_params.r_min; const auto tmp_r_max = m_params.r_max; diff --git a/Source/Parallelization/GuardCellManager.cpp b/Source/Parallelization/GuardCellManager.cpp index a4547c25c6d..4d31cad9a1c 100644 --- a/Source/Parallelization/GuardCellManager.cpp +++ b/Source/Parallelization/GuardCellManager.cpp @@ -103,7 +103,7 @@ guardCellManager::Init ( if (do_moving_window) { WARPX_ALWAYS_ASSERT_WITH_MESSAGE(ref_ratios.size() <= 1, "The number of grow cells for the moving window currently assumes 2 levels max."); - const int nlevs = ref_ratios.size()+1; + const auto nlevs = static_cast(ref_ratios.size()+1); const int max_r = (nlevs > 1) ? ref_ratios[0][moving_window_dir] : 2; ngx = std::max(ngx,max_r); diff --git a/Source/Particles/Collision/BackgroundMCC/BackgroundMCCCollision.cpp b/Source/Particles/Collision/BackgroundMCC/BackgroundMCCCollision.cpp index 3531afb7240..ce7fed952a7 100644 --- a/Source/Particles/Collision/BackgroundMCC/BackgroundMCCCollision.cpp +++ b/Source/Particles/Collision/BackgroundMCC/BackgroundMCCCollision.cpp @@ -181,7 +181,8 @@ BackgroundMCCCollision::get_nu_max(amrex::Vector const& mcc_processe E_step = (energy_step < E_step) ? energy_step : E_step; } - for (amrex::ParticleReal E = E_start; E < E_end; E+=E_step) { + amrex::ParticleReal E = E_start; + while(E < E_end){ amrex::ParticleReal sigma_E = 0.0; // loop through all collision pathways @@ -199,6 +200,8 @@ BackgroundMCCCollision::get_nu_max(amrex::Vector const& mcc_processe if (nu > nu_max) { nu_max = nu; } + + E+=E_step; } return nu_max; } @@ -285,14 +288,14 @@ BackgroundMCCCollision::doCollisions (amrex::Real cur_time, amrex::Real dt, Mult { amrex::Gpu::synchronize(); } - amrex::Real wt = amrex::second(); + auto wt = static_cast(amrex::second()); doBackgroundCollisionsWithinTile(pti, cur_time); if (cost && WarpX::load_balance_costs_update_algo == LoadBalanceCostsUpdateAlgo::Timers) { amrex::Gpu::synchronize(); - wt = amrex::second() - wt; + wt = static_cast(amrex::second()) - wt; amrex::HostDevice::Atomic::Add( &(*cost)[pti.index()], wt); } } @@ -322,7 +325,7 @@ void BackgroundMCCCollision::doBackgroundCollisionsWithinTile // get collision parameters auto scattering_processes = m_scattering_processes_exe.data(); - int const process_count = m_scattering_processes_exe.size(); + auto const process_count = static_cast(m_scattering_processes_exe.size()); auto const total_collision_prob = m_total_collision_prob; auto const nu_max = m_nu_max; @@ -379,7 +382,7 @@ void BackgroundMCCCollision::doBackgroundCollisionsWithinTile vy = uy[ip] - ua_y; vz = uz[ip] - ua_z; v_coll2 = (vx*vx + vy*vy + vz*vz); - v_coll = sqrt(v_coll2); + v_coll = std::sqrt(v_coll2); // calculate the collision energy in eV ParticleUtils::getCollisionEnergy(v_coll2, m, M, gamma, E_coll); @@ -389,7 +392,7 @@ void BackgroundMCCCollision::doBackgroundCollisionsWithinTile auto const& scattering_process = *(scattering_processes + i); // get collision cross-section - sigma_E = scattering_process.getCrossSection(E_coll); + sigma_E = scattering_process.getCrossSection(static_cast(E_coll)); // calculate normalized collision frequency nu_i += n_a * sigma_E * v_coll / nu_max; @@ -411,16 +414,17 @@ void BackgroundMCCCollision::doBackgroundCollisionsWithinTile // At this point the given particle has been chosen for a collision // and so we perform the needed calculations to transform to the // COM frame. - uCOM_x = m * vx / (gamma * m + M); - uCOM_y = m * vy / (gamma * m + M); - uCOM_z = m * vz / (gamma * m + M); + uCOM_x = static_cast(m * vx / (gamma * m + M)); + uCOM_y = static_cast(m * vy / (gamma * m + M)); + uCOM_z = static_cast(m * vz / (gamma * m + M)); // subtract any energy penalty of the collision from the // projectile energy if (scattering_process.m_energy_penalty > 0.0_prt) { ParticleUtils::getEnergy(v_coll2, m, E_coll); E_coll = (E_coll - scattering_process.m_energy_penalty) * PhysConst::q_e; - auto scale_fac = sqrt(E_coll * (E_coll + 2.0_prt*mc2) / c2) / m / v_coll; + const auto scale_fac = static_cast( + std::sqrt(E_coll * (E_coll + 2.0_prt*mc2) / c2) / m / v_coll); vx *= scale_fac; vy *= scale_fac; vz *= scale_fac; @@ -484,7 +488,7 @@ void BackgroundMCCCollision::doBackgroundIonization { amrex::Gpu::synchronize(); } - amrex::Real wt = amrex::second(); + auto wt = static_cast(amrex::second()); auto& elec_tile = species1.ParticlesAt(lev, pti); auto& ion_tile = species2.ParticlesAt(lev, pti); @@ -508,7 +512,7 @@ void BackgroundMCCCollision::doBackgroundIonization if (cost && WarpX::load_balance_costs_update_algo == LoadBalanceCostsUpdateAlgo::Timers) { amrex::Gpu::synchronize(); - wt = amrex::second() - wt; + wt = static_cast(amrex::second()) - wt; amrex::HostDevice::Atomic::Add( &(*cost)[pti.index()], wt); } } diff --git a/Source/Particles/Collision/BackgroundMCC/ImpactIonization.H b/Source/Particles/Collision/BackgroundMCC/ImpactIonization.H index 6e9827d8ab3..88ec7693b4a 100644 --- a/Source/Particles/Collision/BackgroundMCC/ImpactIonization.H +++ b/Source/Particles/Collision/BackgroundMCC/ImpactIonization.H @@ -98,7 +98,7 @@ public: ParticleUtils::getEnergy(u_coll2, m_mass, E_coll); // get collision cross-section - const ParticleReal sigma_E = m_mcc_process.getCrossSection(E_coll); + const ParticleReal sigma_E = m_mcc_process.getCrossSection(static_cast(E_coll)); // calculate normalized collision frequency const ParticleReal nu_i = n_a * sigma_E * sqrt(u_coll2) / m_nu_max; @@ -182,7 +182,7 @@ public: // calculate standard deviation in neutral velocity distribution using // the local temperature - const ParticleReal ion_vel_std = m_sqrt_kb_m * sqrt(m_T_a_func(x, y, z, m_t)); + const ParticleReal ion_vel_std = m_sqrt_kb_m * std::sqrt(m_T_a_func(x, y, z, m_t)); // get references to the original particle's velocity auto& ux = src.m_rdata[PIdx::ux][i_src]; @@ -202,7 +202,7 @@ public: ParticleUtils::getEnergy(u_coll2, m_mass1, E_coll); // each electron gets half the energy (could change this later) - const amrex::ParticleReal E_out = (E_coll - m_energy_cost) / 2.0_prt * PhysConst::q_e; + const amrex::ParticleReal E_out = static_cast((E_coll - m_energy_cost) / 2.0_prt * PhysConst::q_e); // precalculate often used value constexpr auto c2 = PhysConst::c * PhysConst::c; diff --git a/Source/Particles/Collision/BackgroundMCC/MCCProcess.cpp b/Source/Particles/Collision/BackgroundMCC/MCCProcess.cpp index 0451f62be60..bf2138bc78b 100644 --- a/Source/Particles/Collision/BackgroundMCC/MCCProcess.cpp +++ b/Source/Particles/Collision/BackgroundMCC/MCCProcess.cpp @@ -40,7 +40,7 @@ MCCProcess::init (const std::string& scattering_process, const amrex::ParticleRe m_exe_h.m_sigmas_data = m_sigmas_h.data(); // save energy grid parameters for easy use - m_grid_size = m_energies.size(); + m_grid_size = static_cast(m_energies.size()); m_exe_h.m_energy_lo = m_energies[0]; m_exe_h.m_energy_hi = m_energies[m_grid_size-1]; m_exe_h.m_sigma_lo = m_sigmas_h[0]; diff --git a/Source/Particles/Collision/BackgroundStopping/BackgroundStopping.cpp b/Source/Particles/Collision/BackgroundStopping/BackgroundStopping.cpp index e832020683d..878ef8a1f64 100644 --- a/Source/Particles/Collision/BackgroundStopping/BackgroundStopping.cpp +++ b/Source/Particles/Collision/BackgroundStopping/BackgroundStopping.cpp @@ -115,7 +115,7 @@ BackgroundStopping::doCollisions (amrex::Real cur_time, amrex::Real dt, MultiPar { amrex::Gpu::synchronize(); } - amrex::Real wt = amrex::second(); + auto wt = static_cast(amrex::second()); if (background_type == BackgroundStoppingType::ELECTRONS) { doBackgroundStoppingOnElectronsWithinTile(pti, dt, cur_time, species_mass, species_charge); @@ -126,7 +126,7 @@ BackgroundStopping::doCollisions (amrex::Real cur_time, amrex::Real dt, MultiPar if (cost && WarpX::load_balance_costs_update_algo == LoadBalanceCostsUpdateAlgo::Timers) { amrex::Gpu::synchronize(); - wt = amrex::second() - wt; + wt = static_cast(amrex::second()) - wt; amrex::HostDevice::Atomic::Add(&(*cost)[pti.index()], wt); } } diff --git a/Source/Particles/Collision/BinaryCollision/BinaryCollision.H b/Source/Particles/Collision/BinaryCollision/BinaryCollision.H index 9cf2f91b5aa..6728e4cef53 100644 --- a/Source/Particles/Collision/BinaryCollision/BinaryCollision.H +++ b/Source/Particles/Collision/BinaryCollision/BinaryCollision.H @@ -178,7 +178,7 @@ public: { amrex::Gpu::synchronize(); } - amrex::Real wt = amrex::second(); + auto wt = static_cast(amrex::second()); doCollisionsWithinTile( dt, lev, mfi, species1, species2, product_species_vector, copy_species1_data, copy_species2_data); @@ -186,7 +186,7 @@ public: if (cost && WarpX::load_balance_costs_update_algo == LoadBalanceCostsUpdateAlgo::Timers) { amrex::Gpu::synchronize(); - wt = amrex::second() - wt; + wt = static_cast(amrex::second()) - wt; amrex::HostDevice::Atomic::Add( &(*cost)[mfi.index()], wt); } } @@ -247,7 +247,7 @@ public: // Loop over cells, and collide the particles in each cell // Extract low-level data - int const n_cells = bins_1.numBins(); + auto const n_cells = static_cast(bins_1.numBins()); // - Species 1 const auto soa_1 = ptile_1.getParticleTileData(); index_type* AMREX_RESTRICT indices_1 = bins_1.permutationPtr(); @@ -371,7 +371,7 @@ public: for (int i = 0; i < n_product_species; i++) { - setNewParticleIDs(*(tile_products_data[i]), products_np[i], num_added[i]); + setNewParticleIDs(*(tile_products_data[i]), static_cast(products_np[i]), num_added[i]); } } else // species_1 != species_2 @@ -387,7 +387,7 @@ public: // Loop over cells, and collide the particles in each cell // Extract low-level data - int const n_cells = bins_1.numBins(); + auto const n_cells = static_cast(bins_1.numBins()); // - Species 1 const auto soa_1 = ptile_1.getParticleTileData(); index_type* AMREX_RESTRICT indices_1 = bins_1.permutationPtr(); @@ -532,7 +532,7 @@ public: for (int i = 0; i < n_product_species; i++) { - setNewParticleIDs(*(tile_products_data[i]), products_np[i], num_added[i]); + setNewParticleIDs(*(tile_products_data[i]), static_cast(products_np[i]), num_added[i]); } } // end if ( m_isSameSpecies) diff --git a/Source/Particles/Collision/BinaryCollision/Coulomb/ElasticCollisionPerez.H b/Source/Particles/Collision/BinaryCollision/Coulomb/ElasticCollisionPerez.H index 239f63c7f23..b54404d46ba 100644 --- a/Source/Particles/Collision/BinaryCollision/Coulomb/ElasticCollisionPerez.H +++ b/Source/Particles/Collision/BinaryCollision/Coulomb/ElasticCollisionPerez.H @@ -54,8 +54,8 @@ void ElasticCollisionPerez ( amrex::RandomEngine const& engine, bool const isSameSpecies) { - const int NI1 = I1e - I1s; - const int NI2 = I2e - I2s; + const T_index NI1 = I1e - I1s; + const T_index NI2 = I2e - I2s; T_PR * const AMREX_RESTRICT w1 = soa_1.m_rdata[PIdx::w]; T_PR * const AMREX_RESTRICT u1x = soa_1.m_rdata[PIdx::ux]; @@ -84,8 +84,8 @@ void ElasticCollisionPerez ( T_PR n1 = T_PR(0.0); T_PR n2 = T_PR(0.0); T_PR n12 = T_PR(0.0); - for (int i1=I1s; i1(I1e); ++i1) { n1 += w1[ I1[i1] ]; } - for (int i2=I2s; i2(I2e); ++i2) { n2 += w2[ I2[i2] ]; } + for (T_index i1=I1s; i1(I1e) ) { i1 = I1s; } - ++i2; if ( i2 == static_cast(I2e) ) { i2 = I2s; } + ++i1; if ( i1 == I1e ) { i1 = I1s; } + ++i2; if ( i2 == I2e ) { i2 = I2s; } } n12 = n12 / dV; } @@ -126,8 +126,8 @@ void ElasticCollisionPerez ( // call UpdateMomentumPerezElastic() { - int i1 = I1s; int i2 = I2s; - for (int k = 0; k < amrex::max(NI1,NI2); ++k) + T_index i1 = I1s; T_index i2 = I2s; + for (T_index k = 0; k < amrex::max(NI1,NI2); ++k) { #if (defined WARPX_DIM_RZ) @@ -159,8 +159,8 @@ void ElasticCollisionPerez ( u1y[I1[i1]] = u1xbuf_new*std::sin(-theta) + u1y[I1[i1]]*std::cos(-theta); #endif - ++i1; if ( i1 == static_cast(I1e) ) { i1 = I1s; } - ++i2; if ( i2 == static_cast(I2e) ) { i2 = I2s; } + ++i1; if ( i1 == I1e ) { i1 = I1s; } + ++i2; if ( i2 == I2e ) { i2 = I2s; } } } diff --git a/Source/Particles/Collision/BinaryCollision/NuclearFusion/NuclearFusionFunc.H b/Source/Particles/Collision/BinaryCollision/NuclearFusion/NuclearFusionFunc.H index 23939bbc2ab..db8dacce1d4 100644 --- a/Source/Particles/Collision/BinaryCollision/NuclearFusion/NuclearFusionFunc.H +++ b/Source/Particles/Collision/BinaryCollision/NuclearFusion/NuclearFusionFunc.H @@ -144,36 +144,37 @@ public: amrex::ParticleReal * const AMREX_RESTRICT u2z = soa_2.m_rdata[PIdx::uz]; // Number of macroparticles of each species - const int NI1 = I1e - I1s; - const int NI2 = I2e - I2s; - const int max_N = amrex::max(NI1,NI2); + const index_type NI1 = I1e - I1s; + const index_type NI2 = I2e - I2s; + const index_type max_N = amrex::max(NI1,NI2); - int i1 = I1s; - int i2 = I2s; - int pair_index = cell_start_pair; + index_type i1 = I1s; + index_type i2 = I2s; + index_type pair_index = cell_start_pair; // Because the number of particles of each species is not always equal (NI1 != NI2 // in general), some macroparticles will be paired with multiple macroparticles of the // other species and we need to decrease their weight accordingly. // c1 corresponds to the minimum number of times a particle of species 1 will be paired // with a particle of species 2. Same for c2. - const int c1 = amrex::max(NI2/NI1,1); - const int c2 = amrex::max(NI1/NI2,1); + const index_type c1 = amrex::max(NI2/NI1,1u); + const index_type c2 = amrex::max(NI1/NI2,1u); // multiplier ratio to take into account unsampled pairs - const int multiplier_ratio = (m_isSameSpecies)?(2*max_N - 1):(max_N); + const auto multiplier_ratio = static_cast( + (m_isSameSpecies)?(2u*max_N - 1):(max_N)); #if (defined WARPX_DIM_RZ) amrex::ParticleReal * const AMREX_RESTRICT theta1 = soa_1.m_rdata[PIdx::theta]; amrex::ParticleReal * const AMREX_RESTRICT theta2 = soa_2.m_rdata[PIdx::theta]; #endif - for (int k = 0; k < max_N; ++k) + for (index_type k = 0; k < max_N; ++k) { // c1k : how many times the current particle of species 1 is paired with a particle // of species 2. Same for c2k. - const int c1k = (k%NI1 < max_N%NI1) ? c1 + 1: c1; - const int c2k = (k%NI2 < max_N%NI2) ? c2 + 1: c2; + const index_type c1k = (k%NI1 < max_N%NI1) ? c1 + 1: c1; + const index_type c2k = (k%NI2 < max_N%NI2) ? c2 + 1: c2; #if (defined WARPX_DIM_RZ) /* In RZ geometry, macroparticles can collide with other macroparticles @@ -194,7 +195,7 @@ public: u1x[ I1[i1] ], u1y[ I1[i1] ], u1z[ I1[i1] ], u2x[ I2[i2] ], u2y[ I2[i2] ], u2z[ I2[i2] ], m1, m2, w1[ I1[i1] ]/c1k, w2[ I2[i2] ]/c2k, - dt, dV, pair_index, p_mask, p_pair_reaction_weight, + dt, dV, static_cast(pair_index), p_mask, p_pair_reaction_weight, m_fusion_multiplier, multiplier_ratio, m_probability_threshold, m_probability_target_value, @@ -208,8 +209,8 @@ public: p_pair_indices_1[pair_index] = I1[i1]; p_pair_indices_2[pair_index] = I2[i2]; - ++i1; if ( i1 == static_cast(I1e) ) { i1 = I1s; } - ++i2; if ( i2 == static_cast(I2e) ) { i2 = I2s; } + ++i1; if ( i1 == I1e ) { i1 = I1s; } + ++i2; if ( i2 == I2e ) { i2 = I2s; } ++pair_index; } diff --git a/Source/Particles/Collision/BinaryCollision/NuclearFusion/ProtonBoronFusionInitializeMomentum.H b/Source/Particles/Collision/BinaryCollision/NuclearFusion/ProtonBoronFusionInitializeMomentum.H index 085fc597f58..0e92bda5beb 100644 --- a/Source/Particles/Collision/BinaryCollision/NuclearFusion/ProtonBoronFusionInitializeMomentum.H +++ b/Source/Particles/Collision/BinaryCollision/NuclearFusion/ProtonBoronFusionInitializeMomentum.H @@ -97,20 +97,20 @@ namespace { soa_2.m_rdata[PIdx::ux][idx_2], soa_2.m_rdata[PIdx::uy][idx_2], soa_2.m_rdata[PIdx::uz][idx_2], m2, - ux_alpha1, uy_alpha1, uz_alpha1, m_alpha, - ux_Be, uy_Be, uz_Be, m_beryllium, + ux_alpha1, uy_alpha1, uz_alpha1, static_cast(m_alpha), + ux_Be, uy_Be, uz_Be, static_cast(m_beryllium), E_fusion, engine); // Compute momentum of beryllium in lab frame - const amrex::ParticleReal px_Be = m_beryllium * ux_Be; - const amrex::ParticleReal py_Be = m_beryllium * uy_Be; - const amrex::ParticleReal pz_Be = m_beryllium * uz_Be; + const amrex::ParticleReal px_Be = static_cast(m_beryllium) * ux_Be; + const amrex::ParticleReal py_Be = static_cast(m_beryllium) * uy_Be; + const amrex::ParticleReal pz_Be = static_cast(m_beryllium) * uz_Be; // Compute momentum norm of second and third alphas in Beryllium rest frame // Factor 0.5 is here because each alpha only gets half of the decay energy constexpr amrex::ParticleReal gamma_Bestar = (1._prt + 0.5_prt*E_decay/(m_alpha*c_sq)); constexpr amrex::ParticleReal gamma_Bestar_sq_minus_one = gamma_Bestar*gamma_Bestar - 1._prt; - const amrex::ParticleReal p_Bestar = m_alpha*PhysConst::c*std::sqrt(gamma_Bestar_sq_minus_one); + const amrex::ParticleReal p_Bestar = static_cast(m_alpha)*PhysConst::c*std::sqrt(gamma_Bestar_sq_minus_one); // Compute momentum of second alpha in Beryllium rest frame, assuming isotropic distribution amrex::ParticleReal px_Bestar, py_Bestar, pz_Bestar; @@ -120,8 +120,8 @@ namespace { amrex::ParticleReal px_alpha2, py_alpha2, pz_alpha2; // Preliminary calculation: compute Beryllium velocity v_Be const amrex::ParticleReal p_Be_sq = px_Be*px_Be + py_Be*py_Be + pz_Be*pz_Be; - const amrex::ParticleReal g_Be = std::sqrt(1._prt + p_Be_sq / (mBe_sq*c_sq)); - const amrex::ParticleReal mg_Be = m_beryllium*g_Be; + const amrex::ParticleReal g_Be = std::sqrt(1._prt + p_Be_sq / (static_cast(mBe_sq)*c_sq)); + const amrex::ParticleReal mg_Be = static_cast(m_beryllium)*g_Be; const amrex::ParticleReal v_Bex = px_Be / mg_Be; const amrex::ParticleReal v_Bey = py_Be / mg_Be; const amrex::ParticleReal v_Bez = pz_Be / mg_Be; @@ -133,7 +133,7 @@ namespace { { const amrex::ParticleReal vcDps = v_Bex*px_Bestar + v_Bey*py_Bestar + v_Bez*pz_Bestar; const amrex::ParticleReal factor0 = (g_Be-1._prt)/v_Be_sq; - const amrex::ParticleReal factor = factor0*vcDps + m_alpha*gamma_Bestar*g_Be; + const amrex::ParticleReal factor = factor0*vcDps + static_cast(m_alpha)*gamma_Bestar*g_Be; px_alpha2 = px_Bestar + v_Bex * factor; py_alpha2 = py_Bestar + v_Bey * factor; pz_alpha2 = pz_Bestar + v_Bez * factor; @@ -159,18 +159,18 @@ namespace { soa_alpha.m_rdata[PIdx::ux][idx_alpha_start + 1] = ux_alpha1; soa_alpha.m_rdata[PIdx::uy][idx_alpha_start + 1] = uy_alpha1; soa_alpha.m_rdata[PIdx::uz][idx_alpha_start + 1] = uz_alpha1; - soa_alpha.m_rdata[PIdx::ux][idx_alpha_start + 2] = px_alpha2/m_alpha; - soa_alpha.m_rdata[PIdx::uy][idx_alpha_start + 2] = py_alpha2/m_alpha; - soa_alpha.m_rdata[PIdx::uz][idx_alpha_start + 2] = pz_alpha2/m_alpha; - soa_alpha.m_rdata[PIdx::ux][idx_alpha_start + 3] = px_alpha2/m_alpha; - soa_alpha.m_rdata[PIdx::uy][idx_alpha_start + 3] = py_alpha2/m_alpha; - soa_alpha.m_rdata[PIdx::uz][idx_alpha_start + 3] = pz_alpha2/m_alpha; - soa_alpha.m_rdata[PIdx::ux][idx_alpha_start + 4] = px_alpha3/m_alpha; - soa_alpha.m_rdata[PIdx::uy][idx_alpha_start + 4] = py_alpha3/m_alpha; - soa_alpha.m_rdata[PIdx::uz][idx_alpha_start + 4] = pz_alpha3/m_alpha; - soa_alpha.m_rdata[PIdx::ux][idx_alpha_start + 5] = px_alpha3/m_alpha; - soa_alpha.m_rdata[PIdx::uy][idx_alpha_start + 5] = py_alpha3/m_alpha; - soa_alpha.m_rdata[PIdx::uz][idx_alpha_start + 5] = pz_alpha3/m_alpha; + soa_alpha.m_rdata[PIdx::ux][idx_alpha_start + 2] = px_alpha2/static_cast(m_alpha); + soa_alpha.m_rdata[PIdx::uy][idx_alpha_start + 2] = py_alpha2/static_cast(m_alpha); + soa_alpha.m_rdata[PIdx::uz][idx_alpha_start + 2] = pz_alpha2/static_cast(m_alpha); + soa_alpha.m_rdata[PIdx::ux][idx_alpha_start + 3] = px_alpha2/static_cast(m_alpha); + soa_alpha.m_rdata[PIdx::uy][idx_alpha_start + 3] = py_alpha2/static_cast(m_alpha); + soa_alpha.m_rdata[PIdx::uz][idx_alpha_start + 3] = pz_alpha2/static_cast(m_alpha); + soa_alpha.m_rdata[PIdx::ux][idx_alpha_start + 4] = px_alpha3/static_cast(m_alpha); + soa_alpha.m_rdata[PIdx::uy][idx_alpha_start + 4] = py_alpha3/static_cast(m_alpha); + soa_alpha.m_rdata[PIdx::uz][idx_alpha_start + 4] = pz_alpha3/static_cast(m_alpha); + soa_alpha.m_rdata[PIdx::ux][idx_alpha_start + 5] = px_alpha3/static_cast(m_alpha); + soa_alpha.m_rdata[PIdx::uy][idx_alpha_start + 5] = py_alpha3/static_cast(m_alpha); + soa_alpha.m_rdata[PIdx::uz][idx_alpha_start + 5] = pz_alpha3/static_cast(m_alpha); } } diff --git a/Source/Particles/Collision/BinaryCollision/ParticleCreationFunc.H b/Source/Particles/Collision/BinaryCollision/ParticleCreationFunc.H index 7fdf04de6ca..8d85dab11d7 100644 --- a/Source/Particles/Collision/BinaryCollision/ParticleCreationFunc.H +++ b/Source/Particles/Collision/BinaryCollision/ParticleCreationFunc.H @@ -130,7 +130,7 @@ public: // one electron, we create two electrons, one at the position of each particle that // collided. This allows for exact charge conservation. const index_type num_added = total * m_num_products_host[i] * 2; - num_added_vec[i] = num_added; + num_added_vec[i] = static_cast(num_added); tile_products[i]->resize(products_np[i] + num_added); } @@ -184,11 +184,11 @@ public: const auto product_index = products_np_data[j] + 2*(p_offsets[i]*p_num_products_device[j] + k); // Create product particle at position of particle 1 - copy_species1[j](soa_products_data[j], soa_1, p_pair_indices_1[i], - product_index, engine); + copy_species1[j](soa_products_data[j], soa_1, static_cast(p_pair_indices_1[i]), + static_cast(product_index), engine); // Create another product particle at position of particle 2 - copy_species2[j](soa_products_data[j], soa_2, p_pair_indices_2[i], - product_index + 1, engine); + copy_species2[j](soa_products_data[j], soa_2, static_cast(p_pair_indices_2[i]), + static_cast(product_index + 1), engine); // Set the weight of the new particles to p_pair_reaction_weight[i]/2 soa_products_data[j].m_rdata[PIdx::w][product_index] = diff --git a/Source/Particles/ElementaryProcess/QEDInternals/BreitWheelerEngineWrapper.cpp b/Source/Particles/ElementaryProcess/QEDInternals/BreitWheelerEngineWrapper.cpp index 12f479d32ed..911a5c64ea0 100644 --- a/Source/Particles/ElementaryProcess/QEDInternals/BreitWheelerEngineWrapper.cpp +++ b/Source/Particles/ElementaryProcess/QEDInternals/BreitWheelerEngineWrapper.cpp @@ -72,10 +72,10 @@ BreitWheelerEngine::init_lookup_tables_from_raw_data ( if(size_first <= 0 || size_first >= raw_data.size() ) return false; const auto raw_dndt_table = vector{ - raw_iter, raw_iter+size_first}; + raw_iter, raw_iter+static_cast(size_first)}; const auto raw_pair_prod_table = vector{ - raw_iter+size_first, raw_data.end()}; + raw_iter+static_cast(size_first), raw_data.end()}; m_dndt_table = BW_dndt_table{raw_dndt_table}; m_pair_prod_table = BW_pair_prod_table{raw_pair_prod_table}; diff --git a/Source/Particles/ElementaryProcess/QEDInternals/QuantumSyncEngineWrapper.cpp b/Source/Particles/ElementaryProcess/QEDInternals/QuantumSyncEngineWrapper.cpp index c9bede89167..180bd5babce 100644 --- a/Source/Particles/ElementaryProcess/QEDInternals/QuantumSyncEngineWrapper.cpp +++ b/Source/Particles/ElementaryProcess/QEDInternals/QuantumSyncEngineWrapper.cpp @@ -71,10 +71,10 @@ QuantumSynchrotronEngine::init_lookup_tables_from_raw_data ( if(size_first <= 0 || size_first >= raw_data.size() ) return false; const auto raw_dndt_table = vector{ - raw_iter, raw_iter+size_first}; + raw_iter, raw_iter+static_cast(size_first)}; const auto raw_phot_em_table = vector{ - raw_iter+size_first, raw_data.end()}; + raw_iter+static_cast(size_first), raw_data.end()}; m_dndt_table = QS_dndt_table{raw_dndt_table}; m_phot_em_table = QS_phot_em_table{raw_phot_em_table}; diff --git a/Source/Particles/Gather/GetExternalFields.H b/Source/Particles/Gather/GetExternalFields.H index 5fd0acb8eb2..2f388363e17 100644 --- a/Source/Particles/Gather/GetExternalFields.H +++ b/Source/Particles/Gather/GetExternalFields.H @@ -27,7 +27,7 @@ struct GetExternalEBField GetExternalEBField () = default; - GetExternalEBField (const WarpXParIter& a_pti, int a_offset = 0) noexcept; + GetExternalEBField (const WarpXParIter& a_pti, long a_offset = 0) noexcept; ExternalFieldInitType m_Etype; ExternalFieldInitType m_Btype; diff --git a/Source/Particles/Gather/GetExternalFields.cpp b/Source/Particles/Gather/GetExternalFields.cpp index c6d94686c06..057ac51d597 100644 --- a/Source/Particles/Gather/GetExternalFields.cpp +++ b/Source/Particles/Gather/GetExternalFields.cpp @@ -13,7 +13,7 @@ using namespace amrex::literals; -GetExternalEBField::GetExternalEBField (const WarpXParIter& a_pti, int a_offset) noexcept +GetExternalEBField::GetExternalEBField (const WarpXParIter& a_pti, long a_offset) noexcept { auto& warpx = WarpX::GetInstance(); auto& mypc = warpx.GetPartContainer(); @@ -22,7 +22,7 @@ GetExternalEBField::GetExternalEBField (const WarpXParIter& a_pti, int a_offset) AcceleratorLattice const & accelerator_lattice = warpx.get_accelerator_lattice(lev); if (accelerator_lattice.m_lattice_defined) { - d_lattice_element_finder = accelerator_lattice.GetFinderDeviceInstance(a_pti, a_offset); + d_lattice_element_finder = accelerator_lattice.GetFinderDeviceInstance(a_pti, static_cast(a_offset)); } m_gamma_boost = WarpX::gamma_boost; diff --git a/Source/Particles/LaserParticleContainer.cpp b/Source/Particles/LaserParticleContainer.cpp index ff11d1a30e9..098dba0997b 100644 --- a/Source/Particles/LaserParticleContainer.cpp +++ b/Source/Particles/LaserParticleContainer.cpp @@ -487,7 +487,8 @@ LaserParticleContainer::InitData (int lev) const DistributionMapping plane_dm {plane_ba, nprocs}; const Vector& procmap = plane_dm.ProcessorMap(); - for (int i = 0, n = plane_ba.size(); i < n; ++i) + const auto plane_ba_size = static_cast(plane_ba.size()); + for (int i = 0; i < plane_ba_size; ++i) { if (procmap[i] == myproc) { @@ -518,15 +519,16 @@ LaserParticleContainer::InitData (int lev) particle_w.push_back(-m_weight); #else // Particles are laid out in radial spokes - const int n_spokes = (WarpX::n_rz_azimuthal_modes - 1)*m_min_particles_per_mode; + const auto n_spokes = + static_cast((WarpX::n_rz_azimuthal_modes - 1)*m_min_particles_per_mode); for (int spoke = 0 ; spoke < n_spokes ; spoke++) { - const Real phase = 2.*MathConst::pi*spoke/n_spokes; + const Real phase = 2._rt*MathConst::pi*spoke/n_spokes; for (int k = 0; k<2; ++k) { particle_x.push_back(pos[0]*std::cos(phase)); particle_y.push_back(pos[0]*std::sin(phase)); particle_z.push_back(pos[2]); } - const Real r_weight = m_weight*2.*MathConst::pi*pos[0]/n_spokes; + const Real r_weight = m_weight*2._rt*MathConst::pi*pos[0]/n_spokes; particle_w.push_back( r_weight); particle_w.push_back(-r_weight); } @@ -535,7 +537,7 @@ LaserParticleContainer::InitData (int lev) } } } - const int np = particle_z.size(); + const auto np = static_cast(particle_z.size()); amrex::Vector particle_ux(np, 0.0); amrex::Vector particle_uy(np, 0.0); amrex::Vector particle_uz(np, 0.0); @@ -637,18 +639,18 @@ LaserParticleContainer::Evolve (int lev, // WARPX_PROFILE_VAR_START(blp_pp); // Find the coordinates of the particles in the emission plane - calculate_laser_plane_coordinates(pti, np, + calculate_laser_plane_coordinates(pti, static_cast(np), plane_Xp.dataPtr(), plane_Yp.dataPtr()); // Calculate the laser amplitude to be emitted, // at the position of the emission plane m_up_laser_profile->fill_amplitude( - np, plane_Xp.dataPtr(), plane_Yp.dataPtr(), + static_cast(np), plane_Xp.dataPtr(), plane_Yp.dataPtr(), t_lab, amplitude_E.dataPtr()); // Calculate the corresponding momentum and position for the particles - update_laser_particle(pti, np, uxp.dataPtr(), uyp.dataPtr(), + update_laser_particle(pti, static_cast(np), uxp.dataPtr(), uyp.dataPtr(), uzp.dataPtr(), wp.dataPtr(), amplitude_E.dataPtr(), dt); WARPX_PROFILE_VAR_STOP(blp_pp); diff --git a/Source/Particles/MultiParticleContainer.H b/Source/Particles/MultiParticleContainer.H index af826068806..16817cbec07 100644 --- a/Source/Particles/MultiParticleContainer.H +++ b/Source/Particles/MultiParticleContainer.H @@ -229,9 +229,9 @@ public: void SetParticleBoxArray (int lev, amrex::BoxArray& new_ba); void SetParticleDistributionMap (int lev, amrex::DistributionMapping& new_dm); - int nSpecies () const {return species_names.size();} - int nLasers () const {return lasers_names.size();} - int nContainers () const {return allcontainers.size();} + int nSpecies () const {return static_cast(species_names.size());} + int nLasers () const {return static_cast(lasers_names.size());} + int nContainers () const {return static_cast(allcontainers.size());} /** Whether back-transformed diagnostics need to be performed for any plasma species. * @@ -248,13 +248,13 @@ public: int nSpeciesDepositOnMainGrid () const { bool const onMainGrid = true; auto const & v = m_deposit_on_main_grid; - return std::count( v.begin(), v.end(), onMainGrid ); + return static_cast(std::count( v.begin(), v.end(), onMainGrid )); } int nSpeciesGatherFromMainGrid() const { bool const fromMainGrid = true; auto const & v = m_gather_from_main_grid; - return std::count( v.begin(), v.end(), fromMainGrid ); + return static_cast(std::count( v.begin(), v.end(), fromMainGrid )); } // Inject particles during the simulation (for particles entering the diff --git a/Source/Particles/MultiParticleContainer.cpp b/Source/Particles/MultiParticleContainer.cpp index b9802fa448b..67dfda1dbe0 100644 --- a/Source/Particles/MultiParticleContainer.cpp +++ b/Source/Particles/MultiParticleContainer.cpp @@ -294,7 +294,7 @@ MultiParticleContainer::ReadParameters () it != species_names.end(), "species '" + name + "' in particles.deposit_on_main_grid must be part of particles.species_names"); - const int i = std::distance(species_names.begin(), it); + const auto i = static_cast(std::distance(species_names.begin(), it)); m_deposit_on_main_grid[i] = true; } @@ -307,7 +307,7 @@ MultiParticleContainer::ReadParameters () it != species_names.end(), "species '" + name + "' in particles.gather_from_main_grid must be part of particles.species_names"); - const int i = std::distance(species_names.begin(), it); + const auto i = static_cast(std::distance(species_names.begin(), it)); m_gather_from_main_grid.at(i) = true; } @@ -323,7 +323,7 @@ MultiParticleContainer::ReadParameters () it != species_names.end(), "species '" + name + "' in particles.rigid_injected_species must be part of particles.species_names"); - const int i = std::distance(species_names.begin(), it); + const auto i = static_cast(std::distance(species_names.begin(), it)); species_types[i] = PCTypes::RigidInjected; } } @@ -337,7 +337,7 @@ MultiParticleContainer::ReadParameters () it != species_names.end(), "species '" + name + "' in particles.photon_species must be part of particles.species_names"); - const int i = std::distance(species_names.begin(), it); + const auto i = static_cast(std::distance(species_names.begin(), it)); species_types[i] = PCTypes::Photon; } } @@ -366,7 +366,7 @@ MultiParticleContainer::ReadParameters () it != lasers_names.end(), "laser '" + name + "' in lasers.deposit_on_main_grid must be part of lasers.lasers_names"); - const int i = std::distance(lasers_names.begin(), it); + const auto i = static_cast(std::distance(lasers_names.begin(), it)); m_laser_deposit_on_main_grid[i] = true; } @@ -413,7 +413,7 @@ MultiParticleContainer::GetParticleContainerFromName (const std::string& name) c WARPX_ALWAYS_ASSERT_WITH_MESSAGE( it != species_names.end(), "unknown species name"); - const int i = std::distance(species_names.begin(), it); + const auto i = static_cast(std::distance(species_names.begin(), it)); return *allcontainers[i]; } @@ -671,7 +671,7 @@ Vector MultiParticleContainer::GetZeroParticlesInGrid (const int lev) const { const WarpX& warpx = WarpX::GetInstance(); - const int num_boxes = warpx.boxArray(lev).size(); + const auto num_boxes = static_cast(warpx.boxArray(lev).size()); Vector r(num_boxes, 0); return r; } @@ -694,7 +694,7 @@ MultiParticleContainer::NumberOfParticlesInGrid (int lev) const r[j] += ri[j]; } } - ParallelDescriptor::ReduceLongSum(r.data(),r.size()); + ParallelDescriptor::ReduceLongSum(r.data(),static_cast(r.size())); return r; } } @@ -910,7 +910,7 @@ MultiParticleContainer::doFieldIonization (int lev, { amrex::Gpu::synchronize(); } - Real wt = amrex::second(); + auto wt = static_cast(amrex::second()); auto& src_tile = pc_source ->ParticlesAt(lev, pti); auto& dst_tile = pc_product->ParticlesAt(lev, pti); @@ -928,7 +928,7 @@ MultiParticleContainer::doFieldIonization (int lev, if (cost && WarpX::load_balance_costs_update_algo == LoadBalanceCostsUpdateAlgo::Timers) { amrex::Gpu::synchronize(); - wt = amrex::second() - wt; + wt = static_cast(amrex::second()) - wt; amrex::HostDevice::Atomic::Add( &(*cost)[pti.index()], wt); } } @@ -1542,7 +1542,7 @@ void MultiParticleContainer::doQedBreitWheeler (int lev, { amrex::Gpu::synchronize(); } - Real wt = amrex::second(); + auto wt = static_cast(amrex::second()); auto Transform = PairGenerationTransformFunc(pair_gen_functor, pti, lev, Ex.nGrowVect(), @@ -1566,7 +1566,7 @@ void MultiParticleContainer::doQedBreitWheeler (int lev, if (cost && WarpX::load_balance_costs_update_algo == LoadBalanceCostsUpdateAlgo::Timers) { amrex::Gpu::synchronize(); - wt = amrex::second() - wt; + wt = static_cast(amrex::second()) - wt; amrex::HostDevice::Atomic::Add( &(*cost)[pti.index()], wt); } } @@ -1617,7 +1617,7 @@ void MultiParticleContainer::doQedQuantumSync (int lev, { amrex::Gpu::synchronize(); } - Real wt = amrex::second(); + auto wt = static_cast(amrex::second()); auto Transform = PhotonEmissionTransformFunc( m_shr_p_qs_engine->build_optical_depth_functor(), @@ -1645,7 +1645,7 @@ void MultiParticleContainer::doQedQuantumSync (int lev, if (cost && WarpX::load_balance_costs_update_algo == LoadBalanceCostsUpdateAlgo::Timers) { amrex::Gpu::synchronize(); - wt = amrex::second() - wt; + wt = static_cast(amrex::second()) - wt; amrex::HostDevice::Atomic::Add( &(*cost)[pti.index()], wt); } } diff --git a/Source/Particles/ParticleBoundaryBuffer.H b/Source/Particles/ParticleBoundaryBuffer.H index 7099ef4d691..cbc8667c8d4 100644 --- a/Source/Particles/ParticleBoundaryBuffer.H +++ b/Source/Particles/ParticleBoundaryBuffer.H @@ -35,7 +35,7 @@ public: /** Move operator for NamedComponentParticleContainer */ ParticleBoundaryBuffer& operator= ( ParticleBoundaryBuffer && ) = default; - int numSpecies() const { return getSpeciesNames().size(); } + int numSpecies() const { return static_cast(getSpeciesNames().size()); } const std::vector& getSpeciesNames() const; diff --git a/Source/Particles/ParticleBoundaryBuffer.cpp b/Source/Particles/ParticleBoundaryBuffer.cpp index 70c9459df5e..8e6decb1f3f 100644 --- a/Source/Particles/ParticleBoundaryBuffer.cpp +++ b/Source/Particles/ParticleBoundaryBuffer.cpp @@ -149,7 +149,7 @@ void ParticleBoundaryBuffer::printNumParticles () const { auto& buffer = m_particle_containers[2*idim+iside]; for (int i = 0; i < numSpecies(); ++i) { - const int np = buffer[i].isDefined() ? buffer[i].TotalNumberOfParticles(false) : 0; + const auto np = buffer[i].isDefined() ? buffer[i].TotalNumberOfParticles(false) : 0; amrex::Print() << Utils::TextMsg::Info( "Species " + getSpeciesNames()[i] + " has " + std::to_string(np) + " particles in the boundary buffer " @@ -162,7 +162,7 @@ void ParticleBoundaryBuffer::printNumParticles () const { auto& buffer = m_particle_containers[2*AMREX_SPACEDIM]; for (int i = 0; i < numSpecies(); ++i) { - const int np = buffer[i].isDefined() ? buffer[i].TotalNumberOfParticles(false) : 0; + const auto np = buffer[i].isDefined() ? buffer[i].TotalNumberOfParticles(false) : 0; amrex::Print() << Utils::TextMsg::Info( "Species " + getSpeciesNames()[i] + " has " + std::to_string(np) + " particles in the EB boundary buffer" @@ -370,8 +370,12 @@ int ParticleBoundaryBuffer::getNumParticlesInContainer( auto& buffer = m_particle_containers[boundary]; auto index = WarpX::GetInstance().GetPartContainer().getSpeciesID(species_name); - if (buffer[index].isDefined()) return buffer[index].TotalNumberOfParticles(false, local); - else return 0; + if (buffer[index].isDefined()){ + return static_cast(buffer[index].TotalNumberOfParticles(false, local)); + } + else{ + return 0; + } } PinnedMemoryParticleContainer & diff --git a/Source/Particles/ParticleCreation/SmartUtils.H b/Source/Particles/ParticleCreation/SmartUtils.H index ee1dc321cef..4604ef59680 100644 --- a/Source/Particles/ParticleCreation/SmartUtils.H +++ b/Source/Particles/ParticleCreation/SmartUtils.H @@ -31,7 +31,7 @@ struct SmartCopyTag amrex::Gpu::DeviceVector src_comps; amrex::Gpu::DeviceVector dst_comps; - int size () const noexcept { return common_names.size(); } + int size () const noexcept { return static_cast(common_names.size()); } }; PolicyVec getPolicies (const NameMap& names) noexcept; diff --git a/Source/Particles/PhysicalParticleContainer.cpp b/Source/Particles/PhysicalParticleContainer.cpp index 1358011b9b0..f515b750a3e 100644 --- a/Source/Particles/PhysicalParticleContainer.cpp +++ b/Source/Particles/PhysicalParticleContainer.cpp @@ -304,7 +304,7 @@ PhysicalParticleContainer::PhysicalParticleContainer (AmrCore* amr_core, int isp // User-defined integer attributes pp_species_name.queryarr("addIntegerAttributes", m_user_int_attribs); - const int n_user_int_attribs = m_user_int_attribs.size(); + const auto n_user_int_attribs = static_cast(m_user_int_attribs.size()); std::vector< std::string > str_int_attrib_function; str_int_attrib_function.resize(n_user_int_attribs); m_user_int_attrib_parser.resize(n_user_int_attribs); @@ -319,7 +319,7 @@ PhysicalParticleContainer::PhysicalParticleContainer (AmrCore* amr_core, int isp // User-defined real attributes pp_species_name.queryarr("addRealAttributes", m_user_real_attribs); - const int n_user_real_attribs = m_user_real_attribs.size(); + const auto n_user_real_attribs = static_cast(m_user_real_attribs.size()); std::vector< std::string > str_real_attrib_function; str_real_attrib_function.resize(n_user_real_attribs); m_user_real_attrib_parser.resize(n_user_real_attribs); @@ -455,7 +455,6 @@ PhysicalParticleContainer::AddGaussianBeam ( Gpu::HostVector particle_uy; Gpu::HostVector particle_uz; Gpu::HostVector particle_w; - int np = 0; if (ParallelDescriptor::IOProcessor()) { // If do_symmetrize, create either 4x or 8x fewer particles, and @@ -551,7 +550,7 @@ PhysicalParticleContainer::AddGaussianBeam ( } } // Add the temporary CPU vectors to the particle structure - np = particle_z.size(); + auto const np = static_cast(particle_z.size()); amrex::Vector xp(particle_x.data(), particle_x.data() + np); amrex::Vector yp(particle_y.data(), particle_y.data() + np); amrex::Vector zp(particle_z.data(), particle_z.data() + np); @@ -606,30 +605,30 @@ PhysicalParticleContainer::AddPlasmaFromFile(ParticleReal q_tot, #if !defined(WARPX_DIM_1D_Z) // 2D, 3D, and RZ const std::shared_ptr ptr_x = ps["position"]["x"].loadChunk(); const std::shared_ptr ptr_offset_x = ps["positionOffset"]["x"].loadChunk(); - double const position_unit_x = ps["position"]["x"].unitSI(); - double const position_offset_unit_x = ps["positionOffset"]["x"].unitSI(); + auto const position_unit_x = static_cast(ps["position"]["x"].unitSI()); + auto const position_offset_unit_x = static_cast(ps["positionOffset"]["x"].unitSI()); #endif #if !(defined(WARPX_DIM_XZ) || defined(WARPX_DIM_1D_Z)) const std::shared_ptr ptr_y = ps["position"]["y"].loadChunk(); const std::shared_ptr ptr_offset_y = ps["positionOffset"]["y"].loadChunk(); - double const position_unit_y = ps["position"]["y"].unitSI(); - double const position_offset_unit_y = ps["positionOffset"]["y"].unitSI(); + auto const position_unit_y = static_cast(ps["position"]["y"].unitSI()); + auto const position_offset_unit_y = static_cast(ps["positionOffset"]["y"].unitSI()); #endif const std::shared_ptr ptr_z = ps["position"]["z"].loadChunk(); const std::shared_ptr ptr_offset_z = ps["positionOffset"]["z"].loadChunk(); - double const position_unit_z = ps["position"]["z"].unitSI(); - double const position_offset_unit_z = ps["positionOffset"]["z"].unitSI(); + auto const position_unit_z = static_cast(ps["position"]["z"].unitSI()); + auto const position_offset_unit_z = static_cast(ps["positionOffset"]["z"].unitSI()); const std::shared_ptr ptr_ux = ps["momentum"]["x"].loadChunk(); - double const momentum_unit_x = ps["momentum"]["x"].unitSI(); + auto const momentum_unit_x = static_cast(ps["momentum"]["x"].unitSI()); const std::shared_ptr ptr_uz = ps["momentum"]["z"].loadChunk(); - double const momentum_unit_z = ps["momentum"]["z"].unitSI(); + auto const momentum_unit_z = static_cast(ps["momentum"]["z"].unitSI()); const std::shared_ptr ptr_w = ps["weighting"][openPMD::RecordComponent::SCALAR].loadChunk(); - double const w_unit = ps["weighting"][openPMD::RecordComponent::SCALAR].unitSI(); + auto const w_unit = static_cast(ps["weighting"][openPMD::RecordComponent::SCALAR].unitSI()); std::shared_ptr ptr_uy = nullptr; - double momentum_unit_y = 1.0; + auto momentum_unit_y = 1.0_prt; if (ps["momentum"].contains("y")) { ptr_uy = ps["momentum"]["y"].loadChunk(); - momentum_unit_y = ps["momentum"]["y"].unitSI(); + momentum_unit_y = static_cast(ps["momentum"]["y"].unitSI()); } series->flush(); // shared_ptr data can be read now @@ -666,7 +665,7 @@ PhysicalParticleContainer::AddPlasmaFromFile(ParticleReal q_tot, CheckAndAddParticle(x, y, z, ux, uy, uz, weight, particle_x, particle_y, particle_z, particle_ux, particle_uy, particle_uz, - particle_w, t_lab); + particle_w, static_cast(t_lab)); } } auto const np = particle_z.size(); @@ -676,7 +675,7 @@ PhysicalParticleContainer::AddPlasmaFromFile(ParticleReal q_tot, ablastr::warn_manager::WarnPriority::high); } } // IO Processor - auto const np = particle_z.size(); + auto const np = static_cast(particle_z.size()); amrex::Vector xp(particle_x.data(), particle_x.data() + np); amrex::Vector yp(particle_y.data(), particle_y.data() + np); amrex::Vector zp(particle_z.data(), particle_z.data() + np); @@ -711,8 +710,8 @@ PhysicalParticleContainer::DefaultInitializeRuntimeAttributes ( const int np = pinned_tile.numParticles(); // Preparing data needed for user defined attributes - const int n_user_real_attribs = m_user_real_attribs.size(); - const int n_user_int_attribs = m_user_int_attribs.size(); + const auto n_user_real_attribs = static_cast(m_user_real_attribs.size()); + const auto n_user_int_attribs = static_cast(m_user_int_attribs.size()); const auto get_position = GetParticlePosition(pinned_tile); const auto soa = pinned_tile.getParticleTileData(); const amrex::ParticleReal* AMREX_RESTRICT ux = soa.m_rdata[PIdx::ux]; @@ -877,7 +876,7 @@ PhysicalParticleContainer::AddParticles (int lev) amrex::Vector> attr; attr.push_back(plasma_injector->multiple_particles_weight); amrex::Vector> attr_int; - AddNParticles(lev, plasma_injector->multiple_particles_pos_x.size(), + AddNParticles(lev, static_cast(plasma_injector->multiple_particles_pos_x.size()), plasma_injector->multiple_particles_pos_x, plasma_injector->multiple_particles_pos_y, plasma_injector->multiple_particles_pos_z, @@ -984,7 +983,7 @@ PhysicalParticleContainer::AddPlasma (int lev, RealBox part_realbox) { amrex::Gpu::synchronize(); } - Real wt = amrex::second(); + auto wt = static_cast(amrex::second()); const Box& tile_box = mfi.tilebox(); const RealBox tile_realbox = WarpX::getRealBox(tile_box, lev); @@ -1120,8 +1119,8 @@ PhysicalParticleContainer::AddPlasma (int lev, RealBox part_realbox) pa[ia] = soa.GetRealData(ia).data() + old_size; } // user-defined integer and real attributes - const int n_user_int_attribs = m_user_int_attribs.size(); - const int n_user_real_attribs = m_user_real_attribs.size(); + const auto n_user_int_attribs = static_cast(m_user_int_attribs.size()); + const auto n_user_real_attribs = static_cast(m_user_real_attribs.size()); amrex::Gpu::PinnedVector pa_user_int_pinned(n_user_int_attribs); amrex::Gpu::PinnedVector pa_user_real_pinned(n_user_real_attribs); amrex::Gpu::PinnedVector< amrex::ParserExecutor<7> > user_int_attrib_parserexec_pinned(n_user_int_attribs); @@ -1432,7 +1431,7 @@ PhysicalParticleContainer::AddPlasma (int lev, RealBox part_realbox) if (cost && WarpX::load_balance_costs_update_algo == LoadBalanceCostsUpdateAlgo::Timers) { - wt = amrex::second() - wt; + wt = static_cast(amrex::second()) - wt; amrex::HostDevice::Atomic::Add( &(*cost)[mfi.index()], wt); } } @@ -1525,7 +1524,7 @@ PhysicalParticleContainer::AddPlasmaFlux (amrex::Real dt) { amrex::Gpu::synchronize(); } - Real wt = amrex::second(); + auto wt = static_cast(amrex::second()); const Box& tile_box = mfi.tilebox(); const RealBox tile_realbox = WarpX::getRealBox(tile_box, 0); @@ -1670,8 +1669,8 @@ PhysicalParticleContainer::AddPlasmaFlux (amrex::Real dt) } // user-defined integer and real attributes - const int n_user_int_attribs = m_user_int_attribs.size(); - const int n_user_real_attribs = m_user_real_attribs.size(); + const auto n_user_int_attribs = static_cast(m_user_int_attribs.size()); + const auto n_user_real_attribs = static_cast(m_user_real_attribs.size()); amrex::Gpu::PinnedVector pa_user_int_pinned(n_user_int_attribs); amrex::Gpu::PinnedVector pa_user_real_pinned(n_user_real_attribs); amrex::Gpu::PinnedVector< amrex::ParserExecutor<7> > user_int_attrib_parserexec_pinned(n_user_int_attribs); @@ -1923,7 +1922,7 @@ PhysicalParticleContainer::AddPlasmaFlux (amrex::Real dt) if (cost && WarpX::load_balance_costs_update_algo == LoadBalanceCostsUpdateAlgo::Timers) { - wt = amrex::second() - wt; + wt = static_cast(amrex::second()) - wt; amrex::HostDevice::Atomic::Add( &(*cost)[mfi.index()], wt); } } @@ -2011,7 +2010,7 @@ PhysicalParticleContainer::Evolve (int lev, { amrex::Gpu::synchronize(); } - Real wt = amrex::second(); + auto wt = static_cast(amrex::second()); const Box& box = pti.validbox(); @@ -2180,7 +2179,7 @@ PhysicalParticleContainer::Evolve (int lev, if (cost && WarpX::load_balance_costs_update_algo == LoadBalanceCostsUpdateAlgo::Timers) { - wt = amrex::second() - wt; + wt = static_cast(amrex::second()) - wt; amrex::HostDevice::Atomic::Add( &(*cost)[pti.index()], wt); } } diff --git a/Source/Particles/Pusher/CopyParticleAttribs.H b/Source/Particles/Pusher/CopyParticleAttribs.H index 697fe1e0b38..29e5017a3a7 100644 --- a/Source/Particles/Pusher/CopyParticleAttribs.H +++ b/Source/Particles/Pusher/CopyParticleAttribs.H @@ -47,7 +47,7 @@ struct CopyParticleAttribs * always start at the particle with index 0. */ CopyParticleAttribs (const WarpXParIter& a_pti, TmpParticles& tmp_particle_data, - int a_offset = 0) noexcept + long a_offset = 0) noexcept { if (tmp_particle_data.empty()) return; @@ -73,7 +73,7 @@ struct CopyParticleAttribs * temporary data holder */ AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE - void operator() (const int i) const noexcept + void operator() (const long i) const noexcept { AMREX_ASSERT(uxp != nullptr); AMREX_ASSERT(uyp != nullptr); diff --git a/Source/Particles/Pusher/GetAndSetPosition.H b/Source/Particles/Pusher/GetAndSetPosition.H index d8cce61756d..45b9c39fe9d 100644 --- a/Source/Particles/Pusher/GetAndSetPosition.H +++ b/Source/Particles/Pusher/GetAndSetPosition.H @@ -74,7 +74,7 @@ struct GetParticlePosition * \param a_offset offset to apply to the particle indices */ template - GetParticlePosition (const ptiType& a_pti, int a_offset = 0) noexcept + GetParticlePosition (const ptiType& a_pti, long a_offset = 0) noexcept { const auto& aos = a_pti.GetArrayOfStructs(); m_structs = aos().dataPtr() + a_offset; @@ -88,7 +88,7 @@ struct GetParticlePosition * located at index `i + a_offset` and store them in the variables * `x`, `y`, `z` */ AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE - void operator() (const int i, RType& x, RType& y, RType& z) const noexcept + void operator() (const long i, RType& x, RType& y, RType& z) const noexcept { const PType& p = m_structs[i]; #ifdef WARPX_DIM_RZ @@ -117,7 +117,7 @@ struct GetParticlePosition * This is only different for RZ since this returns (r, theta, z) * in that case. */ AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE - void AsStored (const int i, RType& x, RType& y, RType& z) const noexcept + void AsStored (const long i, RType& x, RType& y, RType& z) const noexcept { const PType& p = m_structs[i]; #ifdef WARPX_DIM_RZ @@ -157,7 +157,7 @@ struct SetParticlePosition #endif template - SetParticlePosition (const ptiType& a_pti, int a_offset = 0) noexcept + SetParticlePosition (const ptiType& a_pti, long a_offset = 0) noexcept { auto& aos = a_pti.GetArrayOfStructs(); m_structs = aos().dataPtr() + a_offset; @@ -170,7 +170,7 @@ struct SetParticlePosition /** \brief Set the position of the particle at index `i + a_offset` * to `x`, `y`, `z` */ AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE - void operator() (const int i, RType x, RType y, RType z) const noexcept + void operator() (const long i, RType x, RType y, RType z) const noexcept { #if defined(WARPX_DIM_XZ) amrex::ignore_unused(y); @@ -199,7 +199,7 @@ struct SetParticlePosition * This is only different for RZ since the input should * be (r, theta, z) in that case. */ AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE - void AsStored (const int i, RType x, RType y, RType z) const noexcept + void AsStored (const long i, RType x, RType y, RType z) const noexcept { #if defined(WARPX_DIM_XZ) amrex::ignore_unused(y); diff --git a/Source/Particles/Resampling/LevelingThinning.cpp b/Source/Particles/Resampling/LevelingThinning.cpp index 6877529053c..e3910286c91 100644 --- a/Source/Particles/Resampling/LevelingThinning.cpp +++ b/Source/Particles/Resampling/LevelingThinning.cpp @@ -70,7 +70,7 @@ void LevelingThinning::operator() (WarpXParIter& pti, const int lev, // algorithm. auto bins = ParticleUtils::findParticlesInEachCell(lev, pti, ptile); - const int n_cells = bins.numBins(); + const auto n_cells = static_cast(bins.numBins()); const auto indices = bins.permutationPtr(); const auto cell_offsets = bins.offsetsPtr(); @@ -83,7 +83,7 @@ void LevelingThinning::operator() (WarpXParIter& pti, const int lev, { // The particles that are in the cell `i_cell` are // given by the `indices[cell_start:cell_stop]` - const auto cell_start = cell_offsets[i_cell]; + const auto cell_start = static_cast(cell_offsets[i_cell]); const auto cell_stop = static_cast(cell_offsets[i_cell+1]); const int cell_numparts = cell_stop - cell_start; diff --git a/Source/Particles/WarpXParticleContainer.H b/Source/Particles/WarpXParticleContainer.H index c6da328264b..2d3ba230bf1 100644 --- a/Source/Particles/WarpXParticleContainer.H +++ b/Source/Particles/WarpXParticleContainer.H @@ -297,7 +297,7 @@ public: * @param[in] id if different than -1, this id will be assigned to the particles (used for * particle tagging in some routines, e.g. SplitParticle) */ - void AddNParticles (int lev, int n, + void AddNParticles (int lev, long n, amrex::Vector const & x, amrex::Vector const & y, amrex::Vector const & z, diff --git a/Source/Particles/WarpXParticleContainer.cpp b/Source/Particles/WarpXParticleContainer.cpp index d2da12888ca..a7405bb5741 100644 --- a/Source/Particles/WarpXParticleContainer.cpp +++ b/Source/Particles/WarpXParticleContainer.cpp @@ -144,7 +144,7 @@ WarpXParticleContainer::AllocData () } void -WarpXParticleContainer::AddNParticles (int /*lev*/, int n, +WarpXParticleContainer::AddNParticles (int /*lev*/, long n, amrex::Vector const & x, amrex::Vector const & y, amrex::Vector const & z, @@ -164,13 +164,13 @@ WarpXParticleContainer::AddNParticles (int /*lev*/, int n, WARPX_ALWAYS_ASSERT_WITH_MESSAGE(nattr_int <= NumIntComps(), "Too many integer attributes specified"); - int ibegin = 0; - int iend = n; + long ibegin = 0; + long iend = n; if (!uniqueparticles) { const int myproc = amrex::ParallelDescriptor::MyProc(); const int nprocs = amrex::ParallelDescriptor::NProcs(); - const int navg = n/nprocs; - const int nleft = n - navg * nprocs; + const auto navg = n/nprocs; + const auto nleft = n - navg * nprocs; if (myproc < nleft) { ibegin = myproc*(navg+1); iend = ibegin + navg+1; @@ -196,7 +196,7 @@ WarpXParticleContainer::AddNParticles (int /*lev*/, int n, amrex::Vector theta(np); #endif - for (int i = ibegin; i < iend; ++i) + for (auto i = ibegin; i < iend; ++i) { ParticleType p; if (id==-1) @@ -615,7 +615,7 @@ WarpXParticleContainer::DepositCurrent ( const amrex::Real dt, const amrex::Real relative_time) { // Loop over the refinement levels - int const finest_level = J.size() - 1; + auto const finest_level = static_cast(J.size() - 1); for (int lev = 0; lev <= finest_level; ++lev) { // Loop over particle tiles and deposit current on each level @@ -824,8 +824,8 @@ WarpXParticleContainer::DepositCharge (WarpXParIter& pti, RealVector const& wp, auto permutation = bins.permutationPtr(); amrex::ParallelFor(bins.numBins(), [=] AMREX_GPU_DEVICE (int ibin) { - const int bin_start = offsets_ptr[ibin]; - const int bin_stop = offsets_ptr[ibin+1]; + const auto bin_start = offsets_ptr[ibin]; + const auto bin_stop = offsets_ptr[ibin+1]; if (bin_start < bin_stop) { auto p = pstruct_ptr[permutation[bin_start]]; Box tbx; @@ -964,7 +964,7 @@ WarpXParticleContainer::DepositCharge (amrex::Vector(rho.size() - 1); for (int lev = 0; lev <= finest_level; ++lev) { DepositCharge ( @@ -1252,7 +1252,7 @@ WarpXParticleContainer::PushX (int lev, amrex::Real dt) { amrex::Gpu::synchronize(); } - Real wt = amrex::second(); + auto wt = static_cast(amrex::second()); // // Particle Push @@ -1280,7 +1280,7 @@ WarpXParticleContainer::PushX (int lev, amrex::Real dt) if (costs && WarpX::load_balance_costs_update_algo == LoadBalanceCostsUpdateAlgo::Timers) { amrex::Gpu::synchronize(); - wt = amrex::second() - wt; + wt = static_cast(amrex::second()) - wt; amrex::HostDevice::Atomic::Add( &(*costs)[pti.index()], wt); } } diff --git a/Source/Utils/Parser/IntervalsParser.cpp b/Source/Utils/Parser/IntervalsParser.cpp index 35d13143ddb..16595f6f49c 100644 --- a/Source/Utils/Parser/IntervalsParser.cpp +++ b/Source/Utils/Parser/IntervalsParser.cpp @@ -205,7 +205,7 @@ utils::parser::BTDIntervalsParser::BTDIntervalsParser ( } else { - btd_iter_ind = m_btd_iterations.size() - 1; + btd_iter_ind = static_cast(m_btd_iterations.size() - 1); while (start < m_btd_iterations.at(btd_iter_ind) and btd_iter_ind>0) { btd_iter_ind--; @@ -256,7 +256,7 @@ utils::parser::BTDIntervalsParser::BTDIntervalsParser ( int utils::parser::BTDIntervalsParser::NumSnapshots () const { - return m_btd_iterations.size(); + return static_cast(m_btd_iterations.size()); } diff --git a/Source/Utils/Parser/ParserUtils.H b/Source/Utils/Parser/ParserUtils.H index 870c84e241b..fb86996bcd9 100644 --- a/Source/Utils/Parser/ParserUtils.H +++ b/Source/Utils/Parser/ParserUtils.H @@ -128,9 +128,10 @@ namespace utils::parser auto parser = makeParser(str_val, {}); - if (std::is_same::value) { + if constexpr (std::is_same::value) { - val = safeCastToInt(std::round(parser.compileHost<0>()()), str); + val = safeCastToInt( + static_cast(std::round(parser.compileHost<0>()())), str); } else { val = static_cast(parser.compileHost<0>()()); @@ -154,8 +155,9 @@ namespace utils::parser val.resize(n); for (int i=0 ; i < n ; i++) { auto parser = makeParser(tmp_str_arr[i], {}); - if (std::is_same::value) { - val[i] = safeCastToInt(std::round(parser.compileHost<0>()()), str); + if constexpr (std::is_same::value) { + val[i] = safeCastToInt( + static_cast(std::round(parser.compileHost<0>()())), str); } else { val[i] = static_cast(parser.compileHost<0>()()); @@ -196,8 +198,9 @@ namespace utils::parser val.resize(n); for (int i=0 ; i < n ; i++) { auto parser = makeParser(tmp_str_arr[i], {}); - if (std::is_same::value) { - val[i] = safeCastToInt(std::round(parser.compileHost<0>()()), str); + if constexpr (std::is_same::value) { + val[i] = safeCastToInt( + static_cast(std::round(parser.compileHost<0>()())), str); } else { val[i] = static_cast(parser.compileHost<0>()()); @@ -228,8 +231,9 @@ namespace utils::parser Store_parserString(a_pp, str, str_val); auto parser = makeParser(str_val, {}); - if (std::is_same::value) { - val = safeCastToInt(std::round(parser.compileHost<0>()()), str); + if constexpr (std::is_same::value) { + val = safeCastToInt( + static_cast(std::round(parser.compileHost<0>()())), str); } else { val = static_cast(parser.compileHost<0>()()); @@ -247,8 +251,9 @@ namespace utils::parser val.resize(n); for (int i=0 ; i < n ; i++) { auto parser = makeParser(tmp_str_arr[i], {}); - if (std::is_same::value) { - val[i] = safeCastToInt(std::round(parser.compileHost<0>()()), str); + if constexpr (std::is_same::value) { + val[i] = safeCastToInt( + static_cast(std::round(parser.compileHost<0>()())), str); } else { val[i] = static_cast(parser.compileHost<0>()()); @@ -284,8 +289,9 @@ namespace utils::parser val.resize(n); for (int i=0 ; i < n ; i++) { auto parser = makeParser(tmp_str_arr[i], {}); - if (std::is_same::value) { - val[i] = safeCastToInt(std::round(parser.compileHost<0>()()), str); + if constexpr (std::is_same::value) { + val[i] = safeCastToInt( + static_cast(std::round(parser.compileHost<0>()())), str); } else { val[i] = static_cast(parser.compileHost<0>()()); diff --git a/Source/Utils/ParticleUtils.H b/Source/Utils/ParticleUtils.H index 50dc12a722c..ecd6b7c2739 100644 --- a/Source/Utils/ParticleUtils.H +++ b/Source/Utils/ParticleUtils.H @@ -99,8 +99,8 @@ namespace ParticleUtils { // precompute repeatedly used quantities constexpr auto c2 = PhysConst::c * PhysConst::c; const auto V2 = (Vx*Vx + Vy*Vy + Vz*Vz); - const auto gamma_V = 1.0_prt / sqrt(1.0_prt - V2 / c2); - const auto gamma_u = sqrt(1.0_prt + (ux*ux + uy*uy + uz*uz) / c2); + const auto gamma_V = 1.0_prt / std::sqrt(1.0_prt - V2 / c2); + const auto gamma_u = std::sqrt(1.0_prt + (ux*ux + uy*uy + uz*uz) / c2); // copy velocity vector values const auto vx = ux; diff --git a/Source/Utils/WarpXMovingWindow.cpp b/Source/Utils/WarpXMovingWindow.cpp index 62fabef2542..3fd993ef9da 100644 --- a/Source/Utils/WarpXMovingWindow.cpp +++ b/Source/Utils/WarpXMovingWindow.cpp @@ -524,7 +524,7 @@ WarpX::shiftMF (amrex::MultiFab& mf, const amrex::Geometry& geom, { amrex::Gpu::synchronize(); } - amrex::Real wt = amrex::second(); + auto wt = static_cast(amrex::second()); auto const& dstfab = mf.array(mfi); auto const& srcfab = tmpmf.array(mfi); @@ -589,7 +589,7 @@ WarpX::shiftMF (amrex::MultiFab& mf, const amrex::Geometry& geom, WarpX::load_balance_costs_update_algo == LoadBalanceCostsUpdateAlgo::Timers) { amrex::Gpu::synchronize(); - wt = amrex::second() - wt; + wt = static_cast(amrex::second()) - wt; amrex::HostDevice::Atomic::Add( &(*cost)[mfi.index()], wt); } } @@ -607,7 +607,8 @@ WarpX::shiftMF (amrex::MultiFab& mf, const amrex::Geometry& geom, // The temporary MultiFab is setup to refer to the data of the original Multifab (this can // be done since the shape of the data is all the same, just the indexing is different). amrex::BoxList bl; - for (int i = 0, N=ba.size(); i < N; ++i) { + const auto ba_size = static_cast(ba.size()); + for (int i = 0; i < ba_size; ++i) { bl.push_back(amrex::grow(ba[i], 0, mf.nGrowVect()[0])); } const amrex::BoxArray rba(std::move(bl)); diff --git a/Source/WarpX.cpp b/Source/WarpX.cpp index 2df53dc6d2c..306c4ba049e 100644 --- a/Source/WarpX.cpp +++ b/Source/WarpX.cpp @@ -529,7 +529,7 @@ WarpX::ReadParameters () { const ParmParse pp_algo("algo"); - electromagnetic_solver_id = GetAlgorithmInteger(pp_algo, "maxwell_solver"); + electromagnetic_solver_id = static_cast(GetAlgorithmInteger(pp_algo, "maxwell_solver")); } { @@ -1014,7 +1014,7 @@ WarpX::ReadParameters () // Integer that corresponds to the type of grid used in the simulation // (collocated, staggered, hybrid) - grid_type = GetAlgorithmInteger(pp_warpx, "grid_type"); + grid_type = static_cast(GetAlgorithmInteger(pp_warpx, "grid_type")); // Use same shape factors in all directions, for gathering if (grid_type == GridType::Collocated) galerkin_interpolation = false; @@ -1031,7 +1031,9 @@ WarpX::ReadParameters () const ParmParse pp_fluids("fluids"); std::vector fluid_species_names = {}; pp_fluids.queryarr("species_names", fluid_species_names); + if (!fluid_species_names.empty()) do_fluid_species = 1; + if (do_fluid_species) { WARPX_ALWAYS_ASSERT_WITH_MESSAGE(max_level <= 1, "Fluid species cannot currently be used with mesh refinement."); @@ -1133,9 +1135,9 @@ WarpX::ReadParameters () // note: current_deposition must be set after maxwell_solver (electromagnetic_solver_id) or // do_electrostatic (electrostatic_solver_id) are already determined, // because its default depends on the solver selection - current_deposition_algo = GetAlgorithmInteger(pp_algo, "current_deposition"); - charge_deposition_algo = GetAlgorithmInteger(pp_algo, "charge_deposition"); - particle_pusher_algo = GetAlgorithmInteger(pp_algo, "particle_pusher"); + current_deposition_algo = static_cast(GetAlgorithmInteger(pp_algo, "current_deposition")); + charge_deposition_algo = static_cast(GetAlgorithmInteger(pp_algo, "charge_deposition")); + particle_pusher_algo = static_cast(GetAlgorithmInteger(pp_algo, "particle_pusher")); WARPX_ALWAYS_ASSERT_WITH_MESSAGE( current_deposition_algo != CurrentDepositionAlgo::Esirkepov || @@ -1167,7 +1169,7 @@ WarpX::ReadParameters () // Query algo.field_gathering from input, set field_gathering_algo to // "default" if not found (default defined in Utils/WarpXAlgorithmSelection.cpp) - field_gathering_algo = GetAlgorithmInteger(pp_algo, "field_gathering"); + field_gathering_algo = static_cast(GetAlgorithmInteger(pp_algo, "field_gathering")); // Set default field gathering algorithm for hybrid grids (momentum-conserving) std::string tmp_algo; @@ -1227,7 +1229,7 @@ WarpX::ReadParameters () pp_algo.query("load_balance_knapsack_factor", load_balance_knapsack_factor); utils::parser::queryWithParser(pp_algo, "load_balance_efficiency_ratio_threshold", load_balance_efficiency_ratio_threshold); - load_balance_costs_update_algo = GetAlgorithmInteger(pp_algo, "load_balance_costs_update"); + load_balance_costs_update_algo = static_cast(GetAlgorithmInteger(pp_algo, "load_balance_costs_update")); if (WarpX::load_balance_costs_update_algo==LoadBalanceCostsUpdateAlgo::Heuristic) { utils::parser::queryWithParser( pp_algo, "costs_heuristic_cells_wt", costs_heuristic_cells_wt); @@ -1407,12 +1409,12 @@ WarpX::ReadParameters () // Integer that corresponds to the order of the PSATD solution // (whether the PSATD equations are derived from first-order or // second-order solution) - psatd_solution_type = GetAlgorithmInteger(pp_psatd, "solution_type"); + psatd_solution_type = static_cast(GetAlgorithmInteger(pp_psatd, "solution_type")); // Integers that correspond to the time dependency of J (constant, linear) // and rho (linear, quadratic) for the PSATD algorithm - J_in_time = GetAlgorithmInteger(pp_psatd, "J_in_time"); - rho_in_time = GetAlgorithmInteger(pp_psatd, "rho_in_time"); + J_in_time = static_cast(GetAlgorithmInteger(pp_psatd, "J_in_time")); + rho_in_time = static_cast(GetAlgorithmInteger(pp_psatd, "rho_in_time")); if (psatd_solution_type != PSATDSolutionType::FirstOrder || !do_multi_J) { @@ -3051,11 +3053,11 @@ amrex::Vector WarpX::getFornbergStencilCoefficients(const int n_ord if (a_grid_type == GridType::Collocated) { // First coefficient - coeffs.at(0) = m * 2. / (m+1); + coeffs.at(0) = m * 2._rt / (m+1); // Other coefficients by recurrence for (int n = 1; n < m; n++) { - coeffs.at(n) = - (m-n) * 1. / (m+n+1) * coeffs.at(n-1); + coeffs.at(n) = - (m-n) * 1._rt / (m+n+1) * coeffs.at(n-1); } } // Coefficients for staggered finite-difference approximation @@ -3064,14 +3066,14 @@ amrex::Vector WarpX::getFornbergStencilCoefficients(const int n_ord Real prod = 1.; for (int k = 1; k < m+1; k++) { - prod *= (m + k) / (4. * k); + prod *= (m + k) / (4._rt * k); } // First coefficient - coeffs.at(0) = 4 * m * prod * prod; + coeffs.at(0) = 4_rt * m * prod * prod; // Other coefficients by recurrence for (int n = 1; n < m; n++) { - coeffs.at(n) = - ((2*n-1) * (m-n)) * 1. / ((2*n+1) * (m+n)) * coeffs.at(n-1); + coeffs.at(n) = - ((2_rt*n-1) * (m-n)) * 1._rt / ((2_rt*n+1) * (m+n)) * coeffs.at(n-1); } } diff --git a/Source/ablastr/fields/PoissonSolver.H b/Source/ablastr/fields/PoissonSolver.H index c5824be1774..953c67ab54e 100644 --- a/Source/ablastr/fields/PoissonSolver.H +++ b/Source/ablastr/fields/PoissonSolver.H @@ -81,7 +81,7 @@ namespace details AMREX_GPU_DEVICE AMREX_FORCE_INLINE void - operator() (long i, long j, long k) const noexcept + operator() (int i, int j, int k) const noexcept { amrex::mf_nodebilin_interp(i, j, k, 0, m_phi_fp_arr, 0, m_phi_cp_arr, 0, m_refratio); @@ -155,7 +155,7 @@ computePhi (amrex::Vector const & rho, rel_ref_ratio = amrex::Vector{{amrex::IntVect(AMREX_D_DECL(1, 1, 1))}}; } - int const finest_level = rho.size() - 1u; + auto const finest_level = static_cast(rho.size() - 1); // scale rho appropriately; also determine if rho is zero everywhere amrex::Real max_norm_b = 0.0; @@ -196,10 +196,10 @@ computePhi (amrex::Vector const & rho, geom[lev].CellSize(2)/std::sqrt(1._rt-beta_solver[2]*beta_solver[2]))}; int max_semicoarsening_level = 0; int semicoarsening_direction = -1; - const int min_dir = std::distance(dx_scaled.begin(), - std::min_element(dx_scaled.begin(),dx_scaled.end())); - const int max_dir = std::distance(dx_scaled.begin(), - std::max_element(dx_scaled.begin(),dx_scaled.end())); + const auto min_dir = static_cast(std::distance(dx_scaled.begin(), + std::min_element(dx_scaled.begin(),dx_scaled.end()))); + const auto max_dir = static_cast(std::distance(dx_scaled.begin(), + std::max_element(dx_scaled.begin(),dx_scaled.end()))); if (dx_scaled[max_dir] > dx_scaled[min_dir]) { semicoarsening_direction = max_dir; max_semicoarsening_level = static_cast diff --git a/Source/ablastr/fields/VectorPoissonSolver.H b/Source/ablastr/fields/VectorPoissonSolver.H index 3284b49c8fe..75957974fdb 100644 --- a/Source/ablastr/fields/VectorPoissonSolver.H +++ b/Source/ablastr/fields/VectorPoissonSolver.H @@ -115,7 +115,7 @@ computeVectorPotential ( amrex::Vector > co rel_ref_ratio = amrex::Vector{{amrex::IntVect(AMREX_D_DECL(1, 1, 1))}}; } - int const finest_level = curr.size() - 1u; + auto const finest_level = static_cast(curr.size()) - 1; // scale J appropriately; also determine if current is zero everywhere amrex::Real max_comp_J = 0.0; diff --git a/Source/ablastr/utils/SignalHandling.cpp b/Source/ablastr/utils/SignalHandling.cpp index feaf69d002f..18d43409ec3 100644 --- a/Source/ablastr/utils/SignalHandling.cpp +++ b/Source/ablastr/utils/SignalHandling.cpp @@ -90,7 +90,7 @@ SignalHandling::parseSignalNameToNumber (const std::string &str) std::string name_upper = sp.abbrev; std::string name_lower = name_upper; for (char &c : name_lower) { - c = std::tolower(c); + c = static_cast(std::tolower(static_cast(c))); } signals_parser.setConstant(name_upper, sp.value); diff --git a/Source/ablastr/utils/timer/Timer.H b/Source/ablastr/utils/timer/Timer.H index 6743607a0d6..e7787f36b75 100644 --- a/Source/ablastr/utils/timer/Timer.H +++ b/Source/ablastr/utils/timer/Timer.H @@ -8,8 +8,6 @@ #ifndef ABLASTR_TIMER_H_ #define ABLASTR_TIMER_H_ -#include - namespace ablastr::utils::timer { @@ -46,7 +44,7 @@ namespace ablastr::utils::timer * * @return the duration */ - amrex::Real get_duration () noexcept; + double get_duration () noexcept; /** @@ -55,12 +53,12 @@ namespace ablastr::utils::timer * * @return the maximum duration across all the MPI ranks */ - amrex::Real get_global_duration (); + double get_global_duration (); private: - amrex::Real m_start_time /*! The start time*/; - amrex::Real m_stop_time /*! The stop time*/; + double m_start_time /*! The start time*/; + double m_stop_time /*! The stop time*/; }; } diff --git a/Source/ablastr/utils/timer/Timer.cpp b/Source/ablastr/utils/timer/Timer.cpp index 6ce44eab312..90f6fcb99c5 100644 --- a/Source/ablastr/utils/timer/Timer.cpp +++ b/Source/ablastr/utils/timer/Timer.cpp @@ -25,13 +25,13 @@ Timer::record_stop_time() noexcept m_stop_time = amrex::ParallelDescriptor::second(); } -amrex::Real +double Timer::get_duration () noexcept { return m_stop_time - m_start_time; } -amrex::Real +double Timer::get_global_duration () { auto duration = this->get_duration(); From 38f95017cb85540bd633793a57c639f3e50b81ee Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Mon, 16 Oct 2023 16:26:01 -0700 Subject: [PATCH 06/25] Fix: CMake `Python_EXECUTABLE` (#4379) Replace the hard-coded `python3` with the found/set Python executable of the current build environment. --- CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5d00093e893..d7b68f8cfee 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -646,7 +646,7 @@ if(WarpX_PYTHON) ${CMAKE_COMMAND} -E rm -f -r warpx-whl COMMAND ${CMAKE_COMMAND} -E env PYWARPX_LIB_DIR=$ - python3 -m pip wheel -v --no-build-isolation --no-deps --wheel-dir=warpx-whl ${WarpX_SOURCE_DIR} + ${Python_EXECUTABLE} -m pip wheel -v --no-build-isolation --no-deps --wheel-dir=warpx-whl ${WarpX_SOURCE_DIR} WORKING_DIRECTORY ${WarpX_BINARY_DIR} DEPENDS @@ -660,7 +660,7 @@ if(WarpX_PYTHON) set(pyWarpX_REQUIREMENT_FILE "requirements.txt") endif() add_custom_target(${WarpX_CUSTOM_TARGET_PREFIX}pip_install_requirements - python3 -m pip install ${PYINSTALLOPTIONS} -r "${WarpX_SOURCE_DIR}/${pyWarpX_REQUIREMENT_FILE}" + ${Python_EXECUTABLE} -m pip install ${PYINSTALLOPTIONS} -r "${WarpX_SOURCE_DIR}/${pyWarpX_REQUIREMENT_FILE}" WORKING_DIRECTORY ${WarpX_BINARY_DIR} ) @@ -677,7 +677,7 @@ if(WarpX_PYTHON) # because otherwise pip would also force reinstall all dependencies. add_custom_target(${WarpX_CUSTOM_TARGET_PREFIX}pip_install ${CMAKE_COMMAND} -E env WARPX_MPI=${WarpX_MPI} - python3 -m pip install --force-reinstall --no-index --no-deps ${PYINSTALLOPTIONS} --find-links=warpx-whl pywarpx + ${Python_EXECUTABLE} -m pip install --force-reinstall --no-index --no-deps ${PYINSTALLOPTIONS} --find-links=warpx-whl pywarpx WORKING_DIRECTORY ${WarpX_BINARY_DIR} DEPENDS From 8ca2b937f232ef95d7240f6f0aec279d64fabda2 Mon Sep 17 00:00:00 2001 From: Luca Fedeli Date: Tue, 17 Oct 2023 02:04:47 +0200 Subject: [PATCH 07/25] Reorder WarpX.H so that public, protected, and private only appear once (#4340) * Reorder WarpX.H so that public, protected, and private only appear once Co-authored-by: Axel Huebl --- Source/WarpX.H | 210 ++++++++++++++++++++++++------------------------- 1 file changed, 104 insertions(+), 106 deletions(-) diff --git a/Source/WarpX.H b/Source/WarpX.H index 1bd3f5bf46c..e56d2e647c1 100644 --- a/Source/WarpX.H +++ b/Source/WarpX.H @@ -1042,6 +1042,109 @@ public: // Return the accelerator lattice instance defined at the given refinement level const AcceleratorLattice& get_accelerator_lattice (int lev) {return *(m_accelerator_lattice[lev]);} + // for cuda + void BuildBufferMasksInBox ( amrex::Box tbx, amrex::IArrayBox &buffer_mask, + const amrex::IArrayBox &guard_mask, int ng ); +#ifdef AMREX_USE_EB + amrex::EBFArrayBoxFactory const& fieldEBFactory (int lev) const noexcept { + return static_cast(*m_field_factory[lev]); + } +#endif + + void InitEB (); + +#ifdef AMREX_USE_EB + /** + * \brief Compute the length of the mesh edges. Here the length is a value in [0, 1]. + * An edge of length 0 is fully covered. + */ + static void ComputeEdgeLengths (std::array< std::unique_ptr, 3 >& edge_lengths, + const amrex::EBFArrayBoxFactory& eb_fact); + /** + * \brief Compute the area of the mesh faces. Here the area is a value in [0, 1]. + * An edge of area 0 is fully covered. + */ + static void ComputeFaceAreas (std::array< std::unique_ptr, 3 >& face_areas, + const amrex::EBFArrayBoxFactory& eb_fact); + + /** + * \brief Scale the edges lengths by the mesh width to obtain the real lengths. + */ + static void ScaleEdges (std::array< std::unique_ptr, 3 >& edge_lengths, + const std::array& cell_size); + /** + * \brief Scale the edges areas by the mesh width to obtain the real areas. + */ + static void ScaleAreas (std::array< std::unique_ptr, 3 >& face_areas, + const std::array& cell_size); + /** + * \brief Initialize information for cell extensions. + * The flags convention for m_flag_info_face is as follows + * - 0 for unstable cells + * - 1 for stable cells which have not been intruded + * - 2 for stable cells which have been intruded + * Here we cannot know if a cell is intruded or not so we initialize all stable cells with 1 + */ + void MarkCells(); +#endif + + /** + * \brief Compute the level set function used for particle-boundary interaction. + */ + void ComputeDistanceToEB (); + /** + * \brief Auxiliary function to count the amount of faces which still need to be extended + */ + amrex::Array1D CountExtFaces(); + /** + * \brief Main function computing the cell extension. Where possible it computes one-way + * extensions and, when this is not possible, it does eight-ways extensions. + */ + void ComputeFaceExtensions(); + /** + * \brief Initialize the memory for the FaceInfoBoxes + */ + void InitBorrowing(); + /** + * \brief Shrink the vectors in the FaceInfoBoxes + */ + void ShrinkBorrowing(); + /** + * \brief Do the one-way extension + */ + void ComputeOneWayExtensions(); + /** + * \brief Do the eight-ways extension + */ + void ComputeEightWaysExtensions(); + /** + * \brief Whenever an unstable cell cannot be extended we increase its area to be the minimal for stability. + * This is the method Benkler-Chavannes-Kuster method and it is less accurate than the regular ECT but it + * still works better than staircasing. (see https://ieeexplore.ieee.org/document/1638381) + * + * @param idim Integer indicating the dimension (x->0, y->1, z->2) for which the BCK correction is done + * + */ + void ApplyBCKCorrection(int idim); + + /** + * \brief Subtract the average of the cumulative sums of the preliminary current D + * from the current J (computed from D according to the Vay deposition scheme) + */ + void PSATDSubtractCurrentPartialSumsAvg (); + +#ifdef WARPX_USE_PSATD + +# ifdef WARPX_DIM_RZ + SpectralSolverRZ& +# else + SpectralSolver& +# endif + get_spectral_solver_fp (int lev) {return *spectral_solver_fp[lev];} +#endif + + FiniteDifferenceSolver * get_pointer_fdtd_solver_fp (int lev) { return m_fdtd_solver_fp[lev].get(); } + protected: /** @@ -1241,10 +1344,7 @@ private: void PerformanceHints (); void BuildBufferMasks (); -public: // for cuda - void BuildBufferMasksInBox ( amrex::Box tbx, amrex::IArrayBox &buffer_mask, - const amrex::IArrayBox &guard_mask, int ng ); -private: + const amrex::iMultiFab* getCurrentBufferMasks (int lev) const { return current_buffer_masks[lev].get(); } @@ -1565,97 +1665,7 @@ private: amrex::FabFactory const& fieldFactory (int lev) const noexcept { return *m_field_factory[lev]; } -#ifdef AMREX_USE_EB -public: - amrex::EBFArrayBoxFactory const& fieldEBFactory (int lev) const noexcept { - return static_cast(*m_field_factory[lev]); - } -#endif - -public: - void InitEB (); - /** - * \brief Compute the length of the mesh edges. Here the length is a value in [0, 1]. - * An edge of length 0 is fully covered. - */ - -public: -#ifdef AMREX_USE_EB - static void ComputeEdgeLengths (std::array< std::unique_ptr, 3 >& edge_lengths, - const amrex::EBFArrayBoxFactory& eb_fact); - /** - * \brief Compute the area of the mesh faces. Here the area is a value in [0, 1]. - * An edge of area 0 is fully covered. - */ - static void ComputeFaceAreas (std::array< std::unique_ptr, 3 >& face_areas, - const amrex::EBFArrayBoxFactory& eb_fact); - - /** - * \brief Scale the edges lengths by the mesh width to obtain the real lengths. - */ - static void ScaleEdges (std::array< std::unique_ptr, 3 >& edge_lengths, - const std::array& cell_size); - /** - * \brief Scale the edges areas by the mesh width to obtain the real areas. - */ - static void ScaleAreas (std::array< std::unique_ptr, 3 >& face_areas, - const std::array& cell_size); - /** - * \brief Initialize information for cell extensions. - * The flags convention for m_flag_info_face is as follows - * - 0 for unstable cells - * - 1 for stable cells which have not been intruded - * - 2 for stable cells which have been intruded - * Here we cannot know if a cell is intruded or not so we initialize all stable cells with 1 - */ - void MarkCells(); - /** - * \brief Compute the level set function used for particle-boundary interaction. - */ -#endif - void ComputeDistanceToEB (); - /** - * \brief Auxiliary function to count the amount of faces which still need to be extended - */ - amrex::Array1D CountExtFaces(); - /** - * \brief Main function computing the cell extension. Where possible it computes one-way - * extensions and, when this is not possible, it does eight-ways extensions. - */ - void ComputeFaceExtensions(); - /** - * \brief Initialize the memory for the FaceInfoBoxes - */ - void InitBorrowing(); - /** - * \brief Shrink the vectors in the FaceInfoBoxes - */ - void ShrinkBorrowing(); - /** - * \brief Do the one-way extension - */ - void ComputeOneWayExtensions(); - /** - * \brief Do the eight-ways extension - */ - void ComputeEightWaysExtensions(); - /** - * \brief Whenever an unstable cell cannot be extended we increase its area to be the minimal for stability. - * This is the method Benkler-Chavannes-Kuster method and it is less accurate than the regular ECT but it - * still works better than staircasing. (see https://ieeexplore.ieee.org/document/1638381) - * - * @param idim Integer indicating the dimension (x->0, y->1, z->2) for which the BCK correction is done - * - */ - void ApplyBCKCorrection(int idim); - - /** - * \brief Subtract the average of the cumulative sums of the preliminary current D - * from the current J (computed from D according to the Vay deposition scheme) - */ - void PSATDSubtractCurrentPartialSumsAvg (); -private: void ScrapeParticles (); void PushPSATD (); @@ -1826,20 +1836,8 @@ private: amrex::Vector> spectral_solver_cp; # endif -public: - -# ifdef WARPX_DIM_RZ - SpectralSolverRZ& -# else - SpectralSolver& -# endif - get_spectral_solver_fp (int lev) {return *spectral_solver_fp[lev];} #endif -public: - FiniteDifferenceSolver * get_pointer_fdtd_solver_fp (int lev) { return m_fdtd_solver_fp[lev].get(); } - -private: amrex::Vector> m_fdtd_solver_fp; amrex::Vector> m_fdtd_solver_cp; }; From b600807246b3a601128341044c715710e3d49d7e Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Mon, 16 Oct 2023 21:57:17 -0700 Subject: [PATCH 08/25] CMake: `pip_install_nodeps` Target (#4361) Add a target that does not search of check any dependencies with pip. Useful in package managers. --- CMakeLists.txt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index d7b68f8cfee..4dc886be52d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -686,6 +686,17 @@ if(WarpX_PYTHON) ${WarpX_CUSTOM_TARGET_PREFIX}pip_install_requirements ${_EXTRA_INSTALL_DEPENDS} ) + + # this is for package managers only + add_custom_target(${WarpX_CUSTOM_TARGET_PREFIX}pip_install_nodeps + ${CMAKE_COMMAND} -E env WARPX_MPI=${WarpX_MPI} + ${Python_EXECUTABLE} -m pip install --force-reinstall --no-index --no-deps ${PYINSTALLOPTIONS} --find-links=warpx-whl pywarpx + WORKING_DIRECTORY + ${WarpX_BINARY_DIR} + DEPENDS + pyWarpX_${WarpX_DIMS_LAST} + ${WarpX_CUSTOM_TARGET_PREFIX}pip_wheel + ) endif() From 138bb3e3fd5588aa7ee98b90bce0c95cd2d38c03 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 16 Oct 2023 21:59:28 -0700 Subject: [PATCH 09/25] [pre-commit.ci] pre-commit autoupdate (#4378) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/hadialqattan/pycln: v2.2.2 → v2.3.0](https://github.com/hadialqattan/pycln/compare/v2.2.2...v2.3.0) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index bb8b6c8b33d..b514758caba 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -68,7 +68,7 @@ repos: # Autoremoves unused Python imports - repo: https://github.com/hadialqattan/pycln - rev: v2.2.2 + rev: v2.3.0 hooks: - id: pycln name: pycln (python) From 1b8071289eaeaac5b52c91c78861b18eb0e8e379 Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Mon, 16 Oct 2023 22:22:59 -0700 Subject: [PATCH 10/25] Fix: Fails in Python Callbacks Abort (#4380) * Fix: Fails in Python Callbacks Abort Make sure that errors in Python callbacks abort the simulation. Before, MPI-parallel simulations would hang. * Include * Include --- Source/Python/WarpX_py.H | 1 + Source/Python/WarpX_py.cpp | 22 ++++++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/Source/Python/WarpX_py.H b/Source/Python/WarpX_py.H index a18f9a7f1ce..590f26a804b 100644 --- a/Source/Python/WarpX_py.H +++ b/Source/Python/WarpX_py.H @@ -12,6 +12,7 @@ #include "Utils/export.H" #include "Utils/WarpXProfilerWrapper.H" +#include #include #include diff --git a/Source/Python/WarpX_py.cpp b/Source/Python/WarpX_py.cpp index 49328d0a4a7..afc734d780e 100644 --- a/Source/Python/WarpX_py.cpp +++ b/Source/Python/WarpX_py.cpp @@ -8,6 +8,11 @@ */ #include "WarpX_py.H" +#include +#include +#include + + std::map< std::string, std::function > warpx_callback_py_map; void InstallPythonCallback ( std::string name, std::function callback ) @@ -24,8 +29,21 @@ bool IsPythonCallbackInstalled ( std::string name ) void ExecutePythonCallback ( std::string name ) { if ( IsPythonCallbackInstalled(name) ) { - WARPX_PROFILE("warpx_py_"+name); - warpx_callback_py_map[name](); + WARPX_PROFILE("warpx_py_" + name); + try { + warpx_callback_py_map[name](); + } catch (std::exception &e) { + std::cerr << "Python callback '" << name << "' failed!" << std::endl; + std::cerr << e.what() << std::endl; + std::exit(3); // note: NOT amrex::Abort(), to avoid hangs with MPI + + // future note: + // if we want to rethrow/raise exceptions from Python callbacks through here (C++) and + // back the managing Python interpreter, we first need to discard and clear + // out the Python error in py::error_already_set. Otherwise, MPI-runs will hang + // (and Python will be in continued error state). + // https://pybind11.readthedocs.io/en/stable/advanced/exceptions.html#handling-unraisable-exceptions + } } } From 2770d3dd104c0d450face979f806df1dbc1c0435 Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Tue, 17 Oct 2023 15:03:20 -0700 Subject: [PATCH 11/25] AMReX/PICSAR: Weekly Update (#4363) * AMReX: Weekly Update * AMReX: Weekly Update --- .github/workflows/cuda.yml | 2 +- Regression/WarpX-GPU-tests.ini | 2 +- Regression/WarpX-tests.ini | 2 +- cmake/dependencies/AMReX.cmake | 2 +- run_test.sh | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/cuda.yml b/.github/workflows/cuda.yml index 1754549ab2d..0425842e7cc 100644 --- a/.github/workflows/cuda.yml +++ b/.github/workflows/cuda.yml @@ -111,7 +111,7 @@ jobs: which nvcc || echo "nvcc not in PATH!" git clone https://github.com/AMReX-Codes/amrex.git ../amrex - cd ../amrex && git checkout --detach 23.10 && cd - + cd ../amrex && git checkout --detach 7ee29121ed70d7e255ad98a8b1690d345cb4fb33 && 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: diff --git a/Regression/WarpX-GPU-tests.ini b/Regression/WarpX-GPU-tests.ini index 1a1c1fc612c..aa0167565ea 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 = 23.10 +branch = 7ee29121ed70d7e255ad98a8b1690d345cb4fb33 [source] dir = /home/regtester/git/WarpX diff --git a/Regression/WarpX-tests.ini b/Regression/WarpX-tests.ini index 3eb8101addb..71c510b81a3 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 = 23.10 +branch = 7ee29121ed70d7e255ad98a8b1690d345cb4fb33 [source] dir = /home/regtester/AMReX_RegTesting/warpx diff --git a/cmake/dependencies/AMReX.cmake b/cmake/dependencies/AMReX.cmake index a4d1f0fed5c..0313f4a2128 100644 --- a/cmake/dependencies/AMReX.cmake +++ b/cmake/dependencies/AMReX.cmake @@ -257,7 +257,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 "23.10" +set(WarpX_amrex_branch "7ee29121ed70d7e255ad98a8b1690d345cb4fb33" CACHE STRING "Repository branch for WarpX_amrex_repo if(WarpX_amrex_internal)") diff --git a/run_test.sh b/run_test.sh index 1c948e48713..e362a0ef332 100755 --- a/run_test.sh +++ b/run_test.sh @@ -71,7 +71,7 @@ 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 23.10 && cd - +cd amrex && git checkout --detach 7ee29121ed70d7e255ad98a8b1690d345cb4fb33 && 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 From 0442f3ffd5ccaeb361bf29855c760ea7ed54c740 Mon Sep 17 00:00:00 2001 From: Roelof Groenewald <40245517+roelof-groenewald@users.noreply.github.com> Date: Tue, 17 Oct 2023 20:50:40 -0700 Subject: [PATCH 12/25] Add RZ support for Ohm's law solver (#4161) * add RZ support for `FiniteDifferenceSolver::CalculateCurrentAmpere` * add RZ support in `HybridPICSolveECylindrical` * allow an initial Bz field to be set in RZ * apply PEC boundary to r_max boundary in RZ * WIP normal modes example / CI test * fix typo in Cartesian EM modes example * code cleanup and addition of CI test * some progress on CI test * fix compile issue when `USE_EB=True`; update CI test and analysis script * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix CI test and update docs * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * reset benchmark values for failing tests * update reference amplitude values based on previous values from Azure * reset hybrid-PIC RZ checksum values - not sure why this is needed * add `-DWarpX_PYTHON=ON` cmake option to hybrid-PIC RZ test configuration * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * apply changes requested during code review * fix clang-tidy narrowing conversion warnings --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- Docs/source/refs.bib | 13 + Docs/source/usage/examples.rst | 14 +- .../Tests/ohm_solver_EM_modes/PICMI_inputs.py | 6 +- .../ohm_solver_EM_modes/PICMI_inputs_rz.py | 248 ++++++++++ .../Tests/ohm_solver_EM_modes/analysis_rz.py | 169 +++++++ .../LaserInjectionFromLASYFile_RZ.json | 16 +- .../LaserInjectionFromRZLASYFile.json | 14 +- .../Python_ohms_law_solver_EM_modes_rz.json | 12 + Regression/WarpX-tests.ini | 19 + Source/BoundaryConditions/WarpX_PEC.H | 4 +- Source/BoundaryConditions/WarpX_PEC.cpp | 30 -- .../HybridPICModel/HybridPICModel.cpp | 6 + .../HybridPICSolveE.cpp | 450 +++++++++++++++++- Source/Initialization/WarpXInitData.cpp | 41 +- 14 files changed, 959 insertions(+), 83 deletions(-) create mode 100644 Examples/Tests/ohm_solver_EM_modes/PICMI_inputs_rz.py create mode 100755 Examples/Tests/ohm_solver_EM_modes/analysis_rz.py create mode 100644 Regression/Checksum/benchmarks_json/Python_ohms_law_solver_EM_modes_rz.json diff --git a/Docs/source/refs.bib b/Docs/source/refs.bib index 72d54456a89..fdbbe57cf72 100644 --- a/Docs/source/refs.bib +++ b/Docs/source/refs.bib @@ -483,3 +483,16 @@ @article{Stanier2020 author = {A. Stanier and L. Chacón and A. Le}, keywords = {Hybrid, Particle-in-cell, Plasma, Asymptotic-preserving, Cancellation problem, Space weather}, } + +@book{Stix1992, + author = {Stix, T.H.}, + date-added = {2023-06-29 13:51:16 -0700}, + date-modified = {2023-06-29 13:51:16 -0700}, + isbn = {978-0-88318-859-0}, + lccn = {lc91033341}, + publisher = {American Inst. of Physics}, + title = {Waves in {Plasmas}}, + url = {https://books.google.com/books?id=OsOWJ8iHpmMC}, + year = {1992}, + bdsk-url-1 = {https://books.google.com/books?id=OsOWJ8iHpmMC} +} diff --git a/Docs/source/usage/examples.rst b/Docs/source/usage/examples.rst index e733938a93c..48d37db98c4 100644 --- a/Docs/source/usage/examples.rst +++ b/Docs/source/usage/examples.rst @@ -164,6 +164,18 @@ ion-Bernstein modes as indicated below. python3 PICMI_inputs.py -dim {1/2/3} --bdir {x/y/z} +A RZ-geometry example case for normal modes propagating along an applied magnetic field in a cylinder is also available. +The analytical solution for these modes are described in :cite:t:`ex-Stix1992` Chapter 6, Sec. 2. + +.. figure:: https://user-images.githubusercontent.com/40245517/259251824-33e78375-81d8-410d-a147-3fa0498c66be.png + :alt: Normal EM modes in a metallic cylinder + :width: 90% + +The input file for this example and corresponding analysis can be found at: + +* :download:`Cylinderical modes input <../../../Examples/Tests/ohm_solver_EM_modes/PICMI_inputs_rz.py>` +* :download:`Analysis script <../../../Examples/Tests/ohm_solver_EM_modes/analysis_rz.py>` + Ion beam R instability ^^^^^^^^^^^^^^^^^^^^^^ @@ -243,7 +255,7 @@ The input file for this example and corresponding analysis can be found at: * :download:`Analysis script <../../../Examples/Tests/ohm_solver_magnetic_reconnection/analysis.py>` Many Further Examples, Demos and Tests -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +-------------------------------------- WarpX runs over 200 integration tests on a variety of modeling cases, which validate and demonstrate its functionality. Please see the `Examples/Tests/ `__ directory for many more examples. diff --git a/Examples/Tests/ohm_solver_EM_modes/PICMI_inputs.py b/Examples/Tests/ohm_solver_EM_modes/PICMI_inputs.py index 51dbb53ab43..9363bcebd18 100644 --- a/Examples/Tests/ohm_solver_EM_modes/PICMI_inputs.py +++ b/Examples/Tests/ohm_solver_EM_modes/PICMI_inputs.py @@ -4,8 +4,8 @@ # --- treated as kinetic particles and electrons as an isothermal, inertialess # --- background fluid. The script is set up to produce either parallel or # --- perpendicular (Bernstein) EM modes and can be run in 1d, 2d or 3d -# --- Cartesian geometries. See Section 4.2 and 4.3 of Munoz et al. (2018) As a -# --- CI test only a small number of steps are taken using the 1d version. +# --- Cartesian geometries. See Section 4.2 and 4.3 of Munoz et al. (2018). +# --- As a CI test only a small number of steps are taken using the 1d version. import argparse import os @@ -322,7 +322,7 @@ def _record_average_fields(self): return Bx_warpx = fields.BxWrapper()[...] - By_warpx = fields.BxWrapper()[...] + By_warpx = fields.ByWrapper()[...] Ez_warpx = fields.EzWrapper()[...] if libwarpx.amr.ParallelDescriptor.MyProc() != 0: diff --git a/Examples/Tests/ohm_solver_EM_modes/PICMI_inputs_rz.py b/Examples/Tests/ohm_solver_EM_modes/PICMI_inputs_rz.py new file mode 100644 index 00000000000..21d8cafe750 --- /dev/null +++ b/Examples/Tests/ohm_solver_EM_modes/PICMI_inputs_rz.py @@ -0,0 +1,248 @@ +#!/usr/bin/env python3 +# +# --- Test script for the kinetic-fluid hybrid model in WarpX wherein ions are +# --- treated as kinetic particles and electrons as an isothermal, inertialess +# --- background fluid. The script is set up to produce parallel normal EM modes +# --- in a metallic cylinder and is run in RZ geometry. +# --- As a CI test only a small number of steps are taken. + +import argparse +import sys + +import dill +from mpi4py import MPI as mpi +import numpy as np + +from pywarpx import picmi + +constants = picmi.constants + +comm = mpi.COMM_WORLD + +simulation = picmi.Simulation(verbose=0) + + +class CylindricalNormalModes(object): + '''The following runs a simulation of an uniform plasma at a set ion + temperature (and Te = 0) with an external magnetic field applied in the + z-direction (parallel to domain). + The analysis script (in this same directory) analyzes the output field + data for EM modes. + ''' + # Applied field parameters + B0 = 0.5 # Initial magnetic field strength (T) + beta = 0.01 # Plasma beta, used to calculate temperature + + # Plasma species parameters + m_ion = 400.0 # Ion mass (electron masses) + vA_over_c = 5e-3 # ratio of Alfven speed and the speed of light + + # Spatial domain + Nz = 512 # number of cells in z direction + Nr = 128 # number of cells in r direction + + # Temporal domain (if not run as a CI test) + LT = 800.0 # Simulation temporal length (ion cyclotron periods) + + # Numerical parameters + NPPC = 8000 # Seed number of particles per cell + DZ = 0.4 # Cell size (ion skin depths) + DR = 0.4 # Cell size (ion skin depths) + DT = 0.02 # Time step (ion cyclotron periods) + + # Plasma resistivity - used to dampen the mode excitation + eta = 5e-4 + # Number of substeps used to update B + substeps = 250 + + def __init__(self, test, verbose): + """Get input parameters for the specific case desired.""" + self.test = test + self.verbose = verbose or self.test + + # calculate various plasma parameters based on the simulation input + self.get_plasma_quantities() + + if not self.test: + self.total_steps = int(self.LT / self.DT) + else: + # if this is a test case run for only a small number of steps + self.total_steps = 100 + # and make the grid and particle count smaller + self.Nz = 128 + self.Nr = 64 + self.NPPC = 200 + # output diagnostics 5 times per cyclotron period + self.diag_steps = max(10, int(1.0 / 5 / self.DT)) + + self.Lz = self.Nz * self.DZ * self.l_i + self.Lr = self.Nr * self.DR * self.l_i + + self.dt = self.DT * self.t_ci + + # dump all the current attributes to a dill pickle file + if comm.rank == 0: + with open(f'sim_parameters.dpkl', 'wb') as f: + dill.dump(self, f) + + # print out plasma parameters + if comm.rank == 0: + print( + f"Initializing simulation with input parameters:\n" + f"\tT = {self.T_plasma:.3f} eV\n" + f"\tn = {self.n_plasma:.1e} m^-3\n" + f"\tB0 = {self.B0:.2f} T\n" + f"\tM/m = {self.m_ion:.0f}\n" + ) + print( + f"Plasma parameters:\n" + f"\tl_i = {self.l_i:.1e} m\n" + f"\tt_ci = {self.t_ci:.1e} s\n" + f"\tv_ti = {self.v_ti:.1e} m/s\n" + f"\tvA = {self.vA:.1e} m/s\n" + ) + print( + f"Numerical parameters:\n" + f"\tdt = {self.dt:.1e} s\n" + f"\tdiag steps = {self.diag_steps:d}\n" + f"\ttotal steps = {self.total_steps:d}\n", + flush=True + ) + self.setup_run() + + def get_plasma_quantities(self): + """Calculate various plasma parameters based on the simulation input.""" + # Ion mass (kg) + self.M = self.m_ion * constants.m_e + + # Cyclotron angular frequency (rad/s) and period (s) + self.w_ci = constants.q_e * abs(self.B0) / self.M + self.t_ci = 2.0 * np.pi / self.w_ci + + # Alfven speed (m/s): vA = B / sqrt(mu0 * n * (M + m)) = c * omega_ci / w_pi + self.vA = self.vA_over_c * constants.c + self.n_plasma = ( + (self.B0 / self.vA)**2 / (constants.mu0 * (self.M + constants.m_e)) + ) + + # Ion plasma frequency (Hz) + self.w_pi = np.sqrt( + constants.q_e**2 * self.n_plasma / (self.M * constants.ep0) + ) + + # Skin depth (m) + self.l_i = constants.c / self.w_pi + + # Ion thermal velocity (m/s) from beta = 2 * (v_ti / vA)**2 + self.v_ti = np.sqrt(self.beta / 2.0) * self.vA + + # Temperature (eV) from thermal speed: v_ti = sqrt(kT / M) + self.T_plasma = self.v_ti**2 * self.M / constants.q_e # eV + + # Larmor radius (m) + self.rho_i = self.v_ti / self.w_ci + + def setup_run(self): + """Setup simulation components.""" + + ####################################################################### + # Set geometry and boundary conditions # + ####################################################################### + + self.grid = picmi.CylindricalGrid( + number_of_cells=[self.Nr, self.Nz], + warpx_max_grid_size=self.Nz, + lower_bound=[0, -self.Lz/2.0], + upper_bound=[self.Lr, self.Lz/2.0], + lower_boundary_conditions = ['none', 'periodic'], + upper_boundary_conditions = ['dirichlet', 'periodic'], + lower_boundary_conditions_particles = ['absorbing', 'periodic'], + upper_boundary_conditions_particles = ['reflecting', 'periodic'] + ) + simulation.time_step_size = self.dt + simulation.max_steps = self.total_steps + simulation.current_deposition_algo = 'direct' + simulation.particle_shape = 1 + simulation.verbose = self.verbose + + ####################################################################### + # Field solver and external field # + ####################################################################### + + self.solver = picmi.HybridPICSolver( + grid=self.grid, + Te=0.0, n0=self.n_plasma, plasma_resistivity=self.eta, + substeps=self.substeps, + n_floor=self.n_plasma*0.05 + ) + simulation.solver = self.solver + + B_ext = picmi.AnalyticInitialField( + Bz_expression=self.B0 + ) + simulation.add_applied_field(B_ext) + + ####################################################################### + # Particle types setup # + ####################################################################### + + self.ions = picmi.Species( + name='ions', charge='q_e', mass=self.M, + initial_distribution=picmi.UniformDistribution( + density=self.n_plasma, + rms_velocity=[self.v_ti]*3, + ) + ) + simulation.add_species( + self.ions, + layout=picmi.PseudoRandomLayout( + grid=self.grid, n_macroparticles_per_cell=self.NPPC + ) + ) + + ####################################################################### + # Add diagnostics # + ####################################################################### + + field_diag = picmi.FieldDiagnostic( + name='field_diag', + grid=self.grid, + period=self.diag_steps, + data_list=['B', 'E'], + write_dir='diags', + warpx_file_prefix='field_diags', + warpx_format='openpmd', + warpx_openpmd_backend='h5', + ) + simulation.add_diagnostic(field_diag) + + # add particle diagnostic for checksum + if self.test: + part_diag = picmi.ParticleDiagnostic( + name='diag1', + period=self.total_steps, + species=[self.ions], + data_list=['ux', 'uy', 'uz', 'weighting'], + write_dir='.', + warpx_file_prefix='Python_ohms_law_solver_EM_modes_rz_plt' + ) + simulation.add_diagnostic(part_diag) + + +########################## +# parse input parameters +########################## + +parser = argparse.ArgumentParser() +parser.add_argument( + '-t', '--test', help='toggle whether this script is run as a short CI test', + action='store_true', +) +parser.add_argument( + '-v', '--verbose', help='Verbose output', action='store_true', +) +args, left = parser.parse_known_args() +sys.argv = sys.argv[:1]+left + +run = CylindricalNormalModes(test=args.test, verbose=args.verbose) +simulation.step() diff --git a/Examples/Tests/ohm_solver_EM_modes/analysis_rz.py b/Examples/Tests/ohm_solver_EM_modes/analysis_rz.py new file mode 100755 index 00000000000..9eb747dd6e8 --- /dev/null +++ b/Examples/Tests/ohm_solver_EM_modes/analysis_rz.py @@ -0,0 +1,169 @@ +#!/usr/bin/env python3 +# +# --- Analysis script for the hybrid-PIC example producing EM modes. + +import dill +from matplotlib import colors +import matplotlib.pyplot as plt +import numpy as np +from openpmd_viewer import OpenPMDTimeSeries +import scipy.fft as fft +from scipy.interpolate import RegularGridInterpolator +from scipy.special import j1, jn, jn_zeros + +from pywarpx import picmi + +constants = picmi.constants + +# load simulation parameters +with open(f'sim_parameters.dpkl', 'rb') as f: + sim = dill.load(f) + +diag_dir = "diags/field_diags" + +ts = OpenPMDTimeSeries(diag_dir, check_all_files=True) + +def transform_spatially(data_for_transform): + # interpolate from regular r-grid to special r-grid + interp = RegularGridInterpolator( + (info.z, info.r), data_for_transform, + method='linear' + ) + data_interp = interp((zg, rg)) + + # Applying manual hankel in r + # Fmz = np.sum(proj*data_for_transform, axis=(2,3)) + Fmz = np.einsum('ijkl,kl->ij', proj, data_interp) + # Standard fourier in z + Fmn = fft.fftshift(fft.fft(Fmz, axis=1), axes=1) + return Fmn + +def process(it): + print(f"Processing iteration {it}", flush=True) + field, info = ts.get_field('E', 'y', iteration=it) + F_k = transform_spatially(field) + return F_k + +# grab the first iteration to get the grids +Bz, info = ts.get_field('B', 'z', iteration=0) + +nr = len(info.r) +nz = len(info.z) + +nkr = 12 # number of radial modes to solve for + +r_max = np.max(info.r) + +# create r-grid with points spaced out according to zeros of the Bessel function +r_grid = jn_zeros(1, nr) / jn_zeros(1, nr)[-1] * r_max + +zg, rg = np.meshgrid(info.z, r_grid) + +# Setup Hankel Transform +j_1M = jn_zeros(1, nr)[-1] +r_modes = np.arange(nkr) + +A = ( + 4.0 * np.pi * r_max**2 / j_1M**2 + * j1(np.outer(jn_zeros(1, max(r_modes)+1)[r_modes], jn_zeros(1, nr)) / j_1M) + / jn(2 ,jn_zeros(1, nr))**2 +) + +# No transformation for z +B = np.identity(nz) + +# combine projection arrays +proj = np.einsum('ab,cd->acbd', A, B) + +results = np.zeros((len(ts.t), nkr, nz), dtype=complex) +for ii, it in enumerate(ts.iterations): + results[ii] = process(it) + +# now Fourier transform in time +F_kw = fft.fftshift(fft.fft(results, axis=0), axes=0) + +dz = info.z[1] - info.z[0] +kz = 2*np.pi*fft.fftshift(fft.fftfreq(F_kw[0].shape[1], dz)) +dt = ts.iterations[1] - ts.iterations[0] +omega = 2*np.pi*fft.fftshift(fft.fftfreq(F_kw.shape[0], sim.dt*dt)) + +# Save data for future plotting purposes +np.savez( + "diags/spectrograms.npz", + F_kw=F_kw, dz=dz, kz=kz, dt=dt, omega=omega +) + +# plot the resulting dispersions +k = np.linspace(0, 250, 500) +kappa = k * sim.l_i + +fig, axes = plt.subplots(2, 2, sharex=True, sharey=True, figsize=(6.75, 5)) + +vmin = [2e-3, 1.5e-3, 7.5e-4, 5e-4] +vmax = 1.0 + +# plot m = 1 +for ii, m in enumerate([1, 3, 6, 8]): + ax = axes.flatten()[ii] + ax.set_title(f"m = {m}", fontsize=11) + m -= 1 + pm1 = ax.pcolormesh( + kz*sim.l_i, omega/sim.w_ci, + abs(F_kw[:, m, :])/np.max(abs(F_kw[:, m, :])), + norm=colors.LogNorm(vmin=vmin[ii], vmax=vmax), + cmap='inferno' + ) + cb = fig.colorbar(pm1, ax=ax) + cb.set_label(r'Normalized $E_\theta(k_z, m, \omega)$') + + # Get dispersion relation - see for example + # T. Stix, Waves in Plasmas (American Inst. of Physics, 1992), Chap 6, Sec 2 + nu_m = jn_zeros(1, m+1)[-1] / sim.Lr + R2 = 0.5 * (nu_m**2 * (1.0 + kappa**2) + k**2 * (kappa**2 + 2.0)) + P4 = k**2 * (nu_m**2 + k**2) + omega_fast = sim.vA * np.sqrt(R2 + np.sqrt(R2**2 - P4)) + omega_slow = sim.vA * np.sqrt(R2 - np.sqrt(R2**2 - P4)) + # Upper right corner + ax.plot(k*sim.l_i, omega_fast/sim.w_ci, 'w--', label = f"$\omega_{{fast}}$") + ax.plot(k*sim.l_i, omega_slow/sim.w_ci, color='white', linestyle='--', label = f"$\omega_{{slow}}$") + # Thermal resonance + thermal_res = sim.w_ci + 3*sim.v_ti*k + ax.plot(k*sim.l_i, thermal_res/sim.w_ci, color='magenta', linestyle='--', label = "$\omega = \Omega_i + 3v_{th,i}k$") + ax.plot(-k*sim.l_i, thermal_res/sim.w_ci, color='magenta', linestyle='--', label = "") + thermal_res = sim.w_ci - 3*sim.v_ti*k + ax.plot(k*sim.l_i, thermal_res/sim.w_ci, color='magenta', linestyle='--', label = "$\omega = \Omega_i + 3v_{th,i}k$") + ax.plot(-k*sim.l_i, thermal_res/sim.w_ci, color='magenta', linestyle='--', label = "") + + +for ax in axes.flatten(): + ax.set_xlim(-1.75, 1.75) + ax.set_ylim(0, 1.6) + +axes[0, 0].set_ylabel('$\omega/\Omega_{ci}$') +axes[1, 0].set_ylabel('$\omega/\Omega_{ci}$') +axes[1, 0].set_xlabel('$k_zl_i$') +axes[1, 1].set_xlabel('$k_zl_i$') + +plt.savefig('normal_modes_disp.png', dpi=600) +if not sim.test: + plt.show() +else: + plt.close() + + # check if power spectrum sampling match earlier results + amps = np.abs(F_kw[2, 1, len(kz)//2-2:len(kz)//2+2]) + print("Amplitude sample: ", amps) + assert np.allclose( + amps, np.array([61.41633903, 19.39353485, 101.08693342, 11.09248295]) + ) + +if sim.test: + import os + import sys + sys.path.insert(1, '../../../../warpx/Regression/Checksum/') + import checksumAPI + + # this will be the name of the plot file + fn = sys.argv[1] + test_name = os.path.split(os.getcwd())[1] + checksumAPI.evaluate_checksum(test_name, fn, rtol=1e-6) diff --git a/Regression/Checksum/benchmarks_json/LaserInjectionFromLASYFile_RZ.json b/Regression/Checksum/benchmarks_json/LaserInjectionFromLASYFile_RZ.json index 0d7afc38099..d98aabd84e9 100644 --- a/Regression/Checksum/benchmarks_json/LaserInjectionFromLASYFile_RZ.json +++ b/Regression/Checksum/benchmarks_json/LaserInjectionFromLASYFile_RZ.json @@ -1,12 +1,12 @@ { "lev=0": { - "Br": 100278934.99628444, - "Bz": 2509040.7710191337, - "Er": 3.258814166960793, - "Et": 3.0045384450930932e+16, - "Ez": 0.24012250267165877, - "jr": 50.13336345238631, - "jt": 4.3064420556391546e+17, + "Br": 100278645.72225758, + "Bz": 2509008.1146699777, + "Er": 3.258880159474263, + "Et": 3.0045297157982412e+16, + "Ez": 0.24010979707502123, + "jr": 50.13668665903749, + "jt": 4.305139762894391e+17, "jz": 0.0 } -} \ No newline at end of file +} diff --git a/Regression/Checksum/benchmarks_json/LaserInjectionFromRZLASYFile.json b/Regression/Checksum/benchmarks_json/LaserInjectionFromRZLASYFile.json index 008080d9f5e..8d58f5c9551 100644 --- a/Regression/Checksum/benchmarks_json/LaserInjectionFromRZLASYFile.json +++ b/Regression/Checksum/benchmarks_json/LaserInjectionFromRZLASYFile.json @@ -1,12 +1,12 @@ { "lev=0": { - "Br": 193619956.9879392, - "Bz": 4691018.480978214, - "Er": 197265445300168.38, - "Et": 5.972016823892645e+16, - "Ez": 1383831581199501.0, - "jr": 18581252675.28125, - "jt": 1.194996054262225e+18, + "Br": 193609031.89343664, + "Bz": 4689634.787639907, + "Er": 197280940689075.1, + "Et": 5.9716806429474664e+16, + "Ez": 1383812184076636.0, + "jr": 18582087468.75, + "jt": 1.193738117372394e+18, "jz": 0.0 } } diff --git a/Regression/Checksum/benchmarks_json/Python_ohms_law_solver_EM_modes_rz.json b/Regression/Checksum/benchmarks_json/Python_ohms_law_solver_EM_modes_rz.json new file mode 100644 index 00000000000..870e4a82180 --- /dev/null +++ b/Regression/Checksum/benchmarks_json/Python_ohms_law_solver_EM_modes_rz.json @@ -0,0 +1,12 @@ +{ + "lev=0": {}, + "ions": { + "particle_momentum_x": 5.043873837579827e-17, + "particle_momentum_y": 5.04445113937769e-17, + "particle_momentum_z": 5.051930416996439e-17, + "particle_position_x": 143164.4268324243, + "particle_position_y": 143166.5184643828, + "particle_theta": 2573261.7450408577, + "particle_weight": 8.12868064536689e+18 + } +} diff --git a/Regression/WarpX-tests.ini b/Regression/WarpX-tests.ini index 71c510b81a3..6e0efc9ecba 100644 --- a/Regression/WarpX-tests.ini +++ b/Regression/WarpX-tests.ini @@ -3431,6 +3431,25 @@ doVis = 0 compareParticles = 1 analysisRoutine = Examples/Tests/ohm_solver_EM_modes/analysis.py +[Python_ohms_law_solver_EM_modes_rz] +buildDir = . +inputFile = Examples/Tests/ohm_solver_EM_modes/PICMI_inputs_rz.py +runtime_params = warpx.abort_on_warning_threshold = medium +customRunCmd = python3 PICMI_inputs_rz.py --test +dim = 1 +addToCompileString = USE_PYTHON_MAIN=TRUE USE_OPENPMD=TRUE QED=FALSE USE_RZ=TRUE +cmakeSetupOpts = -DWarpX_DIMS=RZ -DWarpX_APP=OFF -DWarpX_QED=OFF -DWarpX_PYTHON=ON +target = pip_install +restartTest = 0 +useMPI = 1 +numprocs = 2 +useOMP = 1 +numthreads = 1 +compileTest = 0 +doVis = 0 +compareParticles = 1 +analysisRoutine = Examples/Tests/ohm_solver_EM_modes/analysis_rz.py + [Python_ohms_law_solver_ion_beam_1d] buildDir = . inputFile = Examples/Tests/ohm_solver_ion_beam_instability/PICMI_inputs.py diff --git a/Source/BoundaryConditions/WarpX_PEC.H b/Source/BoundaryConditions/WarpX_PEC.H index 78da9349d0d..3d3e4729d45 100644 --- a/Source/BoundaryConditions/WarpX_PEC.H +++ b/Source/BoundaryConditions/WarpX_PEC.H @@ -379,7 +379,7 @@ using namespace amrex; amrex::IntVect iv_mirror = ijk_vec; iv_mirror[idim] = mirrorfac[idim][iside] - ijk_vec[idim]; - // On the PEC boundary the current density is set to 0 + // On the PEC boundary the charge/current density is set to 0 if (ijk_vec == iv_mirror) field(ijk_vec, n) = 0._rt; // otherwise update the internal cell if the mirror guard cell exists else if (fabbox.contains(iv_mirror)) @@ -389,7 +389,7 @@ using namespace amrex; } } // 2) The guard cells are updated with the appropriate image - // charge current based on the current in the valid cells + // charge based on the charge/current in the valid cells for (int idim = 0; idim < AMREX_SPACEDIM; ++idim) { for (int iside = 0; iside < 2; ++iside) diff --git a/Source/BoundaryConditions/WarpX_PEC.cpp b/Source/BoundaryConditions/WarpX_PEC.cpp index b3986da0645..0b8d1c0fcc8 100644 --- a/Source/BoundaryConditions/WarpX_PEC.cpp +++ b/Source/BoundaryConditions/WarpX_PEC.cpp @@ -266,16 +266,6 @@ PEC::ApplyPECtoRhofield (amrex::MultiFab* rho, const int lev, PatchType patch_ty } const int nComp = rho->nComp(); -#ifdef WARPX_DIM_RZ - if (is_pec[0][1]) { - ablastr::warn_manager::WMRecordWarning( - "PEC", - "PEC boundary handling is not yet properly implemented for r_max so it is skipped in PEC::ApplyPECtoRhofield", - ablastr::warn_manager::WarnPriority::medium); - is_pec[0][1] = false; - } -#endif - #ifdef AMREX_USE_OMP #pragma omp parallel if (amrex::Gpu::notInLaunchRegion()) #endif @@ -396,16 +386,6 @@ PEC::ApplyPECtoJfield(amrex::MultiFab* Jx, amrex::MultiFab* Jy, mirrorfac[2][idim][1] = 2*domain_hi[idim] - (1 - Jz_nodal[idim]); } -#ifdef WARPX_DIM_RZ - if (is_pec[0][1]) { - ablastr::warn_manager::WMRecordWarning( - "PEC", - "PEC boundary handling is not yet properly implemented for r_max so it is skipped in PEC::ApplyPECtoJfield", - ablastr::warn_manager::WarnPriority::medium); - is_pec[0][1] = false; - } -#endif - // Each current component is handled separately below, starting with Jx. #ifdef AMREX_USE_OMP #pragma omp parallel if (amrex::Gpu::notInLaunchRegion()) @@ -548,16 +528,6 @@ PEC::ApplyPECtoElectronPressure (amrex::MultiFab* Pefield, const int lev, } const int nComp = Pefield->nComp(); -#ifdef WARPX_DIM_RZ - if (is_pec[0][1]) { - ablastr::warn_manager::WMRecordWarning( - "PEC", - "PEC boundary handling is not yet properly implemented for r_max so it is skipped in PEC::ApplyPECtoPefield", - ablastr::warn_manager::WarnPriority::medium); - is_pec[0][1] = false; - } -#endif - #ifdef AMREX_USE_OMP #pragma omp parallel if (amrex::Gpu::notInLaunchRegion()) #endif diff --git a/Source/FieldSolver/FiniteDifferenceSolver/HybridPICModel/HybridPICModel.cpp b/Source/FieldSolver/FiniteDifferenceSolver/HybridPICModel/HybridPICModel.cpp index 7213e599b67..a94593ded83 100644 --- a/Source/FieldSolver/FiniteDifferenceSolver/HybridPICModel/HybridPICModel.cpp +++ b/Source/FieldSolver/FiniteDifferenceSolver/HybridPICModel/HybridPICModel.cpp @@ -86,6 +86,12 @@ void HybridPICModel::AllocateLevelMFs (int lev, const BoxArray& ba, const Distri dm, ncomps, ngJ, lev, "current_fp_ampere[y]", 0.0_rt); WarpX::AllocInitMultiFab(current_fp_ampere[lev][2], amrex::convert(ba, jz_nodal_flag), dm, ncomps, ngJ, lev, "current_fp_ampere[z]", 0.0_rt); + +#ifdef WARPX_DIM_RZ + WARPX_ALWAYS_ASSERT_WITH_MESSAGE( + (ncomps == 1), + "Ohm's law solver only support m = 0 azimuthal mode at present."); +#endif } void HybridPICModel::ClearLevel (int lev) diff --git a/Source/FieldSolver/FiniteDifferenceSolver/HybridPICSolveE.cpp b/Source/FieldSolver/FiniteDifferenceSolver/HybridPICSolveE.cpp index 38ca6c67fff..d58c2889c62 100644 --- a/Source/FieldSolver/FiniteDifferenceSolver/HybridPICSolveE.cpp +++ b/Source/FieldSolver/FiniteDifferenceSolver/HybridPICSolveE.cpp @@ -49,10 +49,10 @@ void FiniteDifferenceSolver::CalculateCurrentAmpere ( } // /** -// * \brief Calculate electron current from Ampere's law without displacement -// * current and the kinetically tracked ion currents i.e. J_e = curl B. +// * \brief Calculate total current from Ampere's law without displacement +// * current i.e. J = 1/mu_0 curl x B. // * -// * \param[out] Jfield vector of electron current MultiFabs at a given level +// * \param[out] Jfield vector of total current MultiFabs at a given level // * \param[in] Bfield vector of magnetic field MultiFabs at a given level // */ #ifdef WARPX_DIM_RZ @@ -64,11 +64,189 @@ void FiniteDifferenceSolver::CalculateCurrentAmpereCylindrical ( int lev ) { - amrex::ignore_unused(Jfield, Bfield, edge_lengths, lev); - amrex::Abort(Utils::TextMsg::Err( - "currently hybrid E-solve does not work for RZ")); + // for the profiler + amrex::LayoutData* cost = WarpX::getCosts(lev); + +#ifndef AMREX_USE_EB + amrex::ignore_unused(edge_lengths); +#endif + + // reset Jfield + Jfield[0]->setVal(0); + Jfield[1]->setVal(0); + Jfield[2]->setVal(0); + + // Loop through the grids, and over the tiles within each grid +#ifdef AMREX_USE_OMP +#pragma omp parallel if (amrex::Gpu::notInLaunchRegion()) +#endif + for ( MFIter mfi(*Jfield[0], TilingIfNotGPU()); mfi.isValid(); ++mfi ) { + if (cost && WarpX::load_balance_costs_update_algo == LoadBalanceCostsUpdateAlgo::Timers) + { + amrex::Gpu::synchronize(); + } + Real wt = static_cast(amrex::second()); + + // Extract field data for this grid/tile + Array4 const& Jr = Jfield[0]->array(mfi); + Array4 const& Jt = Jfield[1]->array(mfi); + Array4 const& Jz = Jfield[2]->array(mfi); + Array4 const& Br = Bfield[0]->array(mfi); + Array4 const& Bt = Bfield[1]->array(mfi); + Array4 const& Bz = Bfield[2]->array(mfi); + +#ifdef AMREX_USE_EB + amrex::Array4 const& lr = edge_lengths[0]->array(mfi); + amrex::Array4 const& lt = edge_lengths[1]->array(mfi); + amrex::Array4 const& lz = edge_lengths[2]->array(mfi); +#endif + + // Extract stencil coefficients + Real const * const AMREX_RESTRICT coefs_r = m_stencil_coefs_r.dataPtr(); + int const n_coefs_r = static_cast(m_stencil_coefs_r.size()); + Real const * const AMREX_RESTRICT coefs_z = m_stencil_coefs_z.dataPtr(); + int const n_coefs_z = static_cast(m_stencil_coefs_z.size()); + + // Extract cylindrical specific parameters + Real const dr = m_dr; + int const nmodes = m_nmodes; + Real const rmin = m_rmin; + + // Extract tileboxes for which to loop + Box const& tjr = mfi.tilebox(Jfield[0]->ixType().toIntVect()); + Box const& tjt = mfi.tilebox(Jfield[1]->ixType().toIntVect()); + Box const& tjz = mfi.tilebox(Jfield[2]->ixType().toIntVect()); + + Real const one_over_mu0 = 1._rt / PhysConst::mu0; + + // Calculate the total current, using Ampere's law, on the same grid + // as the E-field + amrex::ParallelFor(tjr, tjt, tjz, + + // Jr calculation + [=] AMREX_GPU_DEVICE (int i, int j, int /*k*/){ +#ifdef AMREX_USE_EB + // Skip if this cell is fully covered by embedded boundaries + if (lr(i, j, 0) <= 0) return; +#endif + // Mode m=0 + Jr(i, j, 0, 0) = one_over_mu0 * ( + - T_Algo::DownwardDz(Bt, coefs_z, n_coefs_z, i, j, 0, 0) + ); + + // Higher-order modes + // r on cell-centered point (Jr is cell-centered in r) + Real const r = rmin + (i + 0.5_rt)*dr; + for (int m=1; m 0.5_rt*dr) { + // Mode m=0 + Jt(i, j, 0, 0) = one_over_mu0 * ( + - T_Algo::DownwardDr(Bz, coefs_r, n_coefs_r, i, j, 0, 0) + + T_Algo::DownwardDz(Br, coefs_z, n_coefs_z, i, j, 0, 0) + ); + + // Higher-order modes + for (int m=1 ; m 0.5_rt*dr) { + // Mode m=0 + Jz(i, j, 0, 0) = one_over_mu0 * ( + T_Algo::DownwardDrr_over_r(Bt, r, dr, coefs_r, n_coefs_r, i, j, 0, 0) + ); + // Higher-order modes + for (int m=1 ; m(amrex::second()) - wt; + amrex::HostDevice::Atomic::Add( &(*cost)[mfi.index()], wt); + } + } } + #else + template void FiniteDifferenceSolver::CalculateCurrentAmpereCartesian ( std::array< std::unique_ptr, 3 >& Jfield, @@ -129,8 +307,8 @@ void FiniteDifferenceSolver::CalculateCurrentAmpereCartesian ( Real const one_over_mu0 = 1._rt / PhysConst::mu0; - // First calculate the total current using Ampere's law on the - // same grid as the E-field + // Calculate the total current, using Ampere's law, on the same grid + // as the E-field amrex::ParallelFor(tjx, tjy, tjz, // Jx calculation @@ -238,12 +416,255 @@ void FiniteDifferenceSolver::HybridPICSolveECylindrical ( #ifndef AMREX_USE_EB amrex::ignore_unused(edge_lengths); #endif - amrex::ignore_unused( - Efield, Jfield, Jifield, Bfield, rhofield, Pefield, edge_lengths, - lev, hybrid_model, include_resistivity_term - ); - amrex::Abort(Utils::TextMsg::Err( - "currently hybrid E-solve does not work for RZ")); + + // Both steps below do not currently support m > 0 and should be + // modified if such support wants to be added + WARPX_ALWAYS_ASSERT_WITH_MESSAGE( + (m_nmodes == 1), + "Ohm's law solver only support m = 0 azimuthal mode at present."); + + // for the profiler + amrex::LayoutData* cost = WarpX::getCosts(lev); + + using namespace ablastr::coarsen::sample; + + // get hybrid model parameters + const auto eta = hybrid_model->m_eta; + const auto rho_floor = hybrid_model->m_n_floor * PhysConst::q_e; + + // Index type required for interpolating fields from their respective + // staggering to the Ex, Ey, Ez locations + amrex::GpuArray const& Er_stag = hybrid_model->Ex_IndexType; + amrex::GpuArray const& Et_stag = hybrid_model->Ey_IndexType; + amrex::GpuArray const& Ez_stag = hybrid_model->Ez_IndexType; + amrex::GpuArray const& Jr_stag = hybrid_model->Jx_IndexType; + amrex::GpuArray const& Jt_stag = hybrid_model->Jy_IndexType; + amrex::GpuArray const& Jz_stag = hybrid_model->Jz_IndexType; + amrex::GpuArray const& Br_stag = hybrid_model->Bx_IndexType; + amrex::GpuArray const& Bt_stag = hybrid_model->By_IndexType; + amrex::GpuArray const& Bz_stag = hybrid_model->Bz_IndexType; + + // Parameters for `interp` that maps from Yee to nodal mesh and back + amrex::GpuArray const& nodal = {1, 1, 1}; + // The "coarsening is just 1 i.e. no coarsening" + amrex::GpuArray const& coarsen = {1, 1, 1}; + + // The E-field calculation is done in 2 steps: + // 1) The J x B term is calculated on a nodal mesh in order to ensure + // energy conservation. + // 2) The nodal E-field values are averaged onto the Yee grid and the + // electron pressure & resistivity terms are added (these terms are + // naturally located on the Yee grid). + + // Create a temporary multifab to hold the nodal E-field values + // Note the multifab has 3 values for Ex, Ey and Ez which we can do here + // since all three components will be calculated on the same grid. + // Also note that enE_nodal_mf does not need to have any guard cells since + // these values will be interpolated to the Yee mesh which is contained + // by the nodal mesh. + auto const& ba = convert(rhofield->boxArray(), IntVect::TheNodeVector()); + MultiFab enE_nodal_mf(ba, rhofield->DistributionMap(), 3, IntVect::TheZeroVector()); + + // Loop through the grids, and over the tiles within each grid for the + // initial, nodal calculation of E +#ifdef AMREX_USE_OMP +#pragma omp parallel if (amrex::Gpu::notInLaunchRegion()) +#endif + for ( MFIter mfi(enE_nodal_mf, TilingIfNotGPU()); mfi.isValid(); ++mfi ) { + if (cost && WarpX::load_balance_costs_update_algo == LoadBalanceCostsUpdateAlgo::Timers) + { + amrex::Gpu::synchronize(); + } + Real wt = static_cast(amrex::second()); + + Array4 const& enE_nodal = enE_nodal_mf.array(mfi); + Array4 const& Jr = Jfield[0]->const_array(mfi); + Array4 const& Jt = Jfield[1]->const_array(mfi); + Array4 const& Jz = Jfield[2]->const_array(mfi); + Array4 const& Jir = Jifield[0]->const_array(mfi); + Array4 const& Jit = Jifield[1]->const_array(mfi); + Array4 const& Jiz = Jifield[2]->const_array(mfi); + Array4 const& Br = Bfield[0]->const_array(mfi); + Array4 const& Bt = Bfield[1]->const_array(mfi); + Array4 const& Bz = Bfield[2]->const_array(mfi); + + // Loop over the cells and update the nodal E field + amrex::ParallelFor(mfi.tilebox(), [=] AMREX_GPU_DEVICE (int i, int j, int /*k*/){ + + // interpolate the total current to a nodal grid + auto const jr_interp = Interp(Jr, Jr_stag, nodal, coarsen, i, j, 0, 0); + auto const jt_interp = Interp(Jt, Jt_stag, nodal, coarsen, i, j, 0, 0); + auto const jz_interp = Interp(Jz, Jz_stag, nodal, coarsen, i, j, 0, 0); + + // interpolate the ion current to a nodal grid + auto const jir_interp = Interp(Jir, Jr_stag, nodal, coarsen, i, j, 0, 0); + auto const jit_interp = Interp(Jit, Jt_stag, nodal, coarsen, i, j, 0, 0); + auto const jiz_interp = Interp(Jiz, Jz_stag, nodal, coarsen, i, j, 0, 0); + + // interpolate the B field to a nodal grid + auto const Br_interp = Interp(Br, Br_stag, nodal, coarsen, i, j, 0, 0); + auto const Bt_interp = Interp(Bt, Bt_stag, nodal, coarsen, i, j, 0, 0); + auto const Bz_interp = Interp(Bz, Bz_stag, nodal, coarsen, i, j, 0, 0); + + // calculate enE = (J - Ji) x B + enE_nodal(i, j, 0, 0) = ( + (jt_interp - jit_interp) * Bz_interp + - (jz_interp - jiz_interp) * Bt_interp + ); + enE_nodal(i, j, 0, 1) = ( + (jz_interp - jiz_interp) * Br_interp + - (jr_interp - jir_interp) * Bz_interp + ); + enE_nodal(i, j, 0, 2) = ( + (jr_interp - jir_interp) * Bt_interp + - (jt_interp - jit_interp) * Br_interp + ); + }); + + if (cost && WarpX::load_balance_costs_update_algo == LoadBalanceCostsUpdateAlgo::Timers) + { + amrex::Gpu::synchronize(); + wt = static_cast(amrex::second()) - wt; + amrex::HostDevice::Atomic::Add( &(*cost)[mfi.index()], wt); + } + } + + // Loop through the grids, and over the tiles within each grid again + // for the Yee grid calculation of the E field +#ifdef AMREX_USE_OMP +#pragma omp parallel if (amrex::Gpu::notInLaunchRegion()) +#endif + for ( MFIter mfi(*Efield[0], TilingIfNotGPU()); mfi.isValid(); ++mfi ) { + if (cost && WarpX::load_balance_costs_update_algo == LoadBalanceCostsUpdateAlgo::Timers) + { + amrex::Gpu::synchronize(); + } + Real wt = static_cast(amrex::second()); + + // Extract field data for this grid/tile + Array4 const& Er = Efield[0]->array(mfi); + Array4 const& Et = Efield[1]->array(mfi); + Array4 const& Ez = Efield[2]->array(mfi); + Array4 const& Jr = Jfield[0]->const_array(mfi); + Array4 const& Jt = Jfield[1]->const_array(mfi); + Array4 const& Jz = Jfield[2]->const_array(mfi); + Array4 const& enE = enE_nodal_mf.const_array(mfi); + Array4 const& rho = rhofield->const_array(mfi); + Array4 const& Pe = Pefield->array(mfi); + +#ifdef AMREX_USE_EB + amrex::Array4 const& lr = edge_lengths[0]->array(mfi); + amrex::Array4 const& lt = edge_lengths[1]->array(mfi); + amrex::Array4 const& lz = edge_lengths[2]->array(mfi); +#endif + + // Extract stencil coefficients + Real const * const AMREX_RESTRICT coefs_r = m_stencil_coefs_r.dataPtr(); + int const n_coefs_r = static_cast(m_stencil_coefs_r.size()); + Real const * const AMREX_RESTRICT coefs_z = m_stencil_coefs_z.dataPtr(); + int const n_coefs_z = static_cast(m_stencil_coefs_z.size()); + + // Extract cylindrical specific parameters + Real const dr = m_dr; + Real const rmin = m_rmin; + + Box const& ter = mfi.tilebox(Efield[0]->ixType().toIntVect()); + Box const& tet = mfi.tilebox(Efield[1]->ixType().toIntVect()); + Box const& tez = mfi.tilebox(Efield[2]->ixType().toIntVect()); + + // Loop over the cells and update the E field + amrex::ParallelFor(ter, tet, tez, + + // Er calculation + [=] AMREX_GPU_DEVICE (int i, int j, int /*k*/){ +#ifdef AMREX_USE_EB + // Skip if this cell is fully covered by embedded boundaries + if (lr(i, j, 0) <= 0) return; +#endif + // Interpolate to get the appropriate charge density in space + Real rho_val = Interp(rho, nodal, Er_stag, coarsen, i, j, 0, 0); + + // safety condition since we divide by rho_val later + if (rho_val < rho_floor) rho_val = rho_floor; + + // Get the gradient of the electron pressure + auto grad_Pe = T_Algo::UpwardDr(Pe, coefs_r, n_coefs_r, i, j, 0, 0); + + // interpolate the nodal neE values to the Yee grid + auto enE_r = Interp(enE, nodal, Er_stag, coarsen, i, j, 0, 0); + + Er(i, j, 0) = (enE_r - grad_Pe) / rho_val; + + // Add resistivity only if E field value is used to update B + if (include_resistivity_term) Er(i, j, 0) += eta(rho_val) * Jr(i, j, 0); + }, + + // Et calculation + [=] AMREX_GPU_DEVICE (int i, int j, int /*k*/){ +#ifdef AMREX_USE_EB + // In RZ Et is associated with a mesh node, so we need to check if the mesh node is covered + amrex::ignore_unused(lt); + if (lr(i, j, 0)<=0 || lr(i-1, j, 0)<=0 || lz(i, j-1, 0)<=0 || lz(i, j, 0)<=0) return; +#endif + // r on a nodal grid (Et is nodal in r) + Real const r = rmin + i*dr; + // Mode m=0: // Ensure that Et remains 0 on axis + if (r < 0.5_rt*dr) { + Et(i, j, 0, 0) = 0.; + return; + } + + // Interpolate to get the appropriate charge density in space + Real rho_val = Interp(rho, nodal, Er_stag, coarsen, i, j, 0, 0); + + // safety condition since we divide by rho_val later + if (rho_val < rho_floor) rho_val = rho_floor; + + // Get the gradient of the electron pressure + // -> d/dt = 0 for m = 0 + auto grad_Pe = 0.0_rt; + + // interpolate the nodal neE values to the Yee grid + auto enE_t = Interp(enE, nodal, Et_stag, coarsen, i, j, 0, 1); + + Et(i, j, 0) = (enE_t - grad_Pe) / rho_val; + + // Add resistivity only if E field value is used to update B + if (include_resistivity_term) Et(i, j, 0) += eta(rho_val) * Jt(i, j, 0); + }, + + // Ez calculation + [=] AMREX_GPU_DEVICE (int i, int j, int k){ +#ifdef AMREX_USE_EB + // Skip field solve if this cell is fully covered by embedded boundaries + if (lz(i,j,0) <= 0) return; +#endif + // Interpolate to get the appropriate charge density in space + Real rho_val = Interp(rho, nodal, Ez_stag, coarsen, i, j, k, 0); + + // safety condition since we divide by rho_val later + if (rho_val < rho_floor) rho_val = rho_floor; + + // Get the gradient of the electron pressure + auto grad_Pe = T_Algo::UpwardDz(Pe, coefs_z, n_coefs_z, i, j, k, 0); + + // interpolate the nodal neE values to the Yee grid + auto enE_z = Interp(enE, nodal, Ez_stag, coarsen, i, j, k, 2); + + Ez(i, j, k) = (enE_z - grad_Pe) / rho_val; + + // Add resistivity only if E field value is used to update B + if (include_resistivity_term) Ez(i, j, k) += eta(rho_val) * Jz(i, j, k); + } + ); + + if (cost && WarpX::load_balance_costs_update_algo == LoadBalanceCostsUpdateAlgo::Timers) + { + amrex::Gpu::synchronize(); + wt = static_cast(amrex::second()) - wt; + amrex::HostDevice::Atomic::Add( &(*cost)[mfi.index()], wt); + } + } } #else @@ -470,7 +891,6 @@ void FiniteDifferenceSolver::HybridPICSolveECartesian ( // Ez calculation [=] AMREX_GPU_DEVICE (int i, int j, int k){ - #ifdef AMREX_USE_EB // Skip field solve if this cell is fully covered by embedded boundaries if (lz(i,j,k) <= 0) return; diff --git a/Source/Initialization/WarpXInitData.cpp b/Source/Initialization/WarpXInitData.cpp index 4e82ed0dfb5..e16e97dda17 100644 --- a/Source/Initialization/WarpXInitData.cpp +++ b/Source/Initialization/WarpXInitData.cpp @@ -803,28 +803,35 @@ WarpX::InitLevelData (int lev, Real /*time*/) // provided in the input file. if (B_ext_grid_s == "parse_b_ext_grid_function") { -#ifdef WARPX_DIM_RZ - WARPX_ABORT_WITH_MESSAGE( - "E and B parser for external fields does not work with RZ -- TO DO"); -#endif - - //! Strings storing parser function to initialize the components of the magnetic field on the grid - std::string str_Bx_ext_grid_function; - std::string str_By_ext_grid_function; - std::string str_Bz_ext_grid_function; + //! Strings storing parser function to initialize the components of the magnetic field on the grid + std::string str_Bx_ext_grid_function; + std::string str_By_ext_grid_function; + std::string str_Bz_ext_grid_function; +#ifdef WARPX_DIM_RZ + std::stringstream warnMsg; + warnMsg << "Parser for external B (r and theta) fields does not work with RZ\n" + << "The initial Br and Bt fields are currently hardcoded to 0.\n" + << "The initial Bz field should only be a function of z.\n"; + ablastr::warn_manager::WMRecordWarning( + "Inputs", warnMsg.str(), ablastr::warn_manager::WarnPriority::high); + str_Bx_ext_grid_function = "0"; + str_By_ext_grid_function = "0"; +#else utils::parser::Store_parserString(pp_warpx, "Bx_external_grid_function(x,y,z)", str_Bx_ext_grid_function); utils::parser::Store_parserString(pp_warpx, "By_external_grid_function(x,y,z)", str_By_ext_grid_function); - utils::parser::Store_parserString(pp_warpx, "Bz_external_grid_function(x,y,z)", - str_Bz_ext_grid_function); - Bxfield_parser = std::make_unique( - utils::parser::makeParser(str_Bx_ext_grid_function,{"x","y","z"})); - Byfield_parser = std::make_unique( - utils::parser::makeParser(str_By_ext_grid_function,{"x","y","z"})); - Bzfield_parser = std::make_unique( - utils::parser::makeParser(str_Bz_ext_grid_function,{"x","y","z"})); +#endif + utils::parser::Store_parserString(pp_warpx, "Bz_external_grid_function(x,y,z)", + str_Bz_ext_grid_function); + + Bxfield_parser = std::make_unique( + utils::parser::makeParser(str_Bx_ext_grid_function,{"x","y","z"})); + Byfield_parser = std::make_unique( + utils::parser::makeParser(str_By_ext_grid_function,{"x","y","z"})); + Bzfield_parser = std::make_unique( + utils::parser::makeParser(str_Bz_ext_grid_function,{"x","y","z"})); // Initialize Bfield_fp with external function InitializeExternalFieldsOnGridUsingParser(Bfield_fp[lev][0].get(), From 985992b6b0c68be024aa472910029d23fe0f67f6 Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Tue, 17 Oct 2023 21:40:04 -0700 Subject: [PATCH 13/25] Python: Rename Callback Files (#4381) Renamed after thinning out everything else. --- Source/Evolve/WarpXEvolve.cpp | 2 +- Source/FieldSolver/ElectrostaticSolver.cpp | 2 +- .../MagnetostaticSolver/MagnetostaticSolver.cpp | 2 +- Source/Initialization/WarpXInitData.cpp | 2 +- Source/Python/CMakeLists.txt | 2 +- Source/Python/Make.package | 2 +- Source/Python/{WarpX_py.H => callbacks.H} | 8 ++++---- Source/Python/{WarpX_py.cpp => callbacks.cpp} | 4 ++-- Source/Python/pyWarpX.cpp | 2 +- 9 files changed, 13 insertions(+), 13 deletions(-) rename Source/Python/{WarpX_py.H => callbacks.H} (91%) rename Source/Python/{WarpX_py.cpp => callbacks.cpp} (97%) diff --git a/Source/Evolve/WarpXEvolve.cpp b/Source/Evolve/WarpXEvolve.cpp index d5f01300b06..1515a1b3ff0 100644 --- a/Source/Evolve/WarpXEvolve.cpp +++ b/Source/Evolve/WarpXEvolve.cpp @@ -27,7 +27,7 @@ #include "Fluids/MultiFluidContainer.H" #include "Fluids/WarpXFluidContainer.H" #include "Particles/ParticleBoundaryBuffer.H" -#include "Python/WarpX_py.H" +#include "Python/callbacks.H" #include "Utils/TextMsg.H" #include "Utils/WarpXAlgorithmSelection.H" #include "Utils/WarpXUtil.H" diff --git a/Source/FieldSolver/ElectrostaticSolver.cpp b/Source/FieldSolver/ElectrostaticSolver.cpp index 216e80f7494..73dac03508b 100644 --- a/Source/FieldSolver/ElectrostaticSolver.cpp +++ b/Source/FieldSolver/ElectrostaticSolver.cpp @@ -12,7 +12,7 @@ #include "Parallelization/GuardCellManager.H" #include "Particles/MultiParticleContainer.H" #include "Particles/WarpXParticleContainer.H" -#include "Python/WarpX_py.H" +#include "Python/callbacks.H" #include "Utils/Parser/ParserUtils.H" #include "Utils/WarpXAlgorithmSelection.H" #include "Utils/WarpXConst.H" diff --git a/Source/FieldSolver/MagnetostaticSolver/MagnetostaticSolver.cpp b/Source/FieldSolver/MagnetostaticSolver/MagnetostaticSolver.cpp index 7e9c3e83969..6b77a559b8c 100644 --- a/Source/FieldSolver/MagnetostaticSolver/MagnetostaticSolver.cpp +++ b/Source/FieldSolver/MagnetostaticSolver/MagnetostaticSolver.cpp @@ -10,7 +10,7 @@ #include "Parallelization/GuardCellManager.H" #include "Particles/MultiParticleContainer.H" #include "Particles/WarpXParticleContainer.H" -#include "Python/WarpX_py.H" +#include "Python/callbacks.H" #include "Utils/WarpXAlgorithmSelection.H" #include "Utils/WarpXConst.H" #include "Utils/TextMsg.H" diff --git a/Source/Initialization/WarpXInitData.cpp b/Source/Initialization/WarpXInitData.cpp index e16e97dda17..fbf173992c2 100644 --- a/Source/Initialization/WarpXInitData.cpp +++ b/Source/Initialization/WarpXInitData.cpp @@ -29,7 +29,7 @@ #include "Utils/WarpXConst.H" #include "Utils/WarpXProfilerWrapper.H" #include "Utils/WarpXUtil.H" -#include "Python/WarpX_py.H" +#include "Python/callbacks.H" #include #include diff --git a/Source/Python/CMakeLists.txt b/Source/Python/CMakeLists.txt index d976e3d2c05..17a75301306 100644 --- a/Source/Python/CMakeLists.txt +++ b/Source/Python/CMakeLists.txt @@ -7,7 +7,7 @@ foreach(D IN LISTS WarpX_DIMS) target_sources(lib_${SD} PRIVATE # callback hooks - WarpX_py.cpp + callbacks.cpp ) if(WarpX_PYTHON) target_sources(pyWarpX_${SD} diff --git a/Source/Python/Make.package b/Source/Python/Make.package index f107fbbfaaa..bf7121e3c77 100644 --- a/Source/Python/Make.package +++ b/Source/Python/Make.package @@ -1,3 +1,3 @@ -CEXE_sources += WarpX_py.cpp +CEXE_sources += callbacks.cpp VPATH_LOCATIONS += $(WARPX_HOME)/Source/Python diff --git a/Source/Python/WarpX_py.H b/Source/Python/callbacks.H similarity index 91% rename from Source/Python/WarpX_py.H rename to Source/Python/callbacks.H index 590f26a804b..f0c98caf636 100644 --- a/Source/Python/WarpX_py.H +++ b/Source/Python/callbacks.H @@ -2,12 +2,12 @@ * * This file is part of WarpX. * - * Authors: David Grote, Maxence Thevenet, Weiqun Zhang, Roelof Groenewald + * Authors: David Grote, Maxence Thevenet, Weiqun Zhang, Roelof Groenewald, Axel Huebl * * License: BSD-3-Clause-LBNL */ -#ifndef WARPX_PY_H_ -#define WARPX_PY_H_ +#ifndef WARPX_PY_CALLBACKS_H_ +#define WARPX_PY_CALLBACKS_H_ #include "Utils/export.H" #include "Utils/WarpXProfilerWrapper.H" @@ -46,4 +46,4 @@ void ExecutePythonCallback ( std::string name ); */ void ClearPythonCallback ( std::string name ); -#endif +#endif // WARPX_PY_CALLBACKS_H_ diff --git a/Source/Python/WarpX_py.cpp b/Source/Python/callbacks.cpp similarity index 97% rename from Source/Python/WarpX_py.cpp rename to Source/Python/callbacks.cpp index afc734d780e..930c88e65d1 100644 --- a/Source/Python/WarpX_py.cpp +++ b/Source/Python/callbacks.cpp @@ -2,11 +2,11 @@ * * This file is part of WarpX. * - * Authors: David Grote, Maxence Thevenet, Weiqun Zhang, Roelof Groenewald + * Authors: David Grote, Maxence Thevenet, Weiqun Zhang, Roelof Groenewald, Axel Huebl * * License: BSD-3-Clause-LBNL */ -#include "WarpX_py.H" +#include "callbacks.H" #include #include diff --git a/Source/Python/pyWarpX.cpp b/Source/Python/pyWarpX.cpp index 64db77153bd..26f4c77502d 100644 --- a/Source/Python/pyWarpX.cpp +++ b/Source/Python/pyWarpX.cpp @@ -4,7 +4,7 @@ * License: BSD-3-Clause-LBNL */ #include "pyWarpX.H" -#include "WarpX_py.H" +#include "callbacks.H" #include // todo: move this out to Python/WarpX.cpp #include // todo: move to its own Python/Utils.cpp From 8459109a725bc50cfe7df02616e2119bba2cd1c5 Mon Sep 17 00:00:00 2001 From: Marta Galbiati <47305118+MartaGalbi@users.noreply.github.com> Date: Thu, 19 Oct 2023 05:57:57 +0200 Subject: [PATCH 14/25] add instructions for leonardo hpc (#4353) * add instructions for leonardo hpc * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix wrong name for build directory in leonardo.rst * Update Tools/machines/leonardo-cineca/install_gpu_dependencies.sh add copyright and license notice Co-authored-by: Luca Fedeli * fix formatting in Docs/source/install/hpc/leonardo.rst add space Co-authored-by: Axel Huebl * Fix formatting in Docs/source/install/hpc/leonardo.rst Add equals Co-authored-by: Axel Huebl * Fix formatting in Docs/source/install/hpc/leonardo.rst change quotation marks Co-authored-by: Axel Huebl * Fix formatting in Docs/source/install/hpc/leonardo.rst Co-authored-by: Axel Huebl * add separate instructions to install WarpX as a Python module Co-authored-by: Axel Huebl * add cleaning of both standard and python builds Co-authored-by: Axel Huebl * removed source of profile file in job.sh --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Luca Fedeli Co-authored-by: Axel Huebl --- Docs/source/install/hpc.rst | 1 + Docs/source/install/hpc/leonardo.rst | 172 ++++++++++++++++++ .../install_gpu_dependencies.sh | 103 +++++++++++ Tools/machines/leonardo-cineca/job.sh | 20 ++ .../leonardo_gpu_warpx.profile.example | 43 +++++ 5 files changed, 339 insertions(+) create mode 100644 Docs/source/install/hpc/leonardo.rst create mode 100644 Tools/machines/leonardo-cineca/install_gpu_dependencies.sh create mode 100644 Tools/machines/leonardo-cineca/job.sh create mode 100644 Tools/machines/leonardo-cineca/leonardo_gpu_warpx.profile.example diff --git a/Docs/source/install/hpc.rst b/Docs/source/install/hpc.rst index 67468cc2f02..d6e901276d7 100644 --- a/Docs/source/install/hpc.rst +++ b/Docs/source/install/hpc.rst @@ -42,6 +42,7 @@ This section documents quick-start guides for a selection of supercomputers that hpc/karolina hpc/lassen hpc/lawrencium + hpc/leonardo hpc/lumi hpc/lxplus hpc/ookami diff --git a/Docs/source/install/hpc/leonardo.rst b/Docs/source/install/hpc/leonardo.rst new file mode 100644 index 00000000000..3de7f4755cb --- /dev/null +++ b/Docs/source/install/hpc/leonardo.rst @@ -0,0 +1,172 @@ +.. _building-leonardo: + +Leonardo (CINECA) +================= + +The `Leonardo cluster `_ is hosted at `CINECA `_. + +On Leonardo, each one of the 3456 compute nodes features a custom Atos Bull Sequana XH21355 "Da Vinci" blade, composed of: + +* 1 x CPU Intel Ice Lake Xeon 8358 32 cores 2.60 GHz +* 512 (8 x 64) GB RAM DDR4 3200 MHz +* 4 x NVidia custom Ampere A100 GPU 64GB HBM2 +* 2 x NVidia HDR 2×100 GB/s cards + +Introduction +------------ + +If you are new to this system, **please see the following resources**: + +* `Leonardo website `_ +* `Leonardo user guide `_ + +Storage organization: + +* ``$HOME``: permanent, backed up, user specific (50 GB quota) +* ``$CINECA_SCRATCH``: temporary, user specific, no backup, a large disk for the storage of run time data and files, automatic cleaning procedure of data older than 40 days +* ``$PUBLIC``: permanent, no backup (50 GB quota) +* ``$WORK``: permanent, project specific, no backup + +.. _building-leonardo-preparation: + +Preparation +----------- + +Use the following commands to download the WarpX source code: + +.. code-block:: bash + + git clone https://github.com/ECP-WarpX/WarpX.git $HOME/src/warpx + +We use system software modules, add environment hints and further dependencies via the file ``$HOME/leonardo_gpu_warpx.profile``. +Create it now: + +.. code-block:: bash + + cp $HOME/src/warpx/Tools/machines/leonardo-cineca/leonardo_gpu_warpx.profile.example $HOME/leonardo_gpu_warpx.profile + +.. dropdown:: Script Details + :color: light + :icon: info + :animate: fade-in-slide-down + + .. literalinclude:: ../../../../Tools/machines/leonardo-cineca/leonardo_gpu_warpx.profile.example + :language: bash + +.. important:: + + Now, and as the first step on future logins to Leonardo, activate these environment settings: + + .. code-block:: bash + + source $HOME/leonardo_gpu_warpx.profile + +Finally, since Leonardo does not yet provide software modules for some of our dependencies, install them once: + +.. code-block:: bash + + bash $HOME/src/warpx/Tools/machines/leonardo_cineca/install_gpu_dependencies.sh + source $HOME/sw/venvs/warpx/bin/activate + +.. dropdown:: Script Details + :color: light + :icon: info + :animate: fade-in-slide-down + + .. literalinclude:: ../../../../Tools/machines/leonardo-cineca/install_gpu_dependencies.sh + :language: bash + + +.. _building-leonardo-compilation: + +Compilation +----------- + +Use the following :ref:`cmake commands ` to compile the application executable: + +.. code-block:: bash + + cd $HOME/src/warpx + rm -rf build_gpu + + cmake -S . -B build_gpu -DWarpX_COMPUTE=CUDA -DWarpX_PSATD=ON -DWarpX_QED_TABLE_GEN=ON -DWarpX_DIMS="1;2;RZ;3" + cmake --build build_gpu -j 16 + +The WarpX application executables are now in ``$HOME/src/warpx/build_gpu/bin/``. +Additionally, the following commands will install WarpX as a Python module: + +.. code-block:: bash + + cd $HOME/src/warpx + rm -rf build_gpu_py + + cmake -S . -B build_gpu_py -DWarpX_COMPUTE=CUDA -DWarpX_PSATD=ON -DWarpX_QED_TABLE_GEN=ON -DWarpX_PYTHON=ON -DWarpX_APP=OFF -DWarpX_DIMS="1;2;RZ;3" + cmake --build build_gpu_py -j 16 --target pip_install + +Now, you can :ref:`submit Leonardo compute jobs ` for WarpX :ref:`Python (PICMI) scripts ` (:ref:`example scripts `). +Or, you can use the WarpX executables to submit Leonardo jobs (:ref:`example inputs `). +For executables, you can reference their location in your :ref:`job script ` or copy them to a location in ``$CINECA_SCRATCH``. + +.. _building-leonardo-update: + +Update WarpX & Dependencies +--------------------------- + +If you already installed WarpX in the past and want to update it, start by getting the latest source code: + +.. code-block:: bash + + cd $HOME/src/warpx + + # read the output of this command - does it look ok? + git status + + # get the latest WarpX source code + git fetch + git pull + + # read the output of these commands - do they look ok? + git status + git log # press q to exit + +And, if needed, + +- :ref:`update the leonardo_gpu_warpx.profile file `, +- log out and into the system, activate the now updated environment profile as usual, +- :ref:`execute the dependency install scripts `. + +As a last step, clean the build directories ``rm -rf $HOME/src/warpx/build_gpu*`` and rebuild WarpX. + + +.. _running-leonardo: + +Running +------- +The batch script below can be used to run a WarpX simulation on multiple nodes on Leonardo. +Replace descriptions between chevrons ``<>`` by relevant values. +Note that we run one MPI rank per GPU. + +.. literalinclude:: ../../../../Tools/machines/leonardo-cineca/job.sh + :language: bash + :caption: You can copy this file from ``$HOME/src/warpx/Tools/machines/leonardo-cineca/job.sh``. + +To run a simulation, copy the lines above to a file ``job.sh`` and run + +.. code-block:: bash + + sbatch job.sh + +to submit the job. + +.. _post-processing-leonardo: + +Post-Processing +--------------- + +For post-processing, activate the environment settings: + +.. code-block:: bash + + source $HOME/leonardo_gpu_warpx.profile + +and run python scripts. diff --git a/Tools/machines/leonardo-cineca/install_gpu_dependencies.sh b/Tools/machines/leonardo-cineca/install_gpu_dependencies.sh new file mode 100644 index 00000000000..5b6453b3968 --- /dev/null +++ b/Tools/machines/leonardo-cineca/install_gpu_dependencies.sh @@ -0,0 +1,103 @@ +#!/bin/bash +# +# Copyright 2023 The WarpX Community +# +# This file is part of WarpX. +# +# Author: Axel Huebl, Marta Galbiati +# License: BSD-3-Clause-LBNL + +set -eu -o pipefail + + +# Check: ###################################################################### +# +# Was leonardo_gpu_warpx.profile sourced and configured correctly? +# + + +# Remove old dependencies ##################################################### +# +SW_DIR="$HOME/sw" +rm -rf ${SW_DIR} +mkdir -p ${SW_DIR} + + +# General extra dependencies ################################################## +# + +# ADIOS2 +if [ -d $HOME/src/adios2 ] +then + cd $HOME/src/adios2 + git fetch + git checkout master + git pull + cd - +else + git clone https://github.com/ornladios/ADIOS2.git $HOME/src/adios2 +fi +rm -rf $HOME/src/adios2-gpu-build +cmake -S $HOME/src/adios2 -B $HOME/src/adios2-gpu-build -DADIOS2_USE_Blosc=ON -DADIOS2_USE_Fortran=OFF -DADIOS2_USE_Python=OFF -DADIOS2_USE_ZeroMQ=OFF -DCMAKE_INSTALL_PREFIX=${SW_DIR}/adios2-master +cmake --build $HOME/src/adios2-gpu-build --target install -j 16 +rm -rf $HOME/src/adios2-gpu-build + + +# BLAS++ (for PSATD+RZ) +if [ -d $HOME/src/blaspp ] +then + cd $HOME/src/blaspp + git fetch + git checkout master + git pull + cd - +else + git clone https://github.com/icl-utk-edu/blaspp.git $HOME/src/blaspp +fi +rm -rf $HOME/src/blaspp-gpu-build +CXX=$(which g++) cmake -S $HOME/src/blaspp -B $HOME/src/blaspp-gpu-build -Duse_openmp=OFF -Dgpu_backend=cuda -DCMAKE_CXX_STANDARD=17 -DCMAKE_INSTALL_PREFIX=${SW_DIR}/blaspp-master +cmake --build $HOME/src/blaspp-gpu-build --target install --parallel 16 +rm -rf $HOME/src/blaspp-gpu-build + + +# LAPACK++ (for PSATD+RZ) +if [ -d $HOME/src/lapackpp ] +then + cd $HOME/src/lapackpp + git fetch + git checkout master + git pull + cd - +else + git clone https://github.com/icl-utk-edu/lapackpp.git $HOME/src/lapackpp +fi +rm -rf $HOME/src/lapackpp-gpu-build +CXX=$(which CC) CXXFLAGS="-DLAPACK_FORTRAN_ADD_" cmake -S $HOME/src/lapackpp -B $HOME/src/lapackpp-gpu-build -DCMAKE_CXX_STANDARD=17 -Dbuild_tests=OFF -DCMAKE_INSTALL_RPATH_USE_LINK_PATH=ON -DCMAKE_INSTALL_PREFIX=${SW_DIR}/lapackpp-master +cmake --build $HOME/src/lapackpp-gpu-build --target install --parallel 16 +rm -rf $HOME/src/lapackpp-gpu-build + + +# Python ###################################################################### +# +rm -rf ${SW_DIR}/venvs/warpx +python3 -m venv ${SW_DIR}/venvs/warpx +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 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="gcc -shared" python3 -m pip install --upgrade mpi4py --no-cache-dir --no-build-isolation --no-binary mpi4py +python3 -m pip install --upgrade openpmd-api +python3 -m pip install --upgrade matplotlib +python3 -m pip install --upgrade yt +# install or update WarpX dependencies such as picmistandard +python3 -m pip install --upgrade -r $HOME/src/warpx/requirements.txt +# optional: for libEnsemble +python3 -m pip install -r $HOME/src/warpx/Tools/LibEnsemble/requirements.txt +# optional: for optimas (based on libEnsemble & ax->botorch->gpytorch->pytorch) +python3 -m pip install --upgrade torch # CUDA 11.8 compatible wheel +python3 -m pip install -r $HOME/src/warpx/Tools/optimas/requirements.txt diff --git a/Tools/machines/leonardo-cineca/job.sh b/Tools/machines/leonardo-cineca/job.sh new file mode 100644 index 00000000000..a50c6e1995f --- /dev/null +++ b/Tools/machines/leonardo-cineca/job.sh @@ -0,0 +1,20 @@ +#!/usr/bin/bash +#SBATCH --time=02:00:00 +#SBATCH --nodes=2 +#SBATCH --ntasks-per-node=4 +#SBATCH --ntasks-per-socket=4 +#SBATCH --cpus-per-task=8 +#SBATCH --gpus-per-node=4 +#SBATCH --gpus-per-task=1 +#SBATCH --mem=494000 +#SBATCH --partition=boost_usr_prod +#SBATCH --job-name= +#SBATCH --gres=gpu:4 +#SBATCH --err=job.err +#SBATCH --out=job.out +#SBATCH --account= +#SBATCH --mail-type=ALL +#SBATCH --mail-user= + +cd /leonardo_scratch/large/userexternal// +srun /leonardo/home/userexternal//src/warpx/build_gpu/bin/warpx.2d > output.txt diff --git a/Tools/machines/leonardo-cineca/leonardo_gpu_warpx.profile.example b/Tools/machines/leonardo-cineca/leonardo_gpu_warpx.profile.example new file mode 100644 index 00000000000..af0cdbd41c3 --- /dev/null +++ b/Tools/machines/leonardo-cineca/leonardo_gpu_warpx.profile.example @@ -0,0 +1,43 @@ +# required dependencies +module load profile/base +module load cmake/3.24.3 +module load gmp/6.2.1 +module load mpfr/4.1.0 +module load mpc/1.2.1 +module load gcc/11.3.0 +module load cuda/11.8 +module load zlib/1.2.13--gcc--11.3.0 +module load openmpi/4.1.4--gcc--11.3.0-cuda-11.8 + +# optional: for QED support with detailed tables +module load boost/1.80.0--openmpi--4.1.4--gcc--11.3.0 + +# optional: for openPMD and PSATD+RZ support +module load openblas/0.3.21--gcc--11.3.0 +export CMAKE_PREFIX_PATH=/leonardo/prod/spack/03/install/0.19/linux-rhel8-icelake/gcc-11.3.0/c-blosc-1.21.1-aifmix6v5lwxgt7rigwoebalrgbcnv26:$CMAKE_PREFIX_PATH +export CMAKE_PREFIX_PATH=$HOME/sw/adios2-master:$CMAKE_PREFIX_PATH +export CMAKE_PREFIX_PATH=$HOME/sw/blaspp-master:$CMAKE_PREFIX_PATH +export CMAKE_PREFIX_PATH=$HOME/sw/lapackpp-master:$CMAKE_PREFIX_PATH + +export LD_LIBRARY_PATH=/leonardo/prod/spack/03/install/0.19/linux-rhel8-icelake/gcc-11.3.0/c-blosc-1.21.1-aifmix6v5lwxgt7rigwoebalrgbcnv26/lib64:$LD_LIBRARY_PATH +export LD_LIBRARY_PATH=$HOME/sw/adios2-master/lib64:$LD_LIBRARY_PATH +export LD_LIBRARY_PATH=$HOME/sw/blaspp-master/lib64:$LD_LIBRARY_PATH +export LD_LIBRARY_PATH=$HOME/sw/lapackpp-master/lib64:$LD_LIBRARY_PATH + +# optional: for Python bindings or libEnsemble +module load python/3.10.8--gcc--11.3.0 + +if [ -d "$HOME/sw/venvs/warpx" ] +then + source $HOME/sw/venvs/warpx/bin/activate +fi + +# optimize CUDA compilation for A100 +export AMREX_CUDA_ARCH=8.0 + +# compiler environment hints +export CXX=$(which g++) +export CC=$(which gcc) +export FC=$(which gfortran) +export CUDACXX=$(which nvcc) +export CUDAHOSTCXX=${CXX} From c5628f8ea456b923c718fcc4e0848f2bc6fa76a0 Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Fri, 20 Oct 2023 17:54:43 -0700 Subject: [PATCH 15/25] GetAndSetPosition: General Particle PIdx (#4386) * GetAndSetPosition: General Particle PIdx Generalize the `SetParticlePosition` & `GetParticlePosition` classes to work with arbitrary particle index enumerators. That way, we can reuse them between different particle containers. * FieldProbe: Remove Hack * GetAndSetPosition: Usage w/ Template --- .../AcceleratorLattice/LatticeElementFinder.H | 2 +- .../LatticeElementFinder.cpp | 2 +- .../BackTransformParticleFunctor.H | 4 ++-- .../BackTransformParticleFunctor.cpp | 4 ++-- .../ReducedDiags/ColliderRelevant.cpp | 2 +- Source/Diagnostics/ReducedDiags/FieldProbe.cpp | 4 ++-- .../ReducedDiags/FieldProbeParticleContainer.H | 8 ++------ .../ReducedDiags/ParticleExtrema.cpp | 2 +- .../ReducedDiags/ParticleHistogram.cpp | 2 +- .../ReducedDiags/ParticleHistogram2D.cpp | 2 +- Source/EmbeddedBoundary/ParticleScraper.H | 2 +- .../BackgroundMCC/BackgroundMCCCollision.cpp | 2 +- .../BackgroundStopping/BackgroundStopping.cpp | 4 ++-- .../BinaryCollision/BinaryCollision.H | 10 +++++----- .../Coulomb/PairWiseCoulombCollisionFunc.H | 2 +- .../NuclearFusion/NuclearFusionFunc.H | 2 +- Source/Particles/Deposition/ChargeDeposition.H | 4 ++-- .../Particles/Deposition/CurrentDeposition.H | 8 ++++---- .../Deposition/SharedDepositionUtils.H | 2 +- .../Particles/ElementaryProcess/Ionization.H | 2 +- .../Particles/ElementaryProcess/Ionization.cpp | 2 +- .../ElementaryProcess/QEDPairGeneration.H | 2 +- .../ElementaryProcess/QEDPairGeneration.cpp | 2 +- .../ElementaryProcess/QEDPhotonEmission.H | 2 +- .../ElementaryProcess/QEDPhotonEmission.cpp | 2 +- Source/Particles/Gather/FieldGather.H | 2 +- Source/Particles/Gather/GetExternalFields.H | 2 +- Source/Particles/Gather/GetExternalFields.cpp | 2 +- Source/Particles/LaserParticleContainer.cpp | 6 +++--- Source/Particles/ParticleBoundaryBuffer.cpp | 2 +- Source/Particles/PhotonParticleContainer.cpp | 4 ++-- Source/Particles/PhysicalParticleContainer.cpp | 10 +++++----- Source/Particles/Pusher/CopyParticleAttribs.H | 4 ++-- Source/Particles/Pusher/GetAndSetPosition.H | 18 ++++++++++++++---- Source/Particles/Pusher/PushSelector.H | 4 ++-- .../RigidInjectedParticleContainer.cpp | 10 +++++----- Source/Particles/WarpXParticleContainer.cpp | 12 ++++++------ Source/ablastr/particles/DepositCharge.H | 2 +- 38 files changed, 82 insertions(+), 76 deletions(-) diff --git a/Source/AcceleratorLattice/LatticeElementFinder.H b/Source/AcceleratorLattice/LatticeElementFinder.H index 43e97980774..24cdb691bb0 100644 --- a/Source/AcceleratorLattice/LatticeElementFinder.H +++ b/Source/AcceleratorLattice/LatticeElementFinder.H @@ -167,7 +167,7 @@ struct LatticeElementFinderDevice amrex::ParticleReal m_uz_boost; amrex::Real m_time; - GetParticlePosition m_get_position; + GetParticlePosition m_get_position; const amrex::ParticleReal* AMREX_RESTRICT m_ux = nullptr; const amrex::ParticleReal* AMREX_RESTRICT m_uy = nullptr; const amrex::ParticleReal* AMREX_RESTRICT m_uz = nullptr; diff --git a/Source/AcceleratorLattice/LatticeElementFinder.cpp b/Source/AcceleratorLattice/LatticeElementFinder.cpp index 7e9825c28a6..62ebdcc1f4f 100644 --- a/Source/AcceleratorLattice/LatticeElementFinder.cpp +++ b/Source/AcceleratorLattice/LatticeElementFinder.cpp @@ -96,7 +96,7 @@ LatticeElementFinderDevice::InitLatticeElementFinderDevice (WarpXParIter const& int const lev = a_pti.GetLevel(); - m_get_position = GetParticlePosition(a_pti, a_offset); + m_get_position = GetParticlePosition(a_pti, a_offset); auto& attribs = a_pti.GetAttribs(); m_ux = attribs[PIdx::ux].dataPtr() + a_offset; m_uy = attribs[PIdx::uy].dataPtr() + a_offset; diff --git a/Source/Diagnostics/ComputeDiagFunctors/BackTransformParticleFunctor.H b/Source/Diagnostics/ComputeDiagFunctors/BackTransformParticleFunctor.H index 4bb1b0656aa..afc3e6e8511 100644 --- a/Source/Diagnostics/ComputeDiagFunctors/BackTransformParticleFunctor.H +++ b/Source/Diagnostics/ComputeDiagFunctors/BackTransformParticleFunctor.H @@ -62,7 +62,7 @@ struct SelectParticles } /** Object to extract the positions of the macroparticles inside a ParallelFor kernel */ - GetParticlePosition m_get_position; + GetParticlePosition m_get_position; /** Z coordinate in boosted frame that corresponds to a give snapshot*/ amrex::Real m_current_z_boost; /** Previous Z coordinate in boosted frame that corresponds to a give snapshot*/ @@ -166,7 +166,7 @@ struct LorentzTransformParticles dst.m_rdata[PIdx::uz][i_dst] = uzp; } - GetParticlePosition m_get_position; + GetParticlePosition m_get_position; amrex::ParticleReal* AMREX_RESTRICT m_xpold = nullptr; amrex::ParticleReal* AMREX_RESTRICT m_ypold = nullptr; diff --git a/Source/Diagnostics/ComputeDiagFunctors/BackTransformParticleFunctor.cpp b/Source/Diagnostics/ComputeDiagFunctors/BackTransformParticleFunctor.cpp index 41445c4bede..ce463a11ca3 100644 --- a/Source/Diagnostics/ComputeDiagFunctors/BackTransformParticleFunctor.cpp +++ b/Source/Diagnostics/ComputeDiagFunctors/BackTransformParticleFunctor.cpp @@ -20,7 +20,7 @@ SelectParticles::SelectParticles (const WarpXParIter& a_pti, TmpParticles& tmp_p int a_offset) : m_current_z_boost(current_z_boost), m_old_z_boost(old_z_boost) { - m_get_position = GetParticlePosition(a_pti, a_offset); + m_get_position = GetParticlePosition(a_pti, a_offset); const auto lev = a_pti.GetLevel(); const auto index = a_pti.GetPairIndex(); @@ -38,7 +38,7 @@ LorentzTransformParticles::LorentzTransformParticles ( const WarpXParIter& a_pti using namespace amrex::literals; if (tmp_particle_data.empty()) return; - m_get_position = GetParticlePosition(a_pti, a_offset); + m_get_position = GetParticlePosition(a_pti, a_offset); auto& attribs = a_pti.GetAttribs(); m_wpnew = attribs[PIdx::w].dataPtr(); diff --git a/Source/Diagnostics/ReducedDiags/ColliderRelevant.cpp b/Source/Diagnostics/ReducedDiags/ColliderRelevant.cpp index 188b5f3f76f..c4eaf78745d 100644 --- a/Source/Diagnostics/ReducedDiags/ColliderRelevant.cpp +++ b/Source/Diagnostics/ReducedDiags/ColliderRelevant.cpp @@ -456,7 +456,7 @@ void ColliderRelevant::ComputeDiags (int step) // Loop over boxes for (WarpXParIter pti(myspc, lev); pti.isValid(); ++pti) { - const auto GetPosition = GetParticlePosition(pti); + const auto GetPosition = GetParticlePosition(pti); // get particle arrays amrex::ParticleReal* const AMREX_RESTRICT ux = pti.GetAttribs()[PIdx::ux].dataPtr(); amrex::ParticleReal* const AMREX_RESTRICT uy = pti.GetAttribs()[PIdx::uy].dataPtr(); diff --git a/Source/Diagnostics/ReducedDiags/FieldProbe.cpp b/Source/Diagnostics/ReducedDiags/FieldProbe.cpp index 11975ef0483..98cba72cfae 100644 --- a/Source/Diagnostics/ReducedDiags/FieldProbe.cpp +++ b/Source/Diagnostics/ReducedDiags/FieldProbe.cpp @@ -429,8 +429,8 @@ void FieldProbe::ComputeDiags (int step) for (MyParIter pti(m_probe, lev); pti.isValid(); ++pti) { - const auto getPosition = GetParticlePosition(pti); - auto setPosition = SetParticlePosition(pti); + const auto getPosition = GetParticlePosition(pti); + auto setPosition = SetParticlePosition(pti); const auto& aos = pti.GetArrayOfStructs(); const auto* AMREX_RESTRICT m_structs = aos().dataPtr(); diff --git a/Source/Diagnostics/ReducedDiags/FieldProbeParticleContainer.H b/Source/Diagnostics/ReducedDiags/FieldProbeParticleContainer.H index d658f209c8f..b3277b875d9 100644 --- a/Source/Diagnostics/ReducedDiags/FieldProbeParticleContainer.H +++ b/Source/Diagnostics/ReducedDiags/FieldProbeParticleContainer.H @@ -19,21 +19,17 @@ * This enumerated struct is used to index the field probe particle * values that are being stored as SoA data. Nattribs * is enumerated to give the number of attributes stored. - * The strange insertion of `theta` below is due to the use of - * GetParticlePosition for the field probe locations, which reads the probe - * theta value from PIdx::theta = 4. */ struct FieldProbePIdx { enum { Ex = 0, Ey, Ez, - Bx, + Bx, By, Bz, + S, //!< the Poynting vector #ifdef WARPX_DIM_RZ theta, ///< RZ needs all three position components #endif - By, Bz, - S, //!< the Poynting vector nattribs }; }; diff --git a/Source/Diagnostics/ReducedDiags/ParticleExtrema.cpp b/Source/Diagnostics/ReducedDiags/ParticleExtrema.cpp index e125f44e08f..78f8be8914e 100644 --- a/Source/Diagnostics/ReducedDiags/ParticleExtrema.cpp +++ b/Source/Diagnostics/ReducedDiags/ParticleExtrema.cpp @@ -388,7 +388,7 @@ void ParticleExtrema::ComputeDiags (int step) // Loop over boxes for (WarpXParIter pti(myspc, lev); pti.isValid(); ++pti) { - const auto GetPosition = GetParticlePosition(pti); + const auto GetPosition = GetParticlePosition(pti); // get particle arrays amrex::ParticleReal* const AMREX_RESTRICT ux = pti.GetAttribs()[PIdx::ux].dataPtr(); amrex::ParticleReal* const AMREX_RESTRICT uy = pti.GetAttribs()[PIdx::uy].dataPtr(); diff --git a/Source/Diagnostics/ReducedDiags/ParticleHistogram.cpp b/Source/Diagnostics/ReducedDiags/ParticleHistogram.cpp index 1cbbbaaebff..9da001ba7ed 100644 --- a/Source/Diagnostics/ReducedDiags/ParticleHistogram.cpp +++ b/Source/Diagnostics/ReducedDiags/ParticleHistogram.cpp @@ -196,7 +196,7 @@ void ParticleHistogram::ComputeDiags (int step) { for (WarpXParIter pti(myspc, lev); pti.isValid(); ++pti) { - auto const GetPosition = GetParticlePosition(pti); + auto const GetPosition = GetParticlePosition(pti); auto & attribs = pti.GetAttribs(); ParticleReal* const AMREX_RESTRICT d_w = attribs[PIdx::w].dataPtr(); diff --git a/Source/Diagnostics/ReducedDiags/ParticleHistogram2D.cpp b/Source/Diagnostics/ReducedDiags/ParticleHistogram2D.cpp index 0567f1cfc29..dfb53b7e2c3 100644 --- a/Source/Diagnostics/ReducedDiags/ParticleHistogram2D.cpp +++ b/Source/Diagnostics/ReducedDiags/ParticleHistogram2D.cpp @@ -193,7 +193,7 @@ void ParticleHistogram2D::ComputeDiags (int step) { for (WarpXParIter pti(myspc, lev); pti.isValid(); ++pti) { - auto const GetPosition = GetParticlePosition(pti); + auto const GetPosition = GetParticlePosition(pti); auto & attribs = pti.GetAttribs(); ParticleReal* const AMREX_RESTRICT d_w = attribs[PIdx::w].dataPtr(); diff --git a/Source/EmbeddedBoundary/ParticleScraper.H b/Source/EmbeddedBoundary/ParticleScraper.H index b723fd2ce5e..f1aaf544b32 100644 --- a/Source/EmbeddedBoundary/ParticleScraper.H +++ b/Source/EmbeddedBoundary/ParticleScraper.H @@ -163,7 +163,7 @@ scrapeParticles (PC& pc, const amrex::Vector& distance_t const auto dxi = pc.Geom(lev).InvCellSizeArray(); for(WarpXParIter pti(pc, lev); pti.isValid(); ++pti) { - const auto getPosition = GetParticlePosition(pti); + const auto getPosition = GetParticlePosition(pti); auto& tile = pti.GetParticleTile(); auto ptd = tile.getParticleTileData(); const auto np = tile.numParticles(); diff --git a/Source/Particles/Collision/BackgroundMCC/BackgroundMCCCollision.cpp b/Source/Particles/Collision/BackgroundMCC/BackgroundMCCCollision.cpp index ce7fed952a7..ebf8cb47172 100644 --- a/Source/Particles/Collision/BackgroundMCC/BackgroundMCCCollision.cpp +++ b/Source/Particles/Collision/BackgroundMCC/BackgroundMCCCollision.cpp @@ -340,7 +340,7 @@ void BackgroundMCCCollision::doBackgroundCollisionsWithinTile // we need particle positions in order to calculate the local density // and temperature - auto GetPosition = GetParticlePosition(pti); + auto GetPosition = GetParticlePosition(pti); // get Struct-Of-Array particle data, also called attribs auto& attribs = pti.GetAttribs(); diff --git a/Source/Particles/Collision/BackgroundStopping/BackgroundStopping.cpp b/Source/Particles/Collision/BackgroundStopping/BackgroundStopping.cpp index 878ef8a1f64..83f74840478 100644 --- a/Source/Particles/Collision/BackgroundStopping/BackgroundStopping.cpp +++ b/Source/Particles/Collision/BackgroundStopping/BackgroundStopping.cpp @@ -159,7 +159,7 @@ void BackgroundStopping::doBackgroundStoppingOnElectronsWithinTile (WarpXParIter amrex::ParticleReal* const AMREX_RESTRICT uz = attribs[PIdx::uz].dataPtr(); // May be needed to evaluate the density and/or temperature functions - auto const GetPosition = GetParticlePosition(pti); + auto const GetPosition = GetParticlePosition(pti); amrex::ParallelFor(np, [=] AMREX_GPU_HOST_DEVICE (long ip) @@ -234,7 +234,7 @@ void BackgroundStopping::doBackgroundStoppingOnIonsWithinTile (WarpXParIter& pti amrex::ParticleReal* const AMREX_RESTRICT uz = attribs[PIdx::uz].dataPtr(); // May be needed to evaluate the density function - auto const GetPosition = GetParticlePosition(pti); + auto const GetPosition = GetParticlePosition(pti); amrex::ParallelFor(np, [=] AMREX_GPU_HOST_DEVICE (long ip) diff --git a/Source/Particles/Collision/BinaryCollision/BinaryCollision.H b/Source/Particles/Collision/BinaryCollision/BinaryCollision.H index 6728e4cef53..2f9ddbbcb3f 100644 --- a/Source/Particles/Collision/BinaryCollision/BinaryCollision.H +++ b/Source/Particles/Collision/BinaryCollision/BinaryCollision.H @@ -221,7 +221,7 @@ public: // Store product species data in vectors const int n_product_species = m_product_species.size(); amrex::Vector tile_products; - amrex::Vector get_position_products; + amrex::Vector> get_position_products; amrex::Vector products_np; amrex::Vector products_mass; constexpr int getpos_offset = 0; @@ -229,7 +229,7 @@ public: { ParticleTileType& ptile_product = product_species_vector[i]->ParticlesAt(lev, mfi); tile_products.push_back(&ptile_product); - get_position_products.push_back(GetParticlePosition(ptile_product, + get_position_products.push_back(GetParticlePosition(ptile_product, getpos_offset)); products_np.push_back(ptile_product.numParticles()); products_mass.push_back(product_species_vector[i]->getMass()); @@ -254,7 +254,7 @@ public: index_type const* AMREX_RESTRICT cell_offsets_1 = bins_1.offsetsPtr(); const amrex::ParticleReal q1 = species_1.getCharge(); const amrex::ParticleReal m1 = species_1.getMass(); - auto get_position_1 = GetParticlePosition(ptile_1, getpos_offset); + auto get_position_1 = GetParticlePosition(ptile_1, getpos_offset); // Needed to access the particle id ParticleType * AMREX_RESTRICT particle_ptr_1 = ptile_1.GetArrayOfStructs()().data(); @@ -394,7 +394,7 @@ public: index_type const* AMREX_RESTRICT cell_offsets_1 = bins_1.offsetsPtr(); const amrex::ParticleReal q1 = species_1.getCharge(); const amrex::ParticleReal m1 = species_1.getMass(); - auto get_position_1 = GetParticlePosition(ptile_1, getpos_offset); + auto get_position_1 = GetParticlePosition(ptile_1, getpos_offset); // Needed to access the particle id ParticleType * AMREX_RESTRICT particle_ptr_1 = ptile_1.GetArrayOfStructs()().data(); @@ -404,7 +404,7 @@ public: index_type const* AMREX_RESTRICT cell_offsets_2 = bins_2.offsetsPtr(); const amrex::ParticleReal q2 = species_2.getCharge(); const amrex::ParticleReal m2 = species_2.getMass(); - auto get_position_2 = GetParticlePosition(ptile_2, getpos_offset); + auto get_position_2 = GetParticlePosition(ptile_2, getpos_offset); // Needed to access the particle id ParticleType * AMREX_RESTRICT particle_ptr_2 = ptile_2.GetArrayOfStructs()().data(); diff --git a/Source/Particles/Collision/BinaryCollision/Coulomb/PairWiseCoulombCollisionFunc.H b/Source/Particles/Collision/BinaryCollision/Coulomb/PairWiseCoulombCollisionFunc.H index 3c5f3abd841..d8fdaee8bd0 100644 --- a/Source/Particles/Collision/BinaryCollision/Coulomb/PairWiseCoulombCollisionFunc.H +++ b/Source/Particles/Collision/BinaryCollision/Coulomb/PairWiseCoulombCollisionFunc.H @@ -77,7 +77,7 @@ public: index_type const* AMREX_RESTRICT I1, index_type const* AMREX_RESTRICT I2, SoaData_type soa_1, SoaData_type soa_2, - GetParticlePosition /*get_position_1*/, GetParticlePosition /*get_position_2*/, + GetParticlePosition /*get_position_1*/, GetParticlePosition /*get_position_2*/, amrex::ParticleReal const q1, amrex::ParticleReal const q2, amrex::ParticleReal const m1, amrex::ParticleReal const m2, amrex::Real const dt, amrex::Real const dV, diff --git a/Source/Particles/Collision/BinaryCollision/NuclearFusion/NuclearFusionFunc.H b/Source/Particles/Collision/BinaryCollision/NuclearFusion/NuclearFusionFunc.H index db8dacce1d4..83952357ec5 100644 --- a/Source/Particles/Collision/BinaryCollision/NuclearFusion/NuclearFusionFunc.H +++ b/Source/Particles/Collision/BinaryCollision/NuclearFusion/NuclearFusionFunc.H @@ -123,7 +123,7 @@ public: index_type const* AMREX_RESTRICT I1, index_type const* AMREX_RESTRICT I2, SoaData_type soa_1, SoaData_type soa_2, - GetParticlePosition /*get_position_1*/, GetParticlePosition /*get_position_2*/, + GetParticlePosition /*get_position_1*/, GetParticlePosition /*get_position_2*/, amrex::ParticleReal const /*q1*/, amrex::ParticleReal const /*q2*/, amrex::ParticleReal const m1, amrex::ParticleReal const m2, amrex::Real const dt, amrex::Real const dV, diff --git a/Source/Particles/Deposition/ChargeDeposition.H b/Source/Particles/Deposition/ChargeDeposition.H index 20ec4c2e34d..df7097f7600 100644 --- a/Source/Particles/Deposition/ChargeDeposition.H +++ b/Source/Particles/Deposition/ChargeDeposition.H @@ -37,7 +37,7 @@ * \param load_balance_costs_update_algo Selected method for updating load balance costs. */ template -void doChargeDepositionShapeN (const GetParticlePosition& GetPosition, +void doChargeDepositionShapeN (const GetParticlePosition& GetPosition, const amrex::ParticleReal * const wp, const int* ion_lev, amrex::FArrayBox& rho_fab, @@ -239,7 +239,7 @@ void doChargeDepositionShapeN (const GetParticlePosition& GetPosition, * \param bin_size tile size to use for shared current deposition operations */ template -void doChargeDepositionSharedShapeN (const GetParticlePosition& GetPosition, +void doChargeDepositionSharedShapeN (const GetParticlePosition& GetPosition, const amrex::ParticleReal * const wp, const int* ion_lev, amrex::FArrayBox& rho_fab, diff --git a/Source/Particles/Deposition/CurrentDeposition.H b/Source/Particles/Deposition/CurrentDeposition.H index 49a7c46a3e8..2c4e4bd448d 100644 --- a/Source/Particles/Deposition/CurrentDeposition.H +++ b/Source/Particles/Deposition/CurrentDeposition.H @@ -51,7 +51,7 @@ * \param load_balance_costs_update_algo Selected method for updating load balance costs. */ template -void doDepositionShapeN (const GetParticlePosition& GetPosition, +void doDepositionShapeN (const GetParticlePosition& GetPosition, const amrex::ParticleReal * const wp, const amrex::ParticleReal * const uxp, const amrex::ParticleReal * const uyp, @@ -365,7 +365,7 @@ void doDepositionShapeN (const GetParticlePosition& GetPosition, * \param load_balance_costs_update_algo Selected method for updating load balance costs. */ template -void doDepositionSharedShapeN (const GetParticlePosition& GetPosition, +void doDepositionSharedShapeN (const GetParticlePosition& GetPosition, const amrex::ParticleReal * const wp, const amrex::ParticleReal * const uxp, const amrex::ParticleReal * const uyp, @@ -577,7 +577,7 @@ void doDepositionSharedShapeN (const GetParticlePosition& GetPosition, * \param load_balance_costs_update_algo Selected method for updating load balance costs. */ template -void doEsirkepovDepositionShapeN (const GetParticlePosition& GetPosition, +void doEsirkepovDepositionShapeN (const GetParticlePosition& GetPosition, const amrex::ParticleReal * const wp, const amrex::ParticleReal * const uxp, const amrex::ParticleReal * const uyp, @@ -957,7 +957,7 @@ void doEsirkepovDepositionShapeN (const GetParticlePosition& GetPosition, * \param[in] load_balance_costs_update_algo Selected method for updating load balance costs */ template -void doVayDepositionShapeN (const GetParticlePosition& GetPosition, +void doVayDepositionShapeN (const GetParticlePosition& GetPosition, const amrex::ParticleReal* const wp, const amrex::ParticleReal* const uxp, const amrex::ParticleReal* const uyp, diff --git a/Source/Particles/Deposition/SharedDepositionUtils.H b/Source/Particles/Deposition/SharedDepositionUtils.H index 40407b609c0..646a6add811 100644 --- a/Source/Particles/Deposition/SharedDepositionUtils.H +++ b/Source/Particles/Deposition/SharedDepositionUtils.H @@ -65,7 +65,7 @@ void addLocalToGlobal (const amrex::Box& bx, #if defined(AMREX_USE_HIP) || defined(AMREX_USE_CUDA) template AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE -void depositComponent (const GetParticlePosition& GetPosition, +void depositComponent (const GetParticlePosition& GetPosition, const amrex::ParticleReal * const wp, const amrex::ParticleReal * const uxp, const amrex::ParticleReal * const uyp, diff --git a/Source/Particles/ElementaryProcess/Ionization.H b/Source/Particles/ElementaryProcess/Ionization.H index b6b74644825..742d8127da9 100644 --- a/Source/Particles/ElementaryProcess/Ionization.H +++ b/Source/Particles/ElementaryProcess/Ionization.H @@ -37,7 +37,7 @@ struct IonizationFilterFunc int comp; int m_atomic_number; - GetParticlePosition m_get_position; + GetParticlePosition m_get_position; GetExternalEBField m_get_externalEB; amrex::Array4 m_ex_arr; diff --git a/Source/Particles/ElementaryProcess/Ionization.cpp b/Source/Particles/ElementaryProcess/Ionization.cpp index a4aac9d5e0f..8fcb953e9ff 100644 --- a/Source/Particles/ElementaryProcess/Ionization.cpp +++ b/Source/Particles/ElementaryProcess/Ionization.cpp @@ -42,7 +42,7 @@ IonizationFilterFunc::IonizationFilterFunc (const WarpXParIter& a_pti, int lev, comp = a_comp; m_atomic_number = a_atomic_number; - m_get_position = GetParticlePosition(a_pti, a_offset); + m_get_position = GetParticlePosition(a_pti, a_offset); m_get_externalEB = GetExternalEBField(a_pti, a_offset); m_ex_arr = exfab.array(); diff --git a/Source/Particles/ElementaryProcess/QEDPairGeneration.H b/Source/Particles/ElementaryProcess/QEDPairGeneration.H index dbdbd0e6d53..5a3efe483d7 100644 --- a/Source/Particles/ElementaryProcess/QEDPairGeneration.H +++ b/Source/Particles/ElementaryProcess/QEDPairGeneration.H @@ -168,7 +168,7 @@ private: const BreitWheelerGeneratePairs m_generate_functor; /*!< A copy of the functor to generate pairs. It contains only pointers to the lookup tables.*/ - GetParticlePosition m_get_position; + GetParticlePosition m_get_position; GetExternalEBField m_get_externalEB; amrex::Array4 m_ex_arr; diff --git a/Source/Particles/ElementaryProcess/QEDPairGeneration.cpp b/Source/Particles/ElementaryProcess/QEDPairGeneration.cpp index 68475aa144b..31aafbb1379 100644 --- a/Source/Particles/ElementaryProcess/QEDPairGeneration.cpp +++ b/Source/Particles/ElementaryProcess/QEDPairGeneration.cpp @@ -32,7 +32,7 @@ PairGenerationTransformFunc (BreitWheelerGeneratePairs const generate_functor, using namespace amrex::literals; - m_get_position = GetParticlePosition(a_pti, a_offset); + m_get_position = GetParticlePosition(a_pti, a_offset); m_get_externalEB = GetExternalEBField(a_pti, a_offset); m_ex_arr = exfab.array(); diff --git a/Source/Particles/ElementaryProcess/QEDPhotonEmission.H b/Source/Particles/ElementaryProcess/QEDPhotonEmission.H index 080555e6fe8..0a889077036 100644 --- a/Source/Particles/ElementaryProcess/QEDPhotonEmission.H +++ b/Source/Particles/ElementaryProcess/QEDPhotonEmission.H @@ -178,7 +178,7 @@ private: const QuantumSynchrotronPhotonEmission m_emission_functor; /*!< A copy of the functor to generate photons. It contains only pointers to the lookup tables.*/ - GetParticlePosition m_get_position; + GetParticlePosition m_get_position; GetExternalEBField m_get_externalEB; amrex::Array4 m_ex_arr; diff --git a/Source/Particles/ElementaryProcess/QEDPhotonEmission.cpp b/Source/Particles/ElementaryProcess/QEDPhotonEmission.cpp index 2c060a30f01..a3b3c4103f7 100644 --- a/Source/Particles/ElementaryProcess/QEDPhotonEmission.cpp +++ b/Source/Particles/ElementaryProcess/QEDPhotonEmission.cpp @@ -35,7 +35,7 @@ PhotonEmissionTransformFunc (QuantumSynchrotronGetOpticalDepth opt_depth_functor using namespace amrex::literals; - m_get_position = GetParticlePosition(a_pti, a_offset); + m_get_position = GetParticlePosition(a_pti, a_offset); m_get_externalEB = GetExternalEBField(a_pti, a_offset); m_ex_arr = exfab.array(); diff --git a/Source/Particles/Gather/FieldGather.H b/Source/Particles/Gather/FieldGather.H index 4f5064a0e9b..0b2aae52ecc 100644 --- a/Source/Particles/Gather/FieldGather.H +++ b/Source/Particles/Gather/FieldGather.H @@ -432,7 +432,7 @@ void doGatherShapeN (const amrex::ParticleReal xp, * \param n_rz_azimuthal_modes Number of azimuthal modes when using RZ geometry */ template -void doGatherShapeN(const GetParticlePosition& getPosition, +void doGatherShapeN(const GetParticlePosition& getPosition, const GetExternalEBField& getExternalEB, amrex::ParticleReal * const Exp, amrex::ParticleReal * const Eyp, amrex::ParticleReal * const Ezp, amrex::ParticleReal * const Bxp, diff --git a/Source/Particles/Gather/GetExternalFields.H b/Source/Particles/Gather/GetExternalFields.H index 2f388363e17..8db7565a485 100644 --- a/Source/Particles/Gather/GetExternalFields.H +++ b/Source/Particles/Gather/GetExternalFields.H @@ -45,7 +45,7 @@ struct GetExternalEBField amrex::ParserExecutor<4> m_Byfield_partparser; amrex::ParserExecutor<4> m_Bzfield_partparser; - GetParticlePosition m_get_position; + GetParticlePosition m_get_position; amrex::Real m_time; amrex::ParticleReal m_repeated_plasma_lens_period; diff --git a/Source/Particles/Gather/GetExternalFields.cpp b/Source/Particles/Gather/GetExternalFields.cpp index 057ac51d597..af00e092080 100644 --- a/Source/Particles/Gather/GetExternalFields.cpp +++ b/Source/Particles/Gather/GetExternalFields.cpp @@ -56,7 +56,7 @@ GetExternalEBField::GetExternalEBField (const WarpXParIter& a_pti, long a_offset mypc.m_B_ext_particle_s == "repeated_plasma_lens") { m_time = warpx.gett_new(a_pti.GetLevel()); - m_get_position = GetParticlePosition(a_pti, a_offset); + m_get_position = GetParticlePosition(a_pti, a_offset); } if (mypc.m_E_ext_particle_s == "parse_e_ext_particle_function") diff --git a/Source/Particles/LaserParticleContainer.cpp b/Source/Particles/LaserParticleContainer.cpp index 098dba0997b..782e630e805 100644 --- a/Source/Particles/LaserParticleContainer.cpp +++ b/Source/Particles/LaserParticleContainer.cpp @@ -790,7 +790,7 @@ LaserParticleContainer::calculate_laser_plane_coordinates (const WarpXParIter& p Real * AMREX_RESTRICT const pplane_Xp, Real * AMREX_RESTRICT const pplane_Yp) { - const auto GetPosition = GetParticlePosition(pti); + const auto GetPosition = GetParticlePosition(pti); #if (AMREX_SPACEDIM >= 2) const Real tmp_u_X_0 = m_u_X[0]; @@ -852,8 +852,8 @@ LaserParticleContainer::update_laser_particle (WarpXParIter& pti, Real const * AMREX_RESTRICT const amplitude, const Real dt) { - const auto GetPosition = GetParticlePosition(pti); - auto SetPosition = SetParticlePosition(pti); + const auto GetPosition = GetParticlePosition(pti); + auto SetPosition = SetParticlePosition(pti); const Real tmp_p_X_0 = m_p_X[0]; const Real tmp_p_X_1 = m_p_X[1]; diff --git a/Source/Particles/ParticleBoundaryBuffer.cpp b/Source/Particles/ParticleBoundaryBuffer.cpp index 8e6decb1f3f..b2dfb2f03ef 100644 --- a/Source/Particles/ParticleBoundaryBuffer.cpp +++ b/Source/Particles/ParticleBoundaryBuffer.cpp @@ -313,7 +313,7 @@ void ParticleBoundaryBuffer::gatherParticles (MultiParticleContainer& mypc, auto index = std::make_pair(pti.index(), pti.LocalTileIndex()); if(plevel.find(index) == plevel.end()) continue; - const auto getPosition = GetParticlePosition(pti); + const auto getPosition = GetParticlePosition(pti); auto& ptile_buffer = species_buffer.DefineAndReturnParticleTile(lev, pti.index(), pti.LocalTileIndex()); const auto& ptile = plevel.at(index); diff --git a/Source/Particles/PhotonParticleContainer.cpp b/Source/Particles/PhotonParticleContainer.cpp index 9b7da18bc5e..7609bd67b13 100644 --- a/Source/Particles/PhotonParticleContainer.cpp +++ b/Source/Particles/PhotonParticleContainer.cpp @@ -129,8 +129,8 @@ PhotonParticleContainer::PushPX (WarpXParIter& pti, auto copyAttribs = CopyParticleAttribs(pti, tmp_particle_data, offset); const int do_copy = (m_do_back_transformed_particles && (a_dt_type!=DtType::SecondHalf) ); - const auto GetPosition = GetParticlePosition(pti, offset); - auto SetPosition = SetParticlePosition(pti, offset); + const auto GetPosition = GetParticlePosition(pti, offset); + auto SetPosition = SetParticlePosition(pti, offset); const auto getExternalEB = GetExternalEBField(pti, offset); diff --git a/Source/Particles/PhysicalParticleContainer.cpp b/Source/Particles/PhysicalParticleContainer.cpp index f515b750a3e..632e3fca85b 100644 --- a/Source/Particles/PhysicalParticleContainer.cpp +++ b/Source/Particles/PhysicalParticleContainer.cpp @@ -712,7 +712,7 @@ PhysicalParticleContainer::DefaultInitializeRuntimeAttributes ( // Preparing data needed for user defined attributes const auto n_user_real_attribs = static_cast(m_user_real_attribs.size()); const auto n_user_int_attribs = static_cast(m_user_int_attribs.size()); - const auto get_position = GetParticlePosition(pinned_tile); + const auto get_position = GetParticlePosition(pinned_tile); const auto soa = pinned_tile.getParticleTileData(); const amrex::ParticleReal* AMREX_RESTRICT ux = soa.m_rdata[PIdx::ux]; const amrex::ParticleReal* AMREX_RESTRICT uy = soa.m_rdata[PIdx::uy]; @@ -2298,7 +2298,7 @@ PhysicalParticleContainer::SplitParticles (int lev) // Loop over particle interator for (WarpXParIter pti(*this, lev); pti.isValid(); ++pti) { - const auto GetPosition = GetParticlePosition(pti); + const auto GetPosition = GetParticlePosition(pti); const amrex::Vector ppc_nd = plasma_injector->num_particles_per_cell_each_dim; const std::array& dx = WarpX::CellSize(lev); @@ -2494,7 +2494,7 @@ PhysicalParticleContainer::PushP (int lev, Real dt, const FArrayBox& byfab = By[pti]; const FArrayBox& bzfab = Bz[pti]; - const auto getPosition = GetParticlePosition(pti); + const auto getPosition = GetParticlePosition(pti); const auto getExternalEB = GetExternalEBField(pti); @@ -2670,8 +2670,8 @@ PhysicalParticleContainer::PushPX (WarpXParIter& pti, // Add guard cells to the box. box.grow(ngEB); - const auto getPosition = GetParticlePosition(pti, offset); - auto setPosition = SetParticlePosition(pti, offset); + const auto getPosition = GetParticlePosition(pti, offset); + auto setPosition = SetParticlePosition(pti, offset); const auto getExternalEB = GetExternalEBField(pti, offset); diff --git a/Source/Particles/Pusher/CopyParticleAttribs.H b/Source/Particles/Pusher/CopyParticleAttribs.H index 29e5017a3a7..1f0cee67421 100644 --- a/Source/Particles/Pusher/CopyParticleAttribs.H +++ b/Source/Particles/Pusher/CopyParticleAttribs.H @@ -22,7 +22,7 @@ struct CopyParticleAttribs { using TmpParticles = WarpXParticleContainer::TmpParticles; - GetParticlePosition m_get_position; + GetParticlePosition m_get_position; const amrex::ParticleReal* AMREX_RESTRICT uxp = nullptr; const amrex::ParticleReal* AMREX_RESTRICT uyp = nullptr; @@ -66,7 +66,7 @@ struct CopyParticleAttribs uypold = tmp_particle_data[lev].at(index)[TmpIdx::uyold].dataPtr() + a_offset; uzpold = tmp_particle_data[lev].at(index)[TmpIdx::uzold].dataPtr() + a_offset; - m_get_position = GetParticlePosition(a_pti, a_offset); + m_get_position = GetParticlePosition(a_pti, a_offset); } /** \brief copy the position and momentum of particle i to the diff --git a/Source/Particles/Pusher/GetAndSetPosition.H b/Source/Particles/Pusher/GetAndSetPosition.H index 45b9c39fe9d..e4477a2a60d 100644 --- a/Source/Particles/Pusher/GetAndSetPosition.H +++ b/Source/Particles/Pusher/GetAndSetPosition.H @@ -9,6 +9,7 @@ #define WARPX_PARTICLES_PUSHER_GETANDSETPOSITION_H_ #include "Particles/WarpXParticleContainer.H" +#include "Particles/NamedComponentParticleContainer.H" #include #include @@ -18,7 +19,11 @@ /** \brief Extract the cartesian position coordinates of the particle * p and store them in the variables `x`, `y`, `z` - * This version operates on a SuperParticle */ + * This version operates on a SuperParticle + * + * \tparam T_PIdx particle index enumerator + */ +template AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void get_particle_position (const WarpXParticleContainer::SuperParticleType& p, amrex::ParticleReal& x, @@ -26,7 +31,7 @@ void get_particle_position (const WarpXParticleContainer::SuperParticleType& p, amrex::ParticleReal& z) noexcept { #ifdef WARPX_DIM_RZ - const amrex::ParticleReal theta = p.rdata(PIdx::theta); + const amrex::ParticleReal theta = p.rdata(T_PIdx::theta); const amrex::ParticleReal r = p.pos(0); x = r*std::cos(theta); y = r*std::sin(theta); @@ -48,7 +53,10 @@ void get_particle_position (const WarpXParticleContainer::SuperParticleType& p, /** \brief Functor that can be used to extract the positions of the macroparticles * inside a ParallelFor kernel + * + * \tparam T_PIdx particle index enumerator */ +template struct GetParticlePosition { using PType = WarpXParticleContainer::ParticleType; @@ -80,7 +88,7 @@ struct GetParticlePosition m_structs = aos().dataPtr() + a_offset; #if defined(WARPX_DIM_RZ) const auto& soa = a_pti.GetStructOfArrays(); - m_theta = soa.GetRealData(PIdx::theta).dataPtr() + a_offset; + m_theta = soa.GetRealData(T_PIdx::theta).dataPtr() + a_offset; #endif } @@ -143,9 +151,11 @@ struct GetParticlePosition /** \brief Functor that can be used to modify the positions of the macroparticles, * inside a ParallelFor kernel. * + * \tparam T_PIdx particle index enumerator * \param a_pti iterator to the tile being modified * \param a_offset offset to apply to the particle indices */ +template struct SetParticlePosition { using PType = WarpXParticleContainer::ParticleType; @@ -163,7 +173,7 @@ struct SetParticlePosition m_structs = aos().dataPtr() + a_offset; #if defined(WARPX_DIM_RZ) auto& soa = a_pti.GetStructOfArrays(); - m_theta = soa.GetRealData(PIdx::theta).dataPtr() + a_offset; + m_theta = soa.GetRealData(T_PIdx::theta).dataPtr() + a_offset; #endif } diff --git a/Source/Particles/Pusher/PushSelector.H b/Source/Particles/Pusher/PushSelector.H index b1e59029958..f6fa3ba164f 100644 --- a/Source/Particles/Pusher/PushSelector.H +++ b/Source/Particles/Pusher/PushSelector.H @@ -43,8 +43,8 @@ template AMREX_GPU_DEVICE AMREX_FORCE_INLINE -void doParticlePush(const GetParticlePosition& GetPosition, - const SetParticlePosition& SetPosition, +void doParticlePush(const GetParticlePosition& GetPosition, + const SetParticlePosition& SetPosition, const CopyParticleAttribs& copyAttribs, const long i, amrex::ParticleReal& ux, diff --git a/Source/Particles/RigidInjectedParticleContainer.cpp b/Source/Particles/RigidInjectedParticleContainer.cpp index 28364cb6ef7..e013d41268a 100644 --- a/Source/Particles/RigidInjectedParticleContainer.cpp +++ b/Source/Particles/RigidInjectedParticleContainer.cpp @@ -121,8 +121,8 @@ RigidInjectedParticleContainer::RemapParticles() const auto uyp = attribs[PIdx::uy].dataPtr(); const auto uzp = attribs[PIdx::uz].dataPtr(); - const auto GetPosition = GetParticlePosition(pti); - auto SetPosition = SetParticlePosition(pti); + const auto GetPosition = GetParticlePosition(pti); + auto SetPosition = SetParticlePosition(pti); // Loop over particles const long np = pti.numParticles(); @@ -181,8 +181,8 @@ RigidInjectedParticleContainer::PushPX (WarpXParIter& pti, amrex::Gpu::DeviceVector optical_depth_save; #endif - const auto GetPosition = GetParticlePosition(pti, offset); - auto SetPosition = SetParticlePosition(pti, offset); + const auto GetPosition = GetParticlePosition(pti, offset); + auto SetPosition = SetParticlePosition(pti, offset); amrex::ParticleReal* const AMREX_RESTRICT ux = uxp.dataPtr() + offset; amrex::ParticleReal* const AMREX_RESTRICT uy = uyp.dataPtr() + offset; @@ -357,7 +357,7 @@ RigidInjectedParticleContainer::PushP (int lev, Real dt, const FArrayBox& byfab = By[pti]; const FArrayBox& bzfab = Bz[pti]; - const auto getPosition = GetParticlePosition(pti); + const auto getPosition = GetParticlePosition(pti); const auto getExternalEB = GetExternalEBField(pti); diff --git a/Source/Particles/WarpXParticleContainer.cpp b/Source/Particles/WarpXParticleContainer.cpp index a7405bb5741..df3938ec909 100644 --- a/Source/Particles/WarpXParticleContainer.cpp +++ b/Source/Particles/WarpXParticleContainer.cpp @@ -424,7 +424,7 @@ WarpXParticleContainer::DepositCurrent (WarpXParIter& pti, Array4 const& jz_arr = local_jz[thread_num].array(); #endif - const auto GetPosition = GetParticlePosition(pti, offset); + const auto GetPosition = GetParticlePosition(pti, offset); // Lower corner of tile box physical domain // Note that this includes guard cells since it is after tilebox.ngrow @@ -870,7 +870,7 @@ WarpXParticleContainer::DepositCharge (WarpXParIter& pti, RealVector const& wp, amrex::LayoutData* costs = WarpX::getCosts(lev); amrex::Real* cost = costs ? &((*costs)[pti.index()]) : nullptr; - const auto GetPosition = GetParticlePosition(pti, offset); + const auto GetPosition = GetParticlePosition(pti, offset); const Geometry& geom = Geom(lev); Box box = pti.validbox(); box.grow(ng_rho); @@ -1258,8 +1258,8 @@ WarpXParticleContainer::PushX (int lev, amrex::Real dt) // Particle Push // - const auto GetPosition = GetParticlePosition(pti); - auto SetPosition = SetParticlePosition(pti); + const auto GetPosition = GetParticlePosition(pti); + auto SetPosition = SetParticlePosition(pti); // - momenta are stored as a struct of array, in `attribs` auto& attribs = pti.GetAttribs(); @@ -1345,8 +1345,8 @@ WarpXParticleContainer::ApplyBoundaryConditions (){ #endif for (WarpXParIter pti(*this, lev); pti.isValid(); ++pti) { - auto GetPosition = GetParticlePosition(pti); - auto SetPosition = SetParticlePosition(pti); + auto GetPosition = GetParticlePosition(pti); + auto SetPosition = SetParticlePosition(pti); #ifndef WARPX_DIM_1D_Z const Real xmin = Geom(lev).ProbLo(0); const Real xmax = Geom(lev).ProbHi(0); diff --git a/Source/ablastr/particles/DepositCharge.H b/Source/ablastr/particles/DepositCharge.H index 2fcdcf3b768..eecc56f9acc 100644 --- a/Source/ablastr/particles/DepositCharge.H +++ b/Source/ablastr/particles/DepositCharge.H @@ -170,7 +170,7 @@ deposit_charge (typename T_PC::ParIterType& pti, auto & rho_fab = local_rho; #endif - const auto GetPosition = GetParticlePosition(pti, offset); + const auto GetPosition = GetParticlePosition(pti, offset); // Indices of the lower bound const amrex::Dim3 lo = lbound(tilebox); From d2afb3e7aaee849b7db9a3588dbeae36f0aa6e67 Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Mon, 23 Oct 2023 16:06:18 -0700 Subject: [PATCH 16/25] AMReX: Weekly Update (#4387) --- .github/workflows/cuda.yml | 2 +- Regression/WarpX-GPU-tests.ini | 2 +- Regression/WarpX-tests.ini | 2 +- cmake/dependencies/AMReX.cmake | 2 +- run_test.sh | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/cuda.yml b/.github/workflows/cuda.yml index 0425842e7cc..d3610179695 100644 --- a/.github/workflows/cuda.yml +++ b/.github/workflows/cuda.yml @@ -111,7 +111,7 @@ jobs: which nvcc || echo "nvcc not in PATH!" git clone https://github.com/AMReX-Codes/amrex.git ../amrex - cd ../amrex && git checkout --detach 7ee29121ed70d7e255ad98a8b1690d345cb4fb33 && cd - + cd ../amrex && git checkout --detach da79aff8053058371a78d4bf85488384242368ee && 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: diff --git a/Regression/WarpX-GPU-tests.ini b/Regression/WarpX-GPU-tests.ini index aa0167565ea..17d98e4b76d 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 = 7ee29121ed70d7e255ad98a8b1690d345cb4fb33 +branch = da79aff8053058371a78d4bf85488384242368ee [source] dir = /home/regtester/git/WarpX diff --git a/Regression/WarpX-tests.ini b/Regression/WarpX-tests.ini index 6e0efc9ecba..6f08f34bc2c 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 = 7ee29121ed70d7e255ad98a8b1690d345cb4fb33 +branch = da79aff8053058371a78d4bf85488384242368ee [source] dir = /home/regtester/AMReX_RegTesting/warpx diff --git a/cmake/dependencies/AMReX.cmake b/cmake/dependencies/AMReX.cmake index 0313f4a2128..fbdd39e4f43 100644 --- a/cmake/dependencies/AMReX.cmake +++ b/cmake/dependencies/AMReX.cmake @@ -257,7 +257,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 "7ee29121ed70d7e255ad98a8b1690d345cb4fb33" +set(WarpX_amrex_branch "da79aff8053058371a78d4bf85488384242368ee" CACHE STRING "Repository branch for WarpX_amrex_repo if(WarpX_amrex_internal)") diff --git a/run_test.sh b/run_test.sh index e362a0ef332..2e86618f2f2 100755 --- a/run_test.sh +++ b/run_test.sh @@ -71,7 +71,7 @@ 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 7ee29121ed70d7e255ad98a8b1690d345cb4fb33 && cd - +cd amrex && git checkout --detach da79aff8053058371a78d4bf85488384242368ee && 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 From 52561f93f715579a63b71fea06a4397afa8128e2 Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Wed, 25 Oct 2023 00:47:32 -0700 Subject: [PATCH 17/25] Lassen (LLNL): `h5py` (#4388) * Lassen (LLNL): `h5py` Install `h5py` on Lassen using our pre-compiled HDF5 package. * All Machines: Ensure Setuptools in Venv --- Docs/source/install/hpc/lawrencium.rst | 1 + Tools/machines/adastra-cines/install_dependencies.sh | 1 + Tools/machines/crusher-olcf/install_dependencies.sh | 1 + Tools/machines/frontier-olcf/install_dependencies.sh | 1 + Tools/machines/hpc3-uci/install_gpu_dependencies.sh | 1 + Tools/machines/karolina-it4i/install_cpu_dependencies.sh | 1 + Tools/machines/karolina-it4i/install_gpu_dependencies.sh | 1 + Tools/machines/lassen-llnl/install_v100_dependencies.sh | 9 ++++++++- .../lassen-llnl/install_v100_dependencies_toss3.sh | 9 ++++++++- .../machines/leonardo-cineca/install_gpu_dependencies.sh | 1 + Tools/machines/lumi-csc/install_dependencies.sh | 1 + .../perlmutter-nersc/install_cpu_dependencies.sh | 1 + .../perlmutter-nersc/install_gpu_dependencies.sh | 1 + Tools/machines/quartz-llnl/install_dependencies.sh | 1 + Tools/machines/summit-olcf/install_gpu_dependencies.sh | 1 + 15 files changed, 29 insertions(+), 2 deletions(-) diff --git a/Docs/source/install/hpc/lawrencium.rst b/Docs/source/install/hpc/lawrencium.rst index 09eb67b2ca5..36039e5eda4 100644 --- a/Docs/source/install/hpc/lawrencium.rst +++ b/Docs/source/install/hpc/lawrencium.rst @@ -81,6 +81,7 @@ Optionally, download and install Python packages for :ref:`PICMI ` source $HOME/sw/v100/venvs/warpx/bin/activate python3 -m pip install --upgrade pip python3 -m pip install --upgrade wheel + python3 -m pip install --upgrade setuptools python3 -m pip install --upgrade cython python3 -m pip install --upgrade numpy python3 -m pip install --upgrade pandas diff --git a/Tools/machines/adastra-cines/install_dependencies.sh b/Tools/machines/adastra-cines/install_dependencies.sh index e532ea33924..b94d5224833 100755 --- a/Tools/machines/adastra-cines/install_dependencies.sh +++ b/Tools/machines/adastra-cines/install_dependencies.sh @@ -102,6 +102,7 @@ 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 wheel +python3 -m pip install --upgrade setuptools python3 -m pip install --upgrade cython python3 -m pip install --upgrade numpy python3 -m pip install --upgrade pandas diff --git a/Tools/machines/crusher-olcf/install_dependencies.sh b/Tools/machines/crusher-olcf/install_dependencies.sh index e1f196a519b..2defd795786 100755 --- a/Tools/machines/crusher-olcf/install_dependencies.sh +++ b/Tools/machines/crusher-olcf/install_dependencies.sh @@ -87,6 +87,7 @@ 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 wheel +python3 -m pip install --upgrade setuptools python3 -m pip install --upgrade cython python3 -m pip install --upgrade numpy python3 -m pip install --upgrade pandas diff --git a/Tools/machines/frontier-olcf/install_dependencies.sh b/Tools/machines/frontier-olcf/install_dependencies.sh index 9ef077c69ea..690941b2078 100755 --- a/Tools/machines/frontier-olcf/install_dependencies.sh +++ b/Tools/machines/frontier-olcf/install_dependencies.sh @@ -87,6 +87,7 @@ 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 wheel +python3 -m pip install --upgrade setuptools python3 -m pip install --upgrade cython python3 -m pip install --upgrade numpy python3 -m pip install --upgrade pandas diff --git a/Tools/machines/hpc3-uci/install_gpu_dependencies.sh b/Tools/machines/hpc3-uci/install_gpu_dependencies.sh index 0f8b5c9b880..e7a5f9f086f 100755 --- a/Tools/machines/hpc3-uci/install_gpu_dependencies.sh +++ b/Tools/machines/hpc3-uci/install_gpu_dependencies.sh @@ -117,6 +117,7 @@ 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 wheel +python3 -m pip install --upgrade setuptools python3 -m pip install --upgrade cython python3 -m pip install --upgrade numpy python3 -m pip install --upgrade pandas diff --git a/Tools/machines/karolina-it4i/install_cpu_dependencies.sh b/Tools/machines/karolina-it4i/install_cpu_dependencies.sh index c6e858ba8a6..f5067e03447 100755 --- a/Tools/machines/karolina-it4i/install_cpu_dependencies.sh +++ b/Tools/machines/karolina-it4i/install_cpu_dependencies.sh @@ -121,6 +121,7 @@ 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 wheel +python3 -m pip install --upgrade setuptools python3 -m pip install --upgrade cython python3 -m pip install --upgrade numpy python3 -m pip install --upgrade pandas diff --git a/Tools/machines/karolina-it4i/install_gpu_dependencies.sh b/Tools/machines/karolina-it4i/install_gpu_dependencies.sh index a12092c6e01..4cd1ce5851a 100755 --- a/Tools/machines/karolina-it4i/install_gpu_dependencies.sh +++ b/Tools/machines/karolina-it4i/install_gpu_dependencies.sh @@ -121,6 +121,7 @@ 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 wheel +python3 -m pip install --upgrade setuptools python3 -m pip install --upgrade cython python3 -m pip install --upgrade numpy python3 -m pip install --upgrade pandas diff --git a/Tools/machines/lassen-llnl/install_v100_dependencies.sh b/Tools/machines/lassen-llnl/install_v100_dependencies.sh index 223b41d1967..dfbf139f27d 100755 --- a/Tools/machines/lassen-llnl/install_v100_dependencies.sh +++ b/Tools/machines/lassen-llnl/install_v100_dependencies.sh @@ -108,6 +108,9 @@ cmake --build ${build_dir}/lapackpp-lassen-build --target install --parallel 10 # Python ###################################################################### # +# sometimes, the Lassen PIP Index is down +export PIP_EXTRA_INDEX_URL="https://pypi.org/simple" + python3 -m pip install --upgrade --user virtualenv rm -rf ${SW_DIR}/venvs/warpx-lassen python3 -m venv ${SW_DIR}/venvs/warpx-lassen @@ -115,12 +118,16 @@ source ${SW_DIR}/venvs/warpx-lassen/bin/activate python3 -m pip install --upgrade pip python3 -m pip cache purge python3 -m pip install --upgrade wheel -python3 -m pip install --upgrade cython +python3 -m pip install --upgrade setuptools +# Older version for h4py +# https://github.com/h5py/h5py/issues/2268 +python3 -m pip install --upgrade "cython<3" python3 -m pip install --upgrade numpy python3 -m pip install --upgrade pandas python3 -m pip install --upgrade -Ccompile-args="-j10" scipy python3 -m pip install --upgrade mpi4py --no-cache-dir --no-build-isolation --no-binary mpi4py python3 -m pip install --upgrade openpmd-api +CC=mpicc H5PY_SETUP_REQUIRES=0 HDF5_DIR=${SW_DIR}/hdf5-1.14.1.2 HDF5_MPI=ON python3 -m pip install --upgrade h5py --no-cache-dir --no-build-isolation --no-binary h5py MPLLOCALFREETYPE=1 python3 -m pip install --upgrade matplotlib==3.2.2 # does not try to build freetype itself echo "matplotlib==3.2.2" > ${build_dir}/constraints.txt python3 -m pip install --upgrade -c ${build_dir}/constraints.txt yt diff --git a/Tools/machines/lassen-llnl/install_v100_dependencies_toss3.sh b/Tools/machines/lassen-llnl/install_v100_dependencies_toss3.sh index f62c6018cd5..b8273a69c87 100644 --- a/Tools/machines/lassen-llnl/install_v100_dependencies_toss3.sh +++ b/Tools/machines/lassen-llnl/install_v100_dependencies_toss3.sh @@ -108,6 +108,9 @@ cmake --build ${build_dir}/lapackpp-lassen-build --target install --parallel 10 # Python ###################################################################### # +# sometimes, the Lassen PIP Index is down +export PIP_EXTRA_INDEX_URL="https://pypi.org/simple" + python3 -m pip install --upgrade --user virtualenv rm -rf ${SW_DIR}/venvs/warpx-lassen-toss3 python3 -m venv ${SW_DIR}/venvs/warpx-lassen-toss3 @@ -115,12 +118,16 @@ 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 wheel -python3 -m pip install --upgrade cython +python3 -m pip install --upgrade setuptools +# Older version for h4py +# https://github.com/h5py/h5py/issues/2268 +python3 -m pip install --upgrade "cython<3" python3 -m pip install --upgrade numpy python3 -m pip install --upgrade pandas CMAKE_PREFIX_PATH=/usr/lib64:${CMAKE_PREFIX_PATH} python3 -m pip install --upgrade -Ccompile-args="-j10" -Csetup-args=-Dblas=BLAS -Csetup-args=-Dlapack=BLAS scipy python3 -m pip install --upgrade mpi4py --no-cache-dir --no-build-isolation --no-binary mpi4py python3 -m pip install --upgrade openpmd-api +CC=mpicc H5PY_SETUP_REQUIRES=0 HDF5_DIR=${SW_DIR}/hdf5-1.14.1.2 HDF5_MPI=ON python3 -m pip install --upgrade h5py --no-cache-dir --no-build-isolation --no-binary h5py MPLLOCALFREETYPE=1 python3 -m pip install --upgrade matplotlib==3.2.2 # does not try to build freetype itself echo "matplotlib==3.2.2" > ${build_dir}/constraints.txt python3 -m pip install --upgrade -c ${build_dir}/constraints.txt yt diff --git a/Tools/machines/leonardo-cineca/install_gpu_dependencies.sh b/Tools/machines/leonardo-cineca/install_gpu_dependencies.sh index 5b6453b3968..3a332f97420 100644 --- a/Tools/machines/leonardo-cineca/install_gpu_dependencies.sh +++ b/Tools/machines/leonardo-cineca/install_gpu_dependencies.sh @@ -86,6 +86,7 @@ python3 -m ensurepip --upgrade python3 -m pip cache purge python3 -m pip install --upgrade pip python3 -m pip install --upgrade wheel +python3 -m pip install --upgrade setuptools python3 -m pip install --upgrade cython python3 -m pip install --upgrade numpy python3 -m pip install --upgrade pandas diff --git a/Tools/machines/lumi-csc/install_dependencies.sh b/Tools/machines/lumi-csc/install_dependencies.sh index 1cb1afb4fc4..281ca10c449 100755 --- a/Tools/machines/lumi-csc/install_dependencies.sh +++ b/Tools/machines/lumi-csc/install_dependencies.sh @@ -102,6 +102,7 @@ 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 wheel +python3 -m pip install --upgrade setuptools python3 -m pip install --upgrade cython python3 -m pip install --upgrade numpy python3 -m pip install --upgrade pandas diff --git a/Tools/machines/perlmutter-nersc/install_cpu_dependencies.sh b/Tools/machines/perlmutter-nersc/install_cpu_dependencies.sh index 6bfa47bc380..fa4e77cb309 100755 --- a/Tools/machines/perlmutter-nersc/install_cpu_dependencies.sh +++ b/Tools/machines/perlmutter-nersc/install_cpu_dependencies.sh @@ -117,6 +117,7 @@ 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 wheel +python3 -m pip install --upgrade setuptools python3 -m pip install --upgrade cython python3 -m pip install --upgrade numpy python3 -m pip install --upgrade pandas diff --git a/Tools/machines/perlmutter-nersc/install_gpu_dependencies.sh b/Tools/machines/perlmutter-nersc/install_gpu_dependencies.sh index 7bcc7053974..98e14f09ede 100755 --- a/Tools/machines/perlmutter-nersc/install_gpu_dependencies.sh +++ b/Tools/machines/perlmutter-nersc/install_gpu_dependencies.sh @@ -117,6 +117,7 @@ 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 wheel +python3 -m pip install --upgrade setuptools python3 -m pip install --upgrade cython python3 -m pip install --upgrade numpy python3 -m pip install --upgrade pandas diff --git a/Tools/machines/quartz-llnl/install_dependencies.sh b/Tools/machines/quartz-llnl/install_dependencies.sh index c162ac5d390..114bef3d3c3 100755 --- a/Tools/machines/quartz-llnl/install_dependencies.sh +++ b/Tools/machines/quartz-llnl/install_dependencies.sh @@ -100,6 +100,7 @@ source ${SW_DIR}/venvs/warpx-quartz/bin/activate python3 -m pip install --upgrade pip python3 -m pip cache purge python3 -m pip install --upgrade wheel +python3 -m pip install --upgrade setuptools python3 -m pip install --upgrade cython python3 -m pip install --upgrade numpy python3 -m pip install --upgrade pandas diff --git a/Tools/machines/summit-olcf/install_gpu_dependencies.sh b/Tools/machines/summit-olcf/install_gpu_dependencies.sh index 6bdcda92378..7679b999ea3 100755 --- a/Tools/machines/summit-olcf/install_gpu_dependencies.sh +++ b/Tools/machines/summit-olcf/install_gpu_dependencies.sh @@ -100,6 +100,7 @@ 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 wheel +python3 -m pip install --upgrade setuptools python3 -m pip install --upgrade cython python3 -m pip install --upgrade numpy python3 -m pip install --upgrade pandas From ba217db3e9e0322c09b4bd2704c1a02018badeef Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Wed, 25 Oct 2023 00:48:25 -0700 Subject: [PATCH 18/25] Machines: HDF5 & ADIOS2 Tools in PATH (#4389) Ensure tools such as `bpls`, `bpdump` and `h5ls` are available to users if we self-compile them. --- Tools/machines/adastra-cines/adastra_warpx.profile.example | 2 ++ Tools/machines/hpc3-uci/hpc3_gpu_warpx.profile.example | 1 + .../machines/karolina-it4i/karolina_cpu_warpx.profile.example | 3 +++ .../machines/karolina-it4i/karolina_gpu_warpx.profile.example | 3 +++ Tools/machines/lassen-llnl/lassen_v100_warpx.profile.example | 2 ++ .../lassen-llnl/lassen_v100_warpx_toss3.profile.example | 2 ++ .../machines/lawrencium-lbnl/lawrencium_warpx.profile.example | 2 ++ .../leonardo-cineca/leonardo_gpu_warpx.profile.example | 2 ++ Tools/machines/lumi-csc/lumi_warpx.profile.example | 1 + .../perlmutter-nersc/perlmutter_cpu_warpx.profile.example | 2 ++ .../perlmutter-nersc/perlmutter_gpu_warpx.profile.example | 2 ++ Tools/machines/quartz-llnl/quartz_warpx.profile.example | 1 + 12 files changed, 23 insertions(+) diff --git a/Tools/machines/adastra-cines/adastra_warpx.profile.example b/Tools/machines/adastra-cines/adastra_warpx.profile.example index 49f17d395e4..23441638893 100644 --- a/Tools/machines/adastra-cines/adastra_warpx.profile.example +++ b/Tools/machines/adastra-cines/adastra_warpx.profile.example @@ -21,6 +21,8 @@ module load cray-hdf5-parallel export CMAKE_PREFIX_PATH=${HOME}/sw/adastra/gpu/c-blosc-1.21.1:$CMAKE_PREFIX_PATH export CMAKE_PREFIX_PATH=${HOME}/sw/adastra/gpu/adios2-2.8.3:$CMAKE_PREFIX_PATH +export PATH=${HOME}/sw/adastra/gpu/adios2-2.8.3/bin:${PATH} + # optional: for Python bindings or libEnsemble module load cray-python/3.9.13.1 diff --git a/Tools/machines/hpc3-uci/hpc3_gpu_warpx.profile.example b/Tools/machines/hpc3-uci/hpc3_gpu_warpx.profile.example index 62733f8e70f..9f41cc7e337 100644 --- a/Tools/machines/hpc3-uci/hpc3_gpu_warpx.profile.example +++ b/Tools/machines/hpc3-uci/hpc3_gpu_warpx.profile.example @@ -27,6 +27,7 @@ export LD_LIBRARY_PATH=${HOME}/sw/hpc3/gpu/adios2-2.8.3/lib64:$LD_LIBRARY_PATH export LD_LIBRARY_PATH=${HOME}/sw/hpc3/gpu/blaspp-master/lib64:$LD_LIBRARY_PATH export LD_LIBRARY_PATH=${HOME}/sw/hpc3/gpu/lapackpp-master/lib64:$LD_LIBRARY_PATH +export PATH=${HOME}/sw/hpc3/gpu/adios2-2.8.3/bin:${PATH} # optional: CCache #module load ccache # missing diff --git a/Tools/machines/karolina-it4i/karolina_cpu_warpx.profile.example b/Tools/machines/karolina-it4i/karolina_cpu_warpx.profile.example index 66b2f67a8be..c0a3ed53ee3 100644 --- a/Tools/machines/karolina-it4i/karolina_cpu_warpx.profile.example +++ b/Tools/machines/karolina-it4i/karolina_cpu_warpx.profile.example @@ -27,6 +27,9 @@ export LD_LIBRARY_PATH=${HOME}/sw/karolina/cpu/adios2-2.8.3/lib64:$LD_LIBRARY_PA export LD_LIBRARY_PATH=${HOME}/sw/karolina/cpu/blaspp-master/lib64:$LD_LIBRARY_PATH export LD_LIBRARY_PATH=${HOME}/sw/karolina/cpu/lapackpp-master/lib64:$LD_LIBRARY_PATH +export PATH=${HOME}/sw/karolina/cpu/hdf5-1.14.1.2/bin:${PATH} +export PATH=${HOME}/sw/karolina/cpu/adios2-2.8.3/bin:${PATH} + # optional: CCache (not found) #module load ccache diff --git a/Tools/machines/karolina-it4i/karolina_gpu_warpx.profile.example b/Tools/machines/karolina-it4i/karolina_gpu_warpx.profile.example index f657916dfcd..174598acaac 100644 --- a/Tools/machines/karolina-it4i/karolina_gpu_warpx.profile.example +++ b/Tools/machines/karolina-it4i/karolina_gpu_warpx.profile.example @@ -29,6 +29,9 @@ export LD_LIBRARY_PATH=${HOME}/sw/karolina/gpu/adios2-2.8.3/lib64:$LD_LIBRARY_PA export LD_LIBRARY_PATH=${HOME}/sw/karolina/gpu/blaspp-master/lib64:$LD_LIBRARY_PATH export LD_LIBRARY_PATH=${HOME}/sw/karolina/gpu/lapackpp-master/lib64:$LD_LIBRARY_PATH +export PATH=${HOME}/sw/karolina/gpu/hdf5-1.14.1.2/bin:${PATH} +export PATH=${HOME}/sw/karolina/gpu/adios2-2.8.3/bin:${PATH} + # optional: CCache (not found) #ml ccache diff --git a/Tools/machines/lassen-llnl/lassen_v100_warpx.profile.example b/Tools/machines/lassen-llnl/lassen_v100_warpx.profile.example index 652af2a2822..4d4efbf917d 100644 --- a/Tools/machines/lassen-llnl/lassen_v100_warpx.profile.example +++ b/Tools/machines/lassen-llnl/lassen_v100_warpx.profile.example @@ -18,6 +18,8 @@ export CMAKE_PREFIX_PATH=${SW_DIR}/adios2-2.8.3:$CMAKE_PREFIX_PATH export LD_LIBRARY_PATH=${SW_DIR}/c-blosc-1.21.1/lib64:$LD_LIBRARY_PATH export LD_LIBRARY_PATH=${SW_DIR}/hdf5-1.14.1.2/lib64:$LD_LIBRARY_PATH export LD_LIBRARY_PATH=${SW_DIR}/adios2-2.8.3/lib64:$LD_LIBRARY_PATH +export PATH=${SW_DIR}/hdf5-1.14.1.2/bin:${PATH} +export PATH=${SW_DIR}/adios2-2.8.3/bin:$PATH # optional: for PSATD in RZ geometry support export CMAKE_PREFIX_PATH=${SW_DIR}/blaspp-master:$CMAKE_PREFIX_PATH diff --git a/Tools/machines/lassen-llnl/lassen_v100_warpx_toss3.profile.example b/Tools/machines/lassen-llnl/lassen_v100_warpx_toss3.profile.example index 979c27989fa..19c74348a99 100644 --- a/Tools/machines/lassen-llnl/lassen_v100_warpx_toss3.profile.example +++ b/Tools/machines/lassen-llnl/lassen_v100_warpx_toss3.profile.example @@ -18,6 +18,8 @@ export CMAKE_PREFIX_PATH=${SW_DIR}/adios2-2.8.3:$CMAKE_PREFIX_PATH export LD_LIBRARY_PATH=${SW_DIR}/c-blosc-1.21.1/lib64:$LD_LIBRARY_PATH export LD_LIBRARY_PATH=${SW_DIR}/hdf5-1.14.1.2/lib64:$LD_LIBRARY_PATH export LD_LIBRARY_PATH=${SW_DIR}/adios2-2.8.3/lib64:$LD_LIBRARY_PATH +export PATH=${SW_DIR}/hdf5-1.14.1.2/bin:${PATH} +export PATH=${SW_DIR}/adios2-2.8.3/bin:${PATH} # optional: for PSATD in RZ geometry support export CMAKE_PREFIX_PATH=${SW_DIR}/blaspp-master:$CMAKE_PREFIX_PATH diff --git a/Tools/machines/lawrencium-lbnl/lawrencium_warpx.profile.example b/Tools/machines/lawrencium-lbnl/lawrencium_warpx.profile.example index 9b9bf709ecc..472d0785bb2 100644 --- a/Tools/machines/lawrencium-lbnl/lawrencium_warpx.profile.example +++ b/Tools/machines/lawrencium-lbnl/lawrencium_warpx.profile.example @@ -21,6 +21,8 @@ export CMAKE_PREFIX_PATH=$HOME/sw/v100/adios2-2.8.3:$CMAKE_PREFIX_PATH export CMAKE_PREFIX_PATH=$HOME/sw/v100/blaspp-master:$CMAKE_PREFIX_PATH export CMAKE_PREFIX_PATH=$HOME/sw/v100/lapackpp-master:$CMAKE_PREFIX_PATH +export PATH=$HOME/sw/v100/adios2-2.8.3/bin:$PATH + # optional: CCache #module load ccache # missing diff --git a/Tools/machines/leonardo-cineca/leonardo_gpu_warpx.profile.example b/Tools/machines/leonardo-cineca/leonardo_gpu_warpx.profile.example index af0cdbd41c3..cffe565f9d7 100644 --- a/Tools/machines/leonardo-cineca/leonardo_gpu_warpx.profile.example +++ b/Tools/machines/leonardo-cineca/leonardo_gpu_warpx.profile.example @@ -24,6 +24,8 @@ export LD_LIBRARY_PATH=$HOME/sw/adios2-master/lib64:$LD_LIBRARY_PATH export LD_LIBRARY_PATH=$HOME/sw/blaspp-master/lib64:$LD_LIBRARY_PATH export LD_LIBRARY_PATH=$HOME/sw/lapackpp-master/lib64:$LD_LIBRARY_PATH +export PATH=$HOME/sw/adios2-master/bin:$PATH + # optional: for Python bindings or libEnsemble module load python/3.10.8--gcc--11.3.0 diff --git a/Tools/machines/lumi-csc/lumi_warpx.profile.example b/Tools/machines/lumi-csc/lumi_warpx.profile.example index 31c133ed47a..74b8aa8df17 100644 --- a/Tools/machines/lumi-csc/lumi_warpx.profile.example +++ b/Tools/machines/lumi-csc/lumi_warpx.profile.example @@ -22,6 +22,7 @@ module load Boost/1.81.0-cpeCray-23.03 module load cray-hdf5/1.12.2.3 export CMAKE_PREFIX_PATH=${HOME}/sw/lumi/gpu/c-blosc-1.21.1:$CMAKE_PREFIX_PATH export CMAKE_PREFIX_PATH=${HOME}/sw/lumi/gpu/adios2-2.8.3:$CMAKE_PREFIX_PATH +export PATH=${HOME}/sw/lumi/gpu/adios2-2.8.3/bin:${PATH} # optional: for Python bindings or libEnsemble module load cray-python/3.9.13.1 diff --git a/Tools/machines/perlmutter-nersc/perlmutter_cpu_warpx.profile.example b/Tools/machines/perlmutter-nersc/perlmutter_cpu_warpx.profile.example index d25b4825dde..0150ded4839 100644 --- a/Tools/machines/perlmutter-nersc/perlmutter_cpu_warpx.profile.example +++ b/Tools/machines/perlmutter-nersc/perlmutter_cpu_warpx.profile.example @@ -25,6 +25,8 @@ export LD_LIBRARY_PATH=${CFS}/${proj}/${USER}/sw/perlmutter/cpu/adios2-2.8.3/lib export LD_LIBRARY_PATH=${CFS}/${proj}/${USER}/sw/perlmutter/cpu/blaspp-master/lib64:$LD_LIBRARY_PATH export LD_LIBRARY_PATH=${CFS}/${proj}/${USER}/sw/perlmutter/cpu/lapackpp-master/lib64:$LD_LIBRARY_PATH +export PATH=${CFS}/${proj}/${USER}/sw/perlmutter/cpu/adios2-2.8.3/bin:${PATH} + # optional: CCache export PATH=/global/common/software/spackecp/perlmutter/e4s-23.05/default/spack/opt/spack/linux-sles15-zen3/gcc-11.2.0/ccache-4.8-eqk2d3bipbpkgwxq7ujlp6mckwal4dwz/bin:$PATH diff --git a/Tools/machines/perlmutter-nersc/perlmutter_gpu_warpx.profile.example b/Tools/machines/perlmutter-nersc/perlmutter_gpu_warpx.profile.example index af3e69c1190..13ab2ead605 100644 --- a/Tools/machines/perlmutter-nersc/perlmutter_gpu_warpx.profile.example +++ b/Tools/machines/perlmutter-nersc/perlmutter_gpu_warpx.profile.example @@ -23,6 +23,8 @@ export LD_LIBRARY_PATH=${CFS}/${proj%_g}/${USER}/sw/perlmutter/gpu/adios2-2.8.3/ export LD_LIBRARY_PATH=${CFS}/${proj%_g}/${USER}/sw/perlmutter/gpu/blaspp-master/lib64:$LD_LIBRARY_PATH export LD_LIBRARY_PATH=${CFS}/${proj%_g}/${USER}/sw/perlmutter/gpu/lapackpp-master/lib64:$LD_LIBRARY_PATH +export PATH=${CFS}/${proj%_g}/${USER}/sw/perlmutter/gpu/adios2-2.8.3/bin:${PATH} + # optional: CCache export PATH=/global/common/software/spackecp/perlmutter/e4s-23.05/default/spack/opt/spack/linux-sles15-zen3/gcc-11.2.0/ccache-4.8-eqk2d3bipbpkgwxq7ujlp6mckwal4dwz/bin:$PATH diff --git a/Tools/machines/quartz-llnl/quartz_warpx.profile.example b/Tools/machines/quartz-llnl/quartz_warpx.profile.example index 810005bafb7..a3646bfd557 100644 --- a/Tools/machines/quartz-llnl/quartz_warpx.profile.example +++ b/Tools/machines/quartz-llnl/quartz_warpx.profile.example @@ -18,6 +18,7 @@ module load hdf5-parallel/1.14.0 SW_DIR="/usr/workspace/${USER}/quartz" export CMAKE_PREFIX_PATH=${SW_DIR}/c-blosc-1.21.1:$CMAKE_PREFIX_PATH export CMAKE_PREFIX_PATH=${SW_DIR}/adios2-2.8.3:$CMAKE_PREFIX_PATH +export PATH=${SW_DIR}/adios2-2.8.3/bin:${PATH} # optional: for PSATD in RZ geometry support export CMAKE_PREFIX_PATH=${SW_DIR}/blaspp-master:$CMAKE_PREFIX_PATH From eb9d79eaafed115931f8521a94850c42da40756a Mon Sep 17 00:00:00 2001 From: Luca Fedeli Date: Thu, 26 Oct 2023 15:25:26 +0200 Subject: [PATCH 19/25] Clang tidy CI test: add some cppcoreguidelines-* checks (#4149) * clang-tidy CI test: add some cppcoreguidelines-* checks. Initial work * addressing issues found with clang-tidy * continue addressing issues found with clang-tidy * fix bug * fixed issue * address issues found with clang-tidy * addressing issues found with clang-tidy * fix initialization order * fix initialization order --- .clang-tidy | 9 ++- .../LatticeElements/Drift.H | 2 - .../LatticeElements/HardEdgedPlasmaLens.H | 2 - .../LatticeElements/HardEdgedQuadrupole.H | 2 - .../LatticeElements/LatticeElementBase.H | 2 - .../LatticeElements/LatticeElementBase.cpp | 6 +- Source/BoundaryConditions/PML.H | 10 ++- Source/BoundaryConditions/PML_RZ.H | 2 - Source/Diagnostics/BTD_Plotfile_Header_Impl.H | 9 +-- .../ComputeDiagFunctors/CellCenterFunctor.H | 2 +- .../ComputeDiagFunctors/ComputeDiagFunctor.H | 7 ++ .../ComputeParticleDiagFunctor.H | 6 ++ .../ComputeDiagFunctors/DivBFunctor.H | 2 +- .../ComputeDiagFunctors/DivEFunctor.H | 2 +- .../ComputeDiagFunctors/JFunctor.H | 2 +- .../ComputeDiagFunctors/PartPerCellFunctor.H | 2 +- .../ComputeDiagFunctors/PartPerGridFunctor.H | 2 +- .../ParticleReductionFunctor.H | 2 +- .../ComputeDiagFunctors/RhoFunctor.H | 2 +- Source/Diagnostics/Diagnostics.H | 5 ++ Source/Diagnostics/FlushFormats/FlushFormat.H | 10 ++- .../FlushFormats/FlushFormatAscent.H | 12 +++- .../FlushFormats/FlushFormatAscent.cpp | 2 +- .../FlushFormats/FlushFormatCheckpoint.H | 6 +- .../FlushFormats/FlushFormatCheckpoint.cpp | 2 +- .../FlushFormats/FlushFormatOpenPMD.H | 7 +- .../FlushFormats/FlushFormatOpenPMD.cpp | 2 +- .../FlushFormats/FlushFormatPlotfile.H | 12 +++- .../FlushFormats/FlushFormatPlotfile.cpp | 2 +- .../FlushFormats/FlushFormatSensei.H | 12 ++-- .../FlushFormats/FlushFormatSensei.cpp | 2 +- Source/Diagnostics/FullDiagnostics.cpp | 12 ++-- .../Diagnostics/ReducedDiags/BeamRelevant.H | 2 +- Source/Diagnostics/ReducedDiags/ChargeOnEB.H | 2 +- .../ReducedDiags/ColliderRelevant.H | 2 +- Source/Diagnostics/ReducedDiags/FieldEnergy.H | 2 +- .../Diagnostics/ReducedDiags/FieldMaximum.H | 2 +- .../Diagnostics/ReducedDiags/FieldMomentum.H | 2 +- Source/Diagnostics/ReducedDiags/FieldProbe.H | 8 +-- .../FieldProbeParticleContainer.H | 7 +- .../Diagnostics/ReducedDiags/FieldReduction.H | 2 +- .../ReducedDiags/LoadBalanceCosts.H | 4 +- .../ReducedDiags/LoadBalanceEfficiency.H | 2 +- .../Diagnostics/ReducedDiags/ParticleEnergy.H | 2 +- .../ReducedDiags/ParticleExtrema.H | 2 +- .../ReducedDiags/ParticleHistogram.H | 2 +- .../ReducedDiags/ParticleHistogram.cpp | 17 +++-- .../ReducedDiags/ParticleHistogram2D.H | 4 +- .../ReducedDiags/ParticleMomentum.H | 2 +- .../Diagnostics/ReducedDiags/ParticleNumber.H | 2 +- .../Diagnostics/ReducedDiags/ReducedDiags.H | 7 ++ Source/Diagnostics/ReducedDiags/RhoMaximum.H | 2 +- Source/Diagnostics/WarpXOpenPMD.H | 5 ++ Source/Diagnostics/WarpXOpenPMD.cpp | 13 ++-- .../FiniteDifferenceSolver.cpp | 9 ++- .../PsatdAlgorithmComoving.H | 6 +- .../PsatdAlgorithmFirstOrder.H | 6 +- .../PsatdAlgorithmGalileanRZ.H | 10 +-- .../PsatdAlgorithmGalileanRZ.cpp | 13 ++-- .../PsatdAlgorithmJConstantInTime.H | 6 +- .../PsatdAlgorithmJConstantInTime.cpp | 6 +- .../PsatdAlgorithmJLinearInTime.H | 6 +- .../SpectralAlgorithms/PsatdAlgorithmPml.H | 6 +- .../SpectralAlgorithms/PsatdAlgorithmPml.cpp | 5 +- .../SpectralAlgorithms/PsatdAlgorithmPmlRZ.H | 8 +-- .../PsatdAlgorithmPmlRZ.cpp | 11 ++-- .../SpectralAlgorithms/PsatdAlgorithmRZ.H | 6 +- .../SpectralAlgorithms/PsatdAlgorithmRZ.cpp | 20 +++--- .../SpectralBaseAlgorithm.H | 8 ++- .../SpectralBaseAlgorithmRZ.H | 21 ++++++ .../SpectralSolver/SpectralFieldData.H | 27 +++++++- .../SpectralSolver/SpectralFieldData.cpp | 5 +- .../SpectralSolver/SpectralFieldDataRZ.H | 11 +++- Source/Filter/NCIGodfreyFilter.H | 4 ++ Source/Filter/NCIGodfreyFilter.cpp | 66 +++++++++++-------- Source/Fluids/MultiFluidContainer.H | 5 ++ Source/Fluids/WarpXFluidContainer.H | 5 ++ Source/Fluids/WarpXFluidContainer.cpp | 7 +- Source/Initialization/GetTemperature.cpp | 5 +- Source/Initialization/GetVelocity.cpp | 7 +- Source/Initialization/InjectorDensity.H | 3 + Source/Initialization/InjectorFlux.H | 3 + Source/Initialization/InjectorMomentum.H | 24 +++---- Source/Initialization/InjectorPosition.H | 8 ++- Source/Initialization/PlasmaInjector.H | 7 ++ Source/Initialization/VelocityProperties.cpp | 5 +- Source/Laser/LaserProfiles.H | 24 ++++--- .../BackgroundMCC/BackgroundMCCCollision.H | 7 +- .../Collision/BackgroundMCC/MCCProcess.H | 9 +-- .../BackgroundStopping/BackgroundStopping.H | 7 +- .../BinaryCollision/BinaryCollision.H | 7 +- .../Coulomb/PairWiseCoulombCollisionFunc.H | 9 +-- .../NuclearFusion/NuclearFusionFunc.H | 13 ++-- Source/Particles/Collision/CollisionBase.H | 1 + Source/Particles/Collision/CollisionBase.cpp | 6 +- .../ElementaryProcess/Ionization.cpp | 23 +++---- .../ElementaryProcess/QEDPairGeneration.cpp | 11 ++-- .../ElementaryProcess/QEDPhotonEmission.cpp | 15 +++-- Source/Particles/LaserParticleContainer.H | 24 ++++--- Source/Particles/MultiParticleContainer.H | 5 ++ .../NamedComponentParticleContainer.H | 2 +- Source/Particles/ParticleCreation/SmartCopy.H | 20 +++--- .../Particles/ParticleCreation/SmartCreate.H | 12 ++-- Source/Particles/PhotonParticleContainer.H | 19 ++++-- Source/Particles/PhysicalParticleContainer.H | 29 ++++---- .../Particles/PhysicalParticleContainer.cpp | 15 ++++- .../Particles/Resampling/LevelingThinning.H | 2 +- Source/Particles/Resampling/Resampling.H | 9 +++ .../RigidInjectedParticleContainer.H | 21 ++++-- Source/Particles/Sorting/SortingUtils.H | 42 ++++++------ Source/Particles/WarpXParticleContainer.H | 11 +++- Source/Utils/Parser/IntervalsParser.cpp | 4 +- Source/WarpX.H | 15 ++--- Source/ablastr/parallelization/KernelTimer.H | 5 ++ Source/ablastr/profiler/ProfilerWrapper.H | 6 ++ Source/ablastr/warn_manager/WarnManager.H | 19 +++++- 116 files changed, 604 insertions(+), 379 deletions(-) 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/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/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..2b5c2362ec9 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) 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.cpp b/Source/Diagnostics/FullDiagnostics.cpp index 6848f9e1a18..c1c8f270bca 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 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/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/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..b1a3ac7b0c8 100644 --- a/Source/Initialization/InjectorMomentum.H +++ b/Source/Initialization/InjectorMomentum.H @@ -229,17 +229,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 +258,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 +584,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.cpp b/Source/Particles/ElementaryProcess/Ionization.cpp index 8fcb953e9ff..98b49888d9d 100644 --- a/Source/Particles/ElementaryProcess/Ionization.cpp +++ b/Source/Particles/ElementaryProcess/Ionization.cpp @@ -30,18 +30,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); @@ -69,9 +70,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 31aafbb1379..de027152be7 100644 --- a/Source/Particles/ElementaryProcess/QEDPairGeneration.cpp +++ b/Source/Particles/ElementaryProcess/QEDPairGeneration.cpp @@ -26,8 +26,11 @@ PairGenerationTransformFunc (BreitWheelerGeneratePairs const generate_functor, amrex::FArrayBox const& bxfab, amrex::FArrayBox const& byfab, amrex::FArrayBox const& bzfab, - 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; @@ -59,9 +62,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 a3b3c4103f7..4725f3748e2 100644 --- a/Source/Particles/ElementaryProcess/QEDPhotonEmission.cpp +++ b/Source/Particles/ElementaryProcess/QEDPhotonEmission.cpp @@ -27,10 +27,13 @@ PhotonEmissionTransformFunc (QuantumSynchrotronGetOpticalDepth opt_depth_functor amrex::FArrayBox const& bxfab, amrex::FArrayBox const& byfab, amrex::FArrayBox const& bzfab, - 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; @@ -62,9 +65,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/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/MultiParticleContainer.H b/Source/Particles/MultiParticleContainer.H index 16817cbec07..64ce057e2ff 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 632e3fca85b..7163f506ff8 100644 --- a/Source/Particles/PhysicalParticleContainer.cpp +++ b/Source/Particles/PhysicalParticleContainer.cpp @@ -144,12 +144,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 2d3ba230bf1..3e3a43095e3 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; @@ -462,8 +468,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/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(); From 8af2c31353193df69f29b5bcf3205adda1ba29e8 Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Thu, 26 Oct 2023 11:00:33 -0700 Subject: [PATCH 20/25] Fix External AMReX Builds (#4390) - print version - make AMReX external if pyAMReX is external - new AMReX 23.11+ installed CMake module paths for CMake scripts - `TINYP` is not really required for external packages and thus should not fail if configured not to be used --- .../ReducedDiags/FieldProbeParticleContainer.cpp | 1 - Source/Particles/LaserParticleContainer.cpp | 1 - Source/Particles/PhysicalParticleContainer.cpp | 1 - Source/Particles/WarpXParticleContainer.cpp | 1 - cmake/dependencies/AMReX.cmake | 14 +++++++++++++- cmake/dependencies/pyAMReX.cmake | 2 +- 6 files changed, 14 insertions(+), 6 deletions(-) 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/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/PhysicalParticleContainer.cpp b/Source/Particles/PhysicalParticleContainer.cpp index 7163f506ff8..47898a0344d 100644 --- a/Source/Particles/PhysicalParticleContainer.cpp +++ b/Source/Particles/PhysicalParticleContainer.cpp @@ -83,7 +83,6 @@ #include #include #include -#include #include #include #include diff --git a/Source/Particles/WarpXParticleContainer.cpp b/Source/Particles/WarpXParticleContainer.cpp index df3938ec909..6109cd830f9 100644 --- a/Source/Particles/WarpXParticleContainer.cpp +++ b/Source/Particles/WarpXParticleContainer.cpp @@ -58,7 +58,6 @@ #include #include #include -#include #include diff --git a/cmake/dependencies/AMReX.cmake b/cmake/dependencies/AMReX.cmake index fbdd39e4f43..99ef5c5e263 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.10 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() diff --git a/cmake/dependencies/pyAMReX.cmake b/cmake/dependencies/pyAMReX.cmake index 2ff354785da..c94a41e838d 100644 --- a/cmake/dependencies/pyAMReX.cmake +++ b/cmake/dependencies/pyAMReX.cmake @@ -65,7 +65,7 @@ function(find_pyamrex) elseif(NOT WarpX_pyamrex_internal) # TODO: MPI control find_package(pyAMReX 23.10 CONFIG REQUIRED) - message(STATUS "pyAMReX: Found version '${pyamrex_VERSION}'") + message(STATUS "pyAMReX: Found version '${pyAMReX_VERSION}'") endif() endfunction() From ed13486ac0495b049958989022a9c76e8ef8f042 Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Fri, 27 Oct 2023 09:02:06 -0700 Subject: [PATCH 21/25] CI: setup-python < 3.12 Requires #2821 --- .github/workflows/cuda.yml | 2 +- .github/workflows/windows.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cuda.yml b/.github/workflows/cuda.yml index d3610179695..8eaccd7a2ef 100644 --- a/.github/workflows/cuda.yml +++ b/.github/workflows/cuda.yml @@ -27,7 +27,7 @@ jobs: - uses: actions/setup-python@v4 name: Install Python with: - python-version: '3.x' + python-version: '3.10' - name: install dependencies run: | .github/workflows/dependencies/nvcc11-3.sh diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index e0629e3abca..83160f0a8fa 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -15,7 +15,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 with: - python-version: '3.x' + python-version: '3.10' - name: CCache Cache uses: actions/cache@v3 # - once stored under a key, they become immutable (even if local cache path content changes) @@ -64,7 +64,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 From 8e4b7e811febdc9fd08670b39c21c58ca7ba076a Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Fri, 27 Oct 2023 09:02:40 -0700 Subject: [PATCH 22/25] Doc: Python Backtrace in CXX Segfaults (#4391) Document the workflow to find out which last Python line was called if the code crashes in the CXX part for PICMI runs. --- Docs/source/usage/workflows/debugging.rst | 3 +++ 1 file changed, 3 insertions(+) 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. From dae7987c220aa29314d47b0d49c84fbd243bc9fb Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Mon, 30 Oct 2023 13:09:51 -0700 Subject: [PATCH 23/25] AMReX/pyAMReX/PICSAR: Weekly Update (#4396) * AMReX: Weekly Update * New Tool: `Release/updatepyAMReX.py` * pyAMReX: Weekly Update --- .github/workflows/cuda.yml | 2 +- Docs/source/maintenance/release.rst | 2 + Regression/WarpX-GPU-tests.ini | 2 +- Regression/WarpX-tests.ini | 2 +- Tools/Release/updatepyAMReX.py | 124 ++++++++++++++++++++++++++++ cmake/dependencies/AMReX.cmake | 2 +- cmake/dependencies/pyAMReX.cmake | 2 +- run_test.sh | 2 +- 8 files changed, 132 insertions(+), 6 deletions(-) create mode 100755 Tools/Release/updatepyAMReX.py diff --git a/.github/workflows/cuda.yml b/.github/workflows/cuda.yml index 8eaccd7a2ef..bdceac7a7c7 100644 --- a/.github/workflows/cuda.yml +++ b/.github/workflows/cuda.yml @@ -111,7 +111,7 @@ 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 be6c6415467d09da6109d27cfa218868abc1f9db && 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: 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/Regression/WarpX-GPU-tests.ini b/Regression/WarpX-GPU-tests.ini index 17d98e4b76d..1e5f2a7a619 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 = be6c6415467d09da6109d27cfa218868abc1f9db [source] dir = /home/regtester/git/WarpX diff --git a/Regression/WarpX-tests.ini b/Regression/WarpX-tests.ini index 6f08f34bc2c..14896aff17e 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 = be6c6415467d09da6109d27cfa218868abc1f9db [source] dir = /home/regtester/AMReX_RegTesting/warpx diff --git a/Tools/Release/updatepyAMReX.py b/Tools/Release/updatepyAMReX.py new file mode 100755 index 00000000000..94fde0df1cc --- /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\(AMReX\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/cmake/dependencies/AMReX.cmake b/cmake/dependencies/AMReX.cmake index 99ef5c5e263..c03ea1ba828 100644 --- a/cmake/dependencies/AMReX.cmake +++ b/cmake/dependencies/AMReX.cmake @@ -269,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 "be6c6415467d09da6109d27cfa218868abc1f9db" CACHE STRING "Repository branch for WarpX_amrex_repo if(WarpX_amrex_internal)") diff --git a/cmake/dependencies/pyAMReX.cmake b/cmake/dependencies/pyAMReX.cmake index c94a41e838d..13b84ee3522 100644 --- a/cmake/dependencies/pyAMReX.cmake +++ b/cmake/dependencies/pyAMReX.cmake @@ -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 "056d332d68fa98b9e9509d05ec3b1a3d8ef37673" CACHE STRING "Repository branch for WarpX_pyamrex_repo if(WarpX_pyamrex_internal)") diff --git a/run_test.sh b/run_test.sh index 2e86618f2f2..78e9c4e3bda 100755 --- a/run_test.sh +++ b/run_test.sh @@ -71,7 +71,7 @@ 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 be6c6415467d09da6109d27cfa218868abc1f9db && 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 From 996ea31ffe218c91949717b9e7cc6475dd4ae7ee Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Mon, 30 Oct 2023 16:31:14 -0700 Subject: [PATCH 24/25] Docs: Add Particles-in-PML Paper (#4398) Add paper: "Absorption of charged particles in perfectly matched layers by optimal damping of the deposited current" (2022). --- Docs/source/acknowledge_us.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Docs/source/acknowledge_us.rst b/Docs/source/acknowledge_us.rst index 2c0b1ce35f2..534a314298f 100644 --- a/Docs/source/acknowledge_us.rst +++ b/Docs/source/acknowledge_us.rst @@ -75,6 +75,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 `__ From f6cb58d795bc4024222a8a19f30abb27b2deb687 Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Tue, 31 Oct 2023 03:14:52 -0700 Subject: [PATCH 25/25] Doc: Fix IPAC23 DOI (#4399) Changed since preprint. --- Docs/source/acknowledge_us.rst | 5 ++--- Docs/source/highlights.rst | 7 +++---- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/Docs/source/acknowledge_us.rst b/Docs/source/acknowledge_us.rst index 534a314298f..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**. diff --git a/Docs/source/highlights.rst b/Docs/source/highlights.rst index 1e99629b9c2..2fb5fd49263 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**.