pygbe.tree package

Submodules

pygbe.tree.FMMutils module

It contains the functions to build the tree and compute all the interactions.

class pygbe.tree.FMMutils.Cell(NCRIT, Nm)[source]

Bases: object

Cell class. It contains the information about the cells in the tree.

nsource

int, number of source particles.

ntarget

int, number of target particles.

nchild

int, number of child boxes in binary, 8bit value, if certain – child exists, that bit will be 1.

source

array, pointer to source particles.

target

array, pointer to target particles.

xc

float, x position of the center of cell.

yc

float, y position of the center of cell.

zc

float, z position of the center of cell.

r

float, cell radius, i.e half length.

parent

int, pointer to parent cell.

child

array, pointer to child cell.

M

array, array with multipoles.

Md

array, array with multipoles for grad(G).n.

P2P_list

list, pointer to cells that interact with P2P.

M2P_list

list, pointer to cells that interact with M2P.

M2P_size

list, size of the M2P interaction list.

list_ready

int, flag to know if P2P list is already generated.

twig_array

list, position in the twig array.

pygbe.tree.FMMutils.M2PKt_gpu(surfSrc, surfTar, Ktx_gpu, Kty_gpu, Ktz_gpu, surf, ind0, param, LorY, timing, kernel)[source]

It computes the far field contribution of the adjoint double potential using the sorted data, on the GPU.

Parameters:
  • surfSrc (class, source surface, the one that contains the gauss points.) –
  • surfTar (class, target surface, the one that contains the collocation) – points.
  • Ktx_gpu (array, x component of the far field contribution to the adjoint) – double layer potential.
  • Kty_gpu (array, y component of the far field contribution to the adjoint) – double layer potential.
  • Ktz_gpu (array, z component of the far field contribution to the adjoint) – double layer potential.
  • surf (int, position of the source surface in the surface array.) –
  • ind0 (list, pointers to the location of the mulipole of order i,j,k) – in the multipole array.
  • param (class, parameters related to the surface.) –
  • LorY (int, Laplace (1) or Yukawa (2)) –
  • timing (class, it contains timing information for different parts of) – the code.
  • kernel (pycuda source module.) –
Returns:

  • Ktx_gpu (array, x component of the far field contribution to the adjoint) – double layer potential.
  • Kty_gpu (array, y component of the far field contribution to the adjoint) – double layer potential.
  • Ktz_gpu (array, z component of the far field contribution to the adjoint) – double layer potential.

pygbe.tree.FMMutils.M2PKt_sort(surfSrc, surfTar, Ktx_aux, Kty_aux, Ktz_aux, surf, index, param, LorY, timing)[source]

It computes the far field contribution of the adjoint double potential using the sorted data.

Parameters:
  • surfSrc (class, source surface, the one that contains the gauss points.) –
  • surfTar (class, target surface, the one that contains the collocation) – points.
  • Ktx_aux (array, x component of the far field contribution to the adjoint) – double layer potential.
  • Kty_aux (array, y component of the far field contribution to the adjoint) – double layer potential.
  • Ktz_aux (array, z component of the far field contribution to the adjoint) – double layer potential.
  • surf (int, position of the source surface in the surface array.) –
  • index (list, pointers to the location of the mulipole of order i,j,k) – in the multipole array.
  • param (class, parameters related to the surface.) –
  • LorY (int, Laplace (1) or Yukawa (2)) –
  • timing (class, it contains timing information for different parts of) – the code.
Returns:

  • Ktx_aux (array, x component of the far field contribution to the adjoint) – double layer potential.
  • Kty_aux (array, y component of the far field contribution to the adjoint) – double layer potential.
  • Ktz_aux (array, z component of the far field contribution to the adjoint) – double layer potential.

pygbe.tree.FMMutils.M2P_gpu(surfSrc, surfTar, K_gpu, V_gpu, surf, ind0, param, LorY, timing, kernel)[source]

It computes the far field contribution of the double and single layer potential using the sorted data, on the GPU.

Parameters:
  • surfSrc (class, source surface, the one that contains the gauss points.) –
  • surfTar (class, target surface, the one that contains the collocation) – points.
  • K_gpu (array, far field contribution to the double layer potential.) –
  • V_gpu (array, far field contribution to the single layer potential.) –
  • ind0 (list, pointers to the location of the mulipole of order i,j,k) – in the multipole array.
  • param (class, parameters related to the surface.) –
  • int, Laplace (1) or Yukawa (2) (LorY) –
  • timing (class, it contains timing information for different parts of) – the code.
  • kernel (pycuda source module.) –
