LCOV - code coverage report
Current view: top level - src/Field - Field.hpp (source / functions) Coverage Total Hit
Test: final_report.info Lines: 89.7 % 29 26
Test Date: 2025-07-19 00:25:23 Functions: 67.7 % 130 88

            Line data    Source code
       1              : //
       2              : // Class Field
       3              : //   BareField with a mesh and configurable boundary conditions
       4              : //
       5              : //
       6              : 
       7              : namespace ippl {
       8              :     namespace detail {
       9              :         template <typename T, unsigned Dim, class Mesh, class Centering, class... ViewArgs>
      10              :         struct isExpression<Field<T, Dim, Mesh, Centering, ViewArgs...>> : std::true_type {};
      11              :     }  // namespace detail
      12              : 
      13              :     //////////////////////////////////////////////////////////////////////////
      14              :     // A default constructor, which should be used only if the user calls the
      15              :     // 'initialize' function before doing anything else.  There are no special
      16              :     // checks in the rest of the Field methods to check that the Field has
      17              :     // been properly initialized
      18              :     template <class T, unsigned Dim, class Mesh, class Centering, class... ViewArgs>
      19           48 :     Field<T, Dim, Mesh, Centering, ViewArgs...>::Field()
      20              :         : BareField_t()
      21           48 :         , mesh_m(nullptr)
      22           56 :         , bc_m() {}
      23              : 
      24              :     template <class T, unsigned Dim, class Mesh, class Centering, class... ViewArgs>
      25              :     Field<T, Dim, Mesh, Centering, ViewArgs...>
      26           24 :     Field<T, Dim, Mesh, Centering, ViewArgs...>::deepCopy() const {
      27           24 :         Field<T, Dim, Mesh, Centering, ViewArgs...> copy(*mesh_m, this->getLayout(),
      28              :                                                          this->getNghost());
      29           24 :         Kokkos::deep_copy(copy.getView(), this->getView());
      30              : 
      31           24 :         return copy;
      32            0 :     }
      33              : 
      34              :     //////////////////////////////////////////////////////////////////////////
      35              :     // Constructors which include a Mesh object as argument
      36              :     template <class T, unsigned Dim, class Mesh, class Centering, class... ViewArgs>
      37         1100 :     Field<T, Dim, Mesh, Centering, ViewArgs...>::Field(Mesh_t& m, Layout_t& l, int nghost)
      38              :         : BareField_t(l, nghost)
      39         1100 :         , mesh_m(&m) {
      40         8396 :         for (unsigned int face = 0; face < 2 * Dim; ++face) {
      41         7296 :             bc_m[face] =
      42        14592 :                 std::make_shared<NoBcFace<Field<T, Dim, Mesh, Centering, ViewArgs...>>>(face);
      43              :         }
      44         1100 :     }
      45              : 
      46              :     //////////////////////////////////////////////////////////////////////////
      47              :     // Initialize the Field, also specifying a mesh
      48              :     template <class T, unsigned Dim, class Mesh, class Centering, class... ViewArgs>
      49           48 :     void Field<T, Dim, Mesh, Centering, ViewArgs...>::initialize(Mesh_t& m, Layout_t& l,
      50              :                                                                  int nghost) {
      51           48 :         BareField_t::initialize(l, nghost);
      52           48 :         mesh_m = &m;
      53          384 :         for (unsigned int face = 0; face < 2 * Dim; ++face) {
      54          336 :             bc_m[face] =
      55          672 :                 std::make_shared<NoBcFace<Field<T, Dim, Mesh, Centering, ViewArgs...>>>(face);
      56              :         }
      57           48 :     }
      58              : 
      59              :     template <class T, unsigned Dim, class Mesh, class Centering, class... ViewArgs>
      60           48 :     T Field<T, Dim, Mesh, Centering, ViewArgs...>::getVolumeIntegral() const {
      61           48 :         typename Mesh::value_type dV = mesh_m->getCellVolume();
      62           48 :         return this->sum() * dV;
      63              :     }
      64              : 
      65              :     template <class T, unsigned Dim, class Mesh, class Centering, class... ViewArgs>
      66            0 :     T Field<T, Dim, Mesh, Centering, ViewArgs...>::getVolumeAverage() const {
      67            0 :         return getVolumeIntegral() / mesh_m->getMeshVolume();
      68              :     }
      69              : 
      70              :     template <class T, unsigned Dim, class Mesh, class Centering, class... ViewArgs>
      71           96 :     void Field<T, Dim, Mesh, Centering, ViewArgs...>::updateLayout(Layout_t& l, int nghost) {
      72           96 :         BareField_t::updateLayout(l, nghost);
      73           96 :     }
      74              : 
      75              : }  // namespace ippl
        

Generated by: LCOV version 2.0-1