|
23 | 23 | #pragma once |
24 | 24 |
|
25 | 25 | #include "simulation_defines.hpp" |
| 26 | +#include "fields/Fields.def" |
26 | 27 | #include "math/Vector.hpp" |
27 | 28 |
|
28 | 29 | namespace picongpu |
29 | 30 | { |
30 | | -using namespace PMacc; |
31 | 31 | namespace emfCenteredCell |
32 | 32 | { |
33 | | - |
34 | | -// ___________posE____________ |
35 | | -const float_X posE_x_x = 0.5; |
36 | | -const float_X posE_x_y = 0.5; |
37 | | -const float_X posE_x_z = 0.5; |
38 | | - |
39 | | -const float_X posE_y_x = 0.5; |
40 | | -const float_X posE_y_y = 0.5; |
41 | | -const float_X posE_y_z = 0.5; |
42 | | - |
43 | | -const float_X posE_z_x = 0.5; |
44 | | -const float_X posE_z_y = 0.5; |
45 | | -const float_X posE_z_z = 0.5; |
46 | | - |
47 | | -// ___________posB____________ |
48 | | -const float_X posB_x_x = 0.5; |
49 | | -const float_X posB_x_y = 0.5; |
50 | | -const float_X posB_x_z = 0.5; |
51 | | - |
52 | | -const float_X posB_y_x = 0.5; |
53 | | -const float_X posB_y_y = 0.5; |
54 | | -const float_X posB_y_z = 0.5; |
55 | | - |
56 | | -const float_X posB_z_x = 0.5; |
57 | | -const float_X posB_z_y = 0.5; |
58 | | -const float_X posB_z_z = 0.5; |
59 | | - |
60 | | -// ___________posJ____________ |
61 | | -const float_X posJ_x_x = 0.5; |
62 | | -const float_X posJ_x_y = 0.0; |
63 | | -const float_X posJ_x_z = 0.0; |
64 | | - |
65 | | -const float_X posJ_y_x = 0.0; |
66 | | -const float_X posJ_y_y = 0.5; |
67 | | -const float_X posJ_y_z = 0.0; |
68 | | - |
69 | | -const float_X posJ_z_x = 0.0; |
70 | | -const float_X posJ_z_y = 0.0; |
71 | | -const float_X posJ_z_z = 0.5; |
72 | | - |
73 | | -/** \todo posRho for FieldTmp depositions |
74 | | -const float_X posRho_x_x = 0.0; ? or at center pos ? |
75 | | -const float_X posRho_x_y = 0.0; ? |
76 | | -const float_X posRho_x_z = 0.0; ? |
77 | | -
|
78 | | -const float_X posRho_y_x = 0.0; ? |
79 | | -const float_X posRho_y_y = 0.0; ? |
80 | | -const float_X posRho_y_z = 0.0; ? |
81 | | -
|
82 | | -const float_X posRho_z_x = 0.0; ? |
83 | | -const float_X posRho_z_y = 0.0; ? |
84 | | -const float_X posRho_z_z = 0.0; ? |
85 | | -*/ |
86 | | - |
87 | | -struct EMFCenteredCell |
| 33 | +namespace traits |
88 | 34 | { |
89 | 35 | /** \tparam floatD_X position of the component in the cell |
90 | | - * \tparam DIM3 Fields (E/B) have 3 components, even in 1 or 2D ! */ |
91 | | - typedef ::PMacc::math::Vector<floatD_X,DIM3> VectorVector; |
92 | | - |
93 | | - static HDINLINE VectorVector getEFieldPosition() |
| 36 | + * \tparam DIM3 Fields (E/B/J) have 3 components, even in 1 or 2D ! |
| 37 | + */ |
| 38 | + typedef const ::PMacc::math::Vector<float2_X,DIM3> VectorVector2D3V; |
| 39 | + typedef const ::PMacc::math::Vector<float3_X,DIM3> VectorVector3D3V; |
| 40 | + |
| 41 | + template<typename T_Field, uint32_t T_simDim = simDim> |
| 42 | + struct FieldPosition; |
| 43 | + |
| 44 | + /** position (floatD_X in case of T_simDim == simDim) in cell for |
| 45 | + * E_x, E_y, E_z |
| 46 | + */ |
| 47 | + template<uint32_t T_simDim> |
| 48 | + struct FieldPosition<FieldE, T_simDim> |
94 | 49 | { |
95 | | -#if( SIMDIM == DIM3 ) |
96 | | - const float3_X posE_x(posE_x_x, posE_x_y, posE_x_z); |
97 | | - const float3_X posE_y(posE_y_x, posE_y_y, posE_y_z); |
98 | | - const float3_X posE_z(posE_z_x, posE_z_y, posE_z_z); |
99 | | -#elif( SIMDIM == DIM2 ) |
100 | | - const float2_X posE_x(posE_x_x, posE_x_y); |
101 | | - const float2_X posE_y(posE_y_x, posE_y_y); |
102 | | - const float2_X posE_z(posE_z_x, posE_z_y); |
103 | | -#endif |
104 | | - |
105 | | - /** position (floatD_x) in cell for E_x, E_y, E_z */ |
106 | | - return VectorVector(posE_x, posE_y, posE_z); |
107 | | - } |
108 | | - |
109 | | - static HDINLINE VectorVector getBFieldPosition() |
| 50 | + typedef PMacc::math::Vector<float_X, T_simDim> PosType; |
| 51 | + typedef const PMacc::math::Vector<PosType, DIM3> ReturnType; |
| 52 | + |
| 53 | + /// boost::result_of hints |
| 54 | + template<class> struct result; |
| 55 | + |
| 56 | + template<class F> |
| 57 | + struct result<F()> { |
| 58 | + typedef ReturnType type; |
| 59 | + }; |
| 60 | + |
| 61 | + HDINLINE ReturnType operator()() const |
| 62 | + { |
| 63 | + const PMACC_AUTO(center, PosType::create( 0.5 )); |
| 64 | + |
| 65 | + return ReturnType::create( center ); |
| 66 | + } |
| 67 | + }; |
| 68 | + |
| 69 | + /** position (floatD_X in case of T_simDim == simDim) in cell for |
| 70 | + * B_x, B_y, B_z |
| 71 | + */ |
| 72 | + template<uint32_t T_simDim> |
| 73 | + struct FieldPosition<FieldB, T_simDim> : |
| 74 | + public FieldPosition<FieldE, T_simDim> |
110 | 75 | { |
111 | | -#if( SIMDIM == DIM3 ) |
112 | | - const float3_X posB_x(posB_x_x, posB_x_y, posB_x_z); |
113 | | - const float3_X posB_y(posB_y_x, posB_y_y, posB_y_z); |
114 | | - const float3_X posB_z(posB_z_x, posB_z_y, posB_z_z); |
115 | | -#elif( SIMDIM == DIM2 ) |
116 | | - const float2_X posB_x(posB_x_x, posB_x_y); |
117 | | - const float2_X posB_y(posB_y_x, posB_y_y); |
118 | | - const float2_X posB_z(posB_z_x, posB_z_y); |
119 | | -#endif |
120 | | - |
121 | | - /** position (floatD_x) in cell for B_x, B_y, B_z */ |
122 | | - return VectorVector(posB_x, posB_y, posB_z); |
123 | | - } |
124 | | - |
125 | | - static HDINLINE VectorVector getJFieldPosition() |
| 76 | + HDINLINE FieldPosition() |
| 77 | + { |
| 78 | + } |
| 79 | + }; |
| 80 | + |
| 81 | + /** position (float2_X) in cell for J_x, J_y, J_z */ |
| 82 | + template<> |
| 83 | + struct FieldPosition<FieldJ, DIM2> |
126 | 84 | { |
127 | | -#if( SIMDIM == DIM3 ) |
128 | | - const float3_X posJ_x(posJ_x_x, posJ_x_y, posJ_x_z); |
129 | | - const float3_X posJ_y(posJ_y_x, posJ_y_y, posJ_y_z); |
130 | | - const float3_X posJ_z(posJ_z_x, posJ_z_y, posJ_z_z); |
131 | | -#elif( SIMDIM == DIM2 ) |
132 | | - const float2_X posJ_x(posJ_x_x, posJ_x_y); |
133 | | - const float2_X posJ_y(posJ_y_x, posJ_y_y); |
134 | | - const float2_X posJ_z(posJ_z_x, posJ_z_y); |
135 | | -#endif |
136 | | - |
137 | | - /** position (floatD_x) in cell for J_x, J_y, J_z */ |
138 | | - return VectorVector(posJ_x, posJ_y, posJ_z); |
139 | | - } |
140 | | - |
141 | | -}; |
142 | | - |
| 85 | + /// boost::result_of hints |
| 86 | + template<class> struct result; |
| 87 | + |
| 88 | + template<class F> |
| 89 | + struct result<F()> { |
| 90 | + typedef VectorVector2D3V type; |
| 91 | + }; |
| 92 | + |
| 93 | + HDINLINE VectorVector2D3V operator()() const |
| 94 | + { |
| 95 | + const float2_X posJ_x( 0.5, 0.0 ); |
| 96 | + const float2_X posJ_y( 0.0, 0.5 ); |
| 97 | + const float2_X posJ_z( 0.0, 0.0 ); |
| 98 | + |
| 99 | + return VectorVector2D3V( posJ_x, posJ_y, posJ_z ); |
| 100 | + } |
| 101 | + }; |
| 102 | + |
| 103 | + /** position (float3_X) in cell for J_x, J_y, J_z |
| 104 | + */ |
| 105 | + template<> |
| 106 | + struct FieldPosition<FieldJ, DIM3> |
| 107 | + { |
| 108 | + /// boost::result_of hints |
| 109 | + template<class> struct result; |
| 110 | + |
| 111 | + template<class F> |
| 112 | + struct result<F()> { |
| 113 | + typedef VectorVector3D3V type; |
| 114 | + }; |
| 115 | + |
| 116 | + HDINLINE VectorVector3D3V operator()() const |
| 117 | + { |
| 118 | + const float3_X posJ_x( 0.5, 0.0, 0.0 ); |
| 119 | + const float3_X posJ_y( 0.0, 0.5, 0.0 ); |
| 120 | + const float3_X posJ_z( 0.0, 0.0, 0.5 ); |
| 121 | + |
| 122 | + return VectorVector3D3V( posJ_x, posJ_y, posJ_z ); |
| 123 | + } |
| 124 | + }; |
| 125 | + |
| 126 | + /** position (floatD_X in case of T_simDim == simDim) in cell for the |
| 127 | + * scalar field FieldTmp |
| 128 | + */ |
| 129 | + template<uint32_t T_simDim> |
| 130 | + struct FieldPosition<FieldTmp, T_simDim> |
| 131 | + { |
| 132 | + typedef PMacc::math::Vector<float_X, T_simDim> ReturnType; |
| 133 | + |
| 134 | + /// boost::result_of hints |
| 135 | + template<class> struct result; |
| 136 | + |
| 137 | + template<class F> |
| 138 | + struct result<F()> { |
| 139 | + typedef ReturnType type; |
| 140 | + }; |
| 141 | + |
| 142 | + HDINLINE ReturnType operator()() const |
| 143 | + { |
| 144 | + return ReturnType::create( 0.0 ); |
| 145 | + } |
| 146 | + }; |
| 147 | +} // traits |
143 | 148 | } // emfCenteredCell |
144 | 149 | } // picongpu |
0 commit comments