Returns:

  • K_gpu (array, far field contribution to the double layer potential.)
  • V_gpu (array, far field contribution to the single layer potential.)

pygbe.tree.FMMutils.M2P_nonvec(Cells, CJ, xq, Kval, Vval, index, par_reac, source, time_M2P)[source]

It computes the far field contribution of the double and single layer potential without doing the assumption that all the particles in the same twig cell have the same interaction list.

This is used for the calculation for the reaction potential where the targets are the point-charges location.

Parameters:
  • Cells (array, cells of the tree.) –
  • CJ (int, index of the source cell.) –
  • xq (array, postion of the point charges.) –
  • Kval (array, far field contribution to the double layer potential.) –
  • Vval (array, far field contribution to the single layer potential.) –
  • index (list, pointers to the location of the mulipole of order i,j,k) – in the multipole array.
  • par_reac (class, fine parameters related to the surface.) –
  • source (list, P2P interaction list, which is a list of the cells that) – each charge-point interacts by P2P.
  • time_M2P (real, timed consumed in compute M2P_nonvec function.) –
Returns:

  • Kval (array, far field contribution to the double layer potential.)
  • Vval (array, far field contribution to the single layer potential.)
  • source (list, P2P interaction list, which is a list of the cells that) – each charge-point interacts.
  • time_M2P (real, time consumed in compute M2P_nonvec function.)

pygbe.tree.FMMutils.M2P_sort(surfSrc, surfTar, K_aux, V_aux, surf, index, param, LorY, timing)[source]

It computes the far field contribution of the double and single layer potential using the sorted data.

Parameters:
  • surfSrc (class, source surface, the one that contains the gauss points.) –
  • surfTar (class, target surface, the one that contains the collocation) – points.
  • K_aux (array, far field contribution to the double layer potential.) –
  • V_aux (array, far field contribution to the single layer potential.) –
  • surf (int, position of the source surface in the surface array.) –
  • index (list, pointers to the location of the mulipole of order i,j,k) – in the multipole array.
  • param (class, parameters related to the surface.) –
  • LorY (int, Laplace (1) or Yukawa (2)) –
  • timing (class, it contains timing information for different parts of) – the code.
Returns:

  • K_aux (array, far field contribution to the double layer potential.)
  • V_aux (array, far field contribution to the single layer potential.)

pygbe.tree.FMMutils.P2PKt_gpu(surfSrc, surfTar, m, mKtc, Ktx_gpu, Kty_gpu, Ktz_gpu, surf, LorY, w, param, timing, kernel)[source]

It computes the near field contribution of the double and single layer potential using the sorted data and adds it to the far field contribution given as an input, on the GPU.

Note: In this context when we refer to mass we mean

mass = (vector x gauss weights) mass-clean = (vector)

where ‘vector’ is the vector in the matrix-vector multiplication in the GMRES.

Parameters:
  • surfSrc (class, source surface, the one that contains the gauss points.) –
  • surfTar (class, target surface, the one that contains the collocation) – points.
  • m (array, mass of the source particle for the adjoint double layer) – potential calculation.
  • mKc (array, mass-clean of the source particle for the adjoint double) – layer potential calculation.
  • Ktx_gpu (array, x component of the far field contribution to the adjoint) – double layer potential.
  • Kty_gpu (array, y component of the far field contribution to the adjoint) – double layer potential.
  • Ktz_gpu (array, z component of the far field contribution to the adjoint) – double layer potential.
  • surf (int, position of the source surface in the surface array.) –
  • LorY (int, Laplace (1) or Yukawa (2)) –
  • w (array, gauss points.) –
  • param (class, parameters related to the surface.) –
  • timing (class, it contains timing information for different parts of) – the code.
  • kernel (pycuda source module.) –
Returns:

  • Ktx_gpu (array, x component of the far plus near field contribution to the) – adjoint double layer potential.
  • Kty_gpu (array, y component of the far plus near field contribution to the) – adjoint double layer potential.
  • Ktz_gpu (array, z component of the far plus near field contribution to the) – adjoint double layer potential.

