IPPL (Independent Parallel Particle Layer)
IPPL
Loading...
Searching...
No Matches
UniformCartesian.hpp
Go to the documentation of this file.
1//
2// Class UniformCartesian
3// UniformCartesian class - represents uniform-spacing cartesian meshes.
4//
5#include "Utility/IpplInfo.h"
6#include "Utility/PAssert.h"
7
8#include "Field/BareField.h"
9#include "Field/Field.h"
10
11namespace ippl {
12
13 template <typename T, unsigned Dim>
15 : Mesh<T, Dim>()
16 , volume_m(0.0) {}
17
18 template <typename T, unsigned Dim>
20 const vector_type& hx,
21 const vector_type& origin) {
22 this->initialize(ndi, hx, origin);
23 }
24
25 template <typename T, unsigned Dim>
26 KOKKOS_INLINE_FUNCTION void UniformCartesian<T, Dim>::initialize(const NDIndex<Dim>& ndi,
27 const vector_type& hx,
28 const vector_type& origin) {
29 meshSpacing_m = hx;
31 volume_m = 1.0;
32 for (unsigned d = 0; d < Dim; ++d) {
33 this->gridSizes_m[d] = ndi[d].length();
35 }
36
37 this->setOrigin(origin);
38 }
40 template <typename T, unsigned Dim>
41 KOKKOS_INLINE_FUNCTION void UniformCartesian<T, Dim>::setMeshSpacing(
42 const vector_type& meshSpacing) {
43 meshSpacing_m = meshSpacing;
44 this->updateCellVolume_m();
45 }
46
47 template <typename T, unsigned Dim>
48 KOKKOS_INLINE_FUNCTION T UniformCartesian<T, Dim>::getMeshSpacing(unsigned dim) const {
49 PAssert_LT(dim, Dim);
50 return meshSpacing_m[dim];
51 }
52
53 template <typename T, unsigned Dim>
54 KOKKOS_INLINE_FUNCTION const typename UniformCartesian<T, Dim>::vector_type&
58
59 template <typename T, unsigned Dim>
60 KOKKOS_INLINE_FUNCTION T UniformCartesian<T, Dim>::getCellVolume() const {
61 return volume_m;
62 }
63
64 template <typename T, unsigned Dim>
65 KOKKOS_INLINE_FUNCTION T UniformCartesian<T, Dim>::getMeshVolume() const {
66 T ret = 1;
67 for (unsigned int d = 0; d < Dim; ++d) {
68 ret *= this->getGridsize(d) * this->getMeshSpacing(d);
69 }
70 return ret;
71 }
72
73 template <typename T, unsigned Dim>
74 KOKKOS_INLINE_FUNCTION void UniformCartesian<T, Dim>::updateCellVolume_m() {
75 // update cell volume
76 volume_m = 1.0;
77 for (unsigned i = 0; i < Dim; ++i) {
79 }
80 }
81
82} // namespace ippl
constexpr unsigned Dim
#define PAssert_LT(a, b)
Definition PAssert.h:125
Definition Archive.h:20
void initialize(int &argc, char *argv[], MPI_Comm comm)
Definition Ippl.cpp:16
KOKKOS_INLINE_FUNCTION Vector< size_t, Dim > length() const
Definition NDIndex.hpp:162
KOKKOS_INLINE_FUNCTION Mesh()
Definition Mesh.h:25
KOKKOS_INLINE_FUNCTION void setOrigin(const vector_type &origin)
Definition Mesh.hpp:15
KOKKOS_INLINE_FUNCTION const vector_type & getGridsize() const
Definition Mesh.hpp:20
KOKKOS_INLINE_FUNCTION UniformCartesian()
KOKKOS_INLINE_FUNCTION T getMeshVolume() const override
KOKKOS_INLINE_FUNCTION void setMeshSpacing(const vector_type &meshSpacing)
Mesh< T, Dim >::vector_type vector_type
KOKKOS_INLINE_FUNCTION void updateCellVolume_m()
KOKKOS_INLINE_FUNCTION T getCellVolume() const override
KOKKOS_INLINE_FUNCTION const vector_type & getMeshSpacing() const override
KOKKOS_INLINE_FUNCTION T getMeshSpacing(unsigned dim) const
KOKKOS_INLINE_FUNCTION void initialize(const NDIndex< Dim > &ndi, const vector_type &hx, const vector_type &origin)