IPPL (Independent Parallel Particle Layer)
IPPL
Loading...
Searching...
No Matches
UniformCartesian.h
Go to the documentation of this file.
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
9#include "Meshes/Mesh.h"
10
11namespace ippl {
12
13 template <typename T, unsigned Dim>
14 class UniformCartesian : public Mesh<T, Dim> {
15 public:
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
71
72#endif
constexpr unsigned Dim
Definition Archive.h:20
KOKKOS_INLINE_FUNCTION Vector< int, Dim > first() const
Definition NDIndex.hpp:170
Vector< T, Dim > vector_type
Definition Mesh.h:22
KOKKOS_INLINE_FUNCTION Mesh()
Definition Mesh.h:25
vector_type origin_m
Definition Mesh.h:60
KOKKOS_INLINE_FUNCTION UniformCartesian()
KOKKOS_INLINE_FUNCTION T getMeshVolume() const override
KOKKOS_INLINE_FUNCTION void setMeshSpacing(const vector_type &meshSpacing)
KOKKOS_INLINE_FUNCTION vector_type getVertexPosition(const NDIndex< Dim > &ndi) const override
KOKKOS_INLINE_FUNCTION ~UniformCartesian()=default
Mesh< double, Dim >::vector_type vector_type
KOKKOS_INLINE_FUNCTION void updateCellVolume_m()
KOKKOS_INLINE_FUNCTION T getCellVolume() const override
KOKKOS_INLINE_FUNCTION vector_type getDeltaVertex(const NDIndex< Dim > &ndi) 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)
KOKKOS_INLINE_FUNCTION UniformCartesian(const NDIndex< Dim > &ndi, const vector_type &hx, const vector_type &origin)