|
19 | 19 |
|
20 | 20 | #pragma once |
21 | 21 |
|
22 | | -#include "DirSplitting.def" |
23 | | - |
| 22 | +#include "picongpu/fields/MaxwellSolver/DirSplitting/DirSplitting.def" |
24 | 23 | #include "picongpu/simulation_defines.hpp" |
25 | | - |
26 | 24 | #include "picongpu/fields/MaxwellSolver/DirSplitting/DirSplitting.kernel" |
27 | | -#include <pmacc/dataManagement/DataConnector.hpp> |
28 | 25 | #include "picongpu/fields/FieldB.hpp" |
29 | 26 | #include "picongpu/fields/FieldE.hpp" |
| 27 | +#include "picongpu/fields/numericalCellTypes/NumericalCellTypes.hpp" |
| 28 | + |
30 | 29 | #include <pmacc/cuSTL/algorithm/kernel/ForeachBlock.hpp> |
31 | 30 | #include <pmacc/cuSTL/cursor/NestedCursor.hpp> |
32 | 31 | #include <pmacc/math/Vector.hpp> |
33 | 32 | #include <pmacc/math/vector/Int.hpp> |
34 | 33 | #include <pmacc/math/vector/TwistComponents.hpp> |
35 | 34 | #include <pmacc/math/vector/compile-time/TwistComponents.hpp> |
| 35 | +#include <pmacc/dataManagement/DataConnector.hpp> |
36 | 36 |
|
37 | 37 |
|
38 | 38 | namespace picongpu |
39 | 39 | { |
40 | | -namespace dirSplitting |
| 40 | +namespace fields |
41 | 41 | { |
42 | | -using namespace pmacc; |
43 | | - |
44 | | -/** Check Directional Splitting grid and time conditions |
45 | | - * |
46 | | - * This is a workaround that the condition check is only |
47 | | - * triggered if the current used solver is `DirSplitting` |
48 | | - */ |
49 | | -template<typename T_UsedSolver, typename T_Dummy=void> |
50 | | -struct ConditionCheck |
| 42 | +namespace maxwellSolver |
51 | 43 | { |
52 | | -}; |
53 | | - |
54 | | -template<typename T_Dummy> |
55 | | -struct ConditionCheck<DirSplitting, T_Dummy> |
| 44 | +namespace dirSplitting |
56 | 45 | { |
57 | | - /* Directional Splitting conditions: |
58 | | - * |
59 | | - * using SI units to avoid round off errors |
60 | | - * |
61 | | - * The compiler is allowed to evaluate an expression those not depends on a template parameter |
62 | | - * even if the class is never instantiated. In that case static assert is always |
63 | | - * evaluated (e.g. with clang), this results in an error if the condition is false. |
64 | | - * http://www.boost.org/doc/libs/1_60_0/doc/html/boost_staticassert.html |
| 46 | + /** Check Directional Splitting grid and time conditions |
65 | 47 | * |
66 | | - * A workaround is to add a template dependency to the expression. |
67 | | - * `sizeof(ANY_TYPE) != 0` is always true and defers the evaluation. |
| 48 | + * This is a workaround that the condition check is only |
| 49 | + * triggered if the current used solver is `DirSplitting` |
68 | 50 | */ |
69 | | - PMACC_CASSERT_MSG(DirectionSplitting_Set_dX_equal_dt_times_c____check_your_gridConfig_param_file, |
70 | | - (SI::SPEED_OF_LIGHT_SI * SI::DELTA_T_SI) == SI::CELL_WIDTH_SI && |
71 | | - (sizeof(T_Dummy) != 0)); |
72 | | - PMACC_CASSERT_MSG(DirectionSplitting_use_cubic_cells____check_your_gridConfig_param_file, |
73 | | - SI::CELL_HEIGHT_SI == SI::CELL_WIDTH_SI && |
74 | | - (sizeof(T_Dummy) != 0)); |
75 | | -#if (SIMDIM == DIM3) |
76 | | - PMACC_CASSERT_MSG(DirectionSplitting_use_cubic_cells____check_your_gridConfig_param_file, |
77 | | - SI::CELL_DEPTH_SI == SI::CELL_WIDTH_SI && |
78 | | - (sizeof(T_Dummy) != 0)); |
79 | | -#endif |
80 | | -}; |
81 | | - |
82 | | -class DirSplitting : private ConditionCheck<fieldSolver::FieldSolver> |
83 | | -{ |
84 | | -private: |
85 | | - template<typename OrientationTwist,typename CursorE, typename CursorB, typename GridSize> |
86 | | - void propagate(CursorE cursorE, CursorB cursorB, GridSize gridSize) const |
| 51 | + template<typename T_UsedSolver, typename T_Dummy = void> |
| 52 | + struct ConditionCheck |
87 | 53 | { |
88 | | - using namespace cursor::tools; |
89 | | - using namespace pmacc::math; |
90 | | - |
91 | | - auto gridSizeTwisted = twistComponents<OrientationTwist>(gridSize); |
| 54 | + }; |
92 | 55 |
|
93 | | - /* twist components of the supercell */ |
94 | | - typedef typename CT::TwistComponents<SuperCellSize, OrientationTwist>::type BlockDim; |
95 | | - |
96 | | - algorithm::kernel::ForeachBlock<BlockDim> foreach; |
97 | | - foreach(zone::SphericZone<3>(pmacc::math::Size_t<3>(BlockDim::x::value, gridSizeTwisted.y(), gridSizeTwisted.z())), |
98 | | - cursor::make_NestedCursor(twistVectorFieldAxes<OrientationTwist>(cursorE)), |
99 | | - cursor::make_NestedCursor(twistVectorFieldAxes<OrientationTwist>(cursorB)), |
100 | | - DirSplittingKernel<BlockDim>((int)gridSizeTwisted.x())); |
101 | | - } |
102 | | -public: |
103 | | - DirSplitting(MappingDesc) {} |
104 | | - |
105 | | - void update_beforeCurrent(uint32_t currentStep) const |
| 56 | + template<typename T_CurrentInterpolation, typename T_Dummy> |
| 57 | + struct ConditionCheck<DirSplitting< T_CurrentInterpolation >, T_Dummy> |
106 | 58 | { |
107 | | - typedef SuperCellSize GuardDim; |
108 | | - |
109 | | - DataConnector &dc = Environment<>::get().DataConnector(); |
110 | | - |
111 | | - auto fieldE = dc.get< FieldE >( FieldE::getName(), true ); |
112 | | - auto fieldB = dc.get< FieldB >( FieldB::getName(), true ); |
113 | | - |
114 | | - auto fieldE_coreBorder = |
115 | | - fieldE->getGridBuffer().getDeviceBuffer(). |
116 | | - cartBuffer().view(GuardDim().toRT(), |
117 | | - -GuardDim().toRT()); |
118 | | - auto fieldB_coreBorder = |
119 | | - fieldB->getGridBuffer().getDeviceBuffer(). |
120 | | - cartBuffer().view(GuardDim().toRT(), |
121 | | - -GuardDim().toRT()); |
122 | | - |
123 | | - using namespace cursor::tools; |
124 | | - using namespace pmacc::math; |
125 | | - |
126 | | - pmacc::math::Size_t<3> gridSize = fieldE_coreBorder.size(); |
127 | | - |
128 | | - |
129 | | - typedef pmacc::math::CT::Int<0,1,2> Orientation_X; |
130 | | - propagate<Orientation_X>( |
131 | | - fieldE_coreBorder.origin(), |
132 | | - fieldB_coreBorder.origin(), |
133 | | - gridSize); |
134 | | - |
135 | | - __setTransactionEvent(fieldE->asyncCommunication(__getTransactionEvent())); |
136 | | - __setTransactionEvent(fieldB->asyncCommunication(__getTransactionEvent())); |
137 | | - |
138 | | - typedef pmacc::math::CT::Int<1,2,0> Orientation_Y; |
139 | | - propagate<Orientation_Y>( |
140 | | - fieldE_coreBorder.origin(), |
141 | | - fieldB_coreBorder.origin(), |
142 | | - gridSize); |
143 | | - |
144 | | - __setTransactionEvent(fieldE->asyncCommunication(__getTransactionEvent())); |
145 | | - __setTransactionEvent(fieldB->asyncCommunication(__getTransactionEvent())); |
146 | | - |
147 | | - typedef pmacc::math::CT::Int<2,0,1> Orientation_Z; |
148 | | - propagate<Orientation_Z>( |
149 | | - fieldE_coreBorder.origin(), |
150 | | - fieldB_coreBorder.origin(), |
151 | | - gridSize); |
152 | | - |
153 | | - if (laserProfile::INIT_TIME > float_X(0.0)) |
154 | | - fieldE->laserManipulation(currentStep); |
155 | | - |
156 | | - __setTransactionEvent(fieldE->asyncCommunication(__getTransactionEvent())); |
157 | | - __setTransactionEvent(fieldB->asyncCommunication(__getTransactionEvent())); |
158 | | - |
159 | | - dc.releaseData( FieldE::getName() ); |
160 | | - dc.releaseData( FieldB::getName() ); |
161 | | - } |
162 | | - |
163 | | - void update_afterCurrent(uint32_t) const |
164 | | - { |
165 | | - DataConnector &dc = Environment<>::get().DataConnector(); |
166 | | - |
167 | | - auto fieldE = dc.get< FieldE >( FieldE::getName(), true ); |
168 | | - auto fieldB = dc.get< FieldB >( FieldB::getName(), true ); |
169 | | - |
170 | | - EventTask eRfieldE = fieldE->asyncCommunication(__getTransactionEvent()); |
171 | | - EventTask eRfieldB = fieldB->asyncCommunication(__getTransactionEvent()); |
172 | | - __setTransactionEvent(eRfieldE); |
173 | | - __setTransactionEvent(eRfieldB); |
174 | | - |
175 | | - dc.releaseData( FieldE::getName() ); |
176 | | - dc.releaseData( FieldB::getName() ); |
177 | | - } |
178 | | - |
179 | | - static pmacc::traits::StringProperty getStringProperties() |
| 59 | + /* Directional Splitting conditions: |
| 60 | + * |
| 61 | + * using SI units to avoid round off errors |
| 62 | + * |
| 63 | + * The compiler is allowed to evaluate an expression those not depends on a template parameter |
| 64 | + * even if the class is never instantiated. In that case static assert is always |
| 65 | + * evaluated (e.g. with clang), this results in an error if the condition is false. |
| 66 | + * http://www.boost.org/doc/libs/1_60_0/doc/html/boost_staticassert.html |
| 67 | + * |
| 68 | + * A workaround is to add a template dependency to the expression. |
| 69 | + * `sizeof(ANY_TYPE) != 0` is always true and defers the evaluation. |
| 70 | + */ |
| 71 | + PMACC_CASSERT_MSG(DirectionSplitting_Set_dX_equal_dt_times_c____check_your_gridConfig_param_file, |
| 72 | + (SI::SPEED_OF_LIGHT_SI * SI::DELTA_T_SI) == SI::CELL_WIDTH_SI && |
| 73 | + (sizeof(T_Dummy) != 0)); |
| 74 | + PMACC_CASSERT_MSG(DirectionSplitting_use_cubic_cells____check_your_gridConfig_param_file, |
| 75 | + SI::CELL_HEIGHT_SI == SI::CELL_WIDTH_SI && |
| 76 | + (sizeof(T_Dummy) != 0)); |
| 77 | + #if (SIMDIM == DIM3) |
| 78 | + PMACC_CASSERT_MSG(DirectionSplitting_use_cubic_cells____check_your_gridConfig_param_file, |
| 79 | + SI::CELL_DEPTH_SI == SI::CELL_WIDTH_SI && |
| 80 | + (sizeof(T_Dummy) != 0)); |
| 81 | + #endif |
| 82 | + }; |
| 83 | +} // namespace dirSplitting |
| 84 | + |
| 85 | + template< typename T_CurrentInterpolation > |
| 86 | + class DirSplitting: private dirSplitting::ConditionCheck< DirSplitting< T_CurrentInterpolation > > |
180 | 87 | { |
181 | | - pmacc::traits::StringProperty propList( "name", "DS" ); |
182 | | - return propList; |
183 | | - } |
184 | | -}; |
| 88 | + private: |
| 89 | + template<typename OrientationTwist,typename CursorE, typename CursorB, typename GridSize> |
| 90 | + void propagate(CursorE cursorE, CursorB cursorB, GridSize gridSize) const |
| 91 | + { |
| 92 | + using namespace cursor::tools; |
| 93 | + using namespace pmacc::math; |
185 | 94 |
|
186 | | -} // dirSplitting |
| 95 | + auto gridSizeTwisted = twistComponents<OrientationTwist>(gridSize); |
| 96 | + |
| 97 | + /* twist components of the supercell */ |
| 98 | + typedef typename CT::TwistComponents<SuperCellSize, OrientationTwist>::type BlockDim; |
| 99 | + |
| 100 | + algorithm::kernel::ForeachBlock<BlockDim> foreach; |
| 101 | + foreach(zone::SphericZone<3>(pmacc::math::Size_t<3>(BlockDim::x::value, gridSizeTwisted.y(), gridSizeTwisted.z())), |
| 102 | + cursor::make_NestedCursor(twistVectorFieldAxes<OrientationTwist>(cursorE)), |
| 103 | + cursor::make_NestedCursor(twistVectorFieldAxes<OrientationTwist>(cursorB)), |
| 104 | + DirSplittingKernel<BlockDim>((int)gridSizeTwisted.x())); |
| 105 | + } |
| 106 | + public: |
| 107 | + |
| 108 | + using NummericalCellType = picongpu::numericalCellTypes::EMFCenteredCell; |
| 109 | + using CurrentInterpolation = T_CurrentInterpolation; |
| 110 | + |
| 111 | + DirSplitting(MappingDesc) {} |
| 112 | + |
| 113 | + void update_beforeCurrent(uint32_t currentStep) const |
| 114 | + { |
| 115 | + typedef SuperCellSize GuardDim; |
| 116 | + |
| 117 | + DataConnector &dc = Environment<>::get().DataConnector(); |
| 118 | + |
| 119 | + auto fieldE = dc.get< FieldE >( FieldE::getName(), true ); |
| 120 | + auto fieldB = dc.get< FieldB >( FieldB::getName(), true ); |
| 121 | + |
| 122 | + auto fieldE_coreBorder = |
| 123 | + fieldE->getGridBuffer().getDeviceBuffer(). |
| 124 | + cartBuffer().view(GuardDim().toRT(), |
| 125 | + -GuardDim().toRT()); |
| 126 | + auto fieldB_coreBorder = |
| 127 | + fieldB->getGridBuffer().getDeviceBuffer(). |
| 128 | + cartBuffer().view(GuardDim().toRT(), |
| 129 | + -GuardDim().toRT()); |
| 130 | + |
| 131 | + using namespace cursor::tools; |
| 132 | + using namespace pmacc::math; |
| 133 | + |
| 134 | + pmacc::math::Size_t<3> gridSize = fieldE_coreBorder.size(); |
| 135 | + |
| 136 | + |
| 137 | + typedef pmacc::math::CT::Int<0,1,2> Orientation_X; |
| 138 | + propagate<Orientation_X>( |
| 139 | + fieldE_coreBorder.origin(), |
| 140 | + fieldB_coreBorder.origin(), |
| 141 | + gridSize); |
| 142 | + |
| 143 | + __setTransactionEvent(fieldE->asyncCommunication(__getTransactionEvent())); |
| 144 | + __setTransactionEvent(fieldB->asyncCommunication(__getTransactionEvent())); |
| 145 | + |
| 146 | + typedef pmacc::math::CT::Int<1,2,0> Orientation_Y; |
| 147 | + propagate<Orientation_Y>( |
| 148 | + fieldE_coreBorder.origin(), |
| 149 | + fieldB_coreBorder.origin(), |
| 150 | + gridSize); |
| 151 | + |
| 152 | + __setTransactionEvent(fieldE->asyncCommunication(__getTransactionEvent())); |
| 153 | + __setTransactionEvent(fieldB->asyncCommunication(__getTransactionEvent())); |
| 154 | + |
| 155 | + typedef pmacc::math::CT::Int<2,0,1> Orientation_Z; |
| 156 | + propagate<Orientation_Z>( |
| 157 | + fieldE_coreBorder.origin(), |
| 158 | + fieldB_coreBorder.origin(), |
| 159 | + gridSize); |
| 160 | + |
| 161 | + if (laserProfile::INIT_TIME > float_X(0.0)) |
| 162 | + fieldE->laserManipulation(currentStep); |
| 163 | + |
| 164 | + __setTransactionEvent(fieldE->asyncCommunication(__getTransactionEvent())); |
| 165 | + __setTransactionEvent(fieldB->asyncCommunication(__getTransactionEvent())); |
| 166 | + |
| 167 | + dc.releaseData( FieldE::getName() ); |
| 168 | + dc.releaseData( FieldB::getName() ); |
| 169 | + } |
| 170 | + |
| 171 | + void update_afterCurrent(uint32_t) const |
| 172 | + { |
| 173 | + DataConnector &dc = Environment<>::get().DataConnector(); |
| 174 | + |
| 175 | + auto fieldE = dc.get< FieldE >( FieldE::getName(), true ); |
| 176 | + auto fieldB = dc.get< FieldB >( FieldB::getName(), true ); |
| 177 | + |
| 178 | + EventTask eRfieldE = fieldE->asyncCommunication(__getTransactionEvent()); |
| 179 | + EventTask eRfieldB = fieldB->asyncCommunication(__getTransactionEvent()); |
| 180 | + __setTransactionEvent(eRfieldE); |
| 181 | + __setTransactionEvent(eRfieldB); |
| 182 | + |
| 183 | + dc.releaseData( FieldE::getName() ); |
| 184 | + dc.releaseData( FieldB::getName() ); |
| 185 | + } |
| 186 | + |
| 187 | + static pmacc::traits::StringProperty getStringProperties() |
| 188 | + { |
| 189 | + pmacc::traits::StringProperty propList( "name", "DS" ); |
| 190 | + return propList; |
| 191 | + } |
| 192 | + }; |
187 | 193 |
|
188 | | -} // picongpu |
| 194 | +} // namespace maxwellSolver |
| 195 | +} // namespace fields |
| 196 | +} // namespace picongpu |
0 commit comments