pygbe.tree.FMMutils.P2PKt_sort(surfSrc, surfTar, m, mKc, Ktx_aux, Kty_aux, Ktz_aux, surf, LorY, w, param, timing)[source]

It computes the near field contribution of the double and single layer potential using the sorted data and adds it to the far field contribution given as an input.

Note: In this context when we refer to mass we mean
mass = (vector x gauss weights) mass-clean = (vector)

where ‘vector’ is the vector in the matrix-vector multiplication in the GMRES.

Parameters:
  • surfSrc (class, source surface, the one that contains the gauss points.) –
  • surfTar (class, target surface, the one that contains the collocation) – points.
  • m (array, mass of the source particle for the adjoint double layer) – potential calculation.
  • mKc (array, mass-clean of the source particle for the adjoint double) – layer potential calculation.
  • Ktx_aux (array, x component of the far field contribution to the adjoint) – double layer potential.
  • Kty_aux (array, y component of the far field contribution to the adjoint) – double layer potential.
  • Ktz_aux (array, z component of the far field contribution to the adjoint) – double layer potential.
  • surf (int, position of the source surface in the surface array.) –
  • LorY (int, Laplace (1) or Yukawa (2)) –
  • w (array, gauss points.) –
  • param (class, parameters related to the surface.) –
  • timing (class, it contains timing information for different parts of) – the code.
Returns:

  • Ktx_aux (array, x component of the far plus near field contribution to the) – adjoint double layer potential.
  • Kty_aux (array, y component of the far plus near field contribution to the) – adjoint double layer potential.
  • Ktz_aux (array, z component of the far plus near field contribution to the) – adjoint double layer potential.

pygbe.tree.FMMutils.P2P_gpu(surfSrc, surfTar, m, mx, my, mz, mKc, mVc, K_gpu, V_gpu, surf, LorY, K_diag, IorE, L, w, param, timing, kernel)[source]

It computes the near field contribution of the double and single layer potential using the sorted data and adds it to the far field contribution given as an input, on the GPU.

Note: In this context when we refer to mass we mean
mass = (vector x gauss weights) mass-clean = (vector)

where ‘vector’ is the vector in the matrix-vector multiplication in the GMRES.

Parameters:
  • surfSrc (class, source surface, the one that contains the gauss points.) –
  • surfTar (class, target surface, the one that contains the collocation) – points.
  • m (array, mass of the source particle for the single layer potential) – calculation.
  • mx (array, mass of the source particle times the 'x' component of the) – normal vector, for the double layer potential calculation.
  • my (array, mass of the source particle times the 'y' component of the) – normal vector, for the double layer potential calculation.
  • mz (array, mass of the source particle times the 'z' component of the) – normal vector, for the double layer potential calculation.
  • mKc (array, mass-clean of the source particle for the double layer) – potential calculation.
  • mVc (array, mass-clean of the source particle for the double layer) – potential calculation.
  • K_gpu (array, far field contribution to the double layer potential.) –
  • V_gpu (array, far field contribution to the single layer potential.) –
  • surf (int, position of the source surface in the surface array.) –
  • K_diag (array, diagonal elements of the double layer integral operator.) –
  • IorE (int, internal (1) or external (2)) –
  • L (float, representative distance of the triangles. (sqrt{2*Area})) –
  • w (array, gauss points.) –
  • param (class, parameters related to the surface.) –
  • timing (class, it contains timing information for different parts of) – the code.
  • kernel (pycuda source module.) –
Returns:

  • K_gpu (array, far plus near field contribution to the double layer) – potential.
  • V_gpu (array, far plus near field contribution to the single layer) – potential.

pygbe.tree.FMMutils.P2P_nonvec(Cells, surface, m, mx, my, mz, mKc, mVc, xq, Kval, Vval, IorE, par_reac, w, source, AI_int, time_P2P)[source]

It computes the near field contribution of the double and single layer potential and adds it to the far field contribution given as an input. In this case we don’t do the assumption that all the particles in the same twig cell have the same interaction list.

This is used for the calculation for the reaction potential where the targets are the point-charges location.

