Skip to content

Use int64 for indexing

Markus Holzer requested to merge holzer/lbmpy:type_boundary into master

Fixes #18 (closed)

The code is changed in the following way. As an example, a generated UBB boundary is shown. Before the adaption:


   const int32_t f_in_inv_dir_idx [] = { 0,2,1,4,3,6,5,10,9,8,7,16,15,18,17,12,11,14,13,26,25,24,23,22,21,20,19 };
   const int32_t f_in_inv_offsets_x [] = { 0,0,0,-1,1,0,0,-1,1,-1,1,0,0,-1,1,0,0,-1,1,1,-1,1,-1,1,-1,1,-1 };
   const int32_t f_in_inv_offsets_y [] = { 0,1,-1,0,0,0,0,1,1,-1,-1,1,-1,0,0,1,-1,0,0,1,1,-1,-1,1,1,-1,-1 };
   const int32_t f_in_inv_offsets_z [] = { 0,0,0,0,0,1,-1,0,0,0,0,1,1,1,1,-1,-1,-1,-1,1,1,1,1,-1,-1,-1,-1 };


   const double weights [] = { 0.296296296296296,0.0740740740740741,0.0740740740740741,0.0740740740740741,0.0740740740740741,0.0740740740740741,0.0740740740740741,0.0185185185185185,0.0185185185185185,0.0185185185185185,0.0185185185185185,0.0185185185185185,0.0185185185185185,0.0185185185185185,0.0185185185185185,0.0185185185185185,0.0185185185185185,0.0185185185185185,0.0185185185185185,0.00462962962962963,0.00462962962962963,0.00462962962962963,0.00462962962962963,0.00462962962962963,0.00462962962962963,0.00462962962962963,0.00462962962962963 };



   const int32_t neighbour_offset_x [] = { 0,0,0,-1,1,0,0,-1,1,-1,1,0,0,-1,1,0,0,-1,1,1,-1,1,-1,1,-1,1,-1 };
   const int32_t neighbour_offset_y [] = { 0,1,-1,0,0,0,0,1,1,-1,-1,1,-1,0,0,1,-1,0,0,1,1,-1,-1,1,1,-1,-1 };
   const int32_t neighbour_offset_z [] = { 0,0,0,0,0,1,-1,0,0,0,0,1,1,1,1,-1,-1,-1,-1,1,1,1,1,-1,-1,-1,-1 };

   for (int64_t ctr_0 = 0; ctr_0 < _size_indexField_0; ctr_0 += 1)
   {
      const int32_t x = *((int32_t *)(& _data_indexField[16*_stride_indexField_0*ctr_0]));
      const int32_t y = *((int32_t *)(& _data_indexField[16*_stride_indexField_0*ctr_0 + 4]));
      const int32_t z = *((int32_t *)(& _data_indexField[16*_stride_indexField_0*ctr_0 + 8]));
      const int32_t dir = *((int32_t *)(& _data_indexField[16*_stride_indexField_0*ctr_0 + 12]));
      _data_ldc_pdfSrc[x + 452*y + 204304*z + 92345408*f_in_inv_dir_idx[dir] + f_in_inv_offsets_x[dir] + 452*f_in_inv_offsets_y[dir] + 204304*f_in_inv_offsets_z[dir]] = -0.029999999999999999*neighbour_offset_x[dir]*weights[dir] + _data_ldc_pdfSrc[92345408*dir + x + 452*y + 204304*z];

After the adaption:


   const int64_t f_in_inv_dir_idx [] = { 0,2,1,4,3,6,5,10,9,8,7,16,15,18,17,12,11,14,13,26,25,24,23,22,21,20,19 };
   const int64_t f_in_inv_offsets_x [] = { 0,0,0,-1,1,0,0,-1,1,-1,1,0,0,-1,1,0,0,-1,1,1,-1,1,-1,1,-1,1,-1 };
   const int64_t f_in_inv_offsets_y [] = { 0,1,-1,0,0,0,0,1,1,-1,-1,1,-1,0,0,1,-1,0,0,1,1,-1,-1,1,1,-1,-1 };
   const int64_t f_in_inv_offsets_z [] = { 0,0,0,0,0,1,-1,0,0,0,0,1,1,1,1,-1,-1,-1,-1,1,1,1,1,-1,-1,-1,-1 };


   const double weights [] = { 0.296296296296296,0.0740740740740741,0.0740740740740741,0.0740740740740741,0.0740740740740741,0.0740740740740741,0.0740740740740741,0.0185185185185185,0.0185185185185185,0.0185185185185185,0.0185185185185185,0.0185185185185185,0.0185185185185185,0.0185185185185185,0.0185185185185185,0.0185185185185185,0.0185185185185185,0.0185185185185185,0.0185185185185185,0.00462962962962963,0.00462962962962963,0.00462962962962963,0.00462962962962963,0.00462962962962963,0.00462962962962963,0.00462962962962963,0.00462962962962963 };



   const int64_t neighbour_offset_x [] = { 0,0,0,-1,1,0,0,-1,1,-1,1,0,0,-1,1,0,0,-1,1,1,-1,1,-1,1,-1,1,-1 };
   const int64_t neighbour_offset_y [] = { 0,1,-1,0,0,0,0,1,1,-1,-1,1,-1,0,0,1,-1,0,0,1,1,-1,-1,1,1,-1,-1 };
   const int64_t neighbour_offset_z [] = { 0,0,0,0,0,1,-1,0,0,0,0,1,1,1,1,-1,-1,-1,-1,1,1,1,1,-1,-1,-1,-1 };

   for (int64_t ctr_0 = 0; ctr_0 < _size_indexField_0; ctr_0 += 1)
   {
      const int64_t x = *((int32_t *)(& _data_indexField[16*_stride_indexField_0*ctr_0]));
      const int64_t y = *((int32_t *)(& _data_indexField[16*_stride_indexField_0*ctr_0 + 4]));
      const int64_t z = *((int32_t *)(& _data_indexField[16*_stride_indexField_0*ctr_0 + 8]));
      const int64_t dir = *((int32_t *)(& _data_indexField[16*_stride_indexField_0*ctr_0 + 12]));
      _data_ldc_pdfSrc[x + 452*y + 204304*z + 92345408*f_in_inv_dir_idx[dir] + f_in_inv_offsets_x[dir] + 452*f_in_inv_offsets_y[dir] + 204304*f_in_inv_offsets_z[dir]] = -0.029999999999999999*neighbour_offset_x[dir]*weights[dir] + _data_ldc_pdfSrc[92345408*dir + x + 452*y + 204304*z];
Edited by Markus Holzer

Merge request reports