LCOV - code coverage report
Current view: top level - src/Field - Field.h (source / functions) Coverage Total Hit
Test: report.info Lines: 100.0 % 8 8
Test Date: 2025-05-21 16:07:51 Functions: 63.6 % 220 140

            Line data    Source code
       1              : //
       2              : // Class Field
       3              : //   BareField with a mesh and configurable boundary conditions
       4              : //
       5              : #ifndef IPPL_FIELD_H
       6              : #define IPPL_FIELD_H
       7              : 
       8              : #include "Utility/TypeUtils.h"
       9              : 
      10              : #include "Field/BareField.h"
      11              : #include "Field/BConds.h"
      12              : 
      13              : #include "Meshes/UniformCartesian.h"
      14              : 
      15              : namespace ippl {
      16              : 
      17              :     template <typename T, unsigned Dim, class Mesh, class Centering, class... ViewArgs>
      18              :     class Field : public BareField<T, Dim, ViewArgs...> {
      19              :         template <typename... Props>
      20              :         using base_type = Field<T, Dim, Mesh, Centering, Props...>;
      21              : 
      22              :     public:
      23              :         using Mesh_t      = Mesh;
      24              :         using Centering_t = Cell;
      25              :         using Layout_t    = FieldLayout<Dim>;
      26              :         using BareField_t = BareField<T, Dim, ViewArgs...>;
      27              :         using view_type   = typename BareField_t::view_type;
      28              :         using BConds_t    = BConds<Field<T, Dim, Mesh, Centering, ViewArgs...>, Dim>;
      29              : 
      30              :         using uniform_type =
      31              :             typename detail::CreateUniformType<base_type, typename view_type::uniform_type>::type;
      32              : 
      33              :         // A default constructor, which should be used only if the user calls the
      34              :         // 'initialize' function before doing anything else.  There are no special
      35              :         // checks in the rest of the Field methods to check that the Field has
      36              :         // been properly initialized.
      37              :         Field();
      38              : 
      39           90 :         Field(const Field&) = default;
      40              : 
      41              :         /*!
      42              :          * Creates a new Field with the same properties and contents
      43              :          * @return A deep copy of the field
      44              :          */
      45              :         Field deepCopy() const;
      46              : 
      47          666 :         virtual ~Field() = default;
      48              : 
      49              :         // Constructors including a Mesh object as argument:
      50              :         Field(Mesh_t&, Layout_t&, int nghost = 1);
      51              : 
      52              :         // Initialize the Field, also specifying a mesh
      53              :         void initialize(Mesh_t&, Layout_t&, int nghost = 1);
      54              : 
      55              :         // ML
      56              :         void updateLayout(Layout_t&, int nghost = 1);
      57              : 
      58          140 :         void setFieldBC(BConds_t& bc) {
      59          140 :             bc_m = bc;
      60          140 :             bc_m.findBCNeighbors(*this);
      61          140 :         }
      62              : 
      63              :         // Access to the mesh
      64          230 :         KOKKOS_INLINE_FUNCTION Mesh_t& get_mesh() const { return *mesh_m; }
      65              : 
      66              :         /*!
      67              :          * Use the midpoint rule to calculate the field's volume integral
      68              :          * @return Integral of the field over its domain
      69              :          */
      70              :         T getVolumeIntegral() const;
      71              : 
      72              :         /*!
      73              :          * Use the midpoint rule to calculate the field's volume average
      74              :          * @return Integral of the field divided by the mesh volume
      75              :          */
      76              :         T getVolumeAverage() const;
      77              : 
      78           98 :         BConds_t& getFieldBC() { return bc_m; }
      79              :         // Assignment from constants and other arrays.
      80              :         using BareField<T, Dim, ViewArgs...>::operator=;
      81              : 
      82              :     private:
      83              :         // The Mesh object, and a flag indicating if we constructed it
      84              :         Mesh_t* mesh_m;
      85              : 
      86              :         // The boundary conditions.
      87              :         BConds_t bc_m;
      88              :     };
      89              : }  // namespace ippl
      90              : 
      91              : #include "Field/Field.hpp"
      92              : #include "Field/FieldOperations.hpp"
      93              : 
      94              : #endif
      95              : 
      96              : // vi: set et ts=4 sw=4 sts=4:
      97              : // Local Variables:
      98              : // mode:c
      99              : // c-basic-offset: 4
     100              : // indent-tabs-mode: nil
     101              : // require-final-newline: nil
     102              : // End:
        

Generated by: LCOV version 2.0-1