Parameters:
  • Cells (array, cells of the tree.) –
  • surface (class, surface where we are computing the P2P_nonvec.) –
  • m (array, mass of the source particle for the single layer potential) – calculation.
  • mx (array, mass of the source particle times the 'x' component of the) – normal vector, for the double layer potential calculation.
  • my (array, mass of the source particle times the 'y' component of the) – normal vector, for the double layer potential calculation.
  • mz (array, mass of the source particle times the 'z' component of the) – normal vector, for the double layer potential calculation.
  • mKc (array, mass-clean of the source particle for the double layer) – potential calculation.
  • mVc (array, mass-clean of the source particle for the double layer) – potential calculation.
  • xq (array, postion of the point charges.) –
  • Kval (array, far field contribution to the double layer potential.) –
  • Vval (array, far field contribution to the single layer potential.) –
  • IorE (int, internal (1) or external (2)) –
  • par_reac (class, fine parameters related to the surface.) –
  • w (array, gauss points.) –
  • source (list, P2P interaction list, which is a list of the cells that) – each charge-point interacts.
  • AI_int (int, counter of the amount of near singular integrals solved.) –
  • time_P2P (real, timed consumed in compute P2P_nonvec function.) –
Returns:

  • Kval (array, far plus near field contribution to the double layer) – potential.
  • Vval (array, far plus near field contribution to the single layer) – potential.
  • AI_int (int, counter of the amount of near singular integrals solved.)
  • time_P2P (real, timed consumed in compute P2P_nonvec function.)

pygbe.tree.FMMutils.P2P_sort(surfSrc, surfTar, m, mx, my, mz, mKc, mVc, K_aux, V_aux, surf, LorY, K_diag, V_diag, IorE, L, w, param, timing)[source]

It computes the near field contribution of the double and single layer potential using the sorted data and adds it to the far field contribution given as an input.

Note: In this context when we refer to mass we mean
mass = (vector x gauss weights) mass-clean = (vector)

where ‘vector’ is the vector in the matrix-vector multiplication in the GMRES.

Parameters:
  • surfSrc (class, source surface, the one that contains the gauss points.) –
  • surfTar (class, target surface, the one that contains the collocation) – points.
  • m (array, mass of the source particle for the single layer potential) – calculation.
  • mx (array, mass of the source particle times the 'x' component of the) – normal vector, for the double layer potential calculation.
  • my (array, mass of the source particle times the 'y' component of the) – normal vector, for the double layer potential calculation.
  • mz (array, mass of the source particle times the 'z' component of the) – normal vector, for the double layer potential calculation.
  • mKc (array, mass-clean of the source particle for the double layer) – potential calculation.
  • mVc (array, mass-clean of the source particle for the double layer) – potential calculation.
  • K_aux (array, far field contribution to the double layer potential.) –
  • V_aux (array, far field contribution to the single layer potential.) –
  • surf (int, position of the source surface in the surface array.) –
  • K_diag (array, diagonal elements of the double layer integral operator.) –
  • V_diag (array, diagonal elements of the single layer integral operator.) –
  • IorE (int, internal (1) or external (2)) –
  • L (float, representative distance of the triangles. (sqrt{2*Area})) –
  • w (array, gauss points.) –
  • param (class, parameters related to the surface.) –
  • timing (class, it contains timing information for different parts of) – the code.
Returns:

  • K_aux (array, far plus near field contribution to the double layer) – potential.
  • V_aux (array, far plus near field contribution to the single layer) – potential.

pygbe.tree.FMMutils.addSources(Cells, twig, K)[source]

It adds the source points to the cells. Puts the sources in the same cell as the collocation point of the same panel. This version works fast when used with sorted arrays.

Parameters:
  • Cells (array, cells of the tree.) –
  • twig (array, indices of twigs in Cells array.) –
  • K (int, number of Gauss points per element.) –
pygbe.tree.FMMutils.addSources2(x, y, z, j, Cells, C, NCRIT)[source]

It adds the source points to the cells. Puts the sources in the same cell as the collocation point of the same panel. This version is a generic version that loop over the cells looking for twigs and sets the sources one it finds a twig.

Parameters:
  • x (array, x coordinate of the sources.) –
  • y (array, y coordinate of the sources.) –
  • z (array, z coordinate of the sources.) –
  • j (int, index of the source in the source array.) –
  • Cells (array, cells of the tree.) –
  • C (int, index of cell in the Cells array.) –
  • NCRIT (int, maximum number of boundary elements per twig box of tree) – structure.
