IPPL (Independent Parallel Particle Layer)
IPPL
Loading...
Searching...
No Matches
FieldOperations.hpp
Go to the documentation of this file.
1//
2// File FieldOperations
3// Differential operators for fields
4//
5
6namespace ippl {
11 template <typename Field>
13 constexpr unsigned Dim = Field::dim;
14
15 u.fillHalo();
16 BConds<Field, Dim>& bcField = u.getFieldBC();
17 bcField.apply(u);
18
19 using mesh_type = typename Field::Mesh_t;
20 using vector_type = typename mesh_type::vector_type;
21
22 mesh_type& mesh = u.get_mesh();
23 vector_type vectors[Dim];
24 for (unsigned d = 0; d < Dim; d++) {
25 vectors[d] = 0;
26 vectors[d][d] = 0.5 / mesh.getMeshSpacing(d);
27 }
28 return detail::meta_grad<Field>(u, vectors);
29 }
30
35 template <typename Field>
37 constexpr unsigned Dim = Field::dim;
38
39 u.fillHalo();
40 BConds<Field, Dim>& bcField = u.getFieldBC();
41 bcField.apply(u);
42
43 using mesh_type = typename Field::Mesh_t;
44 using vector_type = typename mesh_type::vector_type;
45
46 mesh_type& mesh = u.get_mesh();
47 vector_type vectors[Dim];
48 for (unsigned d = 0; d < Dim; d++) {
49 vectors[d] = 0;
50 vectors[d][d] = 0.5 / mesh.getMeshSpacing(d);
51 }
52 return detail::meta_div<Field>(u, vectors);
53 }
54
59 template <typename Field>
61 constexpr unsigned Dim = Field::dim;
62
63 u.fillHalo();
64 BConds<Field, Dim>& bcField = u.getFieldBC();
65 bcField.apply(u);
66
67 using mesh_type = typename Field::Mesh_t;
68 mesh_type& mesh = u.get_mesh();
69 typename mesh_type::vector_type hvector(0);
70 for (unsigned d = 0; d < Dim; d++) {
71 hvector[d] = 1.0 / std::pow(mesh.getMeshSpacing(d), 2);
72 }
73 return detail::meta_laplace<Field>(u, hvector);
74 }
75
80 template <typename Field>
82 constexpr unsigned Dim = Field::dim;
83
84 u.fillHalo();
85 BConds<Field, Dim>& bcField = u.getFieldBC();
86 bcField.apply(u);
87
88 using mesh_type = typename Field::Mesh_t;
89 mesh_type& mesh = u.get_mesh();
90 typename mesh_type::vector_type xvector(0);
91 xvector[0] = 1.0;
92 typename mesh_type::vector_type yvector(0);
93 yvector[1] = 1.0;
94 typename mesh_type::vector_type zvector(0);
95 zvector[2] = 1.0;
96 typename mesh_type::vector_type hvector(0);
97 hvector = mesh.getMeshSpacing();
98 return detail::meta_curl<Field>(u, xvector, yvector, zvector, hvector);
99 }
100
105 template <typename Field>
107 constexpr unsigned Dim = Field::dim;
108
109 u.fillHalo();
110 BConds<Field, Dim>& bcField = u.getFieldBC();
111 bcField.apply(u);
112
113 using mesh_type = typename Field::Mesh_t;
114 using vector_type = typename mesh_type::vector_type;
115
116 mesh_type& mesh = u.get_mesh();
117 vector_type vectors[Dim];
118 for (unsigned d = 0; d < Dim; d++) {
119 vectors[d] = 0;
120 vectors[d][d] = 1;
121 }
122 auto hvector = mesh.getMeshSpacing();
123
124 return detail::meta_hess<Field>(u, vectors, hvector);
125 }
126} // namespace ippl
constexpr unsigned Dim
Definition Archive.h:20
detail::meta_div< Field > div(Field &u)
detail::meta_hess< Field > hess(Field &u)
detail::meta_grad< Field > grad(Field &u)
detail::meta_curl< Field > curl(Field &u)
detail::meta_laplace< Field > laplace(Field &u)
void apply(Field &field)
Definition BConds.hpp:29
KOKKOS_INLINE_FUNCTION Mesh_t & get_mesh() const
Definition Field.h:64
BConds_t & getFieldBC()
Definition Field.h:78
virtual KOKKOS_INLINE_FUNCTION const vector_type & getMeshSpacing() const =0