42 for (
int k = 0;
k <
WID; ++
k) {
46#if VECL == 4 && WID == 4
47 const Veci i_indices = Veci({0, 1, 2, 3});
48 const Veci j_indices = Veci({
j,
j,
j,
j});
49#elif VECL == 4 && WID == 8
50#error "__FILE__ : __LINE__ : VECL == 4 && WID == 8 cannot work!"
51#elif VECL == 8 && WID == 4
52 const Veci i_indices = Veci({0, 1, 2, 3,
54 const Veci j_indices = Veci({
j,
j,
j,
j,
55 j + 1,
j + 1,
j + 1,
j + 1});
56#elif VECL == 8 && WID == 8
57 const Veci i_indices = Veci({0, 1, 2, 3, 4, 5, 6, 7});
58 const Veci j_indices = Veci({
j,
j,
j,
j,
j,
j,
j,
j});
59#elif VECL == 16 && WID == 4
60 const Veci i_indices = Veci({0, 1, 2, 3,
64 const Veci j_indices = Veci({
j,
j,
j,
j,
65 j + 1,
j + 1,
j + 1,
j + 1,
66 j + 2,
j + 2,
j + 2,
j + 2,
67 j + 3,
j + 3,
j + 3,
j + 3});
68#elif VECL == 16 && WID == 8
69 const Veci i_indices = Veci({0, 1, 2, 3, 4, 5, 6, 7,
70 0, 1, 2, 3, 4, 5, 6, 7});
71 const Veci j_indices = Veci({
j,
j,
j,
j,
j,
j,
j,
j,
72 j+1,
j+1,
j+1,
j+1,
j+1,
j+1,
j+1,
j+1});
73#elif VECL == 16 && WID == 16
74 const Veci i_indices = Veci({0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15});
75 const Veci j_indices = Veci({
j,
j,
j,
j,
j,
j,
j,
j,
j,
j,
j,
j,
j,
j,
j,
j});
76#elif VECL == 32 && WID == 4
77#error "__FILE__ : __LINE__ : VECL == 32 && WID == 4 cannot work, too long vector for one plane!"
78#elif VECL == 32 && WID == 8
79 const Veci i_indices = Veci({0, 1, 2, 3, 4, 5, 6, 7,
80 0, 1, 2, 3, 4, 5, 6, 7,
81 0, 1, 2, 3, 4, 5, 6, 7,
82 0, 1, 2, 3, 4, 5, 6, 7});
83 const Veci j_indices = Veci({
j,
j,
j,
j,
j,
j,
j,
j,
84 j+1,
j+1,
j+1,
j+1,
j+1,
j+1,
j+1,
j+1,
85 j+2,
j+2,
j+2,
j+2,
j+2,
j+2,
j+2,
j+2,
86 j+3,
j+3,
j+3,
j+3,
j+3,
j+3,
j+3,
j+3});
87#elif VECL == 64 && WID == 4
88#error "__FILE__ : __LINE__ : VECL == 64 && WID == 4 cannot work, too long vector for one plane!"
89#elif VECL == 64 && WID == 8
90 const Veci i_indices = Veci({0, 1, 2, 3, 4, 5, 6, 7,
91 0, 1, 2, 3, 4, 5, 6, 7,
92 0, 1, 2, 3, 4, 5, 6, 7,
93 0, 1, 2, 3, 4, 5, 6, 7,
94 0, 1, 2, 3, 4, 5, 6, 7,
95 0, 1, 2, 3, 4, 5, 6, 7,
96 0, 1, 2, 3, 4, 5, 6, 7,
97 0, 1, 2, 3, 4, 5, 6, 7});
98 const Veci j_indices = Veci({
j,
j,
j,
j,
j,
j,
j,
j,
99 j+1,
j+1,
j+1,
j+1,
j+1,
j+1,
j+1,
j+1,
100 j+2,
j+2,
j+2,
j+2,
j+2,
j+2,
j+2,
j+2,
101 j+3,
j+3,
j+3,
j+3,
j+3,
j+3,
j+3,
j+3,
102 j+4,
j+4,
j+4,
j+4,
j+4,
j+4,
j+4,
j+4,
103 j+5,
j+5,
j+5,
j+5,
j+5,
j+5,
j+5,
j+5,
104 j+6,
j+6,
j+6,
j+6,
j+6,
j+6,
j+6,
j+6,
105 j+7,
j+7,
j+7,
j+7,
j+7,
j+7,
j+7,
j+7});
107#error "This VECL && This WID cannot work!"
108#define xstr(s) str(s)
110#pragma message "VECL =" xstr(VECL)
111#pragma message "WID = "xstr(WID)
114 loop_body(i_indices,j_indices,
k);
121 dccrg::Dccrg<SpatialCell,dccrg::Cartesian_Geometry>& mpiGrid,
const uint popID){
133 const Real epsilon = 0.0;
135 phiprof::Timer diffusionTimer {
"pitch-angle-diffusion"};
146 for (
size_t CellIdx = 0; CellIdx < LocalCells.size(); CellIdx++) {
148 const auto CellID = LocalCells[CellIdx];
156 Realf density_pre_adjust = 0.0;
157 Realf density_post_adjust = 0.0;
162 vectorAdd.load(&cell.
get_data(popID)[
i*VECL]);
163 vectorSum += vectorAdd;
169 Real dtTotalDiff = 0.0;
178 bool currentSpatialLoopComplete;
180 std::array<Real,3> b;
186 popID, CellIdx, currentSpatialLoopComplete,
199 Real checkCFL = std::numeric_limits<Real>::max();
202 std::fill(fmu.begin(), fmu.end(), 0.0);
203 std::fill(fcount.begin(), fcount.end(), 0);
224 const Vec
mu =
Vpara/(
normV+std::numeric_limits<Real>::min());
231 CellValue.load(&cell.
get_data(n,popID)[
WID2*
k +
WID*j_indices[0] + i_indices[0]]);
233 for (uint
i = 0;
i<VECL;
i++) {
262 const int llimit = 0;
284 if( (cRight == 0) && (cLeft != 0) ) {
287 }
else if( (cLeft == 0) && (cRight != 0) ) {
290 }
else if( (cLeft == 0) && (cRight == 0) ) {
295 MUSPACE(dfdmu2,
indv,
indmu) = ( (
MUSPACE(fmu,
indv,
indmu + cRight) -
MUSPACE(fmu,
indv,
indmu))/(cRight*
dmubins) - (
MUSPACE(fmu,
indv,
indmu) -
MUSPACE(fmu,
indv,
indmu - cLeft))/(cLeft*
dmubins) ) / (0.5 *
dmubins * (cRight + cLeft));
309 if (absdfdt > 0.0 && CellValue > Sparsity) {
320 dtTotalDiff = dtTotalDiff + Ddt;
340 const Vec
mu =
Vpara/(
normV+std::numeric_limits<Real>::min());
347 std::array<Realf,VECL>
dfdt = {0};
348 for (uint
i = 0;
i < VECL;
i++) {
355 dfdtUpdate.load(&
dfdt[0]);
359 CellValue.load(&cell.
get_data(n,popID)[
WID2*
k +
WID*j_indices[0] + i_indices[0]]);
374 vectorAdd.load(&cell.
get_data(popID)[
i*VECL]);
375 vectorSum += vectorAdd;
379 if (density_post_adjust != 0.0 && density_pre_adjust != density_post_adjust) {
380 const Vec
adjustRatio = density_pre_adjust/density_post_adjust;
383 vectorAdjust.load(&cell.
get_data(popID)[
i*VECL]);
385 vectorAdjust.store(&cell.
get_data(popID)[
i*VECL]);
void computePitchAngleDiffusionParameters(SpatialCell &cell, const uint popID, const size_t CellIdx, bool ¤tSpatialLoopComplete, Realf &sparsity, std::array< Real, 3 > &b, Real &nu0)
ObjectWrapper & getObjectWrapper()