pygbe.tree.FMMutils.addSources3(x, y, z, Cells, twig)[source]

It adds the source points to the cells. Puts the sources in the same cell as the collocation point of the same panel. This version works fast when we uses the twig_array, array that contains the location in the cells array of the twig cells.

Parameters:
  • x (array, x coordinate of the sources.) –
  • y (array, y coordinate of the sources.) –
  • z (array, z coordinate of the sources.) –
  • j (int, index of the source in the source array.) –
  • Cells (array, cells of the tree.) –
  • twig (array, indices of twigs in Cells array.) –
pygbe.tree.FMMutils.add_child(octant, Cells, i, NCRIT, Nm, Ncell)[source]

It adds a child cell to the Cells.

Parameters:
  • octant (int, octant of the child cell.) –
  • Cells (array, it contains the cells information.) –
  • i (int, index of parent cell in Cells array.) –
  • NCRIT (int, maximum number of boundary elements per twig box of tree) – structure.
  • Nm (int, number of multipole coefficients.) –
  • Ncell (int, number of cells in the tree.) –
Returns:

Ncell

Return type:

int, number of cells in the tree.

pygbe.tree.FMMutils.computeIndices(P, ind0)[source]

It computes the indices (exponents) needed to compute the Taylor expansion.

Parameters:
  • P (int, order of the Taylor expansion.) –
  • ind0 (class, it contains the indices related to the treecode computation.) –
pygbe.tree.FMMutils.findTwigs(Cells, C, twig, NCRIT)[source]

It finds the twig cells, the ones that have < NCRIT.

Parameters:
  • Cells (array, cells of the tree.) –
  • C (int, index of cell in the Cells array.) –
  • twig (array, indices of twigs in Cells array.) –
  • NCRIT (int, maximum number of boundary elements per twig box of tree) – structure.
Returns:

twig

Return type:

array, indices of twigs in Cells array.

pygbe.tree.FMMutils.generateList(surf_array, field_array, param)[source]

Loops over the surfaces to then compute the interactionList().

Parameters:
  • surf_array (array, contains the surface classes of each region on the) – surface.
  • field_array (array, contains the Field classes of each region on the) – surface.
  • param (class, parameters related to the surface.) –
pygbe.tree.FMMutils.generateTree(xi, yi, zi, NCRIT, Nm, N, radius, x_center)[source]

It generates a target-based tree.

Parameters:
  • xi (array, x position of the targets, i.e collocation points.) –
  • yi (array, y position of the targets, i.e collocation points.) –
  • zi (array, z position of the targets, i.e collocation points.) –
  • NCRIT (int, maximum number of boundary elements per twig box of tree) – structure.
  • Nm (int, number of multipole coefficients.) –
  • r (float, cell radius, i.e half length.) –
  • x_center (array, center of the root cell.) –
Returns:

Cells

Return type:

array, cells of the tree.

pygbe.tree.FMMutils.getMultipole(Cells, C, x, y, z, mV, mKx, mKy, mKz, ind0, P, NCRIT)[source]

It gets the multipole of the twig cells. (P2M)

Note: In this context when we refer to mass we mean
mass = (vector x gauss weights)

where ‘vector’ is the vector in the matrix-vector multiplication in the GMRES.

Parameters:
  • Cells (array, it contains the cells information.) –
  • C (int, index of the cell in the Cells array.) –
  • x (array, x coordinate of the sources.) –
  • y (array, y coordinate of the sources.) –
  • z (array, z coordinate of the sources.) –
  • mV (array, mass of the source particle for the single layer potential) – calculation.
  • mKx (array, mass of the source particle times the 'x' component of the) – normal vector, for the double layer potential calculation.
  • mKy (array, mass of the source particle times the 'y' component of the) – normal vector, for the double layer potential calculation.
  • mKz (array, mass of the source particle times the 'z' component of the) – normal vector, for the double layer potential calculation.
  • ind0 (class, it contains the indices related to the treecode computation.) –
  • P (int, order of the Taylor expansion.) –
  • NCRIT (int, maximum number of boundary elements per twig box of tree) – structure.
pygbe.tree.FMMutils.interactionList(surfSrc, surfTar, CJ, CI, theta, NCRIT, offTwg, offMlt, s_src)[source]

It finds the list of cells which each twig cell interacts.

Parameters:
  • surfSrc (class, source surface, the one that contains the gauss points.) –
  • surfTar (class, target surface, the one that contains the collocation) – points.
  • CJ (int, index of source cell.) –
  • CI (int, index of target cell.) –
  • theta (float, Multipole-acceptance criterion (MAC)) –
  • NCRIT (int, maximum number of boundary elements per twig box of tree) – structure.
  • offTwg (array, pointer to the first element in the array P2P_list which) – contains the P2P interaction list for each twig cell.
  • offMlt (array, pointer to the first element in the array M2P_list which) – contains the M2P interaction list for each twig cell.
  • s_src (int, position (index) in the surface-array of the surface that) – contains the sources.
Returns:

  • offTwg (array, pointer to the first element in the P2P interaction list) – for each twig cell.
  • offMlt (array, pointer to the first element in the M2P interaction list) – for each twig cell.

pygbe.tree.FMMutils.precomputeTerms(P, ind0)[source]

It precomputes the terms for P2M and M2M computation.

Parameters:
  • P (int, order of the Taylor expansion.) –
  • ind0 (class, it contains the indices related to the treecode computation.) –
pygbe.tree.FMMutils.sortPoints(surface, Cells, twig, param)[source]

It sort the target and source points.

We sort them to makes the computation easy and faster in the GPU. We unsort them when we need the information to be analized after it was computed.

Parameters:
  • surface (class, surface that we are analysing.) –
  • Cells (array, cells of the tree.) –
  • twig (array, indices of twigs in Cells array.) –
  • param (class, parameters related to the surface.) –
pygbe.tree.FMMutils.split_cell(x, y, z, Cells, C, NCRIT, Nm, Ncell)[source]

It splits a cell with more than (>=) NCRIT particles. Particles in this context means boundary elements.

Parameters:
  • x (array, x position of the particles.) –
  • y (array, y position of the particles.) –
  • z (array, z position of the particles.) –
  • Cells (array, it contains the cells information.) –
  • C (int, index in the Cells array of the cell to be splitted .) –
  • NCRIT (int, maximum number of boundary elements per twig box of tree) – structure.
  • Nm (int, number of multipole coefficients.) –
  • Ncell (int, number of cells in the tree.) –
Returns:

Ncell

Return type:

int, number of cells in the tree.

pygbe.tree.FMMutils.upwardSweep(Cells, CC, PC, P, II, JJ, KK, index, combII, combJJ, combKK, IImii, JJmjj, KKmkk, index_small, index_ptr)[source]

It calculates the M2M. Calculation of the multipole for non-twig cells .

Parameters:
  • Cells (array, it contains the cells information.) –
  • CC (int, index of the child cell in the Cells array .) –
  • PC (int, index of the parent cell in the Cells array) –
  • P (int, order of the Taylor expansion.) –
  • II (list, multipole order in the x-direction for the treecode.) –
  • JJ (list, multipole order in the y-direction for the treecode.) –
  • KK (list, multipole order in the z-direction for the treecode.) –
  • index (list, pointers to the location of the mulipole of order i,j,k) – in the multipole array.
  • combII (array, combinatory of (I, i) where I is the maximum i multipole.) –
  • combJJ (array, combinatory of (J, j) where J is the maximum j multipole.) –
  • combKK (array, combinatory of (K, k) where K is the maximum k multipole.) –
  • IImii (array, I-i where I is the maximum i multipole.) –
  • JJmjj (array, J-j where J is the maximum j multipole.) –
  • KKmkk (array, K-k where K is the maximum k multipole.) –
  • index_small (list, pointers to the position of multipole order i, j, k) – in the multipole array, organized in a 1D array which is compressed with respect to index_large (does not consider combinations of i,j,k which do not have a multipole).
  • index_ptr (list, pointer to index_small. Data in index_small is organized) – in a i-major fashion (i,j,k), and index_ptr points at the position in index_small where the order i changes.

pygbe.tree.calculateMultipoles module

pygbe.tree.cuda_kernels module

pygbe.tree.cuda_kernels.kernels(BSZ, Nm, K_fine, P, REAL)[source]

pygbe.tree.direct module

pygbe.tree.multipole module

Module contents