123 Real in_intersection,
Real in_intersection_di,
Real in_intersection_dj,
Real in_intersection_dk,
124 const uint dimension) {
136 uint block_indices_to_id[3] = {0, 0, 0};
137 uint cell_indices_to_id[3] = {0, 0, 0};
143 if(
vmesh->size() == 0) {
147 dv =
vmesh->getCellSize()[dimension];
161 block_indices_to_id[0] =
vmesh->getGridLength()[0]*
vmesh->getGridLength()[1];
162 block_indices_to_id[1] =
vmesh->getGridLength()[0];
163 block_indices_to_id[2] = 1;
166 cell_indices_to_id[0]=
WID2;
167 cell_indices_to_id[1]=
WID;
168 cell_indices_to_id[2]=1;
179 block_indices_to_id[0]=1;
180 block_indices_to_id[1] =
vmesh->getGridLength()[0]*
vmesh->getGridLength()[1];
181 block_indices_to_id[2] =
vmesh->getGridLength()[0];
184 cell_indices_to_id[0]=1;
185 cell_indices_to_id[1]=
WID2;
186 cell_indices_to_id[2]=
WID;
190 block_indices_to_id[0]=1;
191 block_indices_to_id[1] =
vmesh->getGridLength()[0];
192 block_indices_to_id[2] =
vmesh->getGridLength()[0]*
vmesh->getGridLength()[1];
195 cell_indices_to_id[0]=1;
196 cell_indices_to_id[1]=
WID;
197 cell_indices_to_id[2]=
WID2;
205 std::vector<uint> columnBlockOffsets;
206 std::vector<uint> columnNumBlocks;
207 std::vector<uint> setColumnOffsets;
208 std::vector<uint> setNumColumns;
209 std::vector<int> columnMinBlockK;
210 std::vector<int> columnMaxBlockK;
213 columnBlockOffsets, columnNumBlocks,
214 setColumnOffsets, setNumColumns);
233 blockIndexToBlockData[blockK] = NULL;
239 uint valuesColumnOffset = 0;
240 for(uint columnIndex = setColumnOffsets[
setIndex]; columnIndex < setColumnOffsets[
setIndex] + setNumColumns[
setIndex] ; columnIndex ++){
244 valuesColumnOffset += (n_cblocks + 2) * (
WID3/VECL);
251 vmesh->getIndices(blocks[columnBlockOffsets[setColumnOffsets[
setIndex]]],
252 setFirstBlockIndices[0], setFirstBlockIndices[1], setFirstBlockIndices[2]);
261 max_intersectionMin = std::max(max_intersectionMin,
265 max_intersectionMin = std::max(max_intersectionMin,
269 max_intersectionMin = std::max(max_intersectionMin,
277 min_intersectionMin = std::min(min_intersectionMin,
281 min_intersectionMin = std::min(min_intersectionMin,
285 min_intersectionMin = std::min(min_intersectionMin,
291 for(uint columnIndex = setColumnOffsets[
setIndex]; columnIndex < setColumnOffsets[
setIndex] + setNumColumns[
setIndex] ; columnIndex ++){
296 vmesh->getIndices(cblocks[0],
297 firstBlockIndices[0], firstBlockIndices[1], firstBlockIndices[2]);
298 vmesh->getIndices(cblocks[n_cblocks -1],
299 lastBlockIndices[0], lastBlockIndices[1], lastBlockIndices[2]);
314 const int firstBlock_gk = (int)((firstBlockMinV - max_intersectionMin)/
intersection_dk);
315 const int lastBlock_gk = (int)((lastBlockMaxV - min_intersectionMin)/
intersection_dk);
317 int firstBlockIndexK = firstBlock_gk/
WID;
318 int lastBlockIndexK = lastBlock_gk/
WID;
321 firstBlockIndexK = (firstBlockIndexK >= 0) ? firstBlockIndexK : 0;
323 lastBlockIndexK = (lastBlockIndexK >= 0) ? lastBlockIndexK : 0;
325 if(firstBlockIndexK < wallmargin
327 || lastBlockIndexK < wallmargin
330 string message =
"Some target blocks in acceleration are going to be less than ";
331 message += std::to_string(wallmargin);
332 message +=
" blocks away from the current velocity space walls for population ";
334 message +=
" at CellID ";
336 message +=
". Consider expanding velocity space for that population.";
337 bailout(
true, message, __FILE__, __LINE__);
341 for (uint blockK = firstBlockIndices[2]; blockK <= lastBlockIndices[2]; blockK++){
346 for (uint blockK = firstBlockIndexK; (int)blockK <= lastBlockIndexK; blockK++){
351 columnMinBlockK.push_back(firstBlockIndexK);
352 columnMaxBlockK.push_back(lastBlockIndexK);
359 const int targetBlock =
360 setFirstBlockIndices[0] * block_indices_to_id[0] +
361 setFirstBlockIndices[1] * block_indices_to_id[1] +
362 blockK * block_indices_to_id[2];
367 const int targetBlock =
368 setFirstBlockIndices[0] * block_indices_to_id[0] +
369 setFirstBlockIndices[1] * block_indices_to_id[1] +
370 blockK * block_indices_to_id[2];
372 spatial_cell->remove_velocity_block(targetBlock, popID);
381 const int targetBlock =
382 setFirstBlockIndices[0] * block_indices_to_id[0] +
383 setFirstBlockIndices[1] * block_indices_to_id[1] +
384 blockK * block_indices_to_id[2];
387 blockIndexToBlockData[blockK] = blockContainer->
getData(tblockLID);
394 valuesColumnOffset = 0;
395 for(uint columnIndex = setColumnOffsets[
setIndex]; columnIndex < setColumnOffsets[
setIndex] + setNumColumns[
setIndex] ; columnIndex ++){
402 vmesh->getIndices(cblocks[0],block_indices_begin[0],block_indices_begin[1],block_indices_begin[2]);
415 #if VECL == 4 && WID == 4
416 const Veci i_indices = Veci({0, 1, 2, 3});
417 const Veci j_indices = Veci({
j,
j,
j,
j});
418 #elif VECL == 4 && WID == 8
419 cerr << __FILE__ <<
":" << __LINE__ <<
": VECL == 4 && WID == 8 cannot work!" << endl;
421 #elif VECL == 8 && WID == 4
422 const Veci i_indices = Veci({0, 1, 2, 3,
424 const Veci j_indices = Veci({
j,
j,
j,
j,
425 j + 1,
j + 1,
j + 1,
j + 1});
426 #elif VECL == 8 && WID == 8
427 const Veci i_indices = Veci({0, 1, 2, 3, 4, 5, 6, 7});
428 const Veci j_indices = Veci({
j,
j,
j,
j,
j,
j,
j,
j});
429 #elif VECL == 16 && WID == 4
430 const Veci i_indices = Veci({0, 1, 2, 3,
434 const Veci j_indices = Veci({
j,
j,
j,
j,
435 j + 1,
j + 1,
j + 1,
j + 1,
436 j + 2,
j + 2,
j + 2,
j + 2,
437 j + 3,
j + 3,
j + 3,
j + 3});
438 #elif VECL == 16 && WID == 8
439 const Veci i_indices = Veci({0, 1, 2, 3, 4, 5, 6, 7,
440 0, 1, 2, 3, 4, 5, 6, 7});
441 const Veci j_indices = Veci({
j,
j,
j,
j,
j,
j,
j,
j,
442 j+1,
j+1,
j+1,
j+1,
j+1,
j+1,
j+1,
j+1});
443 #elif VECL == 16 && WID == 16
444 const Veci i_indices = Veci({0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15});
445 const Veci j_indices = Veci({
j,
j,
j,
j,
j,
j,
j,
j,
j,
j,
j,
j,
j,
j,
j,
j});
446 #elif VECL == 32 && WID == 4
447 cerr << __FILE__ <<
":" << __LINE__ <<
": VECL == 32 && WID == 4 cannot work, too long vector for one plane!" << endl;
449 #elif VECL == 32 && WID == 8
450 const Veci i_indices = Veci({0, 1, 2, 3, 4, 5, 6, 7,
451 0, 1, 2, 3, 4, 5, 6, 7,
452 0, 1, 2, 3, 4, 5, 6, 7,
453 0, 1, 2, 3, 4, 5, 6, 7});
454 const Veci j_indices = Veci({
j,
j,
j,
j,
j,
j,
j,
j,
455 j+1,
j+1,
j+1,
j+1,
j+1,
j+1,
j+1,
j+1,
456 j+2,
j+2,
j+2,
j+2,
j+2,
j+2,
j+2,
j+2,
457 j+3,
j+3,
j+3,
j+3,
j+3,
j+3,
j+3,
j+3});
458 #elif VECL == 64 && WID == 4
459 cerr << __FILE__ <<
":" << __LINE__ <<
": VECL == 64 && WID == 4 cannot work, too long vector for one plane!" << endl;
461 #elif VECL == 64 && WID == 8
462 const Veci i_indices = Veci({0, 1, 2, 3, 4, 5, 6, 7,
463 0, 1, 2, 3, 4, 5, 6, 7,
464 0, 1, 2, 3, 4, 5, 6, 7,
465 0, 1, 2, 3, 4, 5, 6, 7,
466 0, 1, 2, 3, 4, 5, 6, 7,
467 0, 1, 2, 3, 4, 5, 6, 7,
468 0, 1, 2, 3, 4, 5, 6, 7,
469 0, 1, 2, 3, 4, 5, 6, 7});
470 const Veci j_indices = Veci({
j,
j,
j,
j,
j,
j,
j,
j,
471 j+1,
j+1,
j+1,
j+1,
j+1,
j+1,
j+1,
j+1,
472 j+2,
j+2,
j+2,
j+2,
j+2,
j+2,
j+2,
j+2,
473 j+3,
j+3,
j+3,
j+3,
j+3,
j+3,
j+3,
j+3,
474 j+4,
j+4,
j+4,
j+4,
j+4,
j+4,
j+4,
j+4,
475 j+5,
j+5,
j+5,
j+5,
j+5,
j+5,
j+5,
j+5,
476 j+6,
j+6,
j+6,
j+6,
j+6,
j+6,
j+6,
j+6,
477 j+7,
j+7,
j+7,
j+7,
j+7,
j+7,
j+7,
j+7});
479 cerr << __FILE__ <<
":" << __LINE__ <<
": Missing implementation for VECL=" << VECL <<
" and WID=" <<
WID <<
"!" << endl;
483 const Veci target_cell_index_common =
484 i_indices * cell_indices_to_id[0] +
485 j_indices * cell_indices_to_id[1];
493 const Vec intersection_min =
502 Vec v_r((
WID * block_indices_begin[2]) *
dv +
v_min);
504#if VECTORCLASS_H >= 20000
505 Veci lagrangian_gk_r=truncatei(lagrangian_v_r);
515 int minGkIndex=0, maxGkIndex=0;
517 Real maxV = std::numeric_limits<Real>::min();
518 Real minV = std::numeric_limits<Real>::max();
519 for(
int i = 0;
i < VECL;
i++) {
520 if ( lagrangian_v_r[
i] > maxV) {
521 maxV = lagrangian_v_r[
i];
524 if ( lagrangian_v_r[
i] < minV) {
525 minV = lagrangian_v_r[
i];
533 for (uint
k=0;
k <
WID * n_cblocks; ++
k ){
537 #ifdef ACC_SEMILAG_PLM
541 #ifdef ACC_SEMILAG_PPM
545 #ifdef ACC_SEMILAG_PQM
552 Vec target_density_r(0.0);
559 const Veci lagrangian_gk_l = lagrangian_gk_r;
560#if VECTORCLASS_H >= 20000
568 int minGk = std::max(
int(lagrangian_gk_l[minGkIndex]),
int(columnMinBlockK[columnIndex] *
WID));
569 int maxGk = std::min(
int(lagrangian_gk_r[maxGkIndex]),
int((columnMaxBlockK[columnIndex] + 1) *
WID - 1));
571 for(
int gk = minGk; gk <= maxGk; gk++){
572 const int blockK = gk/
WID;
573 const int gk_mod_WID = (gk - blockK *
WID);
578 const Veci target_cell(target_cell_index_common + gk_mod_WID * cell_indices_to_id[2]);
585 const Vec v_norm_r = (
min(
max( (gk + 1) *
intersection_dk + intersection_min, v_l), v_r) - v_l) * i_dv;
587 const Vec target_density_l = target_density_r;
590 #ifdef ACC_SEMILAG_PLM
592 v_norm_r * ( a[0] + v_norm_r * a[1] );
594 #ifdef ACC_SEMILAG_PPM
596 v_norm_r * ( a[0] + v_norm_r * ( a[1] + v_norm_r * a[2] ) );
599 #ifdef ACC_SEMILAG_PQM
601 v_norm_r * ( a[0] + v_norm_r * ( a[1] + v_norm_r * ( a[2] + v_norm_r * ( a[3] + v_norm_r * a[4] ) ) ) );
610 Realf* targetDataPointer = blockIndexToBlockData[blockK] +
j * cell_indices_to_id[1] + gk_mod_WID * cell_indices_to_id[2];
612 targetData.load_a(targetDataPointer);
613 targetData += target_density_r - target_density_l;
614 targetData.store_a(targetDataPointer);
618 const Vec target_density = target_density_r - target_density_l;
620 for (
int target_i=0; target_i < VECL; ++target_i) {
621 const Realf tval = target_density[target_i];
622 const uint tcell = target_cell[target_i];
623 blockIndexToBlockData[blockK][tcell] += tval;
630 valuesColumnOffset += (n_cblocks + 2) * (
WID3/VECL) ;