OPALX (Object Oriented Parallel Accelerator Library for Exascale) MINIorX
OPALX
Field.hpp
Go to the documentation of this file.
1//
2// Class Field
3// BareField with a mesh and configurable boundary conditions
4//
5//
6
7namespace 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
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>
20 : BareField_t()
21 , mesh_m(nullptr)
22 , bc_m() {}
23
24 template <class T, unsigned Dim, class Mesh, class Centering, class... ViewArgs>
25 Field<T, Dim, Mesh, Centering, ViewArgs...>
27 Field<T, Dim, Mesh, Centering, ViewArgs...> copy(*mesh_m, this->getLayout(),
28 this->getNghost());
29 Kokkos::deep_copy(copy.getView(), this->getView());
30
31 return copy;
32 }
33
35 // Constructors which include a Mesh object as argument
36 template <class T, unsigned Dim, class Mesh, class Centering, class... ViewArgs>
38 : BareField_t(l, nghost)
39 , mesh_m(&m) {
40 for (unsigned int face = 0; face < 2 * Dim; ++face) {
41 bc_m[face] =
42 std::make_shared<NoBcFace<Field<T, Dim, Mesh, Centering, ViewArgs...>>>(face);
43 }
44 }
47 // Initialize the Field, also specifying a mesh
48 template <class T, unsigned Dim, class Mesh, class Centering, class... ViewArgs>
50 int nghost) {
51 BareField_t::initialize(l, nghost);
52 mesh_m = &m;
53 for (unsigned int face = 0; face < 2 * Dim; ++face) {
54 bc_m[face] =
55 std::make_shared<NoBcFace<Field<T, Dim, Mesh, Centering, ViewArgs...>>>(face);
56 }
57 }
58
59 template <class T, unsigned Dim, class Mesh, class Centering, class... ViewArgs>
61 typename Mesh::value_type dV = mesh_m->getCellVolume();
62 return this->sum() * dV;
63 }
64
65 template <class T, unsigned Dim, class Mesh, class Centering, class... ViewArgs>
67 return getVolumeIntegral() / mesh_m->getMeshVolume();
68 }
69
70 template <class T, unsigned Dim, class Mesh, class Centering, class... ViewArgs>
72 BareField_t::updateLayout(l, nghost);
73 }
74
75} // namespace ippl
Implementations for FFT constructor/destructor and transforms.
Definition: Archive.h:20
void initialize(int &argc, char *argv[], MPI_Comm comm)
Definition: Ippl.cpp:16
void initialize(Mesh_t &, Layout_t &, int nghost=1)
Definition: Field.hpp:49
void updateLayout(Layout_t &, int nghost=1)
Definition: Field.hpp:71
T getVolumeAverage() const
Definition: Field.hpp:66
BConds_t bc_m
Definition: Field.h:87
Field deepCopy() const
Definition: Field.hpp:26
T getVolumeIntegral() const
Definition: Field.hpp:60
constexpr unsigned Dim