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 86 : 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 642 : 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 132 : void setFieldBC(BConds_t& bc) {
59 132 : bc_m = bc;
60 132 : bc_m.findBCNeighbors(*this);
61 132 : }
62 :
63 : // Access to the mesh
64 218 : 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 86 : 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:
|