ImpactX
PushAll.H
Go to the documentation of this file.
1 /* Copyright 2022-2023 The Regents of the University of California, through Lawrence
2  * Berkeley National Laboratory (subject to receipt of any required
3  * approvals from the U.S. Dept. of Energy). All rights reserved.
4  *
5  * This file is part of ImpactX.
6  *
7  * Authors: Axel Huebl
8  * License: BSD-3-Clause-LBNL
9  */
10 #ifndef IMPACTX_PUSH_ALL_H
11 #define IMPACTX_PUSH_ALL_H
12 
14 
15 #include <AMReX_BLProfiler.H>
16 
17 
18 namespace impactx
19 {
31  template<typename T_Element>
32  void push_all (
34  T_Element & element,
35  [[maybe_unused]] int step,
36  [[maybe_unused]] bool omp_parallel = true
37  )
38  {
39  // performance profiling per element
40  std::string const profile_name = "impactx::Push::" + std::string(T_Element::name);
41  BL_PROFILE(profile_name);
42 
43  // preparing to access reference particle data: RefPart
44  RefPart & ref_part = pc.GetRefParticle();
45 
46  // push reference particle in global coordinates
47  {
48  BL_PROFILE("impactx::Push::RefPart");
49  element(ref_part);
50  }
51 
52  // loop over refinement levels
53  int const nLevel = pc.finestLevel();
54  for (int lev = 0; lev <= nLevel; ++lev)
55  {
56  // loop over all particle boxes
58 #ifdef AMREX_USE_OMP
59 #pragma omp parallel if (amrex::Gpu::notInLaunchRegion() && omp_parallel)
60 #endif
61  for (ParIt pti(pc, lev); pti.isValid(); ++pti) {
62  // push beam particles relative to reference particle
63  element(pti, ref_part);
64  } // end loop over all particle boxes
65  } // env mesh-refinement level loop
66  }
67 
68 } // namespace impactx
69 
70 #endif // IMPACTX_PUSH_ALL_H
#define BL_PROFILE(a)
Definition: ImpactXParticleContainer.H:145
impactx::ParIter iterator
amrex iterator for particle boxes
Definition: ImpactXParticleContainer.H:148
RefPart & GetRefParticle()
Definition: ImpactXParticleContainer.cpp:204
Definition: ImpactX.cpp:35
void push_all(ImpactXParticleContainer &pc, T_Element &element, [[maybe_unused]] int step, [[maybe_unused]] bool omp_parallel=true)
Definition: PushAll.H:32
Definition: ReferenceParticle.H:30