IPPL API Reference
Independent Parallel Particle Layer C++ API
Loading...
Searching...
No Matches
UniformCartesian.h
1//
2// Class UniformCartesian
3// UniformCartesian class - represents uniform-spacing cartesian meshes.
4//
5#ifndef IPPL_UNIFORM_CARTESIAN_H
6#define IPPL_UNIFORM_CARTESIAN_H
7
8#include "Meshes/CartesianCentering.h"
9#include "Meshes/Mesh.h"
10
11namespace ippl {
12
13 template <typename T, unsigned Dim>
14 class UniformCartesian : public Mesh<T, Dim> {
15 public:
17 typedef Cell DefaultCentering;
18
19 KOKKOS_INLINE_FUNCTION UniformCartesian();
20
21 KOKKOS_INLINE_FUNCTION UniformCartesian(const NDIndex<Dim>& ndi, const vector_type& hx,
22 const vector_type& origin);
23
24 KOKKOS_INLINE_FUNCTION ~UniformCartesian() = default;
25
26 KOKKOS_INLINE_FUNCTION void initialize(const NDIndex<Dim>& ndi, const vector_type& hx,
27 const vector_type& origin);
28
29 // Set the spacings of mesh vertex positions (recompute Dvc, cell volume):
30 KOKKOS_INLINE_FUNCTION void setMeshSpacing(const vector_type& meshSpacing);
31
32 // Get the spacings of mesh vertex positions along specified direction
33 KOKKOS_INLINE_FUNCTION T getMeshSpacing(unsigned dim) const;
34
35 KOKKOS_INLINE_FUNCTION const vector_type& getMeshSpacing() const override;
36
37 KOKKOS_INLINE_FUNCTION T getCellVolume() const override;
38
39 KOKKOS_INLINE_FUNCTION T getMeshVolume() const override;
40
41 KOKKOS_INLINE_FUNCTION void updateCellVolume_m();
42
43 // (x,y,z) coordinates of indexed vertex:
44 KOKKOS_INLINE_FUNCTION vector_type
45 getVertexPosition(const NDIndex<Dim>& ndi) const override {
46 //printf("inside getVertexPosition");
47 vector_type vertexPosition;
48 for (unsigned int d = 0; d < Dim; d++) {
49 vertexPosition(d) = ndi[d].first() * meshSpacing_m[d] + this->origin_m(d);
50 //printf("vertexPos = %lf", vertexPosition(d));
51 }
52 return vertexPosition;
53 }
54
55 // Vertex-vertex grid spacing of indexed cell:
56 KOKKOS_INLINE_FUNCTION vector_type getDeltaVertex(const NDIndex<Dim>& ndi) const override {
57 vector_type vertexVertexSpacing;
58 for (unsigned int d = 0; d < Dim; d++)
59 vertexVertexSpacing[d] = meshSpacing_m[d] * ndi[d].length();
60 return vertexVertexSpacing;
61 }
62
63 private:
64 vector_type meshSpacing_m; // delta-x, delta-y (>1D), delta-z (>2D)
65 T volume_m; // Cell length(1D), area(2D), or volume (>2D)
66 };
67
68} // namespace ippl
69
70#include "Meshes/UniformCartesian.hpp"
71
72#endif
Definition Centering.h:30
Definition Mesh.h:15
Definition NDIndex.h:21
Definition UniformCartesian.h:14
KOKKOS_INLINE_FUNCTION T getMeshVolume() const override
Definition UniformCartesian.hpp:65
KOKKOS_INLINE_FUNCTION T getCellVolume() const override
Definition UniformCartesian.hpp:60
Definition Vector.h:23
Definition Archive.h:20