LCOV - code coverage report
Current view: top level - src/Particle - ParticleLayout.hpp (source / functions) Coverage Total Hit
Test: report.info Lines: 100.0 % 24 24
Test Date: 2025-05-21 10:57:37 Functions: 92.3 % 13 12
Branches: 64.3 % 28 18

             Branch data     Line data    Source code
       1                 :             : //
       2                 :             : // Class ParticleLayout
       3                 :             : //   Base class for all particle layout classes.
       4                 :             : //
       5                 :             : //   This class is used as the generic base class for all classes
       6                 :             : //   which maintain the information on where all the particles are located
       7                 :             : //   on a parallel machine.  It is responsible for performing particle
       8                 :             : //   load balancing.
       9                 :             : //
      10                 :             : //   If more general layout information is needed, such as the global -> local
      11                 :             : //   mapping for each particle, then derived classes must provide this info.
      12                 :             : //
      13                 :             : //   When particles are created or destroyed, this class is also responsible
      14                 :             : //   for determining where particles are to be created, gathering this
      15                 :             : //   information, and recalculating the global indices of all the particles.
      16                 :             : //   For consistency, creation and destruction requests are cached, and then
      17                 :             : //   performed all in one step when the update routine is called.
      18                 :             : //
      19                 :             : //   Derived classes must provide the following:
      20                 :             : //     1) Specific version of update and loadBalance.  These are not virtual,
      21                 :             : //        as this class is used as a template parameter (instead of being
      22                 :             : //        assigned to a base class pointer).
      23                 :             : //     2) Internal storage to maintain their specific layout mechanism
      24                 :             : //     3) the definition of a class pair_iterator, and a function
      25                 :             : //        void getPairlist(int, pair_iterator&, pair_iterator&) to get a
      26                 :             : //        begin/end iterator pair to access the local neighbor of the Nth
      27                 :             : //        local atom.  This is not a virtual function, it is a requirement of
      28                 :             : //        the templated class for use in other parts of the code.
      29                 :             : //
      30                 :             : 
      31                 :             : namespace ippl {
      32                 :             :     namespace detail {
      33                 :             :         template <typename T, unsigned Dim, typename... Properties>
      34                 :         180 :         void ParticleLayout<T, Dim, Properties...>::applyBC(const particle_position_type& R,
      35                 :             :                                                             const NDRegion<T, Dim>& nr) {
      36                 :             :             /* loop over all faces
      37                 :             :              * 0: lower x-face
      38                 :             :              * 1: upper x-face
      39                 :             :              * 2: lower y-face
      40                 :             :              * 3: upper y-face
      41                 :             :              * etc...
      42                 :             :              */
      43         [ +  - ]:         180 :             Kokkos::RangePolicy<typename particle_position_type::execution_space> policy{
      44                 :         180 :                 0, (unsigned)R.getParticleCount()};
      45         [ +  + ]:        1440 :             for (unsigned face = 0; face < 2 * Dim; ++face) {
      46                 :             :                 // unsigned face = i % Dim;
      47                 :        1260 :                 unsigned d   = face / 2;
      48                 :        1260 :                 bool isUpper = face & 1;
      49   [ +  +  +  + ]:        1260 :                 switch (bcs_m[face]) {
      50                 :         252 :                     case BC::PERIODIC:
      51                 :             :                         // Periodic faces come in pairs and the application of
      52                 :             :                         // BCs checks both sides, so there is no reason to
      53                 :             :                         // apply periodic conditions twice
      54         [ +  + ]:         252 :                         if (isUpper) {
      55                 :         126 :                             break;
      56                 :             :                         }
      57                 :             : 
      58   [ +  -  +  - ]:         126 :                         Kokkos::parallel_for("Periodic BC", policy,
      59         [ +  - ]:         252 :                                              PeriodicBC(R.getView(), nr, d, isUpper));
      60                 :         126 :                         break;
      61                 :         168 :                     case BC::REFLECTIVE:
      62   [ +  -  +  - ]:         168 :                         Kokkos::parallel_for("Reflective BC", policy,
      63         [ +  - ]:         336 :                                              ReflectiveBC(R.getView(), nr, d, isUpper));
      64                 :         168 :                         break;
      65                 :         168 :                     case BC::SINK:
      66   [ +  -  +  - ]:         168 :                         Kokkos::parallel_for("Sink BC", policy,
      67         [ +  - ]:         336 :                                              SinkBC(R.getView(), nr, d, isUpper));
      68                 :         168 :                         break;
      69                 :         672 :                     case BC::NO:
      70                 :             :                     default:
      71                 :         672 :                         break;
      72                 :             :                 }
      73                 :             :             }
      74                 :         180 :         }
      75                 :             :     }  // namespace detail
      76                 :             : }  // namespace ippl
        

Generated by: LCOV version 2.0-1