Branch data Line data Source code
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 : :
11 : : namespace ippl {
12 : :
13 : : template <typename T, unsigned Dim>
14 : : class UniformCartesian : public Mesh<T, Dim> {
15 : : public:
16 : : typedef typename Mesh<T, Dim>::vector_type vector_type;
17 : : typedef Cell DefaultCentering;
18 : :
19 : : UniformCartesian();
20 : :
21 : : UniformCartesian(const NDIndex<Dim>& ndi, const vector_type& hx, const vector_type& origin);
22 : :
23 : 588 : ~UniformCartesian() = default;
24 : :
25 : : void initialize(const NDIndex<Dim>& ndi, const vector_type& hx, const vector_type& origin);
26 : :
27 : : // Set the spacings of mesh vertex positions (recompute Dvc, cell volume):
28 : : void setMeshSpacing(const vector_type& meshSpacing);
29 : :
30 : : // Get the spacings of mesh vertex positions along specified direction
31 : : T getMeshSpacing(unsigned dim) const;
32 : :
33 : : const vector_type& getMeshSpacing() const;
34 : :
35 : : T getCellVolume() const override;
36 : : T getMeshVolume() const override;
37 : :
38 : : void updateCellVolume_m();
39 : :
40 : : // (x,y,z) coordinates of indexed vertex:
41 : 336 : vector_type getVertexPosition(const NDIndex<Dim>& ndi) const {
42 : 336 : vector_type vertexPosition;
43 [ + + ]: 1512 : for (unsigned int d = 0; d < Dim; d++)
44 : 1176 : vertexPosition(d) = ndi[d].first() * meshSpacing_m[d] + this->origin_m(d);
45 : 336 : return vertexPosition;
46 : : }
47 : :
48 : : // Vertex-vertex grid spacing of indexed cell:
49 : : vector_type getDeltaVertex(const NDIndex<Dim>& ndi) const {
50 : : vector_type vertexVertexSpacing;
51 : : for (unsigned int d = 0; d < Dim; d++)
52 : : vertexVertexSpacing[d] = meshSpacing_m[d] * ndi[d].length();
53 : : return vertexVertexSpacing;
54 : : }
55 : :
56 : : private:
57 : : vector_type meshSpacing_m; // delta-x, delta-y (>1D), delta-z (>2D)
58 : : T volume_m; // Cell length(1D), area(2D), or volume (>2D)
59 : : };
60 : :
61 : : } // namespace ippl
62 : :
63 : : #include "Meshes/UniformCartesian.hpp"
64 : :
65 : : #